Code Duplication    Length = 13-20 lines in 5 locations

comics.py 5 locations

@@ 1809-1828 (lines=20) @@
1806
1807
    @classmethod
1808
    def get_comic_info(cls, soup, link):
1809
        """Get information about a particular comics."""
1810
        title = soup.find('meta', property='og:title')['content']
1811
        author = soup.find('meta', attrs={'name': 'shareaholic:article_author_name'})['content']
1812
        date_str = soup.find('meta', attrs={'name': 'shareaholic:article_published_time'})['content']
1813
        date_str = date_str[:10]
1814
        day = string_to_date(date_str, "%Y-%m-%d")
1815
        imgs = soup.find_all('meta', property='og:image')
1816
        skip_imgs = {
1817
            'http://respawncomic.com/wp-content/uploads/2016/03/site/HAROLD2.png',
1818
            'http://respawncomic.com/wp-content/uploads/2016/03/site/DEVA.png'
1819
        }
1820
        return {
1821
            'title': title,
1822
            'author': author,
1823
            'day': day.day,
1824
            'month': day.month,
1825
            'year': day.year,
1826
            'img': [i['content'] for i in imgs if i['content'] not in skip_imgs],
1827
        }
1828
1829
1830
class SafelyEndangered(GenericNavigableComic):
1831
    """Class to retrieve Safely Endangered comics."""
@@ 526-541 (lines=16) @@
523
        li = last_soup.find('li', class_='prev' if next_ else 'next')
524
        return li.find('a') if li else None
525
526
    @classmethod
527
    def get_comic_info(cls, soup, link):
528
        """Get information about a particular comics."""
529
        short_url = soup.find('link', rel='shortlink')['href']
530
        title = soup.find('meta', attrs={'name': 'twitter:title'})['content']
531
        imgs = soup.find_all('meta', property='og:image')
532
        date_str = soup.find('span', property='dc:date')['content']
533
        date_str = date_str[:10]
534
        day = string_to_date(date_str, "%Y-%m-%d")
535
        return {
536
            'short_url': short_url,
537
            'title': title,
538
            'img': [i['content'] for i in imgs],
539
            'day': day.day,
540
            'month': day.month,
541
            'year': day.year,
542
        }
543
544
@@ 4528-4542 (lines=15) @@
4525
4526
    @classmethod
4527
    def get_comic_info(cls, soup, link):
4528
        """Get information about a particular comics."""
4529
        date_str = soup.find('meta', property='article:published_time')['content']
4530
        day = string_to_date(date_str, "%Y-%m-%d")
4531
        imgs = soup.find('picture', class_='img-fluid item-comic-image').find_all('img')
4532
        author = soup.find('meta', property='article:author')['content']
4533
        tags = soup.find('meta', property='article:tag')['content']
4534
        return {
4535
            'day': day.day,
4536
            'month': day.month,
4537
            'year': day.year,
4538
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
4539
            'author': author,
4540
            'tags': tags,
4541
        }
4542
4543
4544
class PearlsBeforeSwine(GenericGoComic):
4545
    """Class to retrieve Pearls Before Swine comics."""
@@ 2984-2998 (lines=15) @@
2981
2982
    @classmethod
2983
    def get_comic_info(cls, soup, link):
2984
        """Get information about a particular comics."""
2985
        date_str = soup.find('time', class_='published')['datetime']
2986
        day = string_to_date(date_str, "%Y-%m-%d")
2987
        author = soup.find('span', class_='blog-author').find('a').string
2988
        title = soup.find('meta', property='og:title')['content']
2989
        imgs = soup.find_all('meta', itemprop='image')
2990
        return {
2991
            'img': [i['content'] for i in imgs],
2992
            'title': title,
2993
            'author': author,
2994
            'day': day.day,
2995
            'month': day.month,
2996
            'year': day.year,
2997
        }
2998
2999
3000
class LittleLifeLines(GenericNavigableComic):
3001
    """Class to retrieve Little Life Lines comics."""
@@ 3052-3064 (lines=13) @@
3049
3050
    @classmethod
3051
    def get_comic_info(cls, soup, link):
3052
        """Get information about a particular comics."""
3053
        title = soup.find('meta', property='og:title')['content']
3054
        imgs = soup.find('div', class_='webcomic-image').find_all('img')
3055
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
3056
        day = string_to_date(date_str, "%Y-%m-%d")
3057
        return {
3058
            'title': title,
3059
            'day': day.day,
3060
            'month': day.month,
3061
            'year': day.year,
3062
            'img': [i['src'] for i in imgs],
3063
        }
3064
3065
3066
class EverythingsStupid(GenericWordPressInkblot):
3067
    """Class to retrieve Everything's stupid Comics."""