Code Duplication    Length = 29-31 lines in 2 locations

comics.py 2 locations

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