Code Duplication    Length = 23-27 lines in 10 locations

comics.py 10 locations

@@ 669-692 (lines=24) @@
666
        }
667
668
669
class OneOneOneOneComic(GenericEmptyComic, GenericNavigableComic):
670
    """Class to retrieve 1111 Comics."""
671
    # Also on http://comics1111.tumblr.com
672
    # Also on https://tapastic.com/series/1111-Comics
673
    name = '1111'
674
    long_name = '1111 Comics'
675
    url = 'http://www.1111comics.me'
676
    _categories = ('ONEONEONEONE', )
677
    get_first_comic_link = get_div_navfirst_a
678
    get_navi_link = get_link_rel_next
679
680
    @classmethod
681
    def get_comic_info(cls, soup, link):
682
        """Get information about a particular comics."""
683
        title = soup.find('h1', class_='comic-title').find('a').string
684
        date_str = soup.find('header', class_='comic-meta entry-meta').find('a').string
685
        day = string_to_date(date_str, "%B %d, %Y")
686
        imgs = soup.find_all('meta', property='og:image')
687
        return {
688
            'title': title,
689
            'month': day.month,
690
            'year': day.year,
691
            'day': day.day,
692
            'img': [i['content'] for i in imgs],
693
        }
694
695
@@ 696-718 (lines=23) @@
693
        }
694
695
696
class AngryAtNothing(GenericNavigableComic):
697
    """Class to retrieve Angry at Nothing comics."""
698
    # Also on http://tapastic.com/series/Comics-yeah-definitely-comics-
699
    name = 'angry'
700
    long_name = 'Angry At Nothing'
701
    url = 'http://www.angryatnothing.net'
702
    get_first_comic_link = get_div_navfirst_a
703
    get_navi_link = get_a_rel_next
704
705
    @classmethod
706
    def get_comic_info(cls, soup, link):
707
        """Get information about a particular comics."""
708
        title = soup.find('h1', class_='comic-title').find('a').string
709
        date_str = soup.find('header', class_='comic-meta entry-meta').find('a').string
710
        day = string_to_date(date_str, "%B %d, %Y")
711
        imgs = soup.find_all('meta', property='og:image')
712
        return {
713
            'title': title,
714
            'month': day.month,
715
            'year': day.year,
716
            'day': day.day,
717
            'img': [i['content'] for i in imgs],
718
        }
719
720
721
class NeDroid(GenericNavigableComic):
@@ 1831-1857 (lines=27) @@
1828
        }
1829
1830
1831
class PicturesInBoxes(GenericNavigableComic):
1832
    """Class to retrieve Pictures In Boxes comics."""
1833
    # Also on http://picturesinboxescomic.tumblr.com
1834
    name = 'picturesinboxes'
1835
    long_name = 'Pictures in Boxes'
1836
    url = 'http://www.picturesinboxes.com'
1837
    get_navi_link = get_a_navi_navinext
1838
    get_first_comic_link = simulate_first_link
1839
    first_url = 'http://www.picturesinboxes.com/2013/10/26/tetris/'
1840
1841
    @classmethod
1842
    def get_comic_info(cls, soup, link):
1843
        """Get information about a particular comics."""
1844
        title = soup.find('h2', class_='post-title').string
1845
        author = soup.find("span", class_="post-author").find("a").string
1846
        date_str = soup.find('span', class_='post-date').string
1847
        day = string_to_date(date_str, '%B %d, %Y')
1848
        imgs = soup.find('div', class_='comicpane').find_all('img')
1849
        assert imgs
1850
        assert all(i['title'] == i['alt'] == title for i in imgs)
1851
        return {
1852
            'day': day.day,
1853
            'month': day.month,
1854
            'year': day.year,
1855
            'img': [i['src'] for i in imgs],
1856
            'title': title,
1857
            'author': author,
1858
        }
1859
1860
@@ 2480-2505 (lines=26) @@
2477
        }
2478
2479
2480
class TheAwkwardYeti(GenericNavigableComic):
2481
    """Class to retrieve The Awkward Yeti comics."""
2482
    # Also on http://www.gocomics.com/the-awkward-yeti
2483
    # Also on http://larstheyeti.tumblr.com
2484
    # Also on https://tapastic.com/series/TheAwkwardYeti
2485
    name = 'yeti'
