Code Duplication    Length = 28-31 lines in 2 locations

comics.py 2 locations

@@ 1767-1797 (lines=31) @@
1764
    long_name = 'Big Foot Justice'
1765
    url = 'http://bigfootjustice.com'
1766
    get_first_comic_link = get_a_navi_navifirst
1767
    get_navi_link = get_a_navi_comicnavnext_navinext
1768
1769
    @classmethod
1770
    def get_comic_info(cls, soup, link):
1771
        """Get information about a particular comics."""
1772
        imgs = soup.find('div', id='comic').find_all('img')
1773
        assert all(i['title'] == i['alt'] for i in imgs)
1774
        title = ' '.join(i['title'] for i in imgs)
1775
        return {
1776
            'img': [i['src'] for i in imgs],
1777
            'title': title,
1778
        }
1779
1780
1781
class RespawnComic(GenericNavigableComic):
1782
    """Class to retrieve Respawn Comic."""
1783
    # Also on http://respawncomic.tumblr.com
1784
    name = 'respawn'
1785
    long_name = 'Respawn Comic'
1786
    url = 'http://respawncomic.com '
1787
    _categories = ('RESPAWN', )
1788
    get_navi_link = get_a_rel_next
1789
    get_first_comic_link = simulate_first_link
1790
    first_url = 'http://respawncomic.com/comic/c0001/'
1791
1792
    @classmethod
1793
    def get_comic_info(cls, soup, link):
1794
        """Get information about a particular comics."""
1795
        title = soup.find('meta', property='og:title')['content']
1796
        author = soup.find('meta', attrs={'name': 'shareaholic:article_author_name'})['content']
1797
        date_str = soup.find('meta', attrs={'name': 'shareaholic:article_published_time'})['content']
1798
        date_str = date_str[:10]
1799
        day = string_to_date(date_str, "%Y-%m-%d")
1800
        imgs = soup.find_all('meta', property='og:image')
@@ 1006-1033 (lines=28) @@
1003
        url = cls.get_url_from_archive_element(link)
1004
        comic_img_re = re.compile('^/archive_b/PBF.*')
1005
        name = link.string
1006
        num = int(link['name'])
1007
        href = link['href']
1008
        assert href == '/%d/' % num
1009
        imgs = soup.find_all('img', src=comic_img_re)
1010
        assert len(imgs) == 1
1011
        assert imgs[0]['alt'] == name
1012
        return {
1013
            'num': num,
1014
            'name': name,
1015
            'img': [urljoin_wrapper(url, i['src']) for i in imgs],
1016
            'prefix': '%d-' % num,
1017
        }
1018
1019
1020
class Mercworks(GenericNavigableComic):
1021
    """Class to retrieve Mercworks comics."""
1022
    # Also on http://mercworks.tumblr.com
1023
    name = 'mercworks'
1024
    long_name = 'Mercworks'
1025
    url = 'http://mercworks.net'
1026
    get_first_comic_link = get_a_comicnavbase_comicnavfirst
1027
    get_navi_link = get_a_rel_next
1028
1029
    @classmethod
1030
    def get_comic_info(cls, soup, link):
1031
        """Get information about a particular comics."""
1032
        title = soup.find('meta', property='og:title')['content']
1033
        metadesc = soup.find('meta', property='og:description')
1034
        desc = metadesc['content'] if metadesc else ""
1035
        author = soup.find('meta', attrs={'name': 'shareaholic:article_author_name'})['content']
1036
        date_str = soup.find('meta', attrs={'name': 'shareaholic:article_published_time'})['content']