Code Duplication    Length = 22-27 lines in 10 locations

comics.py 10 locations

@@ 1864-1890 (lines=27) @@
1861
        }
1862
1863
1864
class PicturesInBoxes(GenericNavigableComic):
1865
    """Class to retrieve Pictures In Boxes comics."""
1866
    # Also on http://picturesinboxescomic.tumblr.com
1867
    name = 'picturesinboxes'
1868
    long_name = 'Pictures in Boxes'
1869
    url = 'http://www.picturesinboxes.com'
1870
    get_navi_link = get_a_navi_navinext
1871
    get_first_comic_link = simulate_first_link
1872
    first_url = 'http://www.picturesinboxes.com/2013/10/26/tetris/'
1873
1874
    @classmethod
1875
    def get_comic_info(cls, soup, link):
1876
        """Get information about a particular comics."""
1877
        title = soup.find('h2', class_='post-title').string
1878
        author = soup.find("span", class_="post-author").find("a").string
1879
        date_str = soup.find('span', class_='post-date').string
1880
        day = string_to_date(date_str, '%B %d, %Y')
1881
        imgs = soup.find('div', class_='comicpane').find_all('img')
1882
        assert imgs
1883
        assert all(i['title'] == i['alt'] == title for i in imgs)
1884
        return {
1885
            'day': day.day,
1886
            'month': day.month,
1887
            'year': day.year,
1888
            'img': [i['src'] for i in imgs],
1889
            'title': title,
1890
            'author': author,
1891
        }
1892
1893
@@ 924-950 (lines=27) @@
921
        }
922
923
924
class ImogenQuest(GenericNavigableComic):
925
    """Class to retrieve Imogen Quest comics."""
926
    # Also on http://imoquest.tumblr.com
927
    name = 'imogen'
928
    long_name = 'Imogen Quest'
929
    url = 'http://imogenquest.net'
930
    get_first_comic_link = get_div_navfirst_a
931
    get_navi_link = get_a_rel_next
932
933
    @classmethod
934
    def get_comic_info(cls, soup, link):
935
        """Get information about a particular comics."""
936
        title = soup.find('h2', class_='post-title').string
937
        author = soup.find("span", class_="post-author").find("a").string
938
        date_str = soup.find('span', class_='post-date').string
939
        day = string_to_date(date_str, '%B %d, %Y')
940
        imgs = soup.find('div', class_='comicpane').find_all('img')
941
        assert all(i['alt'] == i['title'] for i in imgs)
942
        title2 = imgs[0]['title']
943
        return {
944
            'day': day.day,
945
            'month': day.month,
946
            'year': day.year,
947
            'img': [i['src'] for i in imgs],
948
            'title': title,
949
            'title2': title2,
950
            'author': author,
951
        }
952
953
@@ 2513-2538 (lines=26) @@
2510
        }
2511
2512
2513
class TheAwkwardYeti(GenericNavigableComic):
2514
    """Class to retrieve The Awkward Yeti comics."""
2515
    # Also on http://www.gocomics.com/the-awkward-yeti
2516
    # Also on http://larstheyeti.tumblr.com
2517
    # Also on https://tapastic.com/series/TheAwkwardYeti
2518
    name = 'yeti'
2519
    long_name = 'The Awkward Yeti'
2520
    url = 'http://theawkwardyeti.com'
2521
    _categories = ('YETI', )
2522
    get_first_comic_link = get_a_navi_navifirst
2523
    get_navi_link = get_link_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
        date_str = soup.find("span", class_="post-date").string
2530
        day = string_to_date(date_str, "%B %d, %Y")
2531
        imgs = soup.find("div", id="comic").find_all("img")
2532
        assert all(idx > 0 or i['alt'] == i['title'] for idx, i in enumerate(imgs))
2533
        return {
2534
            'img': [i['src'] for i in imgs],
2535
            'title': title,
2536
            'day': day.day,
2537
            'month': day.month,
2538
            'year': day.year
2539
        }
2540
2541
@@ 2767-2791 (lines=25) @@
2764
    first_url = 'http://www.commitstrip.com/en/2012/02/22/interview/'
