Code Duplication    Length = 13-20 lines in 5 locations

comics.py 5 locations

@@ 1852-1871 (lines=20) @@
1849
    get_first_comic_link = simulate_first_link
1850
    first_url = 'http://respawncomic.com/comic/c0001/'
1851
1852
    @classmethod
1853
    def get_comic_info(cls, soup, link):
1854
        """Get information about a particular comics."""
1855
        title = soup.find('meta', property='og:title')['content']
1856
        author = soup.find('meta', attrs={'name': 'shareaholic:article_author_name'})['content']
1857
        date_str = soup.find('meta', attrs={'name': 'shareaholic:article_published_time'})['content']
1858
        date_str = date_str[:10]
1859
        day = string_to_date(date_str, "%Y-%m-%d")
1860
        imgs = soup.find_all('meta', property='og:image')
1861
        skip_imgs = {
1862
            'http://respawncomic.com/wp-content/uploads/2016/03/site/HAROLD2.png',
1863
            'http://respawncomic.com/wp-content/uploads/2016/03/site/DEVA.png'
1864
        }
1865
        return {
1866
            'title': title,
1867
            'author': author,
1868
            'day': day.day,
1869
            'month': day.month,
1870
            'year': day.year,
1871
            'img': [i['content'] for i in imgs if i['content'] not in skip_imgs],
1872
        }
1873
1874
@@ 574-589 (lines=16) @@
571
        li = last_soup.find('li', class_='prev' if next_ else 'next')
572
        return li.find('a') if li else None
573
574
    @classmethod
575
    def get_comic_info(cls, soup, link):
576
        """Get information about a particular comics."""
577
        short_url = soup.find('link', rel='shortlink')['href']
578
        title = soup.find('meta', attrs={'name': 'twitter:title'})['content']
579
        imgs = soup.find_all('meta', property='og:image')
580
        date_str = soup.find('span', property='dc:date')['content']
581
        date_str = date_str[:10]
582
        day = string_to_date(date_str, "%Y-%m-%d")
583
        return {
584
            'short_url': short_url,
585
            'title': title,
586
            'img': [i['content'] for i in imgs],
587
            'day': day.day,
588
            'month': day.month,
589
            'year': day.year,
590
        }
591
592
@@ 3147-3159 (lines=13) @@
3144
        """Get link to first comics."""
3145
        return get_soup_at_url(cls.url).find('a', class_='webcomic-link webcomic1-link first-webcomic-link first-webcomic1-link')
3146
3147
    @classmethod
3148
    def get_comic_info(cls, soup, link):
3149
        """Get information about a particular comics."""
3150
        title = soup.find('meta', property='og:title')['content']
3151
        imgs = soup.find('div', class_='webcomic-image').find_all('img')
3152
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
3153
        day = string_to_date(date_str, "%Y-%m-%d")
3154
        return {
3155
            'title': title,
3156
            'day': day.day,
3157
            'month': day.month,
3158
            'year': day.year,
3159
            'img': [i['src'] for i in imgs],
3160
        }
3161
3162
@@ 5051-5065 (lines=15) @@
5048
        gocomics = 'http://www.gocomics.com'
5049
        return urljoin_wrapper(gocomics, link['href'])
5050
5051
    @classmethod
5052
    def get_comic_info(cls, soup, link):
5053
        """Get information about a particular comics."""
5054
        date_str = soup.find('meta', property='article:published_time')['content']
5055
        day = string_to_date(date_str, "%Y-%m-%d")
5056
        imgs = soup.find('picture', class_='img-fluid item-comic-image').find_all('img')
5057
        author = soup.find('meta', property='article:author')['content']
5058
        tags = soup.find('meta', property='article:tag')['content']
5059
        return {
5060
            'day': day.day,
5061
            'month': day.month,
5062
            'year': day.year,
5063
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
5064
            'author': author,
5065
            'tags': tags,
5066
        }
5067
5068
@@ 1668-1682 (lines=15) @@
1665
        div = last_soup.find('div', title='next' if next_ else 'previous')
1666
        return None if div is None else div.find('a')
1667
1668
    @classmethod
1669
    def get_comic_info(cls, soup, link):
1670
        """Get information about a particular comics."""
1671
        title = soup.find('meta', property='og:title')['content']
1672
        desc = soup.find('meta', property='og:description')['content']
1673
        imgs = soup.find_all('meta', property='og:image')
1674
        date_str = soup.find('span', class_='post-date').find('time').string
1675
        day = string_to_date(date_str, "%d %b %Y")
1676
        return {
1677
            'month': day.month,
1678
            'year': day.year,
1679
            'day': day.day,
1680
            'img': [i['content'] for i in imgs],
1681
            'title': title,
1682
            'description': desc,
1683
        }
1684
1685