Code Duplication    Length = 29-30 lines in 2 locations

comics.py 2 locations

@@ 3320-3349 (lines=30) @@
3317
    url = 'https://consolia-comic.com'
3318
    get_url_from_link = join_cls_url_to_href
3319
3320
    @classmethod
3321
    def get_first_comic_link(cls):
3322
        """Get link to first comics."""
3323
        return get_soup_at_url(cls.url).find('a', class_='first')
3324
3325
    @classmethod
3326
    def get_navi_link(cls, last_soup, next_):
3327
        """Get link to next or previous comic."""
3328
        return last_soup.find('a', class_='next' if next_ else 'prev')
3329
3330
    @classmethod
3331
    def get_comic_info(cls, soup, link):
3332
        """Get information about a particular comics."""
3333
        title = soup.find('meta', property='og:title')['content']
3334
        date_str = soup.find('time')["datetime"]
3335
        day = string_to_date(date_str, "%Y-%m-%d")
3336
        imgs = soup.find_all('meta', property='og:image')
3337
        return {
3338
            'title': title,
3339
            'img': [i['content'] for i in imgs],
3340
            'day': day.day,
3341
            'month': day.month,
3342
            'year': day.year,
3343
        }
3344
3345
3346
class TuMourrasMoinsBete(GenericNavigableComic):
3347
    """Class to retrieve Tu Mourras Moins Bete comics."""
3348
    name = 'mourrasmoinsbete'
3349
    long_name = 'Tu Mourras Moins Bete'
3350
    url = 'http://tumourrasmoinsbete.blogspot.fr'
3351
    _categories = ('FRANCAIS', )
3352
    get_first_comic_link = simulate_first_link
@@ 3190-3218 (lines=29) @@
3187
    url = 'http://www.pomcomic.com'
3188
    get_url_from_link = join_cls_url_to_href
3189
3190
    @classmethod
3191
    def get_first_comic_link(cls):
3192
        """Get link to first comics."""
3193
        return get_soup_at_url(cls.url).find('a', class_='btn_first')
3194
3195
    @classmethod
3196
    def get_navi_link(cls, last_soup, next_):
3197
        """Get link to next or previous comic."""
3198
        return last_soup.find('a', class_='btn_next' if next_ else 'btn_prev')
3199
3200
    @classmethod
3201
    def get_comic_info(cls, soup, link):
3202
        """Get information about a particular comics."""
3203
        title = soup.find('h1', id="comic-name").string
3204
        desc = soup.find('meta', property='og:description')['content']
3205
        tags = soup.find('meta', attrs={'name': 'keywords'})['content']
3206
        imgs = soup.find('div', class_='comic').find_all('img')
3207
        return {
3208
            'title': title,
3209
            'desc': desc,
3210
            'tags': tags,
3211
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
3212
        }
3213
3214
3215
class CubeDrone(GenericEmptyComic, GenericNavigableComic):
3216
    """Class to retrieve Cube Drone comics."""
3217
    name = 'cubedrone'
3218
    long_name = 'Cube Drone'
3219
    url = 'http://cube-drone.com/comics'
3220
    get_url_from_link = join_cls_url_to_href
3221