Code Duplication    Length = 29-32 lines in 3 locations

comics.py 3 locations

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