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
@@ 1203-1226 (lines=24) @@
1200
    url = 'http://english.bouletcorp.com'
1201
1202
1203
class AmazingSuperPowers(GenericNavigableComic):
1204
    """Class to retrieve Amazing Super Powers comics."""
1205
    name = 'asp'
1206
    long_name = 'Amazing Super Powers'
1207
    url = 'http://www.amazingsuperpowers.com'
1208
    get_first_comic_link = get_a_navi_navifirst
1209
    get_navi_link = get_a_navi_navinext
1210
1211
    @classmethod
1212
    def get_comic_info(cls, soup, link):
1213
        """Get information about a particular comics."""
1214
        author = soup.find("span", class_="post-author").find("a").string
1215
        date_str = soup.find('span', class_='post-date').string
1216
        day = string_to_date(date_str, "%B %d, %Y")
1217
        imgs = soup.find('div', id='comic').find_all('img')
1218
        title = ' '.join(i['title'] for i in imgs)
1219
        assert all(i['alt'] == i['title'] for i in imgs)
1220
        return {
1221
            'title': title,
1222
            'author': author,
1223
            'img': [img['src'] for img in imgs],
1224
            'day': day.day,
1225
            'month': day.month,
1226
            'year': day.year
1227
        }
1228
1229
@@ 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
@@ 1904-1930 (lines=27) @@
1901
        }
1902
1903
1904
class PicturesInBoxes(GenericNavigableComic):
1905
    """Class to retrieve Pictures In Boxes comics."""
1906
    # Also on https://picturesinboxescomic.tumblr.com
1907
    name = 'picturesinboxes'
1908
    long_name = 'Pictures in Boxes'
1909
    url = 'http://www.picturesinboxes.com'
1910
    get_navi_link = get_a_navi_navinext
1911
    get_first_comic_link = simulate_first_link
1912
    first_url = 'http://www.picturesinboxes.com/2013/10/26/tetris/'
1913
1914
    @classmethod
1915
    def get_comic_info(cls, soup, link):
1916
        """Get information about a particular comics."""
1917
        title = soup.find('h2', class_='post-title').string
1918
        author = soup.find("span", class_="post-author").find("a").string
1919
        date_str = soup.find('span', class_='post-date').string
1920
        day = string_to_date(date_str, '%B %d, %Y')
1921
        imgs = soup.find('div', class_='comicpane').find_all('img')
1922
        assert imgs
1923
        assert all(i['title'] == i['alt'] == title for i in imgs)
1924
        return {
1925
            'day': day.day,
1926
            'month': day.month,
1927
            'year': day.year,
1928
            'img': [i['src'] for i in imgs],
1929
            'title': title,
1930
            'author': author,
1931
        }
1932
1933
@@ 2858-2882 (lines=25) @@
2855
    first_url = 'http://www.commitstrip.com/en/2012/02/22/interview/'
2856
2857
2858
class GenericBoumerie(GenericNavigableComic):
2859
    """Generic class to retrieve Boumeries comics in different languages."""
2860
    # Also on http://boumeries.tumblr.com
2861
    get_first_comic_link = get_a_navi_navifirst
2862
    get_navi_link = get_link_rel_next
2863
    date_format = NotImplemented
2864
    lang = NotImplemented
2865
2866
    @classmethod
2867
    def get_comic_info(cls, soup, link):
2868
        """Get information about a particular comics."""
2869
        title = soup.find('h2', class_='post-title').string
2870
        short_url = soup.find('link', rel='shortlink')['href']
2871
        author = soup.find("span", class_="post-author").find("a").string
2872
        date_str = soup.find('span', class_='post-date').string
2873
        day = string_to_date(date_str, cls.date_format, cls.lang)
2874
        imgs = soup.find('div', id='comic').find_all('img')
2875
        assert all(i['alt'] == i['title'] for i in imgs)
2876
        return {
2877
            'short_url': short_url,
2878
            'img': [i['src'] for i in imgs],
2879
            'title': title,
2880
            'author': author,
2881
            'month': day.month,
2882
            'year': day.year,
2883
            'day': day.day,
2884
        }
2885
@@ 2604-2629 (lines=26) @@
2601
        }
2602
2603
2604
class TheAwkwardYeti(GenericNavigableComic):
2605
    """Class to retrieve The Awkward Yeti comics."""
2606
    # Also on http://www.gocomics.com/the-awkward-yeti
2607
    # Also on http://larstheyeti.tumblr.com
2608
    # Also on https://tapastic.com/series/TheAwkwardYeti
2609
    name = 'yeti'
2610
    long_name = 'The Awkward Yeti'
2611
    url = 'http://theawkwardyeti.com'
2612
    _categories = ('YETI', )
2613
    get_first_comic_link = get_a_navi_navifirst
