Code Duplication    Length = 29-31 lines in 2 locations

comics.py 2 locations

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