Code Duplication    Length = 35-36 lines in 2 locations

comics.py 2 locations

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