Code Duplication    Length = 21-27 lines in 18 locations

comics.py 18 locations

@@ 720-743 (lines=24) @@
717
        }
718
719
720
class OneOneOneOneComic(GenericComicNotWorking, GenericNavigableComic):
721
    """Class to retrieve 1111 Comics."""
722
    # Also on http://comics1111.tumblr.com
723
    # Also on https://tapastic.com/series/1111-Comics
724
    name = '1111'
725
    long_name = '1111 Comics'
726
    url = 'http://www.1111comics.me'
727
    _categories = ('ONEONEONEONE', )
728
    get_first_comic_link = get_div_navfirst_a
729
    get_navi_link = get_link_rel_next
730
731
    @classmethod
732
    def get_comic_info(cls, soup, link):
733
        """Get information about a particular comics."""
734
        title = soup.find('h1', class_='comic-title').find('a').string
735
        date_str = soup.find('header', class_='comic-meta entry-meta').find('a').string
736
        day = string_to_date(date_str, "%B %d, %Y")
737
        imgs = soup.find_all('meta', property='og:image')
738
        return {
739
            'title': title,
740
            'month': day.month,
741
            'year': day.year,
742
            'day': day.day,
743
            'img': [i['content'] for i in imgs],
744
        }
745
746
@@ 948-970 (lines=23) @@
945
        }
946
947
948
class TheGentlemanArmchair(GenericNavigableComic):
949
    """Class to retrieve The Gentleman Armchair comics."""
950
    name = 'gentlemanarmchair'
951
    long_name = 'The Gentleman Armchair'
952
    url = 'http://thegentlemansarmchair.com'
953
    get_first_comic_link = get_a_navi_navifirst
954
    get_navi_link = get_link_rel_next
955
956
    @classmethod
957
    def get_comic_info(cls, soup, link):
958
        """Get information about a particular comics."""
959
        title = soup.find('h2', class_='post-title').string
960
        author = soup.find("span", class_="post-author").find("a").string
961
        date_str = soup.find('span', class_='post-date').string
962
        day = string_to_date(date_str, "%B %d, %Y")
963
        imgs = soup.find('div', id='comic').find_all('img')
964
        return {
965
            'img': [i['src'] for i in imgs],
966
            'title': title,
967
            'author': author,
968
            'month': day.month,
969
            'year': day.year,
970
            'day': day.day,
971
        }
972
973
@@ 747-768 (lines=22) @@
744
        }
745
746
747
class AngryAtNothing(GenericDeletedComic, GenericNavigableComic):
748
    """Class to retrieve Angry at Nothing comics."""
749
    # Also on http://tapastic.com/series/Comics-yeah-definitely-comics-
750
    # Also on http://angryatnothing.tumblr.com
751
    name = 'angry'
752
    long_name = 'Angry At Nothing'
753
    url = 'http://www.angryatnothing.net'
754
    get_first_comic_link = get_div_navfirst_a
755
    get_navi_link = get_a_rel_next
756
757
    @classmethod
758
    def get_comic_info(cls, soup, link):
759
        """Get information about a particular comics."""
760
        title = soup.find('h1', class_='comic-title').find('a').string
761
        date_str = soup.find('header', class_='comic-meta entry-meta').find('a').string
762
        day = string_to_date(date_str, "%B %d, %Y")
763
        imgs = soup.find_all('meta', property='og:image')
764
        return {
765
            'title': title,
766
            'month': day.month,
767
            'year': day.year,
768
            'day': day.day,
769
            'img': [i['content'] for i in imgs],
770
        }
771
@@ 694-716 (lines=23) @@
691
        }
692
693
694
class PenelopeBagieu(GenericNavigableComic):
695
    """Class to retrieve comics from Penelope Bagieu's blog."""
696
    name = 'bagieu'
697
    long_name = 'Ma vie est tout a fait fascinante (Bagieu)'
698
    url = 'http://www.penelope-jolicoeur.com'
699
    _categories = ('FRANCAIS', )
700
    get_navi_link = get_link_rel_next
701
    get_first_comic_link = simulate_first_link
