Code Duplication    Length = 22-27 lines in 11 locations

comics.py 11 locations

@@ 974-1000 (lines=27) @@
971
        }
972
973
974
class ImogenQuest(GenericNavigableComic):
975
    """Class to retrieve Imogen Quest comics."""
976
    # Also on http://imoquest.tumblr.com
977
    name = 'imogen'
978
    long_name = 'Imogen Quest'
979
    url = 'http://imogenquest.net'
980
    get_first_comic_link = get_div_navfirst_a
981
    get_navi_link = get_a_rel_next
982
983
    @classmethod
984
    def get_comic_info(cls, soup, link):
985
        """Get information about a particular comics."""
986
        title = soup.find('h2', class_='post-title').string
987
        author = soup.find("span", class_="post-author").find("a").string
988
        date_str = soup.find('span', class_='post-date').string
989
        day = string_to_date(date_str, '%B %d, %Y')
990
        imgs = soup.find('div', class_='comicpane').find_all('img')
991
        assert all(i['alt'] == i['title'] for i in imgs)
992
        title2 = imgs[0]['title']
993
        return {
994
            'day': day.day,
995
            'month': day.month,
996
            'year': day.year,
997
            'img': [i['src'] for i in imgs],
998
            'title': title,
999
            'title2': title2,
1000
            'author': author,
1001
        }
1002
1003
@@ 720-743 (lines=24) @@
717
        }
718
719
720
class OneOneOneOneComic(GenericComicNotWorking, GenericNavigableComic):
721
    """Class to retrieve 1111 Comics."""
722
    # Also on http://comics1111.tumblr.com
723
    # Also on https://tapastic.com/series/1111-Comics
724
    name = '1111'
725
    long_name = '1111 Comics'
726
    url = 'http://www.1111comics.me'
727
    _categories = ('ONEONEONEONE', )
728
    get_first_comic_link = get_div_navfirst_a
729
    get_navi_link = get_link_rel_next
730
731
    @classmethod
732
    def get_comic_info(cls, soup, link):
733
        """Get information about a particular comics."""
734
        title = soup.find('h1', class_='comic-title').find('a').string
735
        date_str = soup.find('header', class_='comic-meta entry-meta').find('a').string
736
        day = string_to_date(date_str, "%B %d, %Y")
737
        imgs = soup.find_all('meta', property='og:image')
738
        return {
739
            'title': title,
740
            'month': day.month,
741
            'year': day.year,
742
            'day': day.day,
743
            'img': [i['content'] for i in imgs],
744
        }
745
746
@@ 948-970 (lines=23) @@
945
        }
946
947
948
class TheGentlemanArmchair(GenericNavigableComic):
949
    """Class to retrieve The Gentleman Armchair comics."""
950
    name = 'gentlemanarmchair'
951
    long_name = 'The Gentleman Armchair'
952
    url = 'http://thegentlemansarmchair.com'
953
    get_first_comic_link = get_a_navi_navifirst
954
    get_navi_link = get_link_rel_next
955
956
    @classmethod
957
    def get_comic_info(cls, soup, link):
958
        """Get information about a particular comics."""
959
        title = soup.find('h2', class_='post-title').string
960
        author = soup.find("span", class_="post-author").find("a").string
961
        date_str = soup.find('span', class_='post-date').string
962
        day = string_to_date(date_str, "%B %d, %Y")
963
        imgs = soup.find('div', id='comic').find_all('img')
964
        return {
965
            'img': [i['src'] for i in imgs],
966
            'title': title,
967
            'author': author,
968
            'month': day.month,
969
            'year': day.year,
970
            'day': day.day,
971
        }
972
973
@@ 747-768 (lines=22) @@
744
        }
745
746
747
class AngryAtNothing(GenericDeletedComic, GenericNavigableComic):
748
    """Class to retrieve Angry at Nothing comics."""
749
    # Also on http://tapastic.com/series/Comics-yeah-definitely-comics-
750
    # Also on http://angryatnothing.tumblr.com
751
    name = 'angry'
752
    long_name = 'Angry At Nothing'
753
    url = 'http://www.angryatnothing.net'
754
    get_first_comic_link = get_div_navfirst_a
755
    get_navi_link = get_a_rel_next
756
757
    @classmethod
758
    def get_comic_info(cls, soup, link):
759
        """Get information about a particular comics."""
760
        title = soup.find('h1', class_='comic-title').find('a').string
761
        date_str = soup.find('header', class_='comic-meta entry-meta').find('a').string
762
        day = string_to_date(date_str, "%B %d, %Y")
763
        imgs = soup.find_all('meta', property='og:image')
764
        return {
765
            'title': title,
766
            'month': day.month,
767
            'year': day.year,
768
            'day': day.day,
769
            'img': [i['content'] for i in imgs],
770
        }
