Code Duplication    Length = 29-31 lines in 2 locations

comics.py 2 locations

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