Code Duplication    Length = 22-27 lines in 10 locations

comics.py 10 locations

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