Code Duplication    Length = 30-31 lines in 2 locations

comics.py 2 locations

@@ 524-553 (lines=30) @@
521
    first_url = "http://uneanneeaulycee.blog.lemonde.fr/2016/06/13/la-semaine-du-bac-est-arrivee/"
522
523
524
class Rall(GenericComicNotWorking, GenericNavigableComic):
525
    """Class to retrieve Ted Rall comics."""
526
    # Also on http://www.gocomics.com/tedrall
527
    name = 'rall'
528
    long_name = "Ted Rall"
529
    url = "http://rall.com/comic"
530
    _categories = ('RALL', )
531
    get_navi_link = get_link_rel_next
532
    get_first_comic_link = simulate_first_link
533
    # Not the first but I didn't find an efficient way to retrieve it
534
    first_url = "http://rall.com/2014/01/30/los-angeles-times-cartoon-well-miss-those-california-flowers"
535
536
    @classmethod
537
    def get_comic_info(cls, soup, link):
538
        """Get information about a particular comics."""
539
        title = soup.find('meta', property='og:title')['content']
540
        author = soup.find("span", class_="author vcard").find("a").string
541
        date_str = soup.find("span", class_="entry-date").string
542
        day = string_to_date(date_str, "%B %d, %Y")
543
        desc = soup.find('meta', property='og:description')['content']
544
        imgs = soup.find('div', class_='entry-content').find_all('img')
545
        imgs = imgs[:-7]  # remove social media buttons
546
        return {
547
            'title': title,
548
            'author': author,
549
            'month': day.month,
550
            'year': day.year,
551
            'day': day.day,
552
            'description': desc,
553
            'img': [i['src'] for i in imgs],
554
        }
555
556
@@ 2907-2937 (lines=31) @@
2904
    lang = "fr_FR.utf8"
2905
2906
2907
class UnearthedComics(GenericNavigableComic):
2908
    """Class to retrieve Unearthed comics."""
2909
    # Also on http://tapastic.com/series/UnearthedComics
2910
    # Also on https://unearthedcomics.tumblr.com
2911
    name = 'unearthed'
2912
    long_name = 'Unearthed Comics'
2913
    url = 'http://unearthedcomics.com'
2914
    _categories = ('UNEARTHED', )
2915
    get_navi_link = get_link_rel_next
2916
    get_first_comic_link = simulate_first_link
2917
    first_url = 'http://unearthedcomics.com/comics/world-with-turn-signals/'
2918
2919
    @classmethod
2920
    def get_comic_info(cls, soup, link):
2921
        """Get information about a particular comics."""
2922
        short_url = soup.find('link', rel='shortlink')['href']
2923
        title_elt = soup.find('h1') or soup.find('h2')
2924
        title = title_elt.string if title_elt else ""
2925
        desc = soup.find('meta', property='og:description')
2926
        date_str = soup.find('time', class_='published updated hidden')['datetime']
2927
        day = string_to_date(date_str, "%Y-%m-%d")
2928
        post = soup.find('div', class_="entry content entry-content type-portfolio")
2929
        imgs = post.find_all('img')
2930
        return {
2931
            'title': title,
2932
            'description': desc,
2933
            'url2': short_url,
2934
            'img': [i['src'] for i in imgs],
2935
            'month': day.month,
2936
            'year': day.year,
2937
            'day': day.day,
2938
        }
2939
2940