2765
2766
2767
class GenericBoumerie(GenericNavigableComic):
2768
    """Generic class to retrieve Boumeries comics in different languages."""
2769
    get_first_comic_link = get_a_navi_navifirst
2770
    get_navi_link = get_link_rel_next
2771
    date_format = NotImplemented
2772
    lang = NotImplemented
2773
2774
    @classmethod
2775
    def get_comic_info(cls, soup, link):
2776
        """Get information about a particular comics."""
2777
        title = soup.find('h2', class_='post-title').string
2778
        short_url = soup.find('link', rel='shortlink')['href']
2779
        author = soup.find("span", class_="post-author").find("a").string
2780
        date_str = soup.find('span', class_='post-date').string
2781
        day = string_to_date(date_str, cls.date_format, cls.lang)
2782
        imgs = soup.find('div', id='comic').find_all('img')
2783
        assert all(i['alt'] == i['title'] for i in imgs)
2784
        return {
2785
            'short_url': short_url,
2786
            'img': [i['src'] for i in imgs],
2787
            'title': title,
2788
            'author': author,
2789
            'month': day.month,
2790
            'year': day.year,
2791
            'day': day.day,
2792
        }
2793
2794
@@ 2455-2479 (lines=25) @@
2452
        }
2453
2454
2455
class EveryDayBlues(GenericNavigableComic):
2456
    """Class to retrieve EveryDayBlues Comics."""
2457
    name = "blues"
2458
    long_name = "Every Day Blues"
2459
    url = "http://everydayblues.net"
2460
    get_first_comic_link = get_a_navi_navifirst
2461
    get_navi_link = get_link_rel_next
2462
2463
    @classmethod
2464
    def get_comic_info(cls, soup, link):
2465
        """Get information about a particular comics."""
2466
        title = soup.find("h2", class_="post-title").string
2467
        author = soup.find("span", class_="post-author").find("a").string
2468
        date_str = soup.find("span", class_="post-date").string
2469
        day = string_to_date(date_str, "%d. %B %Y", "de_DE.utf8")
2470
        imgs = soup.find("div", id="comic").find_all("img")
2471
        assert all(i['alt'] == i['title'] == title for i in imgs)
2472
        assert len(imgs) <= 1
2473
        return {
2474
            'img': [i['src'] for i in imgs],
2475
            'title': title,
2476
            'author': author,
2477
            'day': day.day,
2478
            'month': day.month,
2479
            'year': day.year
2480
        }
2481
2482
@@ 1752-1776 (lines=25) @@
1749
        }
1750
1751
1752
class MouseBearComedy(GenericNavigableComic):
1753
    """Class to retrieve Mouse Bear Comedy comics."""
1754
    # Also on http://mousebearcomedy.tumblr.com
1755
    name = 'mousebear'
1756
    long_name = 'Mouse Bear Comedy'
1757
    url = 'http://www.mousebearcomedy.com'
1758
    get_first_comic_link = get_a_navi_navifirst
1759
    get_navi_link = get_a_navi_comicnavnext_navinext
1760
1761
    @classmethod
1762
    def get_comic_info(cls, soup, link):
1763
        """Get information about a particular comics."""
1764
        title = soup.find('h2', class_='post-title').string
1765
        author = soup.find("span", class_="post-author").find("a").string
1766
        date_str = soup.find("span", class_="post-date").string
1767
        day = string_to_date(date_str, '%B %d, %Y')
1768
        imgs = soup.find("div", id="comic").find_all("img")
1769
        assert all(i['alt'] == i['title'] == title for i in imgs)
1770
        return {
1771
            'day': day.day,
1772
            'month': day.month,
1773
            'year': day.year,
1774
            'img': [i['src'] for i in imgs],
1775
            'title': title,
1776
            'author': author,
1777
        }
1778
1779
@@ 1160-1183 (lines=24) @@
1157
    url = 'http://english.bouletcorp.com'
1158
1159
1160
class AmazingSuperPowers(GenericNavigableComic):
1161
    """Class to retrieve Amazing Super Powers comics."""
1162
    name = 'asp'
1163
    long_name = 'Amazing Super Powers'
1164
    url = 'http://www.amazingsuperpowers.com'
1165
    get_first_comic_link = get_a_navi_navifirst
