Code Duplication    Length = 30-31 lines in 2 locations

comics.py 2 locations

@@ 2997-3027 (lines=31) @@
2994
    lang = "fr_FR.utf8"
2995
2996
2997
class UnearthedComics(GenericNavigableComic):
2998
    """Class to retrieve Unearthed comics."""
2999
    # Also on http://tapastic.com/series/UnearthedComics
3000
    # Also on https://unearthedcomics.tumblr.com
3001
    name = 'unearthed'
3002
    long_name = 'Unearthed Comics'
3003
    url = 'http://unearthedcomics.com'
3004
    _categories = ('UNEARTHED', )
3005
    get_navi_link = get_link_rel_next
3006
    get_first_comic_link = simulate_first_link
3007
    first_url = 'http://unearthedcomics.com/comics/world-with-turn-signals/'
3008
3009
    @classmethod
3010
    def get_comic_info(cls, soup, link):
3011
        """Get information about a particular comics."""
3012
        short_url = soup.find('link', rel='shortlink')['href']
3013
        title_elt = soup.find('h1') or soup.find('h2')
3014
        title = title_elt.string if title_elt else ""
3015
        desc = soup.find('meta', property='og:description')
3016
        date_str = soup.find('time', class_='published updated hidden')['datetime']
3017
        day = string_to_date(date_str, "%Y-%m-%d")
3018
        post = soup.find('div', class_="entry content entry-content type-portfolio")
3019
        imgs = post.find_all('img')
3020
        return {
3021
            'title': title,
3022
            'description': desc,
3023
            'url2': short_url,
3024
            'img': [i['src'] for i in imgs],
3025
            'month': day.month,
3026
            'year': day.year,
3027
            'day': day.day,
3028
        }
3029
3030
@@ 551-580 (lines=30) @@
548
    first_url = 'http://morgannavarro.blog.lemonde.fr/2015/09/09/le-doute/'
549
550
551
class Rall(GenericComicNotWorking, GenericNavigableComic):
552
    """Class to retrieve Ted Rall comics."""
553
    # Also on http://www.gocomics.com/tedrall
554
    name = 'rall'
555
    long_name = "Ted Rall"
556
    url = "http://rall.com/comic"
557
    _categories = ('RALL', )
558
    get_navi_link = get_link_rel_next
559
    get_first_comic_link = simulate_first_link
560
    # Not the first but I didn't find an efficient way to retrieve it
561
    first_url = "http://rall.com/2014/01/30/los-angeles-times-cartoon-well-miss-those-california-flowers"
562
563
    @classmethod
564
    def get_comic_info(cls, soup, link):
565
        """Get information about a particular comics."""
566
        title = soup.find('meta', property='og:title')['content']
567
        author = soup.find("span", class_="author vcard").find("a").string
568
        date_str = soup.find("span", class_="entry-date").string
569
        day = string_to_date(date_str, "%B %d, %Y")
570
        desc = soup.find('meta', property='og:description')['content']
571
        imgs = soup.find('div', class_='entry-content').find_all('img')
572
        imgs = imgs[:-7]  # remove social media buttons
573
        return {
574
            'title': title,
575
            'author': author,
576
            'month': day.month,
577
            'year': day.year,
578
            'day': day.day,
579
            'description': desc,
580
            'img': [i['src'] for i in imgs],
581
        }
582
583