Code Duplication    Length = 28-31 lines in 2 locations

comics.py 2 locations

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