702
    first_url = 'http://www.penelope-jolicoeur.com/2007/02/ma-vie-mon-oeuv.html'
703
704
    @classmethod
705
    def get_comic_info(cls, soup, link):
706
        """Get information about a particular comics."""
707
        date_str = soup.find('h2', class_='date-header').string
708
        day = string_to_date(date_str, "%A %d %B %Y", "fr_FR.utf8")
709
        imgs = soup.find('div', class_='entry-body').find_all('img')
710
        title = soup.find('h3', class_='entry-header').string
711
        return {
712
            'title': title,
713
            'img': [i['src'] for i in imgs],
714
            'month': day.month,
715
            'year': day.year,
716
            'day': day.day,
717
        }
718
719
@@ 1908-1934 (lines=27) @@
1905
class PicturesInBoxes(GenericNavigableComic):
1906
    """Class to retrieve Pictures In Boxes comics."""
1907
    # Also on https://picturesinboxescomic.tumblr.com
1908
    name = 'picturesinboxes'
1909
    long_name = 'Pictures in Boxes'
1910
    url = 'http://www.picturesinboxes.com'
1911
    get_navi_link = get_a_navi_navinext
1912
    get_first_comic_link = simulate_first_link
1913
    first_url = 'http://www.picturesinboxes.com/2013/10/26/tetris/'
1914
1915
    @classmethod
1916
    def get_comic_info(cls, soup, link):
1917
        """Get information about a particular comics."""
1918
        title = soup.find('h2', class_='post-title').string
1919
        author = soup.find("span", class_="post-author").find("a").string
1920
        date_str = soup.find('span', class_='post-date').string
1921
        day = string_to_date(date_str, '%B %d, %Y')
1922
        imgs = soup.find('div', class_='comicpane').find_all('img')
1923
        assert imgs
1924
        assert all(i['title'] == i['alt'] == title for i in imgs)
1925
        return {
1926
            'day': day.day,
1927
            'month': day.month,
1928
            'year': day.year,
1929
            'img': [i['src'] for i in imgs],
1930
            'title': title,
1931
            'author': author,
1932
        }
1933
1934
1935
class Penmen(GenericComicNotWorking, GenericNavigableComic):
1936
    """Class to retrieve Penmen comics."""
1937
    name = 'penmen'
@@ 2895-2919 (lines=25) @@
2892
        desc = soup.find('meta', property='og:description')['content']
2893
        title = soup.find('meta', property='og:title')['content']
2894
        imgs = soup.find('div', class_='entry-content').find_all('img')
2895
        title2 = ' '.join(i.get('title', '') for i in imgs)
2896
        return {
2897
            'title': title,
2898
            'title2': title2,
2899
            'description': desc,
2900
            'img': [urljoin_wrapper(cls.url, convert_iri_to_plain_ascii_uri(i['src'])) for i in imgs],
2901
        }
2902
2903
2904
class CommitStripFr(GenericCommitStrip):
2905
    """Class to retrieve Commit Strips in French."""
2906
    name = 'commit_fr'
2907
    long_name = 'Commit Strip (Fr)'
2908
    url = 'http://www.commitstrip.com/fr'
2909
    _categories = ('FRANCAIS', )
2910
    first_url = 'http://www.commitstrip.com/fr/2012/02/22/interview/'
2911
2912
2913
class CommitStripEn(GenericCommitStrip):
2914
    """Class to retrieve Commit Strips in English."""
2915
    name = 'commit_en'
2916
    long_name = 'Commit Strip (En)'
2917
    url = 'http://www.commitstrip.com/en'
2918
    first_url = 'http://www.commitstrip.com/en/2012/02/22/interview/'
2919
2920
2921
class GenericBoumerie(GenericNavigableComic):
2922
    """Generic class to retrieve Boumeries comics in different languages."""
@@ 2641-2666 (lines=26) @@
2638
    """Class to retrieve Biter Comics."""
2639
    name = "biter"
2640
    long_name = "Biter Comics"
2641
    url = "http://www.bitercomics.com"