2486
    long_name = 'The Awkward Yeti'
2487
    url = 'http://theawkwardyeti.com'
2488
    _categories = ('YETI', )
2489
    get_first_comic_link = get_a_navi_navifirst
2490
    get_navi_link = get_link_rel_next
2491
2492
    @classmethod
2493
    def get_comic_info(cls, soup, link):
2494
        """Get information about a particular comics."""
2495
        title = soup.find('h2', class_='post-title').string
2496
        date_str = soup.find("span", class_="post-date").string
2497
        day = string_to_date(date_str, "%B %d, %Y")
2498
        imgs = soup.find("div", id="comic").find_all("img")
2499
        assert all(idx > 0 or i['alt'] == i['title'] for idx, i in enumerate(imgs))
2500
        return {
2501
            'img': [i['src'] for i in imgs],
2502
            'title': title,
2503
            'day': day.day,
2504
            'month': day.month,
2505
            'year': day.year
2506
        }
2507
2508
@@ 2393-2418 (lines=26) @@
2390
        }
2391
2392
2393
class GerbilWithAJetpack(GenericNavigableComic):
2394
    """Class to retrieve GerbilWithAJetpack comics."""
2395
    name = 'gerbil'
2396
    long_name = 'Gerbil With A Jetpack'
2397
    url = 'http://gerbilwithajetpack.com'
2398
    get_first_comic_link = get_a_navi_navifirst
2399
    get_navi_link = get_a_rel_next
2400
2401
    @classmethod
2402
    def get_comic_info(cls, soup, link):
2403
        """Get information about a particular comics."""
2404
        title = soup.find('h2', class_='post-title').string
2405
        author = soup.find("span", class_="post-author").find("a").string
2406
        date_str = soup.find("span", class_="post-date").string
2407
        day = string_to_date(date_str, "%B %d, %Y")
2408
        imgs = soup.find("div", id="comic").find_all("img")
2409
        alt = imgs[0]['alt']
2410
        assert all(i['alt'] == i['title'] == alt for i in imgs)
2411
        return {
2412
            'img': [i['src'] for i in imgs],
2413
            'title': title,
2414
            'alt': alt,
2415
            'author': author,
2416
            'day': day.day,
2417
            'month': day.month,
2418
            'year': day.year
2419
        }
2420
2421
@@ 2734-2758 (lines=25) @@
2731
    first_url = 'http://www.commitstrip.com/en/2012/02/22/interview/'
2732
2733
2734
class GenericBoumerie(GenericNavigableComic):
2735
    """Generic class to retrieve Boumeries comics in different languages."""
2736
    get_first_comic_link = get_a_navi_navifirst
2737
    get_navi_link = get_link_rel_next
2738
    date_format = NotImplemented
2739
    lang = NotImplemented
2740
2741
    @classmethod
2742
    def get_comic_info(cls, soup, link):
2743
        """Get information about a particular comics."""
2744
        title = soup.find('h2', class_='post-title').string
2745
        short_url = soup.find('link', rel='shortlink')['href']
2746
        author = soup.find("span", class_="post-author").find("a").string
2747
        date_str = soup.find('span', class_='post-date').string
2748
        day = string_to_date(date_str, cls.date_format, cls.lang)
2749
        imgs = soup.find('div', id='comic').find_all('img')
2750
        assert all(i['alt'] == i['title'] for i in imgs)
2751
        return {
2752
            'short_url': short_url,
2753
            'img': [i['src'] for i in imgs],
2754
            'title': title,
2755
            'author': author,
2756
            'month': day.month,
2757
            'year': day.year,
2758
            'day': day.day,
2759
        }
2760
2761
@@ 2422-2446 (lines=25) @@
2419
        }
2420
2421
2422
class EveryDayBlues(GenericNavigableComic):
2423
    """Class to retrieve EveryDayBlues Comics."""
2424
    name = "blues"
2425
    long_name = "Every Day Blues"
2426
    url = "http://everydayblues.net"
2427
    get_first_comic_link = get_a_navi_navifirst
2428
    get_navi_link = get_link_rel_next
2429
2430
    @classmethod
2431
    def get_comic_info(cls, soup, link):
2432
        """Get information about a particular comics."""
2433
        title = soup.find("h2", class_="post-title").string
2434
        author = soup.find("span", class_="post-author").find("a").string
