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
@@ 2932-2962 (lines=31) @@
2929
    lang = "fr_FR.utf8"
2930
2931
2932
class UnearthedComics(GenericNavigableComic):
2933
    """Class to retrieve Unearthed comics."""
2934
    # Also on http://tapastic.com/series/UnearthedComics
2935
    # Also on https://unearthedcomics.tumblr.com
2936
    name = 'unearthed'
2937
    long_name = 'Unearthed Comics'
2938
    url = 'http://unearthedcomics.com'
2939
    _categories = ('UNEARTHED', )
2940
    get_navi_link = get_link_rel_next
2941
    get_first_comic_link = simulate_first_link
2942
    first_url = 'http://unearthedcomics.com/comics/world-with-turn-signals/'
2943
2944
    @classmethod
2945
    def get_comic_info(cls, soup, link):
2946
        """Get information about a particular comics."""
2947
        short_url = soup.find('link', rel='shortlink')['href']
2948
        title_elt = soup.find('h1') or soup.find('h2')
2949
        title = title_elt.string if title_elt else ""
2950
        desc = soup.find('meta', property='og:description')
2951
        date_str = soup.find('time', class_='published updated hidden')['datetime']
2952
        day = string_to_date(date_str, "%Y-%m-%d")
2953
        post = soup.find('div', class_="entry content entry-content type-portfolio")
2954
        imgs = post.find_all('img')
2955
        return {
2956
            'title': title,
2957
            'description': desc,
2958
            'url2': short_url,
2959
            'img': [i['src'] for i in imgs],
2960
            'month': day.month,
2961
            'year': day.year,
2962
            'day': day.day,
2963
        }
2964
2965