Code Duplication    Length = 35-36 lines in 2 locations

comics.py 2 locations

@@ 4241-4276 (lines=36) @@
4238
    link_re = re.compile('^/comics/classic/([0-9]+)$')
4239
4240
4241
class GenericGoComic(GenericNavigableComic):
4242
    """Generic class to handle the logic common to comics from gocomics.com."""
4243
    _categories = ('GOCOMIC', )
4244
4245
    @classmethod
4246
    def get_first_comic_link(cls):
4247
        """Get link to first comics."""
4248
        return get_soup_at_url(cls.url).find('a', class_='fa btn btn-outline-default btn-circle fa-backward sm ')
4249
4250
    @classmethod
4251
    def get_navi_link(cls, last_soup, next_):
4252
        """Get link to next or previous comic."""
4253
        PREV = 'fa btn btn-outline-default btn-circle fa-caret-left sm '
4254
        NEXT = 'fa btn btn-outline-default btn-circle fa-caret-right sm '
4255
        return last_soup.find('a', class_=NEXT if next_ else PREV)
4256
4257
    @classmethod
4258
    def get_url_from_link(cls, link):
4259
        gocomics = 'http://www.gocomics.com'
4260
        return urljoin_wrapper(gocomics, link['href'])
4261
4262
    @classmethod
4263
    def get_comic_info(cls, soup, link):
4264
        """Get information about a particular comics."""
4265
        date_str = soup.find('meta', property='article:published_time')['content']
4266
        day = string_to_date(date_str, "%Y-%m-%d")
4267
        imgs = soup.find('picture', class_='img-fluid item-comic-image').find_all('img')
4268
        author = soup.find('meta', property='article:author')['content']
4269
        tags = soup.find('meta', property='article:tag')['content']
4270
        return {
4271
            'day': day.day,
4272
            'month': day.month,
4273
            'year': day.year,
4274
            'img': [i['src'] for i in imgs],
4275
            'author': author,
4276
            'tags': tags,
4277
        }
4278
4279
@@ 3215-3249 (lines=35) @@
3212
        }
3213
3214
3215
class ConsoliaComics(GenericNavigableComic):
3216
    """Class to retrieve Consolia comics."""
3217
    name = 'consolia'
3218
    long_name = 'consolia'
3219
    url = 'https://consolia-comic.com'
3220
    get_url_from_link = join_cls_url_to_href
3221
3222
    @classmethod
3223
    def get_first_comic_link(cls):
3224
        """Get link to first comics."""
3225
        return get_soup_at_url(cls.url).find('span', class_='first').find('a')
3226
3227
    @classmethod
3228
    def get_navi_link(cls, last_soup, next_):
3229
        """Get link to next or previous comic."""
3230
        return last_soup.find('span', class_='next' if next_ else 'prev').find('a')
3231
3232
    @classmethod
3233
    def get_comic_info(cls, soup, link):
3234
        """Get information about a particular comics."""
3235
        title = soup.find('meta', property='og:title')['content']
3236
        date_str = soup.find('time')["datetime"]
3237
        day = string_to_date(date_str, "%Y-%m-%d")
3238
        imgs = soup.find('div', id='comic').find_all('img')
3239
        alt = imgs[0]['title']
3240
        # article = soup.find('div', id='blag')
3241
        # text = article.encode_contents()
3242
        return {
3243
            'title': title,
3244
            'alt': alt,
3245
            'img': [i['src'] for i in imgs],
3246
            # 'text': text,
3247
            'day': day.day,
3248
            'month': day.month,
3249
            'year': day.year,
3250
        }
3251
3252