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