Code Duplication    Length = 29-31 lines in 2 locations

comics.py 2 locations

@@ 1433-1463 (lines=31) @@
1430
        """Get link to next or previous comic."""
1431
        img = last_soup.find('img', src='images/next_button.gif' if next_ else 'images/prev_button.gif')
1432
        return None if img is None else img.parent
1433
1434
    @classmethod
1435
    def get_comic_info(cls, soup, link):
1436
        """Get information about a particular comics."""
1437
        date_str = soup.find('font', face='Arial,Helvetica,Geneva,Swiss,SunSans-Regular', color='white').string.strip()
1438
        try:
1439
            day = string_to_date(date_str, '%m/%d/%Y')
1440
        except ValueError:
1441
            print("Invalid date %s" % date_str)
1442
            day = date.today()
1443
        title = soup.find('meta', attrs={'name': 'twitter:title'})['content']
1444
        return {
1445
            'year': day.year,
1446
            'month': day.month,
1447
            'day': day.day,
1448
            'img': [soup.find('img', id='comic')['src']],
1449
            'title': title,
1450
        }
1451
1452
1453
class Octopuns(GenericEmptyComic, GenericNavigableComic):
1454
    """Class to retrieve Octopuns comics."""
1455
    # Also on http://octopuns.tumblr.com
1456
    name = 'octopuns'
1457
    long_name = 'Octopuns'
1458
    url = 'http://www.octopuns.net'
1459
1460
    @classmethod
1461
    def get_first_comic_link(cls):
1462
        """Get link to first comics."""
1463
        return get_soup_at_url(cls.url).find('img', src=re.compile('.*/First.png')).parent
1464
1465
    @classmethod
1466
    def get_navi_link(cls, last_soup, next_):
@@ 1987-2015 (lines=29) @@
1984
1985
class PoorlyDrawnLines(GenericListableComic):
1986
    """Class to retrieve Poorly Drawn Lines comics."""
1987
    # Also on http://pdlcomics.tumblr.com
1988
    name = 'poorlydrawn'
1989
    long_name = 'Poorly Drawn Lines'
1990
    url = 'http://poorlydrawnlines.com'
1991
    _categories = ('POORLYDRAWN', )
1992
    get_url_from_archive_element = get_href
1993
1994
    @classmethod
1995
    def get_comic_info(cls, soup, link):
1996
        """Get information about a particular comics."""
1997
        imgs = soup.find('div', class_='post').find_all('img')
1998
        assert len(imgs) <= 1
1999
        return {
2000
            'img': [i['src'] for i in imgs],
2001
            'title': imgs[0].get('title', "") if imgs else "",
2002
        }
2003
2004
    @classmethod
2005
    def get_archive_elements(cls):
2006
        archive_url = urljoin_wrapper(cls.url, 'archive')
2007
        url_re = re.compile('^%s/comic/.' % cls.url)
2008
        return reversed(get_soup_at_url(archive_url).find_all('a', href=url_re))
2009
2010
2011
class LoadingComics(GenericNavigableComic):
2012
    """Class to retrieve Loading Artist comics."""
2013
    name = 'loadingartist'
2014
    long_name = 'Loading Artist'
2015
    url = 'http://www.loadingartist.com/latest'
2016
2017
    @classmethod
2018
    def get_first_comic_link(cls):