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
    _categories = ('WARANDPEAS', 'LINS')
2481
2482
2483
class WarAndPeas(GenericNavigableComic):
2484
    """Class to retrieve War And Peas comics."""
2485
    name = 'warandpeas'
2486
    long_name = 'War And Peas'
2487
    url = 'https://warandpeas.com'
2488
    get_navi_link = get_link_rel_next
2489
    get_first_comic_link = simulate_first_link
2490
    first_url = 'https://warandpeas.com/2011/11/07/565/'
2491
    _categories = ('WARANDPEAS', 'LINS')
2492
2493
    @classmethod
2494
    def get_comic_info(cls, soup, link):
2495
        """Get information about a particular comics."""
2496
        title = soup.find('meta', property='og:title')['content']
2497
        imgs = soup.find_all('meta', property='og:image')
2498
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
2499
        day = string_to_date(date_str, "%Y-%m-%d")
2500
        return {
2501
            'title': title,
2502
            'img': [i['content'] for i in imgs],
2503
            'month': day.month,
2504
            'year': day.year,
2505
            'day': day.day,
2506
        }
2507
2508
@@ 1879-1904 (lines=26) @@
1876
        }
1877
1878
1879
class SafelyEndangered(GenericNavigableComic):
1880
    """Class to retrieve Safely Endangered comics."""
1881
    # Also on http://tumblr.safelyendangered.com
1882
    name = 'endangered'
1883
    long_name = 'Safely Endangered'
1884
    url = 'http://www.safelyendangered.com'
1885
    get_navi_link = get_link_rel_next
1886
    get_first_comic_link = simulate_first_link
1887
    first_url = 'http://www.safelyendangered.com/comic/ignored/'
1888
1889
    @classmethod
1890
    def get_comic_info(cls, soup, link):
1891
        """Get information about a particular comics."""
1892
        title = soup.find('h2', class_='post-title').string
1893
        date_str = soup.find('span', class_='post-date').string
1894
        day = string_to_date(date_str, '%B %d, %Y')
1895
        imgs = soup.find('div', id='comic').find_all('img')
1896
        alt = imgs[0]['alt']
1897
        assert all(i['alt'] == i['title'] for i in imgs)
1898
        return {
1899
            'day': day.day,
1900
            'month': day.month,
1901
            'year': day.year,
1902
            'img': [i['src'] for i in imgs],
1903
            'title': title,
1904
            'alt': alt,
1905
        }
1906
1907