Code Duplication    Length = 23-28 lines in 4 locations

comics.py 4 locations

@@ 1092-1119 (lines=28) @@
1089
        }
1090
1091
1092
class Mercworks(GenericDeletedComic):  # Moved to Webtoons
1093
    """Class to retrieve Mercworks comics."""
1094
    # Also on http://mercworks.tumblr.com
1095
    # Also on http://www.webtoons.com/en/comedy/mercworks/list?title_no=426
1096
    # Also on https://tapastic.com/series/MercWorks
1097
    name = 'mercworks'
1098
    long_name = 'Mercworks'
1099
    url = 'http://mercworks.net'
1100
    _categories = ('MERCWORKS', )
1101
    get_first_comic_link = get_a_comicnavbase_comicnavfirst
1102
    get_navi_link = get_link_rel_next
1103
1104
    @classmethod
1105
    def get_comic_info(cls, soup, link):
1106
        """Get information about a particular comics."""
1107
        title = soup.find('meta', property='og:title')['content']
1108
        metadesc = soup.find('meta', property='og:description')
1109
        desc = metadesc['content'] if metadesc else ""
1110
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
1111
        day = string_to_date(date_str, "%Y-%m-%d")
1112
        imgs = soup.find_all('meta', property='og:image')
1113
        return {
1114
            'img': [i['content'] for i in imgs],
1115
            'title': title,
1116
            'desc': desc,
1117
            'day': day.day,
1118
            'month': day.month,
1119
            'year': day.year
1120
        }
1121
1122
@@ 405-430 (lines=26) @@
402
    _categories = ('DELETED', )
403
404
405
class ExtraFabulousComics(GenericNavigableComic):
406
    """Class to retrieve Extra Fabulous Comics."""
407
    # Also on https://extrafabulouscomics.tumblr.com
408
    name = 'efc'
409
    long_name = 'Extra Fabulous Comics'
410
    url = 'http://extrafabulouscomics.com'
411
    _categories = ('EFC', )
412
    get_navi_link = get_link_rel_next
413
    get_first_comic_link = simulate_first_link
414
    first_url = 'http://extrafabulouscomics.com/comic/buttfly/'
415
416
    @classmethod
417
    def get_comic_info(cls, soup, link):
418
        """Get information about a particular comics."""
419
        img_src_re = re.compile('^%s/wp-content/uploads/' % cls.url)
420
        imgs = soup.find_all('img', src=img_src_re)
421
        title = soup.find('meta', property='og:title')['content']
422
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
423
        day = string_to_date(date_str, "%Y-%m-%d")
424
        return {
425
            'title': title,
426
            'img': [i['src'] for i in imgs],
427
            'month': day.month,
428
            'year': day.year,
429
            'day': day.day,
430
            'prefix': title + '-'
431
        }
432
433
@@ 2483-2505 (lines=23) @@
2480
class WarAndPeas(GenericNavigableComic):
2481
    """Class to retrieve War And Peas comics."""
2482
    name = 'warandpeas'
2483
    long_name = 'War And Peas'
2484
    url = 'https://warandpeas.com'
2485
    get_navi_link = get_link_rel_next
2486
    get_first_comic_link = simulate_first_link
2487
    first_url = 'https://warandpeas.com/2011/11/07/565/'
2488
    _categories = ('WARANDPEAS', 'LINS')
2489
2490
    @classmethod
2491
    def get_comic_info(cls, soup, link):
2492
        """Get information about a particular comics."""
2493
        title = soup.find('meta', property='og:title')['content']
2494
        imgs = soup.find_all('meta', property='og:image')
2495
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
2496
        day = string_to_date(date_str, "%Y-%m-%d")
2497
        return {
2498
            'title': title,
2499
            'img': [i['content'] for i in imgs],
2500
            'month': day.month,
2501
            'year': day.year,
2502
            'day': day.day,
2503
        }
2504
2505
2506
class ThorsThundershack(GenericNavigableComic):
2507
    """Class to retrieve Thor's Thundershack comics."""
2508
    # Also on http://tapastic.com/series/Thors-Thundershac
@@ 1879-1904 (lines=26) @@
1876
class SafelyEndangered(GenericNavigableComic):
1877
    """Class to retrieve Safely Endangered comics."""
1878
    # Also on http://tumblr.safelyendangered.com
1879
    name = 'endangered'
1880
    long_name = 'Safely Endangered'
1881
    url = 'http://www.safelyendangered.com'
1882
    get_navi_link = get_link_rel_next
1883
    get_first_comic_link = simulate_first_link
1884
    first_url = 'http://www.safelyendangered.com/comic/ignored/'
1885
1886
    @classmethod
1887
    def get_comic_info(cls, soup, link):
1888
        """Get information about a particular comics."""
1889
        title = soup.find('h2', class_='post-title').string
1890
        date_str = soup.find('span', class_='post-date').string
1891
        day = string_to_date(date_str, '%B %d, %Y')
1892
        imgs = soup.find('div', id='comic').find_all('img')
1893
        alt = imgs[0]['alt']
1894
        assert all(i['alt'] == i['title'] for i in imgs)
1895
        return {
1896
            'day': day.day,
1897
            'month': day.month,
1898
            'year': day.year,
1899
            'img': [i['src'] for i in imgs],
1900
            'title': title,
1901
            'alt': alt,
1902
        }
1903
1904
1905
class PicturesInBoxes(GenericNavigableComic):
1906
    """Class to retrieve Pictures In Boxes comics."""
1907
    # Also on https://picturesinboxescomic.tumblr.com