Code Duplication    Length = 29-31 lines in 2 locations

comics.py 2 locations

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