2642
    get_first_comic_link = get_a_navi_navifirst
2643
    get_navi_link = get_link_rel_next
2644
2645
    @classmethod
2646
    def get_comic_info(cls, soup, link):
2647
        """Get information about a particular comics."""
2648
        title = soup.find("h1", class_="entry-title").string
2649
        author = soup.find("span", class_="author vcard").find("a").string
2650
        date_str = soup.find("span", class_="entry-date").string
2651
        day = string_to_date(date_str, "%B %d, %Y")
2652
        imgs = soup.find("div", id="comic").find_all("img")
2653
        assert all(i['alt'] == i['title'] for i in imgs)
2654
        assert len(imgs) == 1, imgs
2655
        alt = imgs[0]['alt']
2656
        return {
2657
            'img': [i['src'] for i in imgs],
2658
            'title': title,
2659
            'alt': alt,
2660
            'author': author,
2661
            'day': day.day,
2662
            'month': day.month,
2663
            'year': day.year
2664
        }
2665
2666
2667
class TheAwkwardYeti(GenericNavigableComic):
2668
    """Class to retrieve The Awkward Yeti comics."""
2669
    # Also on http://www.gocomics.com/the-awkward-yeti
@@ 2554-2579 (lines=26) @@
2551
        """Get link to next or previous comic."""
2552
        for link in last_soup.find_all('a', rel='next' if next_ else 'prev'):
2553
            if link['href'] != '/comic':
2554
                return link
2555
        return None
2556
2557
    @classmethod
2558
    def get_comic_info(cls, soup, link):
2559
        """Get information about a particular comics."""
2560
        title = soup.find('meta', attrs={'name': 'description'})["content"]
2561
        description = soup.find('div', itemprop='articleBody').text
2562
        author = soup.find('span', itemprop='author copyrightHolder').string
2563
        imgs = soup.find_all('img', itemprop='image')
2564
        assert all(i['title'] == i['alt'] for i in imgs)
2565
        alt = imgs[0]['alt'] if imgs else ""
2566
        date_str = soup.find('time', itemprop='datePublished')["datetime"]
2567
        day = string_to_date(date_str, "%Y-%m-%d %H:%M:%S")
2568
        return {
2569
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
2570
            'month': day.month,
2571
            'year': day.year,
2572
            'day': day.day,
2573
            'author': author,
2574
            'title': title,
2575
            'alt': alt,
2576
            'description': description,
2577
        }
2578
2579
2580
class GerbilWithAJetpack(GenericNavigableComic):
2581
    """Class to retrieve GerbilWithAJetpack comics."""
2582
    name = 'gerbil'
@@ 2583-2607 (lines=25) @@
2580
class GerbilWithAJetpack(GenericNavigableComic):
2581
    """Class to retrieve GerbilWithAJetpack comics."""
2582
    name = 'gerbil'
2583
    long_name = 'Gerbil With A Jetpack'
2584
    url = 'http://gerbilwithajetpack.com'
2585
    get_first_comic_link = get_a_navi_navifirst
2586
    get_navi_link = get_a_rel_next
2587
2588
    @classmethod
2589
    def get_comic_info(cls, soup, link):
2590
        """Get information about a particular comics."""
2591
        title = soup.find('h2', class_='post-title').string
2592
        author = soup.find("span", class_="post-author").find("a").string
2593
        date_str = soup.find("span", class_="post-date").string
2594
        day = string_to_date(date_str, "%B %d, %Y")
2595
        imgs = soup.find("div", id="comic").find_all("img")
2596
        alt = imgs[0]['alt']
2597
        assert all(i['alt'] == i['title'] == alt for i in imgs)
2598
        return {
2599
            'img': [i['src'] for i in imgs],
2600
            'title': title,
2601
            'alt': alt,
2602
            'author': author,
2603
            'day': day.day,
2604
            'month': day.month,
2605
            'year': day.year
2606
        }
2607
2608
2609
class EveryDayBlues(GenericDeletedComic, GenericNavigableComic):
2610
    """Class to retrieve EveryDayBlues Comics."""
