Code Duplication    Length = 29-31 lines in 2 locations

comics.py 2 locations

@@ 1459-1489 (lines=31) @@
1456
        return {
1457
            'year': day.year,
1458
            'month': day.month,
1459
            'day': day.day,
1460
            'img': [soup.find('img', id='comic')['src']],
1461
            'title': title,
1462
        }
1463
1464
1465
class Octopuns(GenericEmptyComic, GenericNavigableComic):
1466
    """Class to retrieve Octopuns comics."""
1467
    # Also on http://octopuns.tumblr.com
1468
    name = 'octopuns'
1469
    long_name = 'Octopuns'
1470
    url = 'http://www.octopuns.net'
1471
1472
    @classmethod
1473
    def get_first_comic_link(cls):
1474
        """Get link to first comics."""
1475
        return get_soup_at_url(cls.url).find('img', src=re.compile('.*/First.png')).parent
1476
1477
    @classmethod
1478
    def get_navi_link(cls, last_soup, next_):
1479
        """Get link to next or previous comic."""
1480
        link = last_soup.find('img', src=re.compile('.*/Next.png' if next_ else '.*/Back.png')).parent
1481
        return None if link.get('href') is None else link
1482
1483
    @classmethod
1484
    def get_comic_info(cls, soup, link):
1485
        """Get information about a particular comics."""
1486
        title = soup.find('h3', class_='post-title entry-title').string
1487
        date_str = soup.find('h2', class_='date-header').string
1488
        day = string_to_date(date_str, "%A, %B %d, %Y")
1489
        imgs = soup.find_all('link', rel='image_src')
1490
        return {
1491
            'img': [i['href'] for i in imgs],
1492
            'title': title,
@@ 2017-2045 (lines=29) @@
2014
        }
2015
2016
    @classmethod
2017
    def get_archive_elements(cls):
2018
        archive_url = urljoin_wrapper(cls.url, 'archive')
2019
        url_re = re.compile('^%s/comic/.' % cls.url)
2020
        return reversed(get_soup_at_url(archive_url).find_all('a', href=url_re))
2021
2022
2023
class LoadingComics(GenericNavigableComic):
2024
    """Class to retrieve Loading Artist comics."""
2025
    name = 'loadingartist'
2026
    long_name = 'Loading Artist'
2027
    url = 'http://www.loadingartist.com/latest'
2028
2029
    @classmethod
2030
    def get_first_comic_link(cls):
2031
        """Get link to first comics."""
2032
        return get_soup_at_url(cls.url).find('a', title="First")
2033
2034
    @classmethod
2035
    def get_navi_link(cls, last_soup, next_):
2036
        """Get link to next or previous comic."""
2037
        return last_soup.find('a', title='Next' if next_ else 'Previous')
2038
2039
    @classmethod
2040
    def get_comic_info(cls, soup, link):
2041
        """Get information about a particular comics."""
2042
        title = soup.find('h1').string
2043
        date_str = soup.find('span', class_='date').string.strip()
2044
        day = string_to_date(date_str, "%B %d, %Y")
2045
        imgs = soup.find('div', class_='comic').find_all('img', alt='', title='')
2046
        return {
2047
            'title': title,
2048
            'img': [i['src'] for i in imgs],