Code Duplication    Length = 29-31 lines in 2 locations

comics.py 2 locations

@@ 1452-1482 (lines=31) @@
1449
        }
1450
1451
1452
class Octopuns(GenericEmptyComic, GenericNavigableComic):
1453
    """Class to retrieve Octopuns comics."""
1454
    # Also on http://octopuns.tumblr.com
1455
    name = 'octopuns'
1456
    long_name = 'Octopuns'
1457
    url = 'http://www.octopuns.net'
1458
1459
    @classmethod
1460
    def get_first_comic_link(cls):
1461
        """Get link to first comics."""
1462
        return get_soup_at_url(cls.url).find('img', src=re.compile('.*/First.png')).parent
1463
1464
    @classmethod
1465
    def get_navi_link(cls, last_soup, next_):
1466
        """Get link to next or previous comic."""
1467
        link = last_soup.find('img', src=re.compile('.*/Next.png' if next_ else '.*/Back.png')).parent
1468
        return None if link.get('href') is None else link
1469
1470
    @classmethod
1471
    def get_comic_info(cls, soup, link):
1472
        """Get information about a particular comics."""
1473
        title = soup.find('h3', class_='post-title entry-title').string
1474
        date_str = soup.find('h2', class_='date-header').string
1475
        day = string_to_date(date_str, "%A, %B %d, %Y")
1476
        imgs = soup.find_all('link', rel='image_src')
1477
        return {
1478
            'img': [i['href'] for i in imgs],
1479
            'title': title,
1480
            'day': day.day,
1481
            'month': day.month,
1482
            'year': day.year,
1483
        }
1484
1485
@@ 2032-2060 (lines=29) @@
2029
        return reversed(get_soup_at_url(archive_url).find_all('a', href=url_re))
2030
2031
2032
class LoadingComics(GenericNavigableComic):
2033
    """Class to retrieve Loading Artist comics."""
2034
    name = 'loadingartist'
2035
    long_name = 'Loading Artist'
2036
    url = 'http://www.loadingartist.com/latest'
2037
2038
    @classmethod
2039
    def get_first_comic_link(cls):
2040
        """Get link to first comics."""
2041
        return get_soup_at_url(cls.url).find('a', title="First")
2042
2043
    @classmethod
2044
    def get_navi_link(cls, last_soup, next_):
2045
        """Get link to next or previous comic."""
2046
        return last_soup.find('a', title='Next' if next_ else 'Previous')
2047
2048
    @classmethod
2049
    def get_comic_info(cls, soup, link):
2050
        """Get information about a particular comics."""
2051
        title = soup.find('h1').string
2052
        date_str = soup.find('span', class_='date').string.strip()
2053
        day = string_to_date(date_str, "%B %d, %Y")
2054
        imgs = soup.find('div', class_='comic').find_all('img', alt='', title='')
2055
        return {
2056
            'title': title,
2057
            'img': [i['src'] for i in imgs],
2058
            'month': day.month,
2059
            'year': day.year,
2060
            'day': day.day,
2061
        }
2062
2063