Code Duplication    Length = 22-27 lines in 11 locations

comics.py 11 locations

@@ 1888-1914 (lines=27) @@
1885
        }
1886
1887
1888
class PicturesInBoxes(GenericNavigableComic):
1889
    """Class to retrieve Pictures In Boxes comics."""
1890
    # Also on https://picturesinboxescomic.tumblr.com
1891
    name = 'picturesinboxes'
1892
    long_name = 'Pictures in Boxes'
1893
    url = 'http://www.picturesinboxes.com'
1894
    get_navi_link = get_a_navi_navinext
1895
    get_first_comic_link = simulate_first_link
1896
    first_url = 'http://www.picturesinboxes.com/2013/10/26/tetris/'
1897
1898
    @classmethod
1899
    def get_comic_info(cls, soup, link):
1900
        """Get information about a particular comics."""
1901
        title = soup.find('h2', class_='post-title').string
1902
        author = soup.find("span", class_="post-author").find("a").string
1903
        date_str = soup.find('span', class_='post-date').string
1904
        day = string_to_date(date_str, '%B %d, %Y')
1905
        imgs = soup.find('div', class_='comicpane').find_all('img')
1906
        assert imgs
1907
        assert all(i['title'] == i['alt'] == title for i in imgs)
1908
        return {
1909
            'day': day.day,
1910
            'month': day.month,
1911
            'year': day.year,
1912
            'img': [i['src'] for i in imgs],
1913
            'title': title,
1914
            'author': author,
1915
        }
1916
1917
@@ 955-981 (lines=27) @@
952
        }
953
954
955
class ImogenQuest(GenericNavigableComic):
956
    """Class to retrieve Imogen Quest comics."""
957
    # Also on http://imoquest.tumblr.com
958
    name = 'imogen'
959
    long_name = 'Imogen Quest'
960
    url = 'http://imogenquest.net'
961
    get_first_comic_link = get_div_navfirst_a
962
    get_navi_link = get_a_rel_next
963
964
    @classmethod
965
    def get_comic_info(cls, soup, link):
966
        """Get information about a particular comics."""
967
        title = soup.find('h2', class_='post-title').string
968
        author = soup.find("span", class_="post-author").find("a").string
969
        date_str = soup.find('span', class_='post-date').string
970
        day = string_to_date(date_str, '%B %d, %Y')
971
        imgs = soup.find('div', class_='comicpane').find_all('img')
972
        assert all(i['alt'] == i['title'] for i in imgs)
973
        title2 = imgs[0]['title']
974
        return {
975
            'day': day.day,
976
            'month': day.month,
977
            'year': day.year,
978
            'img': [i['src'] for i in imgs],
979
            'title': title,
980
            'title2': title2,
981
            'author': author,
982
        }
983
984
@@ 2589-2614 (lines=26) @@
2586
        }
2587
2588
2589
class TheAwkwardYeti(GenericNavigableComic):
2590
    """Class to retrieve The Awkward Yeti comics."""
2591
    # Also on http://www.gocomics.com/the-awkward-yeti
2592
    # Also on http://larstheyeti.tumblr.com
2593
    # Also on https://tapastic.com/series/TheAwkwardYeti
2594
    name = 'yeti'
2595
    long_name = 'The Awkward Yeti'
2596
    url = 'http://theawkwardyeti.com'
2597
    _categories = ('YETI', )
2598
    get_first_comic_link = get_a_navi_navifirst
2599
    get_navi_link = get_link_rel_next
2600
2601
    @classmethod
2602
    def get_comic_info(cls, soup, link):
2603
        """Get information about a particular comics."""
2604
        title = soup.find('h2', class_='post-title').string
2605
        date_str = soup.find("span", class_="post-date").string
2606
        day = string_to_date(date_str, "%B %d, %Y")
2607
        imgs = soup.find("div", id="comic").find_all("img")
2608
        assert all(idx > 0 or i['alt'] == i['title'] for idx, i in enumerate(imgs))
2609
        return {
2610
            'img': [i['src'] for i in imgs],
2611
            'title': title,
2612
            'day': day.day,
2613
            'month': day.month,
2614
            'year': day.year
2615
        }
2616
2617
@@ 2502-2527 (lines=26) @@
2499
        }
2500
2501
2502
class GerbilWithAJetpack(GenericNavigableComic):
2503
    """Class to retrieve GerbilWithAJetpack comics."""
2504
    name = 'gerbil'
2505
    long_name = 'Gerbil With A Jetpack'
2506
    url = 'http://gerbilwithajetpack.com'
2507
    get_first_comic_link = get_a_navi_navifirst
2508
    get_navi_link = get_a_rel_next
2509
2510
    @classmethod
2511
    def get_comic_info(cls, soup, link):