@@ 1796-1820 (lines=25) @@
1793
class MouseBearComedy(GenericComicNotWorking):  # Website has changed
1794
    """Class to retrieve Mouse Bear Comedy comics."""
1795
    # Also on http://mousebearcomedy.tumblr.com
1796
    name = 'mousebear'
1797
    long_name = 'Mouse Bear Comedy'
1798
    url = 'http://www.mousebearcomedy.com'
1799
    get_first_comic_link = get_a_navi_navifirst
1800
    get_navi_link = get_a_navi_comicnavnext_navinext
1801
1802
    @classmethod
1803
    def get_comic_info(cls, soup, link):
1804
        """Get information about a particular comics."""
1805
        title = soup.find('h2', class_='post-title').string
1806
        author = soup.find("span", class_="post-author").find("a").string
1807
        date_str = soup.find("span", class_="post-date").string
1808
        day = string_to_date(date_str, '%B %d, %Y')
1809
        imgs = soup.find("div", id="comic").find_all("img")
1810
        assert all(i['alt'] == i['title'] == title for i in imgs)
1811
        return {
1812
            'day': day.day,
1813
            'month': day.month,
1814
            'year': day.year,
1815
            'img': [i['src'] for i in imgs],
1816
            'title': title,
1817
            'author': author,
1818
        }
1819
1820
1821
class BigFootJustice(GenericNavigableComic):
1822
    """Class to retrieve Big Foot Justice comics."""
1823
    # Also on http://tapastic.com/series/bigfoot-justice
@@ 1206-1229 (lines=24) @@
1203
    url = 'http://english.bouletcorp.com'
1204
1205
1206
class AmazingSuperPowers(GenericNavigableComic):
1207
    """Class to retrieve Amazing Super Powers comics."""
1208
    name = 'asp'
1209
    long_name = 'Amazing Super Powers'
1210
    url = 'http://www.amazingsuperpowers.com'
1211
    get_first_comic_link = get_a_navi_navifirst
1212
    get_navi_link = get_a_navi_navinext
1213
1214
    @classmethod
1215
    def get_comic_info(cls, soup, link):
1216
        """Get information about a particular comics."""
1217
        author = soup.find("span", class_="post-author").find("a").string
1218
        date_str = soup.find('span', class_='post-date').string
1219
        day = string_to_date(date_str, "%B %d, %Y")
1220
        imgs = soup.find('div', id='comic').find_all('img')
1221
        title = ' '.join(i['title'] for i in imgs)
1222
        assert all(i['alt'] == i['title'] for i in imgs)
1223
        return {
1224
            'title': title,
1225
            'author': author,
1226
            'img': [img['src'] for img in imgs],
1227
            'day': day.day,
1228
            'month': day.month,
1229
            'year': day.year
1230
        }
1231
1232
@@ 2611-2637 (lines=27) @@
2608
2609
class EveryDayBlues(GenericDeletedComic, GenericNavigableComic):
2610
    """Class to retrieve EveryDayBlues Comics."""
2611
    name = "blues"
2612
    long_name = "Every Day Blues"
2613
    url = "http://everydayblues.net"
2614
    get_first_comic_link = get_a_navi_navifirst
2615
    get_navi_link = get_link_rel_next
2616
2617
    @classmethod
2618
    def get_comic_info(cls, soup, link):
2619
        """Get information about a particular comics."""
2620
        title = soup.find("h2", class_="post-title").string
2621
        author = soup.find("span", class_="post-author").find("a").string
2622
        date_str = soup.find("span", class_="post-date").string
2623
        day = string_to_date(date_str, "%d. %B %Y", "de_DE.utf8")
2624
        imgs = soup.find("div", id="comic").find_all("img")
2625
        assert all(i['alt'] == i['title'] == title for i in imgs)
2626
        assert len(imgs) <= 1, imgs
2627
        return {
2628
            'img': [i['src'] for i in imgs],
2629
            'title': title,
2630
            'author': author,
2631
            'day': day.day,
2632
            'month': day.month,
2633
            'year': day.year
2634
        }
