Code Duplication    Length = 22-27 lines in 11 locations

comics.py 11 locations

@@ 1855-1881 (lines=27) @@
1852
        }
1853
1854
1855
class PicturesInBoxes(GenericNavigableComic):
1856
    """Class to retrieve Pictures In Boxes comics."""
1857
    # Also on https://picturesinboxescomic.tumblr.com
1858
    name = 'picturesinboxes'
1859
    long_name = 'Pictures in Boxes'
1860
    url = 'http://www.picturesinboxes.com'
1861
    get_navi_link = get_a_navi_navinext
1862
    get_first_comic_link = simulate_first_link
1863
    first_url = 'http://www.picturesinboxes.com/2013/10/26/tetris/'
1864
1865
    @classmethod
1866
    def get_comic_info(cls, soup, link):
1867
        """Get information about a particular comics."""
1868
        title = soup.find('h2', class_='post-title').string
1869
        author = soup.find("span", class_="post-author").find("a").string
1870
        date_str = soup.find('span', class_='post-date').string
1871
        day = string_to_date(date_str, '%B %d, %Y')
1872
        imgs = soup.find('div', class_='comicpane').find_all('img')
1873
        assert imgs
1874
        assert all(i['title'] == i['alt'] == title for i in imgs)
1875
        return {
1876
            'day': day.day,
1877
            'month': day.month,
1878
            'year': day.year,
1879
            'img': [i['src'] for i in imgs],
1880
            'title': title,
1881
            'author': author,
1882
        }
1883
1884
@@ 958-984 (lines=27) @@
955
        }
956
957
958
class ImogenQuest(GenericNavigableComic):
959
    """Class to retrieve Imogen Quest comics."""
960
    # Also on http://imoquest.tumblr.com
961
    name = 'imogen'
962
    long_name = 'Imogen Quest'
963
    url = 'http://imogenquest.net'
964
    get_first_comic_link = get_div_navfirst_a
965
    get_navi_link = get_a_rel_next
966
967
    @classmethod
968
    def get_comic_info(cls, soup, link):
969
        """Get information about a particular comics."""
970
        title = soup.find('h2', class_='post-title').string
971
        author = soup.find("span", class_="post-author").find("a").string
972
        date_str = soup.find('span', class_='post-date').string
973
        day = string_to_date(date_str, '%B %d, %Y')
974
        imgs = soup.find('div', class_='comicpane').find_all('img')
975
        assert all(i['alt'] == i['title'] for i in imgs)
976
        title2 = imgs[0]['title']
977
        return {
978
            'day': day.day,
979
            'month': day.month,
980
            'year': day.year,
981
            'img': [i['src'] for i in imgs],
982
            'title': title,
983
            'title2': title2,
984
            'author': author,
985
        }
986
987
@@ 2809-2833 (lines=25) @@
2806
    first_url = 'http://www.commitstrip.com/en/2012/02/22/interview/'
2807
2808
2809
class GenericBoumerie(GenericNavigableComic):
2810
    """Generic class to retrieve Boumeries comics in different languages."""
2811
    # Also on http://boumeries.tumblr.com
2812
    get_first_comic_link = get_a_navi_navifirst
2813
    get_navi_link = get_link_rel_next
2814
    date_format = NotImplemented
2815
    lang = NotImplemented
2816
2817
    @classmethod
2818
    def get_comic_info(cls, soup, link):
2819
        """Get information about a particular comics."""
2820
        title = soup.find('h2', class_='post-title').string
2821
        short_url = soup.find('link', rel='shortlink')['href']
2822
        author = soup.find("span", class_="post-author").find("a").string
2823
        date_str = soup.find('span', class_='post-date').string
2824
        day = string_to_date(date_str, cls.date_format, cls.lang)
2825
        imgs = soup.find('div', id='comic').find_all('img')
2826
        assert all(i['alt'] == i['title'] for i in imgs)
2827
        return {
2828
            'short_url': short_url,
2829
            'img': [i['src'] for i in imgs],
2830
            'title': title,
2831
            'author': author,
2832
            'month': day.month,
2833
            'year': day.year,
2834
            'day': day.day,
2835
        }
2836
@@ 2555-2580 (lines=26) @@
2552
        }
2553
2554
2555
class TheAwkwardYeti(GenericNavigableComic):
2556
    """Class to retrieve The Awkward Yeti comics."""
2557
    # Also on http://www.gocomics.com/the-awkward-yeti
2558
    # Also on http://larstheyeti.tumblr.com
2559
    # Also on https://tapastic.com/series/TheAwkwardYeti
2560
    name = 'yeti'
2561
    long_name = 'The Awkward Yeti'
2562
    url = 'http://theawkwardyeti.com'
2563
    _categories = ('YETI', )
