Code Duplication    Length = 29-31 lines in 2 locations

comics.py 2 locations

@@ 1482-1512 (lines=31) @@
1479
    """Class to retrieve PHD Comics."""
1480
    name = 'phd'
1481
    long_name = 'PhD Comics'
1482
    url = 'http://phdcomics.com/comics/archive.php'
1483
1484
    @classmethod
1485
    def get_first_comic_link(cls):
1486
        """Get link to first comics."""
1487
        soup = get_soup_at_url(cls.url)
1488
        img = soup.find('img', src='http://phdcomics.com/comics/images/first_button.gif')
1489
        return None if img is None else img.parent
1490
1491
    @classmethod
1492
    def get_navi_link(cls, last_soup, next_):
1493
        """Get link to next or previous comic."""
1494
        url = 'http://phdcomics.com/comics/images/%s_button.gif' % ('next' if next_ else 'prev')
1495
        img = last_soup.find('img', src=url)
1496
        return None if img is None else img.parent
1497
1498
    @classmethod
1499
    def get_comic_info(cls, soup, link):
1500
        """Get information about a particular comics."""
1501
        title = soup.find('meta', attrs={'name': 'twitter:title'})['content']
1502
        imgs = soup.find_all('meta', property='og:image')
1503
        return {
1504
            'img': [i['content'] for i in imgs],
1505
            'title': title,
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
@@ 2062-2090 (lines=29) @@
2059
            'author': author,
2060
        }
2061
2062
2063
class PoorlyDrawnLines(GenericListableComic):
2064
    """Class to retrieve Poorly Drawn Lines comics."""
2065
    # Also on http://pdlcomics.tumblr.com
2066
    name = 'poorlydrawn'
2067
    long_name = 'Poorly Drawn Lines'
2068
    url = 'https://www.poorlydrawnlines.com'
2069
    _categories = ('POORLYDRAWN', )
2070
    get_url_from_archive_element = get_href
2071
2072
    @classmethod
2073
    def get_comic_info(cls, soup, link):
2074
        """Get information about a particular comics."""
2075
        imgs = soup.find('div', class_='post').find_all('img')
2076
        assert len(imgs) <= 1
2077
        return {
2078
            'img': [i['src'] for i in imgs],
2079
            'title': imgs[0].get('title', "") if imgs else "",
2080
        }
2081
2082
    @classmethod
2083
    def get_archive_elements(cls):
2084
        archive_url = urljoin_wrapper(cls.url, 'archive')
2085
        url_re = re.compile('^%s/comic/.' % cls.url)
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'