Code Duplication    Length = 22-27 lines in 11 locations

comics.py 11 locations

@@ 1871-1897 (lines=27) @@
1868
        }
1869
1870
1871
class PicturesInBoxes(GenericNavigableComic):
1872
    """Class to retrieve Pictures In Boxes comics."""
1873
    # Also on https://picturesinboxescomic.tumblr.com
1874
    name = 'picturesinboxes'
1875
    long_name = 'Pictures in Boxes'
1876
    url = 'http://www.picturesinboxes.com'
1877
    get_navi_link = get_a_navi_navinext
1878
    get_first_comic_link = simulate_first_link
1879
    first_url = 'http://www.picturesinboxes.com/2013/10/26/tetris/'
1880
1881
    @classmethod
1882
    def get_comic_info(cls, soup, link):
1883
        """Get information about a particular comics."""
1884
        title = soup.find('h2', class_='post-title').string
1885
        author = soup.find("span", class_="post-author").find("a").string
1886
        date_str = soup.find('span', class_='post-date').string
1887
        day = string_to_date(date_str, '%B %d, %Y')
1888
        imgs = soup.find('div', class_='comicpane').find_all('img')
1889
        assert imgs
1890
        assert all(i['title'] == i['alt'] == title for i in imgs)
1891
        return {
1892
            'day': day.day,
1893
            'month': day.month,
1894
            'year': day.year,
1895
            'img': [i['src'] for i in imgs],
1896
            'title': title,
1897
            'author': author,
1898
        }
1899
1900
@@ 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
@@ 2825-2849 (lines=25) @@
2822
    first_url = 'http://www.commitstrip.com/en/2012/02/22/interview/'
2823
2824
2825
class GenericBoumerie(GenericNavigableComic):
2826
    """Generic class to retrieve Boumeries comics in different languages."""
2827
    # Also on http://boumeries.tumblr.com
2828
    get_first_comic_link = get_a_navi_navifirst
2829
    get_navi_link = get_link_rel_next
2830
    date_format = NotImplemented
2831
    lang = NotImplemented
2832
2833
    @classmethod
2834
    def get_comic_info(cls, soup, link):
2835
        """Get information about a particular comics."""
2836
        title = soup.find('h2', class_='post-title').string
2837
        short_url = soup.find('link', rel='shortlink')['href']
2838
        author = soup.find("span", class_="post-author").find("a").string
2839
        date_str = soup.find('span', class_='post-date').string
2840
        day = string_to_date(date_str, cls.date_format, cls.lang)
2841
        imgs = soup.find('div', id='comic').find_all('img')
2842
        assert all(i['alt'] == i['title'] for i in imgs)
2843
        return {
2844
            'short_url': short_url,
2845
            'img': [i['src'] for i in imgs],
2846
            'title': title,
2847
            'author': author,
2848
            'month': day.month,
2849
            'year': day.year,
2850
            'day': day.day,
2851
        }
2852
@@ 2571-2596 (lines=26) @@
2568
        }
2569
2570
2571
class TheAwkwardYeti(GenericNavigableComic):
2572
    """Class to retrieve The Awkward Yeti comics."""
2573
    # Also on http://www.gocomics.com/the-awkward-yeti
2574
    # Also on http://larstheyeti.tumblr.com
2575
    # Also on https://tapastic.com/series/TheAwkwardYeti
2576
    name = 'yeti'
2577
    long_name = 'The Awkward Yeti'
2578
    url = 'http://theawkwardyeti.com'
2579
    _categories = ('YETI', )
2580
    get_first_comic_link = get_a_navi_navifirst
2581
    get_navi_link = get_link_rel_next
2582
2583
    @classmethod
2584
    def get_comic_info(cls, soup, link):
2585
        """Get information about a particular comics."""
2586
        title = soup.find('h2', class_='post-title').string
2587
        date_str = soup.find("span", class_="post-date").string
2588
        day = string_to_date(date_str, "%B %d, %Y")
2589
        imgs = soup.find("div", id="comic").find_all("img")
2590
        assert all(idx > 0 or i['alt'] == i['title'] for idx, i in enumerate(imgs))
