Code Duplication    Length = 24-24 lines in 3 locations

comics.py 3 locations

@@ 3440-3463 (lines=24) @@
3437
    def get_comic_info(cls, soup, link):
3438
        """Get information about a particular comics."""
3439
        title = soup.find('meta', property='og:title')['content']
3440
        desc = soup.find('meta', property='og:description')['content']
3441
        date_str = soup.find('time', class_='published')['datetime']
3442
        day = string_to_date(date_str, "%Y-%m-%d")
3443
        author = soup.find('a', rel='author').string
3444
        div_content = (soup.find('div', class_="body entry-content") or
3445
                       soup.find('div', class_="special-content"))
3446
        imgs = div_content.find_all('img')
3447
        imgs = [i for i in imgs if i.get('src') is not None]
3448
        assert all('title' not in i or i['alt'] == i['title'] for i in imgs)
3449
        alt = imgs[0].get('alt', "") if imgs else []
3450
        return {
3451
            'title': title,
3452
            'alt': alt,
3453
            'description': desc,
3454
            'author': author,
3455
            'day': day.day,
3456
            'month': day.month,
3457
            'year': day.year,
3458
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
3459
        }
3460
3461
3462
class GloryOwlComix(GenericNavigableComic):
3463
    """Class to retrieve Glory Owl comics."""
3464
    name = 'gloryowl'
3465
    long_name = 'Glory Owl'
3466
    url = 'http://gloryowlcomix.blogspot.fr'
@@ 3373-3396 (lines=24) @@
3370
    def get_first_comic_link(cls):
3371
        """Get link to first comics."""
3372
        return get_soup_at_url(cls.url).find('a', class_='first')
3373
3374
    @classmethod
3375
    def get_navi_link(cls, last_soup, next_):
3376
        """Get link to next or previous comic."""
3377
        return last_soup.find('a', class_='next' if next_ else 'prev')
3378
3379
    @classmethod
3380
    def get_comic_info(cls, soup, link):
3381
        """Get information about a particular comics."""
3382
        title = soup.find('meta', property='og:title')['content']
3383
        date_str = soup.find('time')["datetime"]
3384
        day = string_to_date(date_str, "%Y-%m-%d")
3385
        imgs = soup.find_all('meta', property='og:image')
3386
        return {
3387
            'title': title,
3388
            'img': [i['content'] for i in imgs],
3389
            'day': day.day,
3390
            'month': day.month,
3391
            'year': day.year,
3392
        }
3393
3394
3395
class TuMourrasMoinsBete(GenericNavigableComic):
3396
    """Class to retrieve Tu Mourras Moins Bete comics."""
3397
    name = 'mourrasmoinsbete'
3398
    long_name = 'Tu Mourras Moins Bete'
3399
    url = 'http://tumourrasmoinsbete.blogspot.fr'
@@ 3183-3206 (lines=24) @@
3180
3181
class EarthExplodes(GenericNavigableComic):
3182
    """Class to retrieve The Earth Explodes comics."""
3183
    name = 'earthexplodes'
3184
    long_name = 'The Earth Explodes'
3185
    url = 'http://www.earthexplodes.com'
3186
    get_url_from_link = join_cls_url_to_href
3187
    get_first_comic_link = simulate_first_link
3188
    first_url = 'http://www.earthexplodes.com/comics/000/'
3189
3190
    @classmethod
3191
    def get_navi_link(cls, last_soup, next_):
3192
        """Get link to next or previous comic."""
3193
        return last_soup.find('a', id='next' if next_ else 'prev')
3194
3195
    @classmethod
3196
    def get_comic_info(cls, soup, link):
3197
        """Get information about a particular comics."""
3198
        title = soup.find('title').string
3199
        imgs = soup.find('div', id='image').find_all('img')
3200
        alt = imgs[0].get('title', '')
3201
        return {
3202
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
3203
            'title': title,
3204
            'alt': alt,
3205
        }
3206
3207
3208
class PomComics(GenericNavigableComic):
3209
    """Class to retrieve PomComics."""