Code Duplication    Length = 29-31 lines in 2 locations

comics.py 2 locations

@@ 1509-1539 (lines=31) @@
1506
        }
1507
1508
1509
class Octopuns(GenericComicNotWorking, GenericNavigableComic):  # Website has changed
1510
    """Class to retrieve Octopuns comics."""
1511
    # Also on http://octopuns.tumblr.com
1512
    name = 'octopuns'
1513
    long_name = 'Octopuns'
1514
    url = 'http://www.octopuns.net'
1515
1516
    @classmethod
1517
    def get_first_comic_link(cls):
1518
        """Get link to first comics."""
1519
        return get_soup_at_url(cls.url).find('img', src=re.compile('.*/First.png')).parent
1520
1521
    @classmethod
1522
    def get_navi_link(cls, last_soup, next_):
1523
        """Get link to next or previous comic."""
1524
        link = last_soup.find('img', src=re.compile('.*/Next.png' if next_ else '.*/Back.png')).parent
1525
        return None if link.get('href') is None else link
1526
1527
    @classmethod
1528
    def get_comic_info(cls, soup, link):
1529
        """Get information about a particular comics."""
1530
        title = soup.find('h3', class_='post-title entry-title').string
1531
        date_str = soup.find('h2', class_='date-header').string
1532
        day = string_to_date(date_str, "%A, %B %d, %Y")
1533
        imgs = soup.find_all('link', rel='image_src')
1534
        return {
1535
            'img': [i['href'] for i in imgs],
1536
            'title': title,
1537
            'day': day.day,
1538
            'month': day.month,
1539
            'year': day.year,
1540
        }
1541
1542
@@ 2089-2117 (lines=29) @@
2086
        return reversed(get_soup_at_url(archive_url).find_all('a', href=url_re))
2087
2088
2089
class LoadingComics(GenericNavigableComic):
2090
    """Class to retrieve Loading Artist comics."""
2091
    name = 'loadingartist'
2092
    long_name = 'Loading Artist'
2093
    url = 'http://www.loadingartist.com/latest'
2094
2095
    @classmethod
2096
    def get_first_comic_link(cls):
2097
        """Get link to first comics."""
2098
        return get_soup_at_url(cls.url).find('a', title="First")
2099
2100
    @classmethod
2101
    def get_navi_link(cls, last_soup, next_):
2102
        """Get link to next or previous comic."""
2103
        return last_soup.find('a', title='Next' if next_ else 'Previous')
2104
2105
    @classmethod
2106
    def get_comic_info(cls, soup, link):
2107
        """Get information about a particular comics."""
2108
        title = soup.find('h1').string
2109
        date_str = soup.find('span', class_='date').string.strip()
2110
        day = string_to_date(date_str, "%B %d, %Y")
2111
        imgs = soup.find('div', class_='comic').find_all('img', alt='', title='')
2112
        return {
2113
            'title': title,
2114
            'img': [i['src'] for i in imgs],
2115
            'month': day.month,
2116
            'year': day.year,
2117
            'day': day.day,
2118
        }
2119
2120