Code Duplication    Length = 30-31 lines in 2 locations

comics.py 2 locations

@@ 2835-2865 (lines=31) @@
2832
    lang = "fr_FR.utf8"
2833
2834
2835
class UnearthedComics(GenericNavigableComic):
2836
    """Class to retrieve Unearthed comics."""
2837
    # Also on http://tapastic.com/series/UnearthedComics
2838
    # Also on https://unearthedcomics.tumblr.com
2839
    name = 'unearthed'
2840
    long_name = 'Unearthed Comics'
2841
    url = 'http://unearthedcomics.com'
2842
    _categories = ('UNEARTHED', )
2843
    get_navi_link = get_link_rel_next
2844
    get_first_comic_link = simulate_first_link
2845
    first_url = 'http://unearthedcomics.com/comics/world-with-turn-signals/'
2846
2847
    @classmethod
2848
    def get_comic_info(cls, soup, link):
2849
        """Get information about a particular comics."""
2850
        short_url = soup.find('link', rel='shortlink')['href']
2851
        title_elt = soup.find('h1') or soup.find('h2')
2852
        title = title_elt.string if title_elt else ""
2853
        desc = soup.find('meta', property='og:description')
2854
        date_str = soup.find('time', class_='published updated hidden')['datetime']
2855
        day = string_to_date(date_str, "%Y-%m-%d")
2856
        post = soup.find('div', class_="entry content entry-content type-portfolio")
2857
        imgs = post.find_all('img')
2858
        return {
2859
            'title': title,
2860
            'description': desc,
2861
            'url2': short_url,
2862
            'img': [i['src'] for i in imgs],
2863
            'month': day.month,
2864
            'year': day.year,
2865
            'day': day.day,
2866
        }
2867
2868
@@ 476-505 (lines=30) @@
473
    first_url = "http://uneanneeaulycee.blog.lemonde.fr/2016/06/13/la-semaine-du-bac-est-arrivee/"
474
475
476
class Rall(GenericNavigableComic):
477
    """Class to retrieve Ted Rall comics."""
478
    # Also on http://www.gocomics.com/tedrall
479
    name = 'rall'
480
    long_name = "Ted Rall"
481
    url = "http://rall.com/comic"
482
    _categories = ('RALL', )
483
    get_navi_link = get_link_rel_next
484
    get_first_comic_link = simulate_first_link
485
    # Not the first but I didn't find an efficient way to retrieve it
486
    first_url = "http://rall.com/2014/01/30/los-angeles-times-cartoon-well-miss-those-california-flowers"
487
488
    @classmethod
489
    def get_comic_info(cls, soup, link):
490
        """Get information about a particular comics."""
491
        title = soup.find('meta', property='og:title')['content']
492
        author = soup.find("span", class_="author vcard").find("a").string
493
        date_str = soup.find("span", class_="entry-date").string
494
        day = string_to_date(date_str, "%B %d, %Y")
495
        desc = soup.find('meta', property='og:description')['content']
496
        imgs = soup.find('div', class_='entry-content').find_all('img')
497
        imgs = imgs[:-7]  # remove social media buttons
498
        return {
499
            'title': title,
500
            'author': author,
501
            'month': day.month,
502
            'year': day.year,
503
            'day': day.day,
504
            'description': desc,
505
            'img': [i['src'] for i in imgs],
506
        }
507
508