Code Duplication    Length = 29-31 lines in 2 locations

comics.py 2 locations

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