2512
        """Get information about a particular comics."""
2513
        title = soup.find('h2', class_='post-title').string
2514
        author = soup.find("span", class_="post-author").find("a").string
2515
        date_str = soup.find("span", class_="post-date").string
2516
        day = string_to_date(date_str, "%B %d, %Y")
2517
        imgs = soup.find("div", id="comic").find_all("img")
2518
        alt = imgs[0]['alt']
2519
        assert all(i['alt'] == i['title'] == alt for i in imgs)
2520
        return {
2521
            'img': [i['src'] for i in imgs],
2522
            'title': title,
2523
            'alt': alt,
2524
            'author': author,
2525
            'day': day.day,
2526
            'month': day.month,
2527
            'year': day.year
2528
        }
2529
2530
@@ 2843-2867 (lines=25) @@
2840
    first_url = 'http://www.commitstrip.com/en/2012/02/22/interview/'
2841
2842
2843
class GenericBoumerie(GenericNavigableComic):
2844
    """Generic class to retrieve Boumeries comics in different languages."""
2845
    get_first_comic_link = get_a_navi_navifirst
2846
    get_navi_link = get_link_rel_next
2847
    date_format = NotImplemented
2848
    lang = NotImplemented
2849
2850
    @classmethod
2851
    def get_comic_info(cls, soup, link):
2852
        """Get information about a particular comics."""
2853
        title = soup.find('h2', class_='post-title').string
2854
        short_url = soup.find('link', rel='shortlink')['href']
2855
        author = soup.find("span", class_="post-author").find("a").string
2856
        date_str = soup.find('span', class_='post-date').string
2857
        day = string_to_date(date_str, cls.date_format, cls.lang)
2858
        imgs = soup.find('div', id='comic').find_all('img')
2859
        assert all(i['alt'] == i['title'] for i in imgs)
2860
        return {
2861
            'short_url': short_url,
2862
            'img': [i['src'] for i in imgs],
2863
            'title': title,
2864
            'author': author,
2865
            'month': day.month,
2866
            'year': day.year,
2867
            'day': day.day,
2868
        }
2869
2870
@@ 2531-2555 (lines=25) @@
2528
        }
2529
2530
2531
class EveryDayBlues(GenericDeletedComic, GenericNavigableComic):
2532
    """Class to retrieve EveryDayBlues Comics."""
2533
    name = "blues"
2534
    long_name = "Every Day Blues"
2535
    url = "http://everydayblues.net"
2536
    get_first_comic_link = get_a_navi_navifirst
2537
    get_navi_link = get_link_rel_next
2538
2539
    @classmethod
2540
    def get_comic_info(cls, soup, link):
2541
        """Get information about a particular comics."""
2542
        title = soup.find("h2", class_="post-title").string
2543
        author = soup.find("span", class_="post-author").find("a").string
2544
        date_str = soup.find("span", class_="post-date").string
2545
        day = string_to_date(date_str, "%d. %B %Y", "de_DE.utf8")
2546
        imgs = soup.find("div", id="comic").find_all("img")
2547
        assert all(i['alt'] == i['title'] == title for i in imgs)
2548
        assert len(imgs) <= 1
2549
        return {
2550
            'img': [i['src'] for i in imgs],
2551
            'title': title,
2552
            'author': author,
2553
            'day': day.day,
2554
            'month': day.month,
2555
            'year': day.year
2556
        }
2557
2558
@@ 1776-1800 (lines=25) @@
1773
        }
1774
1775
1776
class MouseBearComedy(GenericComicNotWorking):  # Website has changed
1777
    """Class to retrieve Mouse Bear Comedy comics."""
1778
    # Also on http://mousebearcomedy.tumblr.com
1779
    name = 'mousebear'
1780
    long_name = 'Mouse Bear Comedy'
1781
    url = 'http://www.mousebearcomedy.com'
1782
    get_first_comic_link = get_a_navi_navifirst
1783
    get_navi_link = get_a_navi_comicnavnext_navinext
1784
1785
    @classmethod
1786
    def get_comic_info(cls, soup, link):
1787
        """Get information about a particular comics."""
1788
        title = soup.find('h2', class_='post-title').string
1789
        author = soup.find("span", class_="post-author").find("a").string
1790
        date_str = soup.find("span", class_="post-date").string
1791
        day = string_to_date(date_str, '%B %d, %Y')
1792
        imgs = soup.find("div", id="comic").find_all("img")
1793
        assert all(i['alt'] == i['title'] == title for i in imgs)
1794
        return {
1795
            'day': day.day,
1796
            'month': day.month,
1797
            'year': day.year,
1798
            'img': [i['src'] for i in imgs],
1799
            'title': title,
1800
            'author': author,
1801
        }
