Code Duplication    Length = 24-24 lines in 3 locations

comics.py 3 locations

@@ 3440-3463 (lines=24) @@
3437
3438
    @classmethod
3439
    def get_comic_info(cls, soup, link):
3440
        """Get information about a particular comics."""
3441
        title = soup.find('title').string
3442
        imgs = soup.find('div', itemprop='description articleBody').find_all('img')
3443
        author = soup.find('span', itemprop='author').string
3444
        return {
3445
            'img': [i['src'] for i in imgs],
3446
            'author': author,
3447
            'title': title,
3448
        }
3449
3450
3451
class GeekAndPoke(GenericNavigableComic):
3452
    """Class to retrieve Geek And Poke comics."""
3453
    name = 'geek'
3454
    long_name = 'Geek And Poke'
3455
    url = 'http://geek-and-poke.com'
3456
    get_url_from_link = join_cls_url_to_href
3457
    get_first_comic_link = simulate_first_link
3458
    first_url = 'http://geek-and-poke.com/geekandpoke/2006/8/27/a-new-place-for-a-not-so-old-blog.html'
3459
3460
    @classmethod
3461
    def get_navi_link(cls, last_soup, next_):
3462
        """Get link to next or previous comic."""
3463
        return last_soup.find('a', class_='prev-item' if next_ else 'next-item')
3464
3465
    @classmethod
3466
    def get_comic_info(cls, soup, link):
@@ 3373-3396 (lines=24) @@
3370
    url = 'https://marketoonist.com/cartoons'
3371
    get_first_comic_link = simulate_first_link
3372
    get_navi_link = get_link_rel_next
3373
    first_url = 'https://marketoonist.com/2002/10/the-8-types-of-brand-managers-2.html'
3374
3375
    @classmethod
3376
    def get_comic_info(cls, soup, link):
3377
        """Get information about a particular comics."""
3378
        imgs = soup.find_all('meta', property='og:image')
3379
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
3380
        day = string_to_date(date_str, "%Y-%m-%d")
3381
        title = soup.find('meta', property='og:title')['content']
3382
        return {
3383
            'img': [i['content'] for i in imgs],
3384
            'day': day.day,
3385
            'month': day.month,
3386
            'year': day.year,
3387
            'title': title,
3388
        }
3389
3390
3391
class ConsoliaComics(GenericNavigableComic):
3392
    """Class to retrieve Consolia comics."""
3393
    name = 'consolia'
3394
    long_name = 'consolia'
3395
    url = 'https://consolia-comic.com'
3396
    get_url_from_link = join_cls_url_to_href
3397
3398
    @classmethod
3399
    def get_first_comic_link(cls):
@@ 3183-3206 (lines=24) @@
3180
        }
3181
3182
3183
class Ubertool(GenericNavigableComic):
3184
    """Class to retrieve Ubertool comics."""
3185
    # Also on https://ubertool.tumblr.com
3186
    # Also on https://tapastic.com/series/ubertool
3187
    name = 'ubertool'
3188
    long_name = 'Ubertool'
3189
    url = 'http://ubertoolcomic.com'
3190
    _categories = ('UBERTOOL', )
3191
    get_first_comic_link = get_a_comicnavbase_comicnavfirst
3192
    get_navi_link = get_a_comicnavbase_comicnavnext
3193
3194
    @classmethod
3195
    def get_comic_info(cls, soup, link):
3196
        """Get information about a particular comics."""
3197
        title = soup.find('h2', class_='post-title').string
3198
        date_str = soup.find('span', class_='post-date').string
3199
        day = string_to_date(date_str, "%B %d, %Y")
3200
        imgs = soup.find('div', id='comic').find_all('img')
3201
        return {
3202
            'img': [i['src'] for i in imgs],
3203
            'title': title,
3204
            'month': day.month,
3205
            'year': day.year,
3206
            'day': day.day,
3207
        }
3208
3209