Code Duplication    Length = 29-31 lines in 2 locations

comics.py 2 locations

@@ 1432-1462 (lines=31) @@
1429
        }
1430
1431
1432
class Octopuns(GenericNavigableComic):
1433
    """Class to retrieve Octopuns comics."""
1434
    # Also on http://octopuns.tumblr.com
1435
    name = 'octopuns'
1436
    long_name = 'Octopuns'
1437
    url = 'http://www.octopuns.net'
1438
1439
    @classmethod
1440
    def get_first_comic_link(cls):
1441
        """Get link to first comics."""
1442
        return get_soup_at_url(cls.url).find('img', src=re.compile('.*/First.png')).parent
1443
1444
    @classmethod
1445
    def get_navi_link(cls, last_soup, next_):
1446
        """Get link to next or previous comic."""
1447
        link = last_soup.find('img', src=re.compile('.*/Next.png' if next_ else '.*/Back.png')).parent
1448
        return None if link.get('href') is None else link
1449
1450
    @classmethod
1451
    def get_comic_info(cls, soup, link):
1452
        """Get information about a particular comics."""
1453
        title = soup.find('h3', class_='post-title entry-title').string
1454
        date_str = soup.find('h2', class_='date-header').string
1455
        day = string_to_date(date_str, "%A, %B %d, %Y")
1456
        imgs = soup.find_all('link', rel='image_src')
1457
        return {
1458
            'img': [i['href'] for i in imgs],
1459
            'title': title,
1460
            'day': day.day,
1461
            'month': day.month,
1462
            'year': day.year,
1463
        }
1464
1465
@@ 1986-2014 (lines=29) @@
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
        """Get link to next or previous comic."""
2000
        return last_soup.find('a', title='Next' if next_ else 'Previous')
2001
2002
    @classmethod
2003
    def get_comic_info(cls, soup, link):
2004
        """Get information about a particular comics."""
2005
        title = soup.find('h1').string
2006
        date_str = soup.find('span', class_='date').string.strip()
2007
        day = string_to_date(date_str, "%B %d, %Y")
2008
        imgs = soup.find('div', class_='comic').find_all('img', alt='', title='')
2009
        return {
2010
            'title': title,
2011
            'img': [i['src'] for i in imgs],
2012
            'month': day.month,
2013
            'year': day.year,
2014
            'day': day.day,
2015
        }
2016
2017