2564
    get_first_comic_link = get_a_navi_navifirst
2565
    get_navi_link = get_link_rel_next
2566
2567
    @classmethod
2568
    def get_comic_info(cls, soup, link):
2569
        """Get information about a particular comics."""
2570
        title = soup.find('h2', class_='post-title').string
2571
        date_str = soup.find("span", class_="post-date").string
2572
        day = string_to_date(date_str, "%B %d, %Y")
2573
        imgs = soup.find("div", id="comic").find_all("img")
2574
        assert all(idx > 0 or i['alt'] == i['title'] for idx, i in enumerate(imgs))
2575
        return {
2576
            'img': [i['src'] for i in imgs],
2577
            'title': title,
2578
            'day': day.day,
2579
            'month': day.month,
2580
            'year': day.year
2581
        }
2582
2583
@@ 2468-2493 (lines=26) @@
2465
        }
2466
2467
2468
class GerbilWithAJetpack(GenericNavigableComic):
2469
    """Class to retrieve GerbilWithAJetpack comics."""
2470
    name = 'gerbil'
2471
    long_name = 'Gerbil With A Jetpack'
2472
    url = 'http://gerbilwithajetpack.com'
2473
    get_first_comic_link = get_a_navi_navifirst
2474
    get_navi_link = get_a_rel_next
2475
2476
    @classmethod
2477
    def get_comic_info(cls, soup, link):
2478
        """Get information about a particular comics."""
2479
        title = soup.find('h2', class_='post-title').string
2480
        author = soup.find("span", class_="post-author").find("a").string
2481
        date_str = soup.find("span", class_="post-date").string
2482
        day = string_to_date(date_str, "%B %d, %Y")
2483
        imgs = soup.find("div", id="comic").find_all("img")
2484
        alt = imgs[0]['alt']
2485
        assert all(i['alt'] == i['title'] == alt for i in imgs)
2486
        return {
2487
            'img': [i['src'] for i in imgs],
2488
            'title': title,
2489
            'alt': alt,
2490
            'author': author,
2491
            'day': day.day,
2492
            'month': day.month,
2493
            'year': day.year
2494
        }
2495
2496
@@ 2497-2521 (lines=25) @@
2494
        }
2495
2496
2497
class EveryDayBlues(GenericDeletedComic, GenericNavigableComic):
2498
    """Class to retrieve EveryDayBlues Comics."""
2499
    name = "blues"
2500
    long_name = "Every Day Blues"
2501
    url = "http://everydayblues.net"
2502
    get_first_comic_link = get_a_navi_navifirst
2503
    get_navi_link = get_link_rel_next
2504
2505
    @classmethod
2506
    def get_comic_info(cls, soup, link):
2507
        """Get information about a particular comics."""
2508
        title = soup.find("h2", class_="post-title").string
2509
        author = soup.find("span", class_="post-author").find("a").string
2510
        date_str = soup.find("span", class_="post-date").string
2511
        day = string_to_date(date_str, "%d. %B %Y", "de_DE.utf8")
2512
        imgs = soup.find("div", id="comic").find_all("img")
2513
        assert all(i['alt'] == i['title'] == title for i in imgs)
2514
        assert len(imgs) <= 1, imgs
2515
        return {
2516
            'img': [i['src'] for i in imgs],
2517
            'title': title,
2518
            'author': author,
2519
            'day': day.day,
2520
            'month': day.month,
2521
            'year': day.year
2522
        }
2523
2524
@@ 1743-1767 (lines=25) @@
1740
        }
1741
1742
1743
class MouseBearComedy(GenericComicNotWorking):  # Website has changed
1744
    """Class to retrieve Mouse Bear Comedy comics."""
1745
    # Also on http://mousebearcomedy.tumblr.com
1746
    name = 'mousebear'
1747
    long_name = 'Mouse Bear Comedy'
1748
    url = 'http://www.mousebearcomedy.com'
1749
    get_first_comic_link = get_a_navi_navifirst
1750
    get_navi_link = get_a_navi_comicnavnext_navinext
1751
1752
    @classmethod
1753
    def get_comic_info(cls, soup, link):
1754
        """Get information about a particular comics."""
1755
        title = soup.find('h2', class_='post-title').string
1756
        author = soup.find("span", class_="post-author").find("a").string
1757
        date_str = soup.find("span", class_="post-date").string
1758
        day = string_to_date(date_str, '%B %d, %Y')
1759
        imgs = soup.find("div", id="comic").find_all("img")
1760
        assert all(i['alt'] == i['title'] == title for i in imgs)
1761
        return {
1762
            'day': day.day,
1763
            'month': day.month,
1764
            'year': day.year,
1765
            'img': [i['src'] for i in imgs],
1766
            'title': title,
1767
            'author': author,
1768
        }
