Code Duplication    Length = 22-25 lines in 4 locations

comics.py 4 locations

@@ 357-379 (lines=23) @@
354
        return []
355
356
357
class ExtraFabulousComics(GenericNavigableComic):
358
    """Class to retrieve Extra Fabulous Comics."""
359
    name = 'efc'
360
    long_name = 'Extra Fabulous Comics'
361
    url = 'http://extrafabulouscomics.com'
362
    get_first_comic_link = get_a_navi_navifirst
363
    get_navi_link = get_link_rel_next
364
365
    @classmethod
366
    def get_comic_info(cls, soup, link):
367
        """Get information about a particular comics."""
368
        img_src_re = re.compile('^%s/wp-content/uploads/' % cls.url)
369
        imgs = soup.find_all('img', src=img_src_re)
370
        title = soup.find('meta', property='og:title')['content']
371
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
372
        day = string_to_date(date_str, "%Y-%m-%d")
373
        return {
374
            'title': title,
375
            'img': [i['src'] for i in imgs],
376
            'month': day.month,
377
            'year': day.year,
378
            'day': day.day,
379
            'prefix': title + '-'
380
        }
381
382
@@ 2371-2395 (lines=25) @@
2368
        }
2369
2370
2371
class LinsEditions(GenericNavigableComic):
2372
    """Class to retrieve L.I.N.S. Editions comics."""
2373
    # Also on https://linscomics.tumblr.com
2374
    # Now on https://warandpeas.com
2375
    name = 'lins'
2376
    long_name = 'L.I.N.S. Editions'
2377
    url = 'https://linsedition.com'
2378
    _categories = ('LINS', )
2379
    get_navi_link = get_link_rel_next
2380
    get_first_comic_link = simulate_first_link
2381
    first_url = 'https://linsedition.com/2011/09/07/l-i-n-s/'
2382
2383
    @classmethod
2384
    def get_comic_info(cls, soup, link):
2385
        """Get information about a particular comics."""
2386
        title = soup.find('meta', property='og:title')['content']
2387
        imgs = soup.find_all('meta', property='og:image')
2388
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
2389
        day = string_to_date(date_str, "%Y-%m-%d")
2390
        return {
2391
            'title': title,
2392
            'img': [i['content'] for i in imgs],
2393
            'month': day.month,
2394
            'year': day.year,
2395
            'day': day.day,
2396
        }
2397
2398
@@ 1043-1067 (lines=25) @@
1040
        }
1041
1042
1043
class Mercworks(GenericNavigableComic):
1044
    """Class to retrieve Mercworks comics."""
1045
    # Also on http://mercworks.tumblr.com
1046
    name = 'mercworks'
1047
    long_name = 'Mercworks'
1048
    url = 'http://mercworks.net'
1049
    get_first_comic_link = get_a_comicnavbase_comicnavfirst
1050
    get_navi_link = get_link_rel_next
1051
1052
    @classmethod
1053
    def get_comic_info(cls, soup, link):
1054
        """Get information about a particular comics."""
1055
        title = soup.find('meta', property='og:title')['content']
1056
        metadesc = soup.find('meta', property='og:description')
1057
        desc = metadesc['content'] if metadesc else ""
1058
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
1059
        day = string_to_date(date_str, "%Y-%m-%d")
1060
        imgs = soup.find_all('meta', property='og:image')
1061
        return {
1062
            'img': [i['content'] for i in imgs],
1063
            'title': title,
1064
            'desc': desc,
1065
            'day': day.day,
1066
            'month': day.month,
1067
            'year': day.year
1068
        }
1069
1070
@@ 3312-3333 (lines=22) @@
3309
        }
3310
3311
3312
class MarketoonistComics(GenericNavigableComic):
3313
    """Class to retrieve Marketoonist Comics."""
3314
    name = 'marketoonist'
3315
    long_name = 'Marketoonist'
3316
    url = 'https://marketoonist.com/cartoons'
3317
    get_first_comic_link = simulate_first_link
3318
    get_navi_link = get_link_rel_next
3319
    first_url = 'https://marketoonist.com/2002/10/the-8-types-of-brand-managers-2.html'
3320
3321
    @classmethod
3322
    def get_comic_info(cls, soup, link):
3323
        """Get information about a particular comics."""
3324
        imgs = soup.find_all('meta', property='og:image')
3325
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
3326
        day = string_to_date(date_str, "%Y-%m-%d")
3327
        title = soup.find('meta', property='og:title')['content']
3328
        return {
3329
            'img': [i['content'] for i in imgs],
3330
            'day': day.day,
3331
            'month': day.month,
3332
            'year': day.year,
3333
            'title': title,
3334
        }
3335
3336