2591
        return {
2592
            'img': [i['src'] for i in imgs],
2593
            'title': title,
2594
            'day': day.day,
2595
            'month': day.month,
2596
            'year': day.year
2597
        }
2598
2599
@@ 2484-2509 (lines=26) @@
2481
        }
2482
2483
2484
class GerbilWithAJetpack(GenericNavigableComic):
2485
    """Class to retrieve GerbilWithAJetpack comics."""
2486
    name = 'gerbil'
2487
    long_name = 'Gerbil With A Jetpack'
2488
    url = 'http://gerbilwithajetpack.com'
2489
    get_first_comic_link = get_a_navi_navifirst
2490
    get_navi_link = get_a_rel_next
2491
2492
    @classmethod
2493
    def get_comic_info(cls, soup, link):
2494
        """Get information about a particular comics."""
2495
        title = soup.find('h2', class_='post-title').string
2496
        author = soup.find("span", class_="post-author").find("a").string
2497
        date_str = soup.find("span", class_="post-date").string
2498
        day = string_to_date(date_str, "%B %d, %Y")
2499
        imgs = soup.find("div", id="comic").find_all("img")
2500
        alt = imgs[0]['alt']
2501
        assert all(i['alt'] == i['title'] == alt for i in imgs)
2502
        return {
2503
            'img': [i['src'] for i in imgs],
2504
            'title': title,
2505
            'alt': alt,
2506
            'author': author,
2507
            'day': day.day,
2508
            'month': day.month,
2509
            'year': day.year
2510
        }
2511
2512
@@ 2513-2537 (lines=25) @@
2510
        }
2511
2512
2513
class EveryDayBlues(GenericDeletedComic, GenericNavigableComic):
2514
    """Class to retrieve EveryDayBlues Comics."""
2515
    name = "blues"
2516
    long_name = "Every Day Blues"
2517
    url = "http://everydayblues.net"
2518
    get_first_comic_link = get_a_navi_navifirst
2519
    get_navi_link = get_link_rel_next
2520
2521
    @classmethod
2522
    def get_comic_info(cls, soup, link):
2523
        """Get information about a particular comics."""
2524
        title = soup.find("h2", class_="post-title").string
2525
        author = soup.find("span", class_="post-author").find("a").string
2526
        date_str = soup.find("span", class_="post-date").string
2527
        day = string_to_date(date_str, "%d. %B %Y", "de_DE.utf8")
2528
        imgs = soup.find("div", id="comic").find_all("img")
2529
        assert all(i['alt'] == i['title'] == title for i in imgs)
2530
        assert len(imgs) <= 1, imgs
2531
        return {
2532
            'img': [i['src'] for i in imgs],
2533
            'title': title,
2534
            'author': author,
2535
            'day': day.day,
2536
            'month': day.month,
2537
            'year': day.year
2538
        }
2539
2540
@@ 1759-1783 (lines=25) @@
1756
        }
1757
1758
1759
class MouseBearComedy(GenericComicNotWorking):  # Website has changed
1760
    """Class to retrieve Mouse Bear Comedy comics."""
1761
    # Also on http://mousebearcomedy.tumblr.com
1762
    name = 'mousebear'
1763
    long_name = 'Mouse Bear Comedy'
1764
    url = 'http://www.mousebearcomedy.com'
1765
    get_first_comic_link = get_a_navi_navifirst
1766
    get_navi_link = get_a_navi_comicnavnext_navinext
1767
1768
    @classmethod
1769
    def get_comic_info(cls, soup, link):
1770
        """Get information about a particular comics."""
1771
        title = soup.find('h2', class_='post-title').string
1772
        author = soup.find("span", class_="post-author").find("a").string
1773
        date_str = soup.find("span", class_="post-date").string
1774
        day = string_to_date(date_str, '%B %d, %Y')
1775
        imgs = soup.find("div", id="comic").find_all("img")
1776
        assert all(i['alt'] == i['title'] == title for i in imgs)
1777
        return {
1778
            'day': day.day,
1779
            'month': day.month,
1780
            'year': day.year,
1781
            'img': [i['src'] for i in imgs],
1782
            'title': title,
1783
            'author': author,
1784
        }
1785
1786
@@ 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