Code Duplication    Length = 30-31 lines in 2 locations

comics.py 2 locations

@@ 2890-2920 (lines=31) @@
2887
    lang = "fr_FR.utf8"
2888
2889
2890
class UnearthedComics(GenericNavigableComic):
2891
    """Class to retrieve Unearthed comics."""
2892
    # Also on http://tapastic.com/series/UnearthedComics
2893
    # Also on https://unearthedcomics.tumblr.com
2894
    name = 'unearthed'
2895
    long_name = 'Unearthed Comics'
2896
    url = 'http://unearthedcomics.com'
2897
    _categories = ('UNEARTHED', )
2898
    get_navi_link = get_link_rel_next
2899
    get_first_comic_link = simulate_first_link
2900
    first_url = 'http://unearthedcomics.com/comics/world-with-turn-signals/'
2901
2902
    @classmethod
2903
    def get_comic_info(cls, soup, link):
2904
        """Get information about a particular comics."""
2905
        short_url = soup.find('link', rel='shortlink')['href']
2906
        title_elt = soup.find('h1') or soup.find('h2')
2907
        title = title_elt.string if title_elt else ""
2908
        desc = soup.find('meta', property='og:description')
2909
        date_str = soup.find('time', class_='published updated hidden')['datetime']
2910
        day = string_to_date(date_str, "%Y-%m-%d")
2911
        post = soup.find('div', class_="entry content entry-content type-portfolio")
2912
        imgs = post.find_all('img')
2913
        return {
2914
            'title': title,
2915
            'description': desc,
2916
            'url2': short_url,
2917
            'img': [i['src'] for i in imgs],
2918
            'month': day.month,
2919
            'year': day.year,
2920
            'day': day.day,
2921
        }
2922
2923
@@ 505-534 (lines=30) @@
502
    first_url = "http://uneanneeaulycee.blog.lemonde.fr/2016/06/13/la-semaine-du-bac-est-arrivee/"
503
504
505
class Rall(GenericComicNotWorking, GenericNavigableComic):
506
    """Class to retrieve Ted Rall comics."""
507
    # Also on http://www.gocomics.com/tedrall
508
    name = 'rall'
509
    long_name = "Ted Rall"
510
    url = "http://rall.com/comic"
511
    _categories = ('RALL', )
512
    get_navi_link = get_link_rel_next
513
    get_first_comic_link = simulate_first_link
514
    # Not the first but I didn't find an efficient way to retrieve it
515
    first_url = "http://rall.com/2014/01/30/los-angeles-times-cartoon-well-miss-those-california-flowers"
516
517
    @classmethod
518
    def get_comic_info(cls, soup, link):
519
        """Get information about a particular comics."""
520
        title = soup.find('meta', property='og:title')['content']
521
        author = soup.find("span", class_="author vcard").find("a").string
522
        date_str = soup.find("span", class_="entry-date").string
523
        day = string_to_date(date_str, "%B %d, %Y")
524
        desc = soup.find('meta', property='og:description')['content']
525
        imgs = soup.find('div', class_='entry-content').find_all('img')
526
        imgs = imgs[:-7]  # remove social media buttons
527
        return {
528
            'title': title,
529
            'author': author,
530
            'month': day.month,
531
            'year': day.year,
532
            'day': day.day,
533
            'description': desc,
534
            'img': [i['src'] for i in imgs],
535
        }
536
537