771
@@ 1908-1934 (lines=27) @@
1905
        }
1906
1907
1908
class PicturesInBoxes(GenericNavigableComic):
1909
    """Class to retrieve Pictures In Boxes comics."""
1910
    # Also on https://picturesinboxescomic.tumblr.com
1911
    name = 'picturesinboxes'
1912
    long_name = 'Pictures in Boxes'
1913
    url = 'http://www.picturesinboxes.com'
1914
    get_navi_link = get_a_navi_navinext
1915
    get_first_comic_link = simulate_first_link
1916
    first_url = 'http://www.picturesinboxes.com/2013/10/26/tetris/'
1917
1918
    @classmethod
1919
    def get_comic_info(cls, soup, link):
1920
        """Get information about a particular comics."""
1921
        title = soup.find('h2', class_='post-title').string
1922
        author = soup.find("span", class_="post-author").find("a").string
1923
        date_str = soup.find('span', class_='post-date').string
1924
        day = string_to_date(date_str, '%B %d, %Y')
1925
        imgs = soup.find('div', class_='comicpane').find_all('img')
1926
        assert imgs
1927
        assert all(i['title'] == i['alt'] == title for i in imgs)
1928
        return {
1929
            'day': day.day,
1930
            'month': day.month,
1931
            'year': day.year,
1932
            'img': [i['src'] for i in imgs],
1933
            'title': title,
1934
            'author': author,
1935
        }
1936
1937
@@ 2895-2919 (lines=25) @@
2892
    first_url = 'http://www.commitstrip.com/en/2012/02/22/interview/'
2893
2894
2895
class GenericBoumerie(GenericNavigableComic):
2896
    """Generic class to retrieve Boumeries comics in different languages."""
2897
    # Also on http://boumeries.tumblr.com
2898
    get_first_comic_link = get_a_navi_navifirst
2899
    get_navi_link = get_link_rel_next
2900
    date_format = NotImplemented
2901
    lang = NotImplemented
2902
2903
    @classmethod
2904
    def get_comic_info(cls, soup, link):
2905
        """Get information about a particular comics."""
2906
        title = soup.find('h2', class_='post-title').string
2907
        short_url = soup.find('link', rel='shortlink')['href']
2908
        author = soup.find("span", class_="post-author").find("a").string
2909
        date_str = soup.find('span', class_='post-date').string
2910
        day = string_to_date(date_str, cls.date_format, cls.lang)
2911
        imgs = soup.find('div', id='comic').find_all('img')
2912
        assert all(i['alt'] == i['title'] for i in imgs)
2913
        return {
2914
            'short_url': short_url,
2915
            'img': [i['src'] for i in imgs],
2916
            'title': title,
2917
            'author': author,
2918
            'month': day.month,
2919
            'year': day.year,
2920
            'day': day.day,
2921
        }
2922
@@ 2641-2666 (lines=26) @@
2638
        }
2639
2640
2641
class TheAwkwardYeti(GenericNavigableComic):
2642
    """Class to retrieve The Awkward Yeti comics."""
2643
    # Also on http://www.gocomics.com/the-awkward-yeti
2644
    # Also on http://larstheyeti.tumblr.com
2645
    # Also on https://tapastic.com/series/TheAwkwardYeti
2646
    name = 'yeti'
2647
    long_name = 'The Awkward Yeti'
2648
    url = 'http://theawkwardyeti.com'
2649
    _categories = ('YETI', )
2650
    get_first_comic_link = get_a_navi_navifirst
2651
    get_navi_link = get_link_rel_next
2652
2653
    @classmethod
2654
    def get_comic_info(cls, soup, link):
2655
        """Get information about a particular comics."""
2656
        title = soup.find('h2', class_='post-title').string
2657
        date_str = soup.find("span", class_="post-date").string
2658
        day = string_to_date(date_str, "%B %d, %Y")
2659
        imgs = soup.find("div", id="comic").find_all("img")
2660
        assert all(idx > 0 or i['alt'] == i['title'] for idx, i in enumerate(imgs))
2661
        return {
2662
            'img': [i['src'] for i in imgs],
2663
            'title': title,
2664
            'day': day.day,
2665
            'month': day.month,
2666
            'year': day.year
2667
        }
2668
2669
@@ 2554-2579 (lines=26) @@
2551
        }
2552
2553
2554
class GerbilWithAJetpack(GenericNavigableComic):
2555
    """Class to retrieve GerbilWithAJetpack comics."""
2556
    name = 'gerbil'
2557
    long_name = 'Gerbil With A Jetpack'
2558
    url = 'http://gerbilwithajetpack.com'
2559
    get_first_comic_link = get_a_navi_navifirst
2560
    get_navi_link = get_a_rel_next