1769
1770
@@ 1187-1210 (lines=24) @@
1184
    url = 'http://english.bouletcorp.com'
1185
1186
1187
class AmazingSuperPowers(GenericNavigableComic):
1188
    """Class to retrieve Amazing Super Powers comics."""
1189
    name = 'asp'
1190
    long_name = 'Amazing Super Powers'
1191
    url = 'http://www.amazingsuperpowers.com'
1192
    get_first_comic_link = get_a_navi_navifirst
1193
    get_navi_link = get_a_navi_navinext
1194
1195
    @classmethod
1196
    def get_comic_info(cls, soup, link):
1197
        """Get information about a particular comics."""
1198
        author = soup.find("span", class_="post-author").find("a").string
1199
        date_str = soup.find('span', class_='post-date').string
1200
        day = string_to_date(date_str, "%B %d, %Y")
1201
        imgs = soup.find('div', id='comic').find_all('img')
1202
        title = ' '.join(i['title'] for i in imgs)
1203
        assert all(i['alt'] == i['title'] for i in imgs)
1204
        return {
1205
            'title': title,
1206
            'author': author,
1207
            'img': [img['src'] for img in imgs],
1208
            'day': day.day,
1209
            'month': day.month,
1210
            'year': day.year
1211
        }
1212
1213
@@ 704-727 (lines=24) @@
701
        }
702
703
704
class OneOneOneOneComic(GenericComicNotWorking, GenericNavigableComic):
705
    """Class to retrieve 1111 Comics."""
706
    # Also on http://comics1111.tumblr.com
707
    # Also on https://tapastic.com/series/1111-Comics
708
    name = '1111'
709
    long_name = '1111 Comics'
710
    url = 'http://www.1111comics.me'
711
    _categories = ('ONEONEONEONE', )
712
    get_first_comic_link = get_div_navfirst_a
713
    get_navi_link = get_link_rel_next
714
715
    @classmethod
716
    def get_comic_info(cls, soup, link):
717
        """Get information about a particular comics."""
718
        title = soup.find('h1', class_='comic-title').find('a').string
719
        date_str = soup.find('header', class_='comic-meta entry-meta').find('a').string
720
        day = string_to_date(date_str, "%B %d, %Y")
721
        imgs = soup.find_all('meta', property='og:image')
722
        return {
723
            'title': title,
724
            'month': day.month,
725
            'year': day.year,
726
            'day': day.day,
727
            'img': [i['content'] for i in imgs],
728
        }
729
730
@@ 932-954 (lines=23) @@
929
        }
930
931
932
class TheGentlemanArmchair(GenericNavigableComic):
933
    """Class to retrieve The Gentleman Armchair comics."""
934
    name = 'gentlemanarmchair'
935
    long_name = 'The Gentleman Armchair'
936
    url = 'http://thegentlemansarmchair.com'
937
    get_first_comic_link = get_a_navi_navifirst
938
    get_navi_link = get_link_rel_next
939
940
    @classmethod
941
    def get_comic_info(cls, soup, link):
942
        """Get information about a particular comics."""
943
        title = soup.find('h2', class_='post-title').string
944
        author = soup.find("span", class_="post-author").find("a").string
945
        date_str = soup.find('span', class_='post-date').string
946
        day = string_to_date(date_str, "%B %d, %Y")
947
        imgs = soup.find('div', id='comic').find_all('img')
948
        return {
949
            'img': [i['src'] for i in imgs],
950
            'title': title,
951
            'author': author,
952
            'month': day.month,
953
            'year': day.year,
954
            'day': day.day,
955
        }
956
957
@@ 731-752 (lines=22) @@
728
        }
729
730
731
class AngryAtNothing(GenericDeletedComic, GenericNavigableComic):
732
    """Class to retrieve Angry at Nothing comics."""
733
    # Also on http://tapastic.com/series/Comics-yeah-definitely-comics-
734
    # Also on http://angryatnothing.tumblr.com
735
    name = 'angry'
736
    long_name = 'Angry At Nothing'
737
    url = 'http://www.angryatnothing.net'
738
    get_first_comic_link = get_div_navfirst_a
739
    get_navi_link = get_a_rel_next
740
741
    @classmethod
742
    def get_comic_info(cls, soup, link):
743
        """Get information about a particular comics."""
744
        title = soup.find('h1', class_='comic-title').find('a').string
745
        date_str = soup.find('header', class_='comic-meta entry-meta').find('a').string
746
        day = string_to_date(date_str, "%B %d, %Y")
747
        imgs = soup.find_all('meta', property='og:image')
748
        return {
749
            'title': title,
750
            'month': day.month,
751
            'year': day.year,
752
            'day': day.day,
753
            'img': [i['content'] for i in imgs],
754
        }
755