Code Duplication    Length = 30-31 lines in 2 locations

comics.py 2 locations

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