2561
2562
    @classmethod
2563
    def get_comic_info(cls, soup, link):
2564
        """Get information about a particular comics."""
2565
        title = soup.find('h2', class_='post-title').string
2566
        author = soup.find("span", class_="post-author").find("a").string
2567
        date_str = soup.find("span", class_="post-date").string
2568
        day = string_to_date(date_str, "%B %d, %Y")
2569
        imgs = soup.find("div", id="comic").find_all("img")
2570
        alt = imgs[0]['alt']
2571
        assert all(i['alt'] == i['title'] == alt for i in imgs)
2572
        return {
2573
            'img': [i['src'] for i in imgs],
2574
            'title': title,
2575
            'alt': alt,
2576
            'author': author,
2577
            'day': day.day,
2578
            'month': day.month,
2579
            'year': day.year
2580
        }
2581
2582
@@ 2583-2607 (lines=25) @@
2580
        }
2581
2582
2583
class EveryDayBlues(GenericDeletedComic, GenericNavigableComic):
2584
    """Class to retrieve EveryDayBlues Comics."""
2585
    name = "blues"
2586
    long_name = "Every Day Blues"
2587
    url = "http://everydayblues.net"
2588
    get_first_comic_link = get_a_navi_navifirst
2589
    get_navi_link = get_link_rel_next
2590
2591
    @classmethod
2592
    def get_comic_info(cls, soup, link):
2593
        """Get information about a particular comics."""
2594
        title = soup.find("h2", class_="post-title").string
2595
        author = soup.find("span", class_="post-author").find("a").string
2596
        date_str = soup.find("span", class_="post-date").string
2597
        day = string_to_date(date_str, "%d. %B %Y", "de_DE.utf8")
2598
        imgs = soup.find("div", id="comic").find_all("img")
2599
        assert all(i['alt'] == i['title'] == title for i in imgs)
2600
        assert len(imgs) <= 1, imgs
2601
        return {
2602
            'img': [i['src'] for i in imgs],
2603
            'title': title,
2604
            'author': author,
2605
            'day': day.day,
2606
            'month': day.month,
2607
            'year': day.year
2608
        }
2609
2610
@@ 1796-1820 (lines=25) @@
1793
        }
1794
1795
1796
class MouseBearComedy(GenericComicNotWorking):  # Website has changed
1797
    """Class to retrieve Mouse Bear Comedy comics."""
1798
    # Also on http://mousebearcomedy.tumblr.com
1799
    name = 'mousebear'
1800
    long_name = 'Mouse Bear Comedy'
1801
    url = 'http://www.mousebearcomedy.com'
1802
    get_first_comic_link = get_a_navi_navifirst
1803
    get_navi_link = get_a_navi_comicnavnext_navinext
1804
1805
    @classmethod
1806
    def get_comic_info(cls, soup, link):
1807
        """Get information about a particular comics."""
1808
        title = soup.find('h2', class_='post-title').string
1809
        author = soup.find("span", class_="post-author").find("a").string
1810
        date_str = soup.find("span", class_="post-date").string
1811
        day = string_to_date(date_str, '%B %d, %Y')
1812
        imgs = soup.find("div", id="comic").find_all("img")
1813
        assert all(i['alt'] == i['title'] == title for i in imgs)
1814
        return {
1815
            'day': day.day,
1816
            'month': day.month,
1817
            'year': day.year,
1818
            'img': [i['src'] for i in imgs],
1819
            'title': title,
1820
            'author': author,
1821
        }
1822
1823
@@ 1206-1229 (lines=24) @@
1203
    url = 'http://english.bouletcorp.com'
1204
1205
1206
class AmazingSuperPowers(GenericNavigableComic):
1207
    """Class to retrieve Amazing Super Powers comics."""
1208
    name = 'asp'
1209
    long_name = 'Amazing Super Powers'
1210
    url = 'http://www.amazingsuperpowers.com'
1211
    get_first_comic_link = get_a_navi_navifirst
1212
    get_navi_link = get_a_navi_navinext
1213
1214
    @classmethod
1215
    def get_comic_info(cls, soup, link):
1216
        """Get information about a particular comics."""
1217
        author = soup.find("span", class_="post-author").find("a").string
1218
        date_str = soup.find('span', class_='post-date').string
1219
        day = string_to_date(date_str, "%B %d, %Y")
1220
        imgs = soup.find('div', id='comic').find_all('img')
1221
        title = ' '.join(i['title'] for i in imgs)
1222
        assert all(i['alt'] == i['title'] for i in imgs)
1223
        return {
1224
            'title': title,
1225
            'author': author,
1226
            'img': [img['src'] for img in imgs],
1227
            'day': day.day,
1228
            'month': day.month,
1229
            'year': day.year
1230
        }
1231
1232