Code Duplication    Length = 29-32 lines in 3 locations

comics.py 3 locations

@@ 3693-3724 (lines=32) @@
3690
            'author': author,
3691
            'day': day.day,
3692
            'month': day.month,
3693
            'year': day.year,
3694
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
3695
        }
3696
3697
3698
class GloryOwlComix(GenericBlogspotComic):
3699
    """Class to retrieve Glory Owl comics."""
3700
    name = 'gloryowl'
3701
    long_name = 'Glory Owl'
3702
    url = 'http://gloryowlcomix.blogspot.fr'
3703
    _categories = ('NSFW', 'FRANCAIS')
3704
    first_url = 'http://gloryowlcomix.blogspot.fr/2013/02/1_7.html'
3705
3706
    @classmethod
3707
    def get_comic_info(cls, soup, link):
3708
        """Get information about a particular comics."""
3709
        title = soup.find('title').string
3710
        imgs = soup.find_all('link', rel='image_src')
3711
        author = soup.find('a', rel='author').string
3712
        return {
3713
            'img': [i['href'] for i in imgs],
3714
            'author': author,
3715
            'title': title,
3716
        }
3717
3718
3719
class GenericSquareSpace(GenericNavigableComic):
3720
    """Generic class to retrieve comics using SquareSpace."""
3721
    _categories = ('SQUARESPACE', )
3722
    get_url_from_link = join_cls_url_to_href
3723
    get_first_comic_link = simulate_first_link
3724
3725
    @classmethod
3726
    def get_navi_link(cls, last_soup, next_):
3727
        """Get link to next or previous comic."""
@@ 3541-3570 (lines=30) @@
3538
            'author': author,
3539
        }
3540
3541
3542
class MarketoonistComics(GenericNavigableComic):
3543
    """Class to retrieve Marketoonist Comics."""
3544
    name = 'marketoonist'
3545
    long_name = 'Marketoonist'
3546
    url = 'https://marketoonist.com/cartoons'
3547
    get_first_comic_link = simulate_first_link
3548
    get_navi_link = get_link_rel_next
3549
    first_url = 'https://marketoonist.com/2002/10/the-8-types-of-brand-managers-2.html'
3550
3551
    @classmethod
3552
    def get_comic_info(cls, soup, link):
3553
        """Get information about a particular comics."""
3554
        imgs = soup.find_all('meta', property='og:image')
3555
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
3556
        day = string_to_date(date_str, "%Y-%m-%d")
3557
        title = soup.find('meta', property='og:title')['content']
3558
        return {
3559
            'img': [i['content'] for i in imgs],
3560
            'day': day.day,
3561
            'month': day.month,
3562
            'year': day.year,
3563
            'title': title,
3564
        }
3565
3566
3567
class ConsoliaComics(GenericNavigableComic):
3568
    """Class to retrieve Consolia comics."""
3569
    name = 'consolia'
3570
    long_name = 'consolia'
3571
    url = 'https://consolia-comic.com'
3572
    get_url_from_link = join_cls_url_to_href
3573
@@ 3360-3388 (lines=29) @@
3357
3358
3359
class EarthExplodes(GenericNavigableComic):
3360
    """Class to retrieve The Earth Explodes comics."""
3361
    name = 'earthexplodes'
3362
    long_name = 'The Earth Explodes'
3363
    url = 'http://www.earthexplodes.com'
3364
    get_url_from_link = join_cls_url_to_href
3365
    get_first_comic_link = simulate_first_link
3366
    first_url = 'http://www.earthexplodes.com/comics/000/'
3367
3368
    @classmethod
3369
    def get_navi_link(cls, last_soup, next_):
3370
        """Get link to next or previous comic."""
3371
        return last_soup.find('a', id='next' if next_ else 'prev')
3372
3373
    @classmethod
3374
    def get_comic_info(cls, soup, link):
3375
        """Get information about a particular comics."""
3376
        title = soup.find('title').string
3377
        imgs = soup.find('div', id='image').find_all('img')
3378
        alt = imgs[0].get('title', '')
3379
        return {
3380
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
3381
            'title': title,
3382
            'alt': alt,
3383
        }
3384
3385
3386
class PomComics(GenericNavigableComic):
3387
    """Class to retrieve PomComics."""
3388
    name = 'pom'
3389
    long_name = 'Pom Comics / Piece of Me'
3390
    url = 'http://www.pomcomic.com'
3391
    get_url_from_link = join_cls_url_to_href