2635
2636
2637
class BiterComics(GenericNavigableComic):
2638
    """Class to retrieve Biter Comics."""
2639
    name = "biter"
2640
    long_name = "Biter Comics"
@@ 2264-2289 (lines=26) @@
2261
class HappleTea(GenericNavigableComic):
2262
    """Class to retrieve Happle Tea Comics."""
2263
    name = 'happletea'
2264
    long_name = 'Happle Tea'
2265
    url = 'http://www.happletea.com'
2266
    get_first_comic_link = get_a_navi_navifirst
2267
    get_navi_link = get_link_rel_next
2268
2269
    @classmethod
2270
    def get_comic_info(cls, soup, link):
2271
        """Get information about a particular comics."""
2272
        imgs = soup.find('div', id='comic').find_all('img')
2273
        post = soup.find('div', class_='post-content')
2274
        title = post.find('h2', class_='post-title').string
2275
        author = post.find('a', rel='author').string
2276
        date_str = post.find('span', class_='post-date').string
2277
        day = string_to_date(date_str, "%B %d, %Y")
2278
        assert all(i['alt'] == i['title'] for i in imgs)
2279
        return {
2280
            'title': title,
2281
            'img': [i['src'] for i in imgs],
2282
            'alt': ''.join(i['alt'] for i in imgs),
2283
            'month': day.month,
2284
            'year': day.year,
2285
            'day': day.day,
2286
            'author': author,
2287
        }
2288
2289
2290
class RockPaperScissors(GenericNavigableComic):
2291
    """Class to retrieve Rock Paper Scissors comics."""
2292
    name = 'rps'
@@ 2445-2469 (lines=25) @@
2442
    def get_url_from_archive_element(cls, tr):
2443
        """Get url corresponding to an archive element."""
2444
        _, td_comic, td_date, _ = tr.find_all('td')
2445
        link = td_comic.find('a')
2446
        return urljoin_wrapper(cls.url, link['href'])
2447
2448
    @classmethod
2449
    def get_comic_info(cls, soup, tr):
2450
        """Get information about a particular comics."""
2451
        td_num, td_comic, td_date, _ = tr.find_all('td')
2452
        num = int(td_num.string)
2453
        link = td_comic.find('a')
2454
        title = link.string
2455
        imgs = soup.find_all('img', id='comic_image')
2456
        date_str = td_date.string
2457
        day = string_to_date(remove_st_nd_rd_th_from_date(date_str), "%B %d, %Y, %I:%M %p")
2458
        assert len(imgs) == 1, imgs
2459
        assert all(i.get('alt') == i.get('title') for i in imgs)
2460
        return {
2461
            'num': num,
2462
            'title': title,
2463
            'alt': imgs[0].get('alt', ''),
2464
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
2465
            'month': day.month,
2466
            'year': day.year,
2467
            'day': day.day,
2468
        }
2469
2470
2471
class LonnieMillsap(GenericNavigableComic):
2472
    """Class to retrieve Lonnie Millsap's comics."""
@@ 3306-3329 (lines=24) @@
3303
        day = string_to_date(date_str, "%B %d, %Y")
3304
        return {
3305
            'img': [i['src'] for i in imgs],
3306
            'title': title,
3307
            'month': day.month,
3308
            'year': day.year,
3309
            'day': day.day,
3310
        }
3311
3312
3313
class TheMeerkatguy(GenericNavigableComic):
3314
    """Class to retrieve The Meerkatguy comics."""
3315
    long_name = 'The Meerkatguy'
3316
    url = 'http://www.themeerkatguy.com'
3317
    name = 'meerkatguy'
3318
    get_first_comic_link = get_a_comicnavbase_comicnavfirst
3319
    get_navi_link = get_a_comicnavbase_comicnavnext
3320
3321
    @classmethod
3322
    def get_comic_info(cls, soup, link):
3323
        """Get information about a particular comics."""
3324
        title = soup.find('title').string
3325
        imgs = soup.find_all('meta', property='og:image')
3326
        return {
3327
            'img': [i['content'] for i in imgs],
3328
            'title': title,
3329
        }
