Code Duplication    Length = 24-27 lines in 2 locations

comics.py 2 locations

@@ 1720-1746 (lines=27) @@
1717
        author = soup.find("span", class_="post-author").find("a").string
1718
        date_str = soup.find("span", class_="post-date").string
1719
        day = string_to_date(date_str, '%B %d, %Y')
1720
        imgs = soup.find("div", id="comic").find_all("img")
1721
        assert all(i['alt'] == i['title'] == title for i in imgs)
1722
        return {
1723
            'day': day.day,
1724
            'month': day.month,
1725
            'year': day.year,
1726
            'img': [i['src'] for i in imgs],
1727
            'title': title,
1728
            'author': author,
1729
        }
1730
1731
1732
class BigFootJustice(GenericNavigableComic):
1733
    """Class to retrieve Big Foot Justice comics."""
1734
    # Also on http://tapastic.com/series/bigfoot-justice
1735
    name = 'bigfoot'
1736
    long_name = 'Big Foot Justice'
1737
    url = 'http://bigfootjustice.com'
1738
    get_first_comic_link = get_a_navi_navifirst
1739
    get_navi_link = get_a_navi_comicnavnext_navinext
1740
1741
    @classmethod
1742
    def get_comic_info(cls, soup, link):
1743
        """Get information about a particular comics."""
1744
        imgs = soup.find('div', id='comic').find_all('img')
1745
        assert all(i['title'] == i['alt'] for i in imgs)
1746
        title = ' '.join(i['title'] for i in imgs)
1747
        return {
1748
            'img': [i['src'] for i in imgs],
1749
            'title': title,
@@ 2174-2197 (lines=24) @@
2171
2172
    @classmethod
2173
    def get_comic_info(cls, soup, link):
2174
        """Get information about a particular comics."""
2175
        title = soup.find('meta', attrs={'name': 'twitter:title'})['content']
2176
        description = soup.find('meta', attrs={'name': 'description'})['content']
2177
        tags_prop = soup.find('meta', property='article:tag')
2178
        tags = tags_prop['content'] if tags_prop else ""
2179
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
2180
        day = string_to_date(date_str, "%Y-%m-%d")
2181
        imgs = soup.find_all('img', attrs={'data-recalc-dims': "1"})
2182
        assert len(imgs) == 1
2183
        return {
2184
            'title': title,
2185
            'description': description,
2186
            'tags': tags,
2187
            'alt': "".join(i['alt'] for i in imgs),
2188
            'img': [i['src'].rsplit('?', 1)[0] for i in imgs],
2189
            'month': day.month,
2190
            'year': day.year,
2191
            'day': day.day,
2192
        }
2193
2194
2195
class AnythingComic(GenericComic):
2196
    """Class to retrieve Anything Comics."""
2197
    # Also on http://tapastic.com/series/anything
2198
    name = 'anythingcomic'
2199
    long_name = 'Anything Comic'
2200
    url = 'http://www.anythingcomic.com'