Code Duplication    Length = 23-27 lines in 10 locations

comics.py 10 locations

@@ 1844-1870 (lines=27) @@
1841
        }
1842
1843
1844
class PicturesInBoxes(GenericNavigableComic):
1845
    """Class to retrieve Pictures In Boxes comics."""
1846
    # Also on http://picturesinboxescomic.tumblr.com
1847
    name = 'picturesinboxes'
1848
    long_name = 'Pictures in Boxes'
1849
    url = 'http://www.picturesinboxes.com'
1850
    get_navi_link = get_a_navi_navinext
1851
    get_first_comic_link = simulate_first_link
1852
    first_url = 'http://www.picturesinboxes.com/2013/10/26/tetris/'
1853
1854
    @classmethod
1855
    def get_comic_info(cls, soup, link):
1856
        """Get information about a particular comics."""
1857
        title = soup.find('h2', class_='post-title').string
1858
        author = soup.find("span", class_="post-author").find("a").string
1859
        date_str = soup.find('span', class_='post-date').string
1860
        day = string_to_date(date_str, '%B %d, %Y')
1861
        imgs = soup.find('div', class_='comicpane').find_all('img')
1862
        assert imgs
1863
        assert all(i['title'] == i['alt'] == title for i in imgs)
1864
        return {
1865
            'day': day.day,
1866
            'month': day.month,
1867
            'year': day.year,
1868
            'img': [i['src'] for i in imgs],
1869
            'title': title,
1870
            'author': author,
1871
        }
1872
1873
@@ 2448-2473 (lines=26) @@
2445
        }
2446
2447
2448
class TheAwkwardYeti(GenericNavigableComic):
2449
    """Class to retrieve The Awkward Yeti comics."""
2450
    # Also on http://www.gocomics.com/the-awkward-yeti
2451
    # Also on http://larstheyeti.tumblr.com
2452
    # Also on https://tapastic.com/series/TheAwkwardYeti
2453
    name = 'yeti'
2454
    long_name = 'The Awkward Yeti'
2455
    url = 'http://theawkwardyeti.com'
2456
    _categories = ('YETI', )
2457
    get_first_comic_link = get_a_navi_navifirst
2458
    get_navi_link = get_link_rel_next
2459
2460
    @classmethod
2461
    def get_comic_info(cls, soup, link):
2462
        """Get information about a particular comics."""
2463
        title = soup.find('h2', class_='post-title').string
2464
        date_str = soup.find("span", class_="post-date").string
2465
        day = string_to_date(date_str, "%B %d, %Y")
2466
        imgs = soup.find("div", id="comic").find_all("img")
2467
        assert all(idx > 0 or i['alt'] == i['title'] for idx, i in enumerate(imgs))
2468
        return {
2469
            'img': [i['src'] for i in imgs],
2470
            'title': title,
2471
            'day': day.day,
2472
            'month': day.month,
2473
            'year': day.year
2474
        }
2475
2476
@@ 2361-2386 (lines=26) @@
2358
        }
2359
2360
2361
class GerbilWithAJetpack(GenericNavigableComic):
2362
    """Class to retrieve GerbilWithAJetpack comics."""
2363
    name = 'gerbil'
2364
    long_name = 'Gerbil With A Jetpack'
2365
    url = 'http://gerbilwithajetpack.com'
2366
    get_first_comic_link = get_a_navi_navifirst
2367
    get_navi_link = get_a_rel_next
2368
2369
    @classmethod
2370
    def get_comic_info(cls, soup, link):
2371
        """Get information about a particular comics."""
2372
        title = soup.find('h2', class_='post-title').string
2373
        author = soup.find("span", class_="post-author").find("a").string
2374
        date_str = soup.find("span", class_="post-date").string
2375
        day = string_to_date(date_str, "%B %d, %Y")
2376
        imgs = soup.find("div", id="comic").find_all("img")
2377
        alt = imgs[0]['alt']
2378
        assert all(i['alt'] == i['title'] == alt for i in imgs)
2379
        return {
2380
            'img': [i['src'] for i in imgs],
2381
            'title': title,
2382
            'alt': alt,
2383
            'author': author,
2384
            'day': day.day,
2385
            'month': day.month,
2386
            'year': day.year
2387
        }
2388
2389
@@ 2702-2726 (lines=25) @@
2699
    first_url = 'http://www.commitstrip.com/en/2012/02/22/interview/'
2700
2701
2702
class GenericBoumerie(GenericNavigableComic):
2703
    """Generic class to retrieve Boumeries comics in different languages."""
2704
    get_first_comic_link = get_a_navi_navifirst
2705
    get_navi_link = get_link_rel_next
2706
    date_format = NotImplemented
2707
    lang = NotImplemented
2708
2709
    @classmethod
2710
    def get_comic_info(cls, soup, link):
2711
        """Get information about a particular comics."""
2712
        title = soup.find('h2', class_='post-title').string
2713
        short_url = soup.find('link', rel='shortlink')['href']
2714
        author = soup.find("span", class_="post-author").find("a").string
2715
        date_str = soup.find('span', class_='post-date').string
2716
        day = string_to_date(date_str, cls.date_format, cls.lang)
2717
        imgs = soup.find('div', id='comic').find_all('img')
2718
        assert all(i['alt'] == i['title'] for i in imgs)
