Code Duplication    Length = 28-30 lines in 2 locations

comics.py 2 locations

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