2614
    get_navi_link = get_link_rel_next
2615
2616
    @classmethod
2617
    def get_comic_info(cls, soup, link):
2618
        """Get information about a particular comics."""
2619
        title = soup.find('h2', class_='post-title').string
2620
        date_str = soup.find("span", class_="post-date").string
2621
        day = string_to_date(date_str, "%B %d, %Y")
2622
        imgs = soup.find("div", id="comic").find_all("img")
2623
        assert all(idx > 0 or i['alt'] == i['title'] for idx, i in enumerate(imgs))
2624
        return {
2625
            'img': [i['src'] for i in imgs],
2626
            'title': title,
2627
            'day': day.day,
2628
            'month': day.month,
2629
            'year': day.year
2630
        }
2631
2632
@@ 2517-2542 (lines=26) @@
2514
        }
2515
2516
2517
class GerbilWithAJetpack(GenericNavigableComic):
2518
    """Class to retrieve GerbilWithAJetpack comics."""
2519
    name = 'gerbil'
2520
    long_name = 'Gerbil With A Jetpack'
2521
    url = 'http://gerbilwithajetpack.com'
2522
    get_first_comic_link = get_a_navi_navifirst
2523
    get_navi_link = get_a_rel_next
2524
2525
    @classmethod
2526
    def get_comic_info(cls, soup, link):
2527
        """Get information about a particular comics."""
2528
        title = soup.find('h2', class_='post-title').string
2529
        author = soup.find("span", class_="post-author").find("a").string
2530
        date_str = soup.find("span", class_="post-date").string
2531
        day = string_to_date(date_str, "%B %d, %Y")
2532
        imgs = soup.find("div", id="comic").find_all("img")
2533
        alt = imgs[0]['alt']
2534
        assert all(i['alt'] == i['title'] == alt for i in imgs)
2535
        return {
2536
            'img': [i['src'] for i in imgs],
2537
            'title': title,
2538
            'alt': alt,
2539
            'author': author,
2540
            'day': day.day,
2541
            'month': day.month,
2542
            'year': day.year
2543
        }
2544
2545
@@ 2546-2570 (lines=25) @@
2543
        }
2544
2545
2546
class EveryDayBlues(GenericDeletedComic, GenericNavigableComic):
2547
    """Class to retrieve EveryDayBlues Comics."""
2548
    name = "blues"
2549
    long_name = "Every Day Blues"
2550
    url = "http://everydayblues.net"
2551
    get_first_comic_link = get_a_navi_navifirst
2552
    get_navi_link = get_link_rel_next
2553
2554
    @classmethod
2555
    def get_comic_info(cls, soup, link):
2556
        """Get information about a particular comics."""
2557
        title = soup.find("h2", class_="post-title").string
2558
        author = soup.find("span", class_="post-author").find("a").string
2559
        date_str = soup.find("span", class_="post-date").string
2560
        day = string_to_date(date_str, "%d. %B %Y", "de_DE.utf8")
2561
        imgs = soup.find("div", id="comic").find_all("img")
2562
        assert all(i['alt'] == i['title'] == title for i in imgs)
2563
        assert len(imgs) <= 1, imgs
2564
        return {
2565
            'img': [i['src'] for i in imgs],
2566
            'title': title,
2567
            'author': author,
2568
            'day': day.day,
2569
            'month': day.month,
2570
            'year': day.year
2571
        }
2572
2573
@@ 1792-1816 (lines=25) @@
1789
        }
1790
1791
1792
class MouseBearComedy(GenericComicNotWorking):  # Website has changed
1793
    """Class to retrieve Mouse Bear Comedy comics."""
1794
    # Also on http://mousebearcomedy.tumblr.com
1795
    name = 'mousebear'
1796
    long_name = 'Mouse Bear Comedy'
1797
    url = 'http://www.mousebearcomedy.com'
1798
    get_first_comic_link = get_a_navi_navifirst
1799
    get_navi_link = get_a_navi_comicnavnext_navinext
1800
1801
    @classmethod
1802
    def get_comic_info(cls, soup, link):
1803
        """Get information about a particular comics."""
1804
        title = soup.find('h2', class_='post-title').string
1805
        author = soup.find("span", class_="post-author").find("a").string
1806
        date_str = soup.find("span", class_="post-date").string
1807
        day = string_to_date(date_str, '%B %d, %Y')
1808
        imgs = soup.find("div", id="comic").find_all("img")
1809
        assert all(i['alt'] == i['title'] == title for i in imgs)
1810
        return {
1811
            'day': day.day,
1812
            'month': day.month,
1813
            'year': day.year,
1814
            'img': [i['src'] for i in imgs],
1815
            'title': title,
1816
            'author': author,
1817
        }
1818
1819