Code Duplication    Length = 29-31 lines in 2 locations

comics.py 2 locations

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