Code Duplication    Length = 28-31 lines in 2 locations

comics.py 2 locations

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