Code Duplication    Length = 28-30 lines in 2 locations

comics.py 2 locations

@@ 1438-1467 (lines=30) @@
1435
        }
1436
1437
1438
class Octopuns(GenericNavigableComic):
1439
    """Class to retrieve Octopuns comics."""
1440
    # Also on http://octopuns.tumblr.com
1441
    name = 'octopuns'
1442
    long_name = 'Octopuns'
1443
    url = 'http://www.octopuns.net'
1444
1445
    @classmethod
1446
    def get_first_comic_link(cls):
1447
        """Get link to first comics."""
1448
        return get_soup_at_url(cls.url).find('img', src=re.compile('.*/First.png')).parent
1449
1450
    @classmethod
1451
    def get_navi_link(cls, last_soup, next_):
1452
        link = last_soup.find('img', src=re.compile('.*/Next.png' if next_ else '.*/Back.png')).parent
1453
        return None if link.get('href') is None else link
1454
1455
    @classmethod
1456
    def get_comic_info(cls, soup, link):
1457
        """Get information about a particular comics."""
1458
        title = soup.find('h3', class_='post-title entry-title').string
1459
        date_str = soup.find('h2', class_='date-header').string
1460
        day = string_to_date(date_str, "%A, %B %d, %Y")
1461
        imgs = soup.find_all('link', rel='image_src')
1462
        return {
1463
            'img': [i['href'] for i in imgs],
1464
            'title': title,
1465
            'day': day.day,
1466
            'month': day.month,
1467
            'year': day.year,
1468
        }
1469
1470
@@ 1986-2013 (lines=28) @@
1983
        return reversed(get_soup_at_url(archive_url).find_all('a', href=url_re))
1984
1985
1986
class LoadingComics(GenericNavigableComic):
1987
    """Class to retrieve Loading Artist comics."""
1988
    name = 'loadingartist'
1989
    long_name = 'Loading Artist'
1990
    url = 'http://www.loadingartist.com/latest'
1991
1992
    @classmethod
1993
    def get_first_comic_link(cls):
1994
        """Get link to first comics."""
1995
        return get_soup_at_url(cls.url).find('a', title="First")
1996
1997
    @classmethod
1998
    def get_navi_link(cls, last_soup, next_):
1999
        return last_soup.find('a', title='Next' if next_ else 'Previous')
2000
2001
    @classmethod
2002
    def get_comic_info(cls, soup, link):
2003
        """Get information about a particular comics."""
2004
        title = soup.find('h1').string
2005
        date_str = soup.find('span', class_='date').string.strip()
2006
        day = string_to_date(date_str, "%B %d, %Y")
2007
        imgs = soup.find('div', class_='comic').find_all('img', alt='', title='')
2008
        return {
2009
            'title': title,
2010
            'img': [i['src'] for i in imgs],
2011
            'month': day.month,
2012
            'year': day.year,
2013
            'day': day.day,
2014
        }
2015
2016