2435
        date_str = soup.find("span", class_="post-date").string
2436
        day = string_to_date(date_str, "%d. %B %Y", "de_DE.utf8")
2437
        imgs = soup.find("div", id="comic").find_all("img")
2438
        assert all(i['alt'] == i['title'] == title for i in imgs)
2439
        assert len(imgs) <= 1
2440
        return {
2441
            'img': [i['src'] for i in imgs],
2442
            'title': title,
2443
            'author': author,
2444
            'day': day.day,
2445
            'month': day.month,
2446
            'year': day.year
2447
        }
2448
2449
@@ 1719-1743 (lines=25) @@
1716
        }
1717
1718
1719
class MouseBearComedy(GenericNavigableComic):
1720
    """Class to retrieve Mouse Bear Comedy comics."""
1721
    # Also on http://mousebearcomedy.tumblr.com
1722
    name = 'mousebear'
1723
    long_name = 'Mouse Bear Comedy'
1724
    url = 'http://www.mousebearcomedy.com'
1725
    get_first_comic_link = get_a_navi_navifirst
1726
    get_navi_link = get_a_navi_comicnavnext_navinext
1727
1728
    @classmethod
1729
    def get_comic_info(cls, soup, link):
1730
        """Get information about a particular comics."""
1731
        title = soup.find('h2', class_='post-title').string
1732
        author = soup.find("span", class_="post-author").find("a").string
1733
        date_str = soup.find("span", class_="post-date").string
1734
        day = string_to_date(date_str, '%B %d, %Y')
1735
        imgs = soup.find("div", id="comic").find_all("img")
1736
        assert all(i['alt'] == i['title'] == title for i in imgs)
1737
        return {
1738
            'day': day.day,
1739
            'month': day.month,
1740
            'year': day.year,
1741
            'img': [i['src'] for i in imgs],
1742
            'title': title,
1743
            'author': author,
1744
        }
1745
1746
@@ 1127-1150 (lines=24) @@
1124
    url = 'http://english.bouletcorp.com'
1125
1126
1127
class AmazingSuperPowers(GenericNavigableComic):
1128
    """Class to retrieve Amazing Super Powers comics."""
1129
    name = 'asp'
1130
    long_name = 'Amazing Super Powers'
1131
    url = 'http://www.amazingsuperpowers.com'
1132
    get_first_comic_link = get_a_navi_navifirst
1133
    get_navi_link = get_a_navi_navinext
1134
1135
    @classmethod
1136
    def get_comic_info(cls, soup, link):
1137
        """Get information about a particular comics."""
1138
        author = soup.find("span", class_="post-author").find("a").string
1139
        date_str = soup.find('span', class_='post-date').string
1140
        day = string_to_date(date_str, "%B %d, %Y")
1141
        imgs = soup.find('div', id='comic').find_all('img')
1142
        title = ' '.join(i['title'] for i in imgs)
1143
        assert all(i['alt'] == i['title'] for i in imgs)
1144
        return {
1145
            'title': title,
1146
            'author': author,
1147
            'img': [img['src'] for img in imgs],
1148
            'day': day.day,
1149
            'month': day.month,
1150
            'year': day.year
1151
        }
1152
1153
@@ 895-917 (lines=23) @@
892
        }
893
894
895
class TheGentlemanArmchair(GenericNavigableComic):
896
    """Class to retrieve The Gentleman Armchair comics."""
897
    name = 'gentlemanarmchair'
898
    long_name = 'The Gentleman Armchair'
899
    url = 'http://thegentlemansarmchair.com'
900
    get_first_comic_link = get_a_navi_navifirst
901
    get_navi_link = get_link_rel_next
902
903
    @classmethod
904
    def get_comic_info(cls, soup, link):
905
        """Get information about a particular comics."""
906
        title = soup.find('h2', class_='post-title').string
907
        author = soup.find("span", class_="post-author").find("a").string
908
        date_str = soup.find('span', class_='post-date').string
909
        day = string_to_date(date_str, "%B %d, %Y")
910
        imgs = soup.find('div', id='comic').find_all('img')
911
        return {
912
            'img': [i['src'] for i in imgs],
913
            'title': title,
914
            'author': author,
915
            'month': day.month,
916
            'year': day.year,
917
            'day': day.day,
918
        }
919
920