Code Duplication    Length = 29-30 lines in 2 locations

comics.py 2 locations

@@ 3340-3369 (lines=30) @@
3337
3338
3339
class MarketoonistComics(GenericNavigableComic):
3340
    """Class to retrieve Marketoonist Comics."""
3341
    name = 'marketoonist'
3342
    long_name = 'Marketoonist'
3343
    url = 'https://marketoonist.com/cartoons'
3344
    get_first_comic_link = simulate_first_link
3345
    get_navi_link = get_link_rel_next
3346
    first_url = 'https://marketoonist.com/2002/10/the-8-types-of-brand-managers-2.html'
3347
3348
    @classmethod
3349
    def get_comic_info(cls, soup, link):
3350
        """Get information about a particular comics."""
3351
        imgs = soup.find_all('meta', property='og:image')
3352
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
3353
        day = string_to_date(date_str, "%Y-%m-%d")
3354
        title = soup.find('meta', property='og:title')['content']
3355
        return {
3356
            'img': [i['content'] for i in imgs],
3357
            'day': day.day,
3358
            'month': day.month,
3359
            'year': day.year,
3360
            'title': title,
3361
        }
3362
3363
3364
class ConsoliaComics(GenericNavigableComic):
3365
    """Class to retrieve Consolia comics."""
3366
    name = 'consolia'
3367
    long_name = 'consolia'
3368
    url = 'https://consolia-comic.com'
3369
    get_url_from_link = join_cls_url_to_href
3370
3371
    @classmethod
3372
    def get_first_comic_link(cls):
@@ 3210-3238 (lines=29) @@
3207
        }
3208
3209
3210
class PomComics(GenericNavigableComic):
3211
    """Class to retrieve PomComics."""
3212
    name = 'pom'
3213
    long_name = 'Pom Comics / Piece of Me'
3214
    url = 'http://www.pomcomic.com'
3215
    get_url_from_link = join_cls_url_to_href
3216
3217
    @classmethod
3218
    def get_first_comic_link(cls):
3219
        """Get link to first comics."""
3220
        return get_soup_at_url(cls.url).find('a', class_='btn_first')
3221
3222
    @classmethod
3223
    def get_navi_link(cls, last_soup, next_):
3224
        """Get link to next or previous comic."""
3225
        return last_soup.find('a', class_='btn_next' if next_ else 'btn_prev')
3226
3227
    @classmethod
3228
    def get_comic_info(cls, soup, link):
3229
        """Get information about a particular comics."""
3230
        title = soup.find('h1', id="comic-name").string
3231
        desc = soup.find('meta', property='og:description')['content']
3232
        tags = soup.find('meta', attrs={'name': 'keywords'})['content']
3233
        imgs = soup.find('div', class_='comic').find_all('img')
3234
        return {
3235
            'title': title,
3236
            'desc': desc,
3237
            'tags': tags,
3238
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
3239
        }
3240
3241