Code Duplication    Length = 30-31 lines in 2 locations

comics.py 2 locations

@@ 3628-3658 (lines=31) @@
3625
        }
3626
3627
3628
class AtRandomComics(GenericNavigableComic):
3629
    """Class to retrieve At Random Comics."""
3630
    name = 'atrandom'
3631
    long_name = 'At Random Comics'
3632
    url = 'http://www.atrandomcomics.com'
3633
    get_url_from_link = join_cls_url_to_href
3634
    get_first_comic_link = simulate_first_link
3635
    first_url = 'http://www.atrandomcomics.com/at-random-comics-home/2015/5/5/can-of-worms'
3636
3637
    @classmethod
3638
    def get_navi_link(cls, last_soup, next_):
3639
        """Get link to next or previous comic."""
3640
        return last_soup.find('a', id='prevLink' if next_ else 'nextLink')
3641
3642
    @classmethod
3643
    def get_comic_info(cls, soup, link):
3644
        """Get information about a particular comics."""
3645
        title = soup.find('meta', property='og:title')['content']
3646
        desc = soup.find('meta', property='og:description')['content']
3647
        date_str = soup.find('time', itemprop='datePublished')["datetime"]
3648
        day = string_to_date(date_str, "%Y-%m-%d")
3649
        author = soup.find('a', rel='author').string
3650
        imgs = soup.find_all('meta', property='og:image')
3651
        return {
3652
            'title': title,
3653
            'img': [i['content'] for i in imgs],
3654
            'month': day.month,
3655
            'year': day.year,
3656
            'day': day.day,
3657
            'author': author,
3658
            'description': desc,
3659
        }
3660
3661
@@ 1653-1682 (lines=30) @@
1650
    url = 'http://www.somethingofthatilk.com'
1651
1652
1653
class MonkeyUser(GenericNavigableComic):
1654
    """Class to retrieve Monkey User comics."""
1655
    name = 'monkeyuser'
1656
    long_name = 'Monkey User'
1657
    url = 'http://www.monkeyuser.com'
1658
    get_first_comic_link = simulate_first_link
1659
    first_url = 'http://www.monkeyuser.com/2016/project-lifecycle/'
1660
    get_url_from_link = join_cls_url_to_href
1661
1662
    @classmethod
1663
    def get_navi_link(cls, last_soup, next_):
1664
        """Get link to next or previous comic."""
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