Code Duplication    Length = 23-27 lines in 10 locations

comics.py 10 locations

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