Code Duplication    Length = 30-31 lines in 2 locations

comics.py 2 locations

@@ 2858-2888 (lines=31) @@
2855
    lang = "fr_FR.utf8"
2856
2857
2858
class UnearthedComics(GenericNavigableComic):
2859
    """Class to retrieve Unearthed comics."""
2860
    # Also on http://tapastic.com/series/UnearthedComics
2861
    # Also on https://unearthedcomics.tumblr.com
2862
    name = 'unearthed'
2863
    long_name = 'Unearthed Comics'
2864
    url = 'http://unearthedcomics.com'
2865
    _categories = ('UNEARTHED', )
2866
    get_navi_link = get_link_rel_next
2867
    get_first_comic_link = simulate_first_link
2868
    first_url = 'http://unearthedcomics.com/comics/world-with-turn-signals/'
2869
2870
    @classmethod
2871
    def get_comic_info(cls, soup, link):
2872
        """Get information about a particular comics."""
2873
        short_url = soup.find('link', rel='shortlink')['href']
2874
        title_elt = soup.find('h1') or soup.find('h2')
2875
        title = title_elt.string if title_elt else ""
2876
        desc = soup.find('meta', property='og:description')
2877
        date_str = soup.find('time', class_='published updated hidden')['datetime']
2878
        day = string_to_date(date_str, "%Y-%m-%d")
2879
        post = soup.find('div', class_="entry content entry-content type-portfolio")
2880
        imgs = post.find_all('img')
2881
        return {
2882
            'title': title,
2883
            'description': desc,
2884
            'url2': short_url,
2885
            'img': [i['src'] for i in imgs],
2886
            'month': day.month,
2887
            'year': day.year,
2888
            'day': day.day,
2889
        }
2890
2891
@@ 508-537 (lines=30) @@
505
    first_url = "http://uneanneeaulycee.blog.lemonde.fr/2016/06/13/la-semaine-du-bac-est-arrivee/"
506
507
508
class Rall(GenericComicNotWorking, GenericNavigableComic):
509
    """Class to retrieve Ted Rall comics."""
510
    # Also on http://www.gocomics.com/tedrall
511
    name = 'rall'
512
    long_name = "Ted Rall"
513
    url = "http://rall.com/comic"
514
    _categories = ('RALL', )
515
    get_navi_link = get_link_rel_next
516
    get_first_comic_link = simulate_first_link
517
    # Not the first but I didn't find an efficient way to retrieve it
518
    first_url = "http://rall.com/2014/01/30/los-angeles-times-cartoon-well-miss-those-california-flowers"
519
520
    @classmethod
521
    def get_comic_info(cls, soup, link):
522
        """Get information about a particular comics."""
523
        title = soup.find('meta', property='og:title')['content']
524
        author = soup.find("span", class_="author vcard").find("a").string
525
        date_str = soup.find("span", class_="entry-date").string
526
        day = string_to_date(date_str, "%B %d, %Y")
527
        desc = soup.find('meta', property='og:description')['content']
528
        imgs = soup.find('div', class_='entry-content').find_all('img')
529
        imgs = imgs[:-7]  # remove social media buttons
530
        return {
531
            'title': title,
532
            'author': author,
533
            'month': day.month,
534
            'year': day.year,
535
            'day': day.day,
536
            'description': desc,
537
            'img': [i['src'] for i in imgs],
538
        }
539
540