Code Duplication    Length = 29-31 lines in 2 locations

comics.py 2 locations

@@ 1485-1515 (lines=31) @@
1482
            'title': title,
1483
        }
1484
1485
1486
class Octopuns(GenericEmptyComic, GenericNavigableComic):
1487
    """Class to retrieve Octopuns comics."""
1488
    # Also on http://octopuns.tumblr.com
1489
    name = 'octopuns'
1490
    long_name = 'Octopuns'
1491
    url = 'http://www.octopuns.net'
1492
1493
    @classmethod
1494
    def get_first_comic_link(cls):
1495
        """Get link to first comics."""
1496
        return get_soup_at_url(cls.url).find('img', src=re.compile('.*/First.png')).parent
1497
1498
    @classmethod
1499
    def get_navi_link(cls, last_soup, next_):
1500
        """Get link to next or previous comic."""
1501
        link = last_soup.find('img', src=re.compile('.*/Next.png' if next_ else '.*/Back.png')).parent
1502
        return None if link.get('href') is None else link
1503
1504
    @classmethod
1505
    def get_comic_info(cls, soup, link):
1506
        """Get information about a particular comics."""
1507
        title = soup.find('h3', class_='post-title entry-title').string
1508
        date_str = soup.find('h2', class_='date-header').string
1509
        day = string_to_date(date_str, "%A, %B %d, %Y")
1510
        imgs = soup.find_all('link', rel='image_src')
1511
        return {
1512
            'img': [i['href'] for i in imgs],
1513
            'title': title,
1514
            'day': day.day,
1515
            'month': day.month,
1516
            'year': day.year,
1517
        }
1518
@@ 2065-2093 (lines=29) @@
2062
        url_re = re.compile('^%s/comic/.' % cls.url)
2063
        return reversed(get_soup_at_url(archive_url).find_all('a', href=url_re))
2064
2065
2066
class LoadingComics(GenericNavigableComic):
2067
    """Class to retrieve Loading Artist comics."""
2068
    name = 'loadingartist'
2069
    long_name = 'Loading Artist'
2070
    url = 'http://www.loadingartist.com/latest'
2071
2072
    @classmethod
2073
    def get_first_comic_link(cls):
2074
        """Get link to first comics."""
2075
        return get_soup_at_url(cls.url).find('a', title="First")
2076
2077
    @classmethod
2078
    def get_navi_link(cls, last_soup, next_):
2079
        """Get link to next or previous comic."""
2080
        return last_soup.find('a', title='Next' if next_ else 'Previous')
2081
2082
    @classmethod
2083
    def get_comic_info(cls, soup, link):
2084
        """Get information about a particular comics."""
2085
        title = soup.find('h1').string
2086
        date_str = soup.find('span', class_='date').string.strip()
2087
        day = string_to_date(date_str, "%B %d, %Y")
2088
        imgs = soup.find('div', class_='comic').find_all('img', alt='', title='')
2089
        return {
2090
            'title': title,
2091
            'img': [i['src'] for i in imgs],
2092
            'month': day.month,
2093
            'year': day.year,
2094
            'day': day.day,
2095
        }
2096