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
@@ 2411-2435 (lines=25) @@
2408
        }
2409
2410
2411
class LinsEditions(GenericNavigableComic):
2412
    """Class to retrieve L.I.N.S. Editions comics."""
2413
    # Also on https://linscomics.tumblr.com
2414
    # Now on https://warandpeas.com
2415
    name = 'lins'
2416
    long_name = 'L.I.N.S. Editions'
2417
    url = 'https://linsedition.com'
2418
    _categories = ('LINS', )
2419
    get_navi_link = get_link_rel_next
2420
    get_first_comic_link = simulate_first_link
2421
    first_url = 'https://linsedition.com/2011/09/07/l-i-n-s/'
2422
2423
    @classmethod
2424
    def get_comic_info(cls, soup, link):
2425
        """Get information about a particular comics."""
2426
        title = soup.find('meta', property='og:title')['content']
2427
        imgs = soup.find_all('meta', property='og:image')
2428
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
2429
        day = string_to_date(date_str, "%Y-%m-%d")
2430
        return {
2431
            'title': title,
2432
            'img': [i['content'] for i in imgs],
2433
            'month': day.month,
2434
            'year': day.year,
2435
            'day': day.day,
2436
        }
2437
2438
@@ 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
@@ 3418-3439 (lines=22) @@
3415
        }
3416
3417
3418
class MarketoonistComics(GenericNavigableComic):
3419
    """Class to retrieve Marketoonist Comics."""
3420
    name = 'marketoonist'
3421
    long_name = 'Marketoonist'
3422
    url = 'https://marketoonist.com/cartoons'
3423
    get_first_comic_link = simulate_first_link
3424
    get_navi_link = get_link_rel_next
3425
    first_url = 'https://marketoonist.com/2002/10/the-8-types-of-brand-managers-2.html'
3426
3427
    @classmethod
3428
    def get_comic_info(cls, soup, link):
3429
        """Get information about a particular comics."""
3430
        imgs = soup.find_all('meta', property='og:image')
3431
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
3432
        day = string_to_date(date_str, "%Y-%m-%d")
3433
        title = soup.find('meta', property='og:title')['content']
3434
        return {
3435
            'img': [i['content'] for i in imgs],
3436
            'day': day.day,
3437
            'month': day.month,
3438
            'year': day.year,
3439
            'title': title,
3440
        }
3441
3442
@@ 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