Code Duplication    Length = 29-30 lines in 2 locations

comics.py 2 locations

@@ 453-481 (lines=29) @@
450
    first_url = "http://uneanneeaulycee.blog.lemonde.fr/2016/06/13/la-semaine-du-bac-est-arrivee/"
451
452
453
class Rall(GenericNavigableComic):
454
    """Class to retrieve Ted Rall comics."""
455
    # Also on http://www.gocomics.com/tedrall
456
    name = 'rall'
457
    long_name = "Ted Rall"
458
    url = "http://rall.com/comic"
459
    get_navi_link = get_link_rel_next
460
    get_first_comic_link = simulate_first_link
461
    # Not the first but I didn't find an efficient way to retrieve it
462
    first_url = "http://rall.com/2014/01/30/los-angeles-times-cartoon-well-miss-those-california-flowers"
463
464
    @classmethod
465
    def get_comic_info(cls, soup, link):
466
        """Get information about a particular comics."""
467
        title = soup.find('meta', property='og:title')['content']
468
        author = soup.find("span", class_="author vcard").find("a").string
469
        date_str = soup.find("span", class_="entry-date").string
470
        day = string_to_date(date_str, "%B %d, %Y")
471
        desc = soup.find('meta', property='og:description')['content']
472
        imgs = soup.find('div', class_='entry-content').find_all('img')
473
        imgs = imgs[:-7]  # remove social media buttons
474
        return {
475
            'title': title,
476
            'author': author,
477
            'month': day.month,
478
            'year': day.year,
479
            'day': day.day,
480
            'description': desc,
481
            'img': [i['src'] for i in imgs],
482
        }
483
484
@@ 2705-2734 (lines=30) @@
2702
    lang = "fr_FR.utf8"
2703
2704
2705
class UnearthedComics(GenericNavigableComic):
2706
    """Class to retrieve Unearthed comics."""
2707
    # Also on http://tapastic.com/series/UnearthedComics
2708
    # Also on http://unearthedcomics.tumblr.com
2709
    name = 'unearthed'
2710
    long_name = 'Unearthed Comics'
2711
    url = 'http://unearthedcomics.com'
2712
    get_navi_link = get_link_rel_next
2713
    get_first_comic_link = simulate_first_link
2714
    first_url = 'http://unearthedcomics.com/comics/world-with-turn-signals/'
2715
2716
    @classmethod
2717
    def get_comic_info(cls, soup, link):
2718
        """Get information about a particular comics."""
2719
        short_url = soup.find('link', rel='shortlink')['href']
2720
        title_elt = soup.find('h1') or soup.find('h2')
2721
        title = title_elt.string if title_elt else ""
2722
        desc = soup.find('meta', property='og:description')
2723
        date_str = soup.find('time', class_='published updated hidden')['datetime']
2724
        day = string_to_date(date_str, "%Y-%m-%d")
2725
        post = soup.find('div', class_="entry content entry-content type-portfolio")
2726
        imgs = post.find_all('img')
2727
        return {
2728
            'title': title,
2729
            'description': desc,
2730
            'url2': short_url,
2731
            'img': [i['src'] for i in imgs],
2732
            'month': day.month,
2733
            'year': day.year,
2734
            'day': day.day,
2735
        }
2736
2737