2719
        return {
2720
            'short_url': short_url,
2721
            'img': [i['src'] for i in imgs],
2722
            'title': title,
2723
            'author': author,
2724
            'month': day.month,
2725
            'year': day.year,
2726
            'day': day.day,
2727
        }
2728
2729
@@ 2390-2414 (lines=25) @@
2387
        }
2388
2389
2390
class EveryDayBlues(GenericNavigableComic):
2391
    """Class to retrieve EveryDayBlues Comics."""
2392
    name = "blues"
2393
    long_name = "Every Day Blues"
2394
    url = "http://everydayblues.net"
2395
    get_first_comic_link = get_a_navi_navifirst
2396
    get_navi_link = get_link_rel_next
2397
2398
    @classmethod
2399
    def get_comic_info(cls, soup, link):
2400
        """Get information about a particular comics."""
2401
        title = soup.find("h2", class_="post-title").string
2402
        author = soup.find("span", class_="post-author").find("a").string
2403
        date_str = soup.find("span", class_="post-date").string
2404
        day = string_to_date(date_str, "%d. %B %Y", "de_DE.utf8")
2405
        imgs = soup.find("div", id="comic").find_all("img")
2406
        assert all(i['alt'] == i['title'] == title for i in imgs)
2407
        assert len(imgs) <= 1
2408
        return {
2409
            'img': [i['src'] for i in imgs],
2410
            'title': title,
2411
            'author': author,
2412
            'day': day.day,
2413
            'month': day.month,
2414
            'year': day.year
2415
        }
2416
2417
@@ 1732-1756 (lines=25) @@
1729
        }
1730
1731
1732
class MouseBearComedy(GenericNavigableComic):
1733
    """Class to retrieve Mouse Bear Comedy comics."""
1734
    # Also on http://mousebearcomedy.tumblr.com
1735
    name = 'mousebear'
1736
    long_name = 'Mouse Bear Comedy'
1737
    url = 'http://www.mousebearcomedy.com'
1738
    get_first_comic_link = get_a_navi_navifirst
1739
    get_navi_link = get_a_navi_comicnavnext_navinext
1740
1741
    @classmethod
1742
    def get_comic_info(cls, soup, link):
1743
        """Get information about a particular comics."""
1744
        title = soup.find('h2', class_='post-title').string
1745
        author = soup.find("span", class_="post-author").find("a").string
1746
        date_str = soup.find("span", class_="post-date").string
1747
        day = string_to_date(date_str, '%B %d, %Y')
1748
        imgs = soup.find("div", id="comic").find_all("img")
1749
        assert all(i['alt'] == i['title'] == title for i in imgs)
1750
        return {
1751
            'day': day.day,
1752
            'month': day.month,
1753
            'year': day.year,
1754
            'img': [i['src'] for i in imgs],
1755
            'title': title,
1756
            'author': author,
1757
        }
1758
1759
@@ 1134-1157 (lines=24) @@
1131
    url = 'http://english.bouletcorp.com'
1132
1133
1134
class AmazingSuperPowers(GenericNavigableComic):
1135
    """Class to retrieve Amazing Super Powers comics."""
1136
    name = 'asp'
1137
    long_name = 'Amazing Super Powers'
1138
    url = 'http://www.amazingsuperpowers.com'
1139
    get_first_comic_link = get_a_navi_navifirst
1140
    get_navi_link = get_a_navi_navinext
1141
1142
    @classmethod
1143
    def get_comic_info(cls, soup, link):
1144
        """Get information about a particular comics."""
1145
        author = soup.find("span", class_="post-author").find("a").string
1146
        date_str = soup.find('span', class_='post-date').string
1147
        day = string_to_date(date_str, "%B %d, %Y")
1148
        imgs = soup.find('div', id='comic').find_all('img')
1149
        title = ' '.join(i['title'] for i in imgs)
1150
        assert all(i['alt'] == i['title'] for i in imgs)
1151
        return {
1152
            'title': title,
1153
            'author': author,
1154
            'img': [img['src'] for img in imgs],
1155
            'day': day.day,
1156
            'month': day.month,
1157
            'year': day.year
1158
        }
1159
1160
@@ 669-692 (lines=24) @@
666
        }
667
668
669
class OneOneOneOneComic(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
@@ 899-921 (lines=23) @@
896
        }
897
898
899
class TheGentlemanArmchair(GenericNavigableComic):
900
    """Class to retrieve The Gentleman Armchair comics."""
901
    name = 'gentlemanarmchair'
902
    long_name = 'The Gentleman Armchair'
903
    url = 'http://thegentlemansarmchair.com'
904
    get_first_comic_link = get_a_navi_navifirst
905
    get_navi_link = get_link_rel_next
906
907
    @classmethod
908
    def get_comic_info(cls, soup, link):
909
        """Get information about a particular comics."""
910
        title = soup.find('h2', class_='post-title').string
911
        author = soup.find("span", class_="post-author").find("a").string
912
        date_str = soup.find('span', class_='post-date').string
913
        day = string_to_date(date_str, "%B %d, %Y")
914
        imgs = soup.find('div', id='comic').find_all('img')
915
        return {
916
            'img': [i['src'] for i in imgs],
917
            'title': title,
918
            'author': author,
919
            'month': day.month,
920
            'year': day.year,
921
            'day': day.day,
922
        }
923
924
@@ 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):