Code Duplication    Length = 24-24 lines in 2 locations

comics.py 2 locations

@@ 3191-3214 (lines=24) @@
3188
    @classmethod
3189
    def get_navi_link(cls, last_soup, next_):
3190
        """Get link to next or previous comic."""
3191
        return last_soup.find('a', class_='prev-item' if next_ else 'next-item')
3192
3193
    @classmethod
3194
    def get_comic_info(cls, soup, link):
3195
        """Get information about a particular comics."""
3196
        title = soup.find('meta', property='og:title')['content']
3197
        desc = soup.find('meta', property='og:description')['content']
3198
        date_str = soup.find('time', class_='published')['datetime']
3199
        day = string_to_date(date_str, "%Y-%m-%d")
3200
        author = soup.find('a', rel='author').string
3201
        div_content = (soup.find('div', class_="body entry-content") or
3202
                       soup.find('div', class_="special-content"))
3203
        imgs = div_content.find_all('img')
3204
        imgs = [i for i in imgs if i.get('src') is not None]
3205
        assert all('title' not in i or i['alt'] == i['title'] for i in imgs)
3206
        alt = imgs[0].get('alt', "") if imgs else []
3207
        return {
3208
            'title': title,
3209
            'alt': alt,
3210
            'description': desc,
3211
            'author': author,
3212
            'day': day.day,
3213
            'month': day.month,
3214
            'year': day.year,
3215
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
3216
        }
3217
@@ 3124-3147 (lines=24) @@
3121
3122
    @classmethod
3123
    def get_nav(cls, soup):
3124
        """Get the navigation elements from soup object."""
3125
        cnav = soup.find_all(class_='cnav')
3126
        nav1, nav2 = cnav[:5], cnav[5:]
3127
        assert nav1 == nav2
3128
        # begin, prev, archive, next_, end = nav1
3129
        return [None if i.get('href') is None else i for i in nav1]
3130
3131
    @classmethod
3132
    def get_first_comic_link(cls):
3133
        """Get link to first comics."""
3134
        return cls.get_nav(get_soup_at_url(cls.url))[0]
3135
3136
    @classmethod
3137
    def get_navi_link(cls, last_soup, next_):
3138
        """Get link to next or previous comic."""
3139
        return cls.get_nav(last_soup)[3 if next_ else 1]
3140
3141
    @classmethod
3142
    def get_comic_info(cls, soup, link):
3143
        """Get information about a particular comics."""
3144
        title = link['title']
3145
        imgs = soup.find_all('img', id='comicimg')
3146
        return {
3147
            'title': title,
3148
            'img': [i['src'] for i in imgs],
3149
        }
3150