Code Duplication    Length = 19-21 lines in 2 locations

comics.py 2 locations

@@ 3071-3091 (lines=21) @@
3068
        li = last_soup.find('li', class_='prev' if next_ else 'next')
3069
        return li.find('a') if li else None
3070
3071
    @classmethod
3072
    def get_comic_info(cls, soup, link):
3073
        """Get information about a particular comics."""
3074
        title = soup.find('meta', property='og:title')['content']
3075
        desc = soup.find('meta', property='og:description')['content']
3076
        date_str = soup.find('time', class_='published')['datetime']
3077
        day = string_to_date(date_str, "%Y-%m-%d")
3078
        author = soup.find('a', rel='author').string
3079
        div_content = soup.find('div', class_="body entry-content")
3080
        imgs = div_content.find_all('img')
3081
        imgs = [i for i in imgs if i.get('src') is not None]
3082
        alt = imgs[0]['alt']
3083
        return {
3084
            'title': title,
3085
            'alt': alt,
3086
            'description': desc,
3087
            'author': author,
3088
            'day': day.day,
3089
            'month': day.month,
3090
            'year': day.year,
3091
            'img': [i['src'] for i in imgs],
3092
        }
3093
3094
@@ 829-847 (lines=19) @@
826
        link = last_soup.find('div', class_='nav-comic nav-right' if next_ else 'nav-comic nav-left')
827
        return link.find('a') if link else None
828
829
    @classmethod
830
    def get_comic_info(cls, soup, link):
831
        """Get information about a particular comics."""
832
        title = soup.find('meta', property='og:title')['content']
833
        imgs = soup.find_all('meta', property='og:image')
834
        desc = soup.find('meta', property='og:description')['content']
835
        date_str = soup.find('meta', property='article:publish_date')['content']
836
        day = string_to_date(date_str, "%B %d, %Y")
837
        author = soup.find('meta', property='article:author')['content']
838
        tags = soup.find('meta', property='article:tag')['content']
839
        return {
840
            'title': title,
841
            'description': desc,
842
            'img': [i['content'] for i in imgs],
843
            'author': author,
844
            'tags': tags,
845
            'day': day.day,
846
            'month': day.month,
847
            'year': day.year
848
        }
849
850