Code Duplication    Length = 29-31 lines in 2 locations

comics.py 2 locations

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