Code Duplication    Length = 30-31 lines in 2 locations

comics.py 2 locations

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