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