1166
    get_navi_link = get_a_navi_navinext
1167
1168
    @classmethod
1169
    def get_comic_info(cls, soup, link):
1170
        """Get information about a particular comics."""
1171
        author = soup.find("span", class_="post-author").find("a").string
1172
        date_str = soup.find('span', class_='post-date').string
1173
        day = string_to_date(date_str, "%B %d, %Y")
1174
        imgs = soup.find('div', id='comic').find_all('img')
1175
        title = ' '.join(i['title'] for i in imgs)
1176
        assert all(i['alt'] == i['title'] for i in imgs)
1177
        return {
1178
            'title': title,
1179
            'author': author,
1180
            'img': [img['src'] for img in imgs],
1181
            'day': day.day,
1182
            'month': day.month,
1183
            'year': day.year
1184
        }
1185
1186
@@ 671-694 (lines=24) @@
668
        }
669
670
671
class OneOneOneOneComic(GenericNavigableComic):
672
    """Class to retrieve 1111 Comics."""
673
    # Also on http://comics1111.tumblr.com
674
    # Also on https://tapastic.com/series/1111-Comics
675
    name = '1111'
676
    long_name = '1111 Comics'
677
    url = 'http://www.1111comics.me'
678
    _categories = ('ONEONEONEONE', )
679
    get_first_comic_link = get_div_navfirst_a
680
    get_navi_link = get_link_rel_next
681
682
    @classmethod
683
    def get_comic_info(cls, soup, link):
684
        """Get information about a particular comics."""
685
        title = soup.find('h1', class_='comic-title').find('a').string
686
        date_str = soup.find('header', class_='comic-meta entry-meta').find('a').string
687
        day = string_to_date(date_str, "%B %d, %Y")
688
        imgs = soup.find_all('meta', property='og:image')
689
        return {
690
            'title': title,
691
            'month': day.month,
692
            'year': day.year,
693
            'day': day.day,
694
            'img': [i['content'] for i in imgs],
695
        }
696
697
@@ 898-920 (lines=23) @@
895
        }
896
897
898
class TheGentlemanArmchair(GenericNavigableComic):
899
    """Class to retrieve The Gentleman Armchair comics."""
900
    name = 'gentlemanarmchair'
901
    long_name = 'The Gentleman Armchair'
902
    url = 'http://thegentlemansarmchair.com'
903
    get_first_comic_link = get_a_navi_navifirst
904
    get_navi_link = get_link_rel_next
905
906
    @classmethod
907
    def get_comic_info(cls, soup, link):
908
        """Get information about a particular comics."""
909
        title = soup.find('h2', class_='post-title').string
910
        author = soup.find("span", class_="post-author").find("a").string
911
        date_str = soup.find('span', class_='post-date').string
912
        day = string_to_date(date_str, "%B %d, %Y")
913
        imgs = soup.find('div', id='comic').find_all('img')
914
        return {
915
            'img': [i['src'] for i in imgs],
916
            'title': title,
917
            'author': author,
918
            'month': day.month,
919
            'year': day.year,
920
            'day': day.day,
921
        }
922
923
@@ 698-719 (lines=22) @@
695
        }
696
697
698
class AngryAtNothing(GenericNavigableComic):
699
    """Class to retrieve Angry at Nothing comics."""
700
    # Also on http://tapastic.com/series/Comics-yeah-definitely-comics-
701
    name = 'angry'
702
    long_name = 'Angry At Nothing'
703
    url = 'http://www.angryatnothing.net'
704
    get_first_comic_link = get_div_navfirst_a
705
    get_navi_link = get_a_rel_next
706
707
    @classmethod
708
    def get_comic_info(cls, soup, link):
709
        """Get information about a particular comics."""
710
        title = soup.find('h1', class_='comic-title').find('a').string
711
        date_str = soup.find('header', class_='comic-meta entry-meta').find('a').string
712
        day = string_to_date(date_str, "%B %d, %Y")
713
        imgs = soup.find_all('meta', property='og:image')
714
        return {
715
            'title': title,
716
            'month': day.month,
717
            'year': day.year,
718
            'day': day.day,
719
            'img': [i['content'] for i in imgs],
720
        }
721
722