3330
3331
3332
class Ubertool(GenericNavigableComic):
@@ 3607-3627 (lines=21) @@
3604
    _categories = ('BLOGSPOT', )
3605
3606
    @classmethod
3607
    def get_navi_link(cls, last_soup, next_):
3608
        """Get link to next or previous comic."""
3609
        return last_soup.find('a', id='Blog1_blog-pager-newer-link' if next_ else 'Blog1_blog-pager-older-link')
3610
3611
3612
class TuMourrasMoinsBete(GenericBlogspotComic):
3613
    """Class to retrieve Tu Mourras Moins Bete comics."""
3614
    name = 'mourrasmoinsbete'
3615
    long_name = 'Tu Mourras Moins Bete'
3616
    url = 'http://tumourrasmoinsbete.blogspot.fr'
3617
    _categories = ('FRANCAIS', )
3618
    first_url = 'http://tumourrasmoinsbete.blogspot.fr/2008/06/essai.html'
3619
3620
    @classmethod
3621
    def get_comic_info(cls, soup, link):
3622
        """Get information about a particular comics."""
3623
        title = soup.find('title').string
3624
        imgs = soup.find('div', itemprop='description articleBody').find_all('img')
3625
        author = soup.find('span', itemprop='author').string
3626
        return {
3627
            'img': [i['src'] for i in imgs],
3628
            'author': author,
3629
            'title': title,
3630
        }
@@ 3263-3283 (lines=21) @@
3260
    long_name = 'Sheldon Comics'
3261
    url = 'http://www.sheldoncomics.com'
3262
3263
    @classmethod
3264
    def get_first_comic_link(cls):
3265
        """Get link to first comics."""
3266
        return get_soup_at_url(cls.url).find("a", id="nav-first")
3267
3268
    @classmethod
3269
    def get_navi_link(cls, last_soup, next_):
3270
        """Get link to next or previous comic."""
3271
        for link in last_soup.find_all("a", id="nav-next" if next_ else "nav-prev"):
3272
            if link['href'] != 'http://www.sheldoncomics.com':
3273
                return link
3274
        return None
3275
3276
    @classmethod
3277
    def get_comic_info(cls, soup, link):
3278
        """Get information about a particular comics."""
3279
        imgs = soup.find("div", id="comic-foot").find_all("img")
3280
        assert all(i['alt'] == i['title'] for i in imgs)
3281
        assert len(imgs) == 1, imgs
3282
        title = imgs[0]['title']
3283
        return {
3284
            'title': title,
3285
            'img': [i['src'] for i in imgs],
3286
        }
@@ 2053-2079 (lines=27) @@
2050
class CompletelySeriousComics(GenericNavigableComic):
2051
    """Class to retrieve Completely Serious comics."""
2052
    name = 'completelyserious'
2053
    long_name = 'Completely Serious Comics'
2054
    url = 'http://completelyseriouscomics.com'
2055
    get_first_comic_link = get_a_navi_navifirst
2056
    get_navi_link = get_a_navi_navinext
2057
2058
    @classmethod
2059
    def get_comic_info(cls, soup, link):
2060
        """Get information about a particular comics."""
2061
        title = soup.find('h2', class_='post-title').string
2062
        author = soup.find('span', class_='post-author').contents[1].string
2063
        date_str = soup.find('span', class_='post-date').string
2064
        day = string_to_date(date_str, '%B %d, %Y')
2065
        imgs = soup.find('div', class_='comicpane').find_all('img')
2066
        assert imgs
2067
        alt = imgs[0]['title']
2068
        assert all(i['title'] == i['alt'] == alt for i in imgs)
2069
        return {
2070
            'month': day.month,
2071
            'year': day.year,
2072
            'day': day.day,
2073
            'img': [i['src'] for i in imgs],
2074
            'title': title,
2075
            'alt': alt,
2076
            'author': author,
2077
        }
2078
2079
2080
class PoorlyDrawnLines(GenericListableComic):
2081
    """Class to retrieve Poorly Drawn Lines comics."""
2082
    # Also on http://pdlcomics.tumblr.com