Code Duplication    Length = 30-31 lines in 2 locations

comics.py 2 locations

@@ 471-500 (lines=30) @@
468
    first_url = "http://uneanneeaulycee.blog.lemonde.fr/2016/06/13/la-semaine-du-bac-est-arrivee/"
469
470
471
class Rall(GenericNavigableComic):
472
    """Class to retrieve Ted Rall comics."""
473
    # Also on http://www.gocomics.com/tedrall
474
    name = 'rall'
475
    long_name = "Ted Rall"
476
    url = "http://rall.com/comic"
477
    _categories = ('RALL', )
478
    get_navi_link = get_link_rel_next
479
    get_first_comic_link = simulate_first_link
480
    # Not the first but I didn't find an efficient way to retrieve it
481
    first_url = "http://rall.com/2014/01/30/los-angeles-times-cartoon-well-miss-those-california-flowers"
482
483
    @classmethod
484
    def get_comic_info(cls, soup, link):
485
        """Get information about a particular comics."""
486
        title = soup.find('meta', property='og:title')['content']
487
        author = soup.find("span", class_="author vcard").find("a").string
488
        date_str = soup.find("span", class_="entry-date").string
489
        day = string_to_date(date_str, "%B %d, %Y")
490
        desc = soup.find('meta', property='og:description')['content']
491
        imgs = soup.find('div', class_='entry-content').find_all('img')
492
        imgs = imgs[:-7]  # remove social media buttons
493
        return {
494
            'title': title,
495
            'author': author,
496
            'month': day.month,
497
            'year': day.year,
498
            'day': day.day,
499
            'description': desc,
500
            'img': [i['src'] for i in imgs],
501
        }
502
503
@@ 2812-2842 (lines=31) @@
2809
    lang = "fr_FR.utf8"
2810
2811
2812
class UnearthedComics(GenericNavigableComic):
2813
    """Class to retrieve Unearthed comics."""
2814
    # Also on http://tapastic.com/series/UnearthedComics
2815
    # Also on http://unearthedcomics.tumblr.com
2816
    name = 'unearthed'
2817
    long_name = 'Unearthed Comics'
2818
    url = 'http://unearthedcomics.com'
2819
    _categories = ('UNEARTHED', )
2820
    get_navi_link = get_link_rel_next
2821
    get_first_comic_link = simulate_first_link
2822
    first_url = 'http://unearthedcomics.com/comics/world-with-turn-signals/'
2823
2824
    @classmethod
2825
    def get_comic_info(cls, soup, link):
2826
        """Get information about a particular comics."""
2827
        short_url = soup.find('link', rel='shortlink')['href']
2828
        title_elt = soup.find('h1') or soup.find('h2')
2829
        title = title_elt.string if title_elt else ""
2830
        desc = soup.find('meta', property='og:description')
2831
        date_str = soup.find('time', class_='published updated hidden')['datetime']
2832
        day = string_to_date(date_str, "%Y-%m-%d")
2833
        post = soup.find('div', class_="entry content entry-content type-portfolio")
2834
        imgs = post.find_all('img')
2835
        return {
2836
            'title': title,
2837
            'description': desc,
2838
            'url2': short_url,
2839
            'img': [i['src'] for i in imgs],
2840
            'month': day.month,
2841
            'year': day.year,
2842
            'day': day.day,
2843
        }
2844
2845