Code Duplication    Length = 24-26 lines in 5 locations

comics.py 5 locations

@@ 1699-1723 (lines=25) @@
1696
        }
1697
1698
1699
class MouseBearComedy(GenericNavigableComic):
1700
    """Class to retrieve Mouse Bear Comedy comics."""
1701
    # Also on http://mousebearcomedy.tumblr.com
1702
    name = 'mousebear'
1703
    long_name = 'Mouse Bear Comedy'
1704
    url = 'http://www.mousebearcomedy.com'
1705
    get_first_comic_link = get_a_navi_navifirst
1706
    get_navi_link = get_a_navi_comicnavnext_navinext
1707
1708
    @classmethod
1709
    def get_comic_info(cls, soup, link):
1710
        """Get information about a particular comics."""
1711
        title = soup.find('h2', class_='post-title').string
1712
        author = soup.find("span", class_="post-author").find("a").string
1713
        date_str = soup.find("span", class_="post-date").string
1714
        day = string_to_date(date_str, '%B %d, %Y')
1715
        imgs = soup.find("div", id="comic").find_all("img")
1716
        assert all(i['alt'] == i['title'] == title for i in imgs)
1717
        return {
1718
            'day': day.day,
1719
            'month': day.month,
1720
            'year': day.year,
1721
            'img': [i['src'] for i in imgs],
1722
            'title': title,
1723
            'author': author,
1724
        }
1725
1726
@@ 900-925 (lines=26) @@
897
        }
898
899
900
class MyExtraLife(GenericNavigableComic):
901
    """Class to retrieve My Extra Life comics."""
902
    name = 'extralife'
903
    long_name = 'My Extra Life'
904
    url = 'http://www.myextralife.com'
905
    get_navi_link = get_link_rel_next
906
907
    @classmethod
908
    def get_first_comic_link(cls):
909
        """Get link to first comics."""
910
        return get_soup_at_url(cls.url).find('a', class_='comic_nav_link first_comic_link')
911
912
    @classmethod
913
    def get_comic_info(cls, soup, link):
914
        """Get information about a particular comics."""
915
        title = soup.find("h1", class_="comic_title").string
916
        date_str = soup.find("span", class_="comic_date").string
917
        day = string_to_date(date_str, "%B %d, %Y")
918
        imgs = soup.find_all("img", class_="comic")
919
        assert all(i['alt'] == i['title'] == title for i in imgs)
920
        return {
921
            'title': title,
922
            'img': [i['src'] for i in imgs if i["src"]],
923
            'day': day.day,
924
            'month': day.month,
925
            'year': day.year
926
        }
927
928
@@ 2408-2432 (lines=25) @@
2405
        }
2406
2407
2408
class TheAwkwardYeti(GenericNavigableComic):
2409
    """Class to retrieve The Awkward Yeti comics."""
2410
    # Also on http://www.gocomics.com/the-awkward-yeti
2411
    # Also on http://larstheyeti.tumblr.com
2412
    # Also on https://tapastic.com/series/TheAwkwardYeti
2413
    name = 'yeti'
2414
    long_name = 'The Awkward Yeti'
2415
    url = 'http://theawkwardyeti.com'
2416
    get_first_comic_link = get_a_navi_navifirst
2417
    get_navi_link = get_link_rel_next
2418
2419
    @classmethod
2420
    def get_comic_info(cls, soup, link):
2421
        """Get information about a particular comics."""
2422
        title = soup.find('h2', class_='post-title').string
2423
        date_str = soup.find("span", class_="post-date").string
2424
        day = string_to_date(date_str, "%B %d, %Y")
2425
        imgs = soup.find("div", id="comic").find_all("img")
2426
        assert all(idx > 0 or i['alt'] == i['title'] for idx, i in enumerate(imgs))
2427
        return {
2428
            'img': [i['src'] for i in imgs],
2429
            'title': title,
2430
            'day': day.day,
2431
            'month': day.month,
2432
            'year': day.year
2433
        }
2434
2435
@@ 2350-2374 (lines=25) @@
2347
        }
2348
2349
2350
class EveryDayBlues(GenericNavigableComic):
2351
    """Class to retrieve EveryDayBlues Comics."""
2352
    name = "blues"
2353
    long_name = "Every Day Blues"
2354
    url = "http://everydayblues.net"
2355
    get_first_comic_link = get_a_navi_navifirst
2356
    get_navi_link = get_link_rel_next
2357
2358
    @classmethod
2359
    def get_comic_info(cls, soup, link):
2360
        """Get information about a particular comics."""
2361
        title = soup.find("h2", class_="post-title").string
2362
        author = soup.find("span", class_="post-author").find("a").string
2363
        date_str = soup.find("span", class_="post-date").string
2364
        day = string_to_date(date_str, "%d. %B %Y", "de_DE.utf8")
2365
        imgs = soup.find("div", id="comic").find_all("img")
2366
        assert all(i['alt'] == i['title'] == title for i in imgs)
2367
        assert len(imgs) <= 1
2368
        return {
2369
            'img': [i['src'] for i in imgs],
2370
            'title': title,
2371
            'author': author,
2372
            'day': day.day,
2373
            'month': day.month,
2374
            'year': day.year
2375
        }
2376
2377
@@ 1105-1128 (lines=24) @@
1102
    url = 'http://english.bouletcorp.com'
1103
1104
1105
class AmazingSuperPowers(GenericNavigableComic):
1106
    """Class to retrieve Amazing Super Powers comics."""
1107
    name = 'asp'
1108
    long_name = 'Amazing Super Powers'
1109
    url = 'http://www.amazingsuperpowers.com'
1110
    get_first_comic_link = get_a_navi_navifirst
1111
    get_navi_link = get_a_navi_navinext
1112
1113
    @classmethod
1114
    def get_comic_info(cls, soup, link):
1115
        """Get information about a particular comics."""
1116
        author = soup.find("span", class_="post-author").find("a").string
1117
        date_str = soup.find('span', class_='post-date').string
1118
        day = string_to_date(date_str, "%B %d, %Y")
1119
        imgs = soup.find('div', id='comic').find_all('img')
1120
        title = ' '.join(i['title'] for i in imgs)
1121
        assert all(i['alt'] == i['title'] for i in imgs)
1122
        return {
1123
            'title': title,
1124
            'author': author,
1125
            'img': [img['src'] for img in imgs],
1126
            'day': day.day,
1127
            'month': day.month,
1128
            'year': day.year
1129
        }
1130
1131