Code Duplication    Length = 24-24 lines in 3 locations

comics.py 3 locations

@@ 3419-3442 (lines=24) @@
3416
        """Get information about a particular comics."""
3417
        title = soup.find('meta', property='og:title')['content']
3418
        desc = soup.find('meta', property='og:description')['content']
3419
        date_str = soup.find('time', class_='published')['datetime']
3420
        day = string_to_date(date_str, "%Y-%m-%d")
3421
        author = soup.find('a', rel='author').string
3422
        div_content = (soup.find('div', class_="body entry-content") or
3423
                       soup.find('div', class_="special-content"))
3424
        imgs = div_content.find_all('img')
3425
        imgs = [i for i in imgs if i.get('src') is not None]
3426
        assert all('title' not in i or i['alt'] == i['title'] for i in imgs)
3427
        alt = imgs[0].get('alt', "") if imgs else []
3428
        return {
3429
            'title': title,
3430
            'alt': alt,
3431
            'description': desc,
3432
            'author': author,
3433
            'day': day.day,
3434
            'month': day.month,
3435
            'year': day.year,
3436
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
3437
        }
3438
3439
3440
class GloryOwlComix(GenericNavigableComic):
3441
    """Class to retrieve Glory Owl comics."""
3442
    name = 'gloryowl'
3443
    long_name = 'Glory Owl'
3444
    url = 'http://gloryowlcomix.blogspot.fr'
3445
    _categories = ('NSFW', 'FRANCAIS')
@@ 3352-3375 (lines=24) @@
3349
        """Get link to first comics."""
3350
        return get_soup_at_url(cls.url).find('a', class_='first')
3351
3352
    @classmethod
3353
    def get_navi_link(cls, last_soup, next_):
3354
        """Get link to next or previous comic."""
3355
        return last_soup.find('a', class_='next' if next_ else 'prev')
3356
3357
    @classmethod
3358
    def get_comic_info(cls, soup, link):
3359
        """Get information about a particular comics."""
3360
        title = soup.find('meta', property='og:title')['content']
3361
        date_str = soup.find('time')["datetime"]
3362
        day = string_to_date(date_str, "%Y-%m-%d")
3363
        imgs = soup.find_all('meta', property='og:image')
3364
        return {
3365
            'title': title,
3366
            'img': [i['content'] for i in imgs],
3367
            'day': day.day,
3368
            'month': day.month,
3369
            'year': day.year,
3370
        }
3371
3372
3373
class TuMourrasMoinsBete(GenericNavigableComic):
3374
    """Class to retrieve Tu Mourras Moins Bete comics."""
3375
    name = 'mourrasmoinsbete'
3376
    long_name = 'Tu Mourras Moins Bete'
3377
    url = 'http://tumourrasmoinsbete.blogspot.fr'
3378
    _categories = ('FRANCAIS', )
@@ 3162-3185 (lines=24) @@
3159
    # Also on https://tapastic.com/series/ubertool
3160
    name = 'ubertool'
3161
    long_name = 'Ubertool'
3162
    url = 'http://ubertoolcomic.com'
3163
    _categories = ('UBERTOOL', )
3164
    get_first_comic_link = get_a_comicnavbase_comicnavfirst
3165
    get_navi_link = get_a_comicnavbase_comicnavnext
3166
3167
    @classmethod
3168
    def get_comic_info(cls, soup, link):
3169
        """Get information about a particular comics."""
3170
        title = soup.find('h2', class_='post-title').string
3171
        date_str = soup.find('span', class_='post-date').string
3172
        day = string_to_date(date_str, "%B %d, %Y")
3173
        imgs = soup.find('div', id='comic').find_all('img')
3174
        return {
3175
            'img': [i['src'] for i in imgs],
3176
            'title': title,
3177
            'month': day.month,
3178
            'year': day.year,
3179
            'day': day.day,
3180
        }
3181
3182
3183
class EarthExplodes(GenericNavigableComic):
3184
    """Class to retrieve The Earth Explodes comics."""
3185
    name = 'earthexplodes'
3186
    long_name = 'The Earth Explodes'
3187
    url = 'http://www.earthexplodes.com'
3188
    get_url_from_link = join_cls_url_to_href