Code Duplication    Length = 23-27 lines in 11 locations

comics.py 11 locations

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