1802
1803
@@ 1184-1207 (lines=24) @@
1181
    url = 'http://english.bouletcorp.com'
1182
1183
1184
class AmazingSuperPowers(GenericNavigableComic):
1185
    """Class to retrieve Amazing Super Powers comics."""
1186
    name = 'asp'
1187
    long_name = 'Amazing Super Powers'
1188
    url = 'http://www.amazingsuperpowers.com'
1189
    get_first_comic_link = get_a_navi_navifirst
1190
    get_navi_link = get_a_navi_navinext
1191
1192
    @classmethod
1193
    def get_comic_info(cls, soup, link):
1194
        """Get information about a particular comics."""
1195
        author = soup.find("span", class_="post-author").find("a").string
1196
        date_str = soup.find('span', class_='post-date').string
1197
        day = string_to_date(date_str, "%B %d, %Y")
1198
        imgs = soup.find('div', id='comic').find_all('img')
1199
        title = ' '.join(i['title'] for i in imgs)
1200
        assert all(i['alt'] == i['title'] for i in imgs)
1201
        return {
1202
            'title': title,
1203
            'author': author,
1204
            'img': [img['src'] for img in imgs],
1205
            'day': day.day,
1206
            'month': day.month,
1207
            'year': day.year
1208
        }
1209
1210
@@ 701-724 (lines=24) @@
698
        }
699
700
701
class OneOneOneOneComic(GenericComicNotWorking, GenericNavigableComic):
702
    """Class to retrieve 1111 Comics."""
703
    # Also on http://comics1111.tumblr.com
704
    # Also on https://tapastic.com/series/1111-Comics
705
    name = '1111'
706
    long_name = '1111 Comics'
707
    url = 'http://www.1111comics.me'
708
    _categories = ('ONEONEONEONE', )
709
    get_first_comic_link = get_div_navfirst_a
710
    get_navi_link = get_link_rel_next
711
712
    @classmethod
713
    def get_comic_info(cls, soup, link):
714
        """Get information about a particular comics."""
715
        title = soup.find('h1', class_='comic-title').find('a').string
716
        date_str = soup.find('header', class_='comic-meta entry-meta').find('a').string
717
        day = string_to_date(date_str, "%B %d, %Y")
718
        imgs = soup.find_all('meta', property='og:image')
719
        return {
720
            'title': title,
721
            'month': day.month,
722
            'year': day.year,
723
            'day': day.day,
724
            'img': [i['content'] for i in imgs],
725
        }
726
727
@@ 929-951 (lines=23) @@
926
        }
927
928
929
class TheGentlemanArmchair(GenericNavigableComic):
930
    """Class to retrieve The Gentleman Armchair comics."""
931
    name = 'gentlemanarmchair'
932
    long_name = 'The Gentleman Armchair'
933
    url = 'http://thegentlemansarmchair.com'
934
    get_first_comic_link = get_a_navi_navifirst
935
    get_navi_link = get_link_rel_next
936
937
    @classmethod
938
    def get_comic_info(cls, soup, link):
939
        """Get information about a particular comics."""
940
        title = soup.find('h2', class_='post-title').string
941
        author = soup.find("span", class_="post-author").find("a").string
942
        date_str = soup.find('span', class_='post-date').string
943
        day = string_to_date(date_str, "%B %d, %Y")
944
        imgs = soup.find('div', id='comic').find_all('img')
945
        return {
946
            'img': [i['src'] for i in imgs],
947
            'title': title,
948
            'author': author,
949
            'month': day.month,
950
            'year': day.year,
951
            'day': day.day,
952
        }
953
954
@@ 728-749 (lines=22) @@
725
        }
726
727
728
class AngryAtNothing(GenericDeletedComic, GenericNavigableComic):
729
    """Class to retrieve Angry at Nothing comics."""
730
    # Also on http://tapastic.com/series/Comics-yeah-definitely-comics-
731
    # Also on http://angryatnothing.tumblr.com
732
    name = 'angry'
733
    long_name = 'Angry At Nothing'
734
    url = 'http://www.angryatnothing.net'
735
    get_first_comic_link = get_div_navfirst_a
736
    get_navi_link = get_a_rel_next
737
738
    @classmethod
739
    def get_comic_info(cls, soup, link):
740
        """Get information about a particular comics."""
741
        title = soup.find('h1', class_='comic-title').find('a').string
742
        date_str = soup.find('header', class_='comic-meta entry-meta').find('a').string
743
        day = string_to_date(date_str, "%B %d, %Y")
744
        imgs = soup.find_all('meta', property='og:image')
745
        return {
746
            'title': title,
747
            'month': day.month,
748
            'year': day.year,
749
            'day': day.day,
750
            'img': [i['content'] for i in imgs],
751
        }
752