Code Duplication    Length = 22-24 lines in 2 locations

comics.py 2 locations

@@ 2083-2106 (lines=24) @@
2080
class PoorlyDrawnLines(GenericListableComic):
2081
    """Class to retrieve Poorly Drawn Lines comics."""
2082
    # Also on http://pdlcomics.tumblr.com
2083
    name = 'poorlydrawn'
2084
    long_name = 'Poorly Drawn Lines'
2085
    url = 'https://www.poorlydrawnlines.com'
2086
    _categories = ('POORLYDRAWN', )
2087
    get_url_from_archive_element = get_href
2088
2089
    @classmethod
2090
    def get_comic_info(cls, soup, link):
2091
        """Get information about a particular comics."""
2092
        imgs = soup.find('div', class_='post').find_all('img')
2093
        assert len(imgs) <= 1, imgs
2094
        return {
2095
            'img': [i['src'] for i in imgs],
2096
            'title': imgs[0].get('title', "") if imgs else "",
2097
        }
2098
2099
    @classmethod
2100
    def get_archive_elements(cls):
2101
        archive_url = urljoin_wrapper(cls.url, 'archive')
2102
        url_re = re.compile('^%s/comic/.' % cls.url)
2103
        return reversed(get_soup_at_url(archive_url).find_all('a', href=url_re))
2104
2105
2106
class LoadingComics(GenericNavigableComic):
2107
    """Class to retrieve Loading Artist comics."""
2108
    name = 'loadingartist'
2109
    long_name = 'Loading Artist'
@@ 1067-1088 (lines=22) @@
1064
        }
1065
1066
1067
class PerryBibleFellowship(GenericListableComic):  # Is now navigable too
1068
    """Class to retrieve Perry Bible Fellowship comics."""
1069
    name = 'pbf'
1070
    long_name = 'Perry Bible Fellowship'
1071
    url = 'http://pbfcomics.com'
1072
    get_url_from_archive_element = join_cls_url_to_href
1073
1074
    @classmethod
1075
    def get_archive_elements(cls):
1076
        soup = get_soup_at_url(cls.url)
1077
        thumbnails = soup.find('div', id='all_thumbnails')
1078
        return reversed(thumbnails.find_all('a'))
1079
1080
    @classmethod
1081
    def get_comic_info(cls, soup, link):
1082
        """Get information about a particular comics."""
1083
        name = soup.find('meta', property='og:title')['content']
1084
        imgs = soup.find_all('meta', property='og:image')
1085
        assert len(imgs) == 1, imgs
1086
        return {
1087
            'name': name,
1088
            'img': [i['content'] for i in imgs],
1089
        }
1090
1091