Code Duplication    Length = 30-31 lines in 2 locations

comics.py 2 locations

@@ 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
@@ 2854-2884 (lines=31) @@
2851
    lang = "fr_FR.utf8"
2852
2853
2854
class UnearthedComics(GenericNavigableComic):
2855
    """Class to retrieve Unearthed comics."""
2856
    # Also on http://tapastic.com/series/UnearthedComics
2857
    # Also on https://unearthedcomics.tumblr.com
2858
    name = 'unearthed'
2859
    long_name = 'Unearthed Comics'
2860
    url = 'http://unearthedcomics.com'
2861
    _categories = ('UNEARTHED', )
2862
    get_navi_link = get_link_rel_next
2863
    get_first_comic_link = simulate_first_link
2864
    first_url = 'http://unearthedcomics.com/comics/world-with-turn-signals/'
2865
2866
    @classmethod
2867
    def get_comic_info(cls, soup, link):
2868
        """Get information about a particular comics."""
2869
        short_url = soup.find('link', rel='shortlink')['href']
2870
        title_elt = soup.find('h1') or soup.find('h2')
2871
        title = title_elt.string if title_elt else ""
2872
        desc = soup.find('meta', property='og:description')
2873
        date_str = soup.find('time', class_='published updated hidden')['datetime']
2874
        day = string_to_date(date_str, "%Y-%m-%d")
2875
        post = soup.find('div', class_="entry content entry-content type-portfolio")
2876
        imgs = post.find_all('img')
2877
        return {
2878
            'title': title,
2879
            'description': desc,
2880
            'url2': short_url,
2881
            'img': [i['src'] for i in imgs],
2882
            'month': day.month,
2883
            'year': day.year,
2884
            'day': day.day,
2885
        }
2886
2887