Code Duplication    Length = 29-31 lines in 2 locations

comics.py 2 locations

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