Code Duplication    Length = 28-30 lines in 2 locations

comics.py 2 locations

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