Code Duplication    Length = 22-26 lines in 5 locations

comics.py 5 locations

@@ 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
@@ 1092-1116 (lines=25) @@
1089
        }
1090
1091
1092
class Mercworks(GenericNavigableComic):
1093
    """Class to retrieve Mercworks comics."""
1094
    # Also on http://mercworks.tumblr.com
1095
    name = 'mercworks'
1096
    long_name = 'Mercworks'
1097
    url = 'http://mercworks.net'
1098
    get_first_comic_link = get_a_comicnavbase_comicnavfirst
1099
    get_navi_link = get_link_rel_next
1100
1101
    @classmethod
1102
    def get_comic_info(cls, soup, link):
1103
        """Get information about a particular comics."""
1104
        title = soup.find('meta', property='og:title')['content']
1105
        metadesc = soup.find('meta', property='og:description')
1106
        desc = metadesc['content'] if metadesc else ""
1107
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
1108
        day = string_to_date(date_str, "%Y-%m-%d")
1109
        imgs = soup.find_all('meta', property='og:image')
1110
        return {
1111
            'img': [i['content'] for i in imgs],
1112
            'title': title,
1113
            'desc': desc,
1114
            'day': day.day,
1115
            'month': day.month,
1116
            'year': day.year
1117
        }
1118
1119
@@ 434-455 (lines=22) @@
431
        }
432
433
434
class GenericLeMondeBlog(GenericNavigableComic):
435
    """Generic class to retrieve comics from Le Monde blogs."""
436
    _categories = ('LEMONDE', 'FRANCAIS')
437
    get_navi_link = get_link_rel_next
438
    get_first_comic_link = simulate_first_link
439
    first_url = NotImplemented
440
441
    @classmethod
442
    def get_comic_info(cls, soup, link):
443
        """Get information about a particular comics."""
444
        url2 = soup.find('link', rel='shortlink')['href']
445
        title = soup.find('meta', property='og:title')['content']
446
        date_str = soup.find("span", class_="entry-date").string
447
        day = string_to_date(date_str, "%d %B %Y", "fr_FR.utf8")
448
        imgs = soup.find_all('meta', property='og:image')
449
        return {
450
            'title': title,
451
            'url2': url2,
452
            'img': [convert_iri_to_plain_ascii_uri(i['content']) for i in imgs],
453
            'month': day.month,
454
            'year': day.year,
455
            'day': day.day,
456
        }
457
458
@@ 2444-2468 (lines=25) @@
2441
        }
2442
2443
2444
class LinsEditions(GenericNavigableComic):
2445
    """Class to retrieve L.I.N.S. Editions comics."""
2446
    # Also on https://linscomics.tumblr.com
2447
    # Now on https://warandpeas.com
2448
    name = 'lins'
2449
    long_name = 'L.I.N.S. Editions'
2450
    url = 'https://linsedition.com'
2451
    _categories = ('LINS', )
2452
    get_navi_link = get_link_rel_next
2453
    get_first_comic_link = simulate_first_link
2454
    first_url = 'https://linsedition.com/2011/09/07/l-i-n-s/'
2455
2456
    @classmethod
2457
    def get_comic_info(cls, soup, link):
2458
        """Get information about a particular comics."""
2459
        title = soup.find('meta', property='og:title')['content']
2460
        imgs = soup.find_all('meta', property='og:image')
2461
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
2462
        day = string_to_date(date_str, "%Y-%m-%d")
2463
        return {
2464
            'title': title,
2465
            'img': [i['content'] for i in imgs],
2466
            'month': day.month,
2467
            'year': day.year,
2468
            'day': day.day,
2469
        }
2470
2471
@@ 3451-3472 (lines=22) @@
3448
        }
3449
3450
3451
class MarketoonistComics(GenericNavigableComic):
3452
    """Class to retrieve Marketoonist Comics."""
3453
    name = 'marketoonist'
3454
    long_name = 'Marketoonist'
3455
    url = 'https://marketoonist.com/cartoons'
3456
    get_first_comic_link = simulate_first_link
3457
    get_navi_link = get_link_rel_next
3458
    first_url = 'https://marketoonist.com/2002/10/the-8-types-of-brand-managers-2.html'
3459
3460
    @classmethod
3461
    def get_comic_info(cls, soup, link):
3462
        """Get information about a particular comics."""
3463
        imgs = soup.find_all('meta', property='og:image')
3464
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
3465
        day = string_to_date(date_str, "%Y-%m-%d")
3466
        title = soup.find('meta', property='og:title')['content']
3467
        return {
3468
            'img': [i['content'] for i in imgs],
3469
            'day': day.day,
3470
            'month': day.month,
3471
            'year': day.year,
3472
            'title': title,
3473
        }
3474
3475