Code Duplication    Length = 35-37 lines in 2 locations

comics.py 2 locations

@@ 3161-3197 (lines=37) @@
3158
        }
3159
3160
3161
class LittleLifeLines(GenericNavigableComic):
3162
    """Class to retrieve Little Life Lines comics."""
3163
    # Also on https://little-life-lines.tumblr.com
3164
    name = 'life'
3165
    long_name = 'Little Life Lines'
3166
    url = 'http://www.littlelifelines.com'
3167
    get_url_from_link = join_cls_url_to_href
3168
    get_first_comic_link = simulate_first_link
3169
    first_url = 'http://www.littlelifelines.com/comics/well-done'
3170
3171
    @classmethod
3172
    def get_navi_link(cls, last_soup, next_):
3173
        """Get link to next or previous comic."""
3174
        # prev is next / next is prev
3175
        li = last_soup.find('li', class_='prev' if next_ else 'next')
3176
        return li.find('a') if li else None
3177
3178
    @classmethod
3179
    def get_comic_info(cls, soup, link):
3180
        """Get information about a particular comics."""
3181
        title = soup.find('meta', property='og:title')['content']
3182
        desc = soup.find('meta', property='og:description')['content']
3183
        date_str = soup.find('time', class_='published')['datetime']
3184
        day = string_to_date(date_str, "%Y-%m-%d")
3185
        author = soup.find('a', rel='author').string
3186
        div_content = soup.find('div', class_="body entry-content")
3187
        imgs = div_content.find_all('img')
3188
        imgs = [i for i in imgs if i.get('src') is not None]
3189
        alt = imgs[0]['alt']
3190
        return {
3191
            'title': title,
3192
            'alt': alt,
3193
            'description': desc,
3194
            'author': author,
3195
            'day': day.day,
3196
            'month': day.month,
3197
            'year': day.year,
3198
            'img': [i['src'] for i in imgs],
3199
        }
3200
@@ 857-891 (lines=35) @@
854
        }
855
856
857
class Dilbert(GenericNavigableComic):
858
    """Class to retrieve Dilbert comics."""
859
    # Also on http://www.gocomics.com/dilbert-classics
860
    name = 'dilbert'
861
    long_name = 'Dilbert'
862
    url = 'http://dilbert.com'
863
    get_url_from_link = join_cls_url_to_href
864
    get_first_comic_link = simulate_first_link
865
    first_url = 'http://dilbert.com/strip/1989-04-16'
866
867
    @classmethod
868
    def get_navi_link(cls, last_soup, next_):
869
        """Get link to next or previous comic."""
870
        link = last_soup.find('div', class_='nav-comic nav-right' if next_ else 'nav-comic nav-left')
871
        return link.find('a') if link else None
872
873
    @classmethod
874
    def get_comic_info(cls, soup, link):
875
        """Get information about a particular comics."""
876
        title = soup.find('meta', property='og:title')['content']
877
        imgs = soup.find_all('meta', property='og:image')
878
        desc = soup.find('meta', property='og:description')['content']
879
        date_str = soup.find('meta', property='article:publish_date')['content']
880
        day = string_to_date(date_str, "%B %d, %Y")
881
        author = soup.find('meta', property='article:author')['content']
882
        tags = soup.find('meta', property='article:tag')['content']
883
        return {
884
            'title': title,
885
            'description': desc,
886
            'img': [i['content'] for i in imgs],
887
            'author': author,
888
            'tags': tags,
889
            'day': day.day,
890
            'month': day.month,
891
            'year': day.year
892
        }
893
894