Code Duplication    Length = 30-31 lines in 2 locations

comics.py 2 locations

@@ 2735-2765 (lines=31) @@
2732
    lang = "fr_FR.utf8"
2733
2734
2735
class UnearthedComics(GenericNavigableComic):
2736
    """Class to retrieve Unearthed comics."""
2737
    # Also on http://tapastic.com/series/UnearthedComics
2738
    # Also on http://unearthedcomics.tumblr.com
2739
    name = 'unearthed'
2740
    long_name = 'Unearthed Comics'
2741
    url = 'http://unearthedcomics.com'
2742
    _categories = ('UNEARTHED', )
2743
    get_navi_link = get_link_rel_next
2744
    get_first_comic_link = simulate_first_link
2745
    first_url = 'http://unearthedcomics.com/comics/world-with-turn-signals/'
2746
2747
    @classmethod
2748
    def get_comic_info(cls, soup, link):
2749
        """Get information about a particular comics."""
2750
        short_url = soup.find('link', rel='shortlink')['href']
2751
        title_elt = soup.find('h1') or soup.find('h2')
2752
        title = title_elt.string if title_elt else ""
2753
        desc = soup.find('meta', property='og:description')
2754
        date_str = soup.find('time', class_='published updated hidden')['datetime']
2755
        day = string_to_date(date_str, "%Y-%m-%d")
2756
        post = soup.find('div', class_="entry content entry-content type-portfolio")
2757
        imgs = post.find_all('img')
2758
        return {
2759
            'title': title,
2760
            'description': desc,
2761
            'url2': short_url,
2762
            'img': [i['src'] for i in imgs],
2763
            'month': day.month,
2764
            'year': day.year,
2765
            'day': day.day,
2766
        }
2767
2768
@@ 457-486 (lines=30) @@
454
    first_url = "http://uneanneeaulycee.blog.lemonde.fr/2016/06/13/la-semaine-du-bac-est-arrivee/"
455
456
457
class Rall(GenericNavigableComic):
458
    """Class to retrieve Ted Rall comics."""
459
    # Also on http://www.gocomics.com/tedrall
460
    name = 'rall'
461
    long_name = "Ted Rall"
462
    url = "http://rall.com/comic"
463
    _categories = ('RALL', )
464
    get_navi_link = get_link_rel_next
465
    get_first_comic_link = simulate_first_link
466
    # Not the first but I didn't find an efficient way to retrieve it
467
    first_url = "http://rall.com/2014/01/30/los-angeles-times-cartoon-well-miss-those-california-flowers"
468
469
    @classmethod
470
    def get_comic_info(cls, soup, link):
471
        """Get information about a particular comics."""
472
        title = soup.find('meta', property='og:title')['content']
473
        author = soup.find("span", class_="author vcard").find("a").string
474
        date_str = soup.find("span", class_="entry-date").string
475
        day = string_to_date(date_str, "%B %d, %Y")
476
        desc = soup.find('meta', property='og:description')['content']
477
        imgs = soup.find('div', class_='entry-content').find_all('img')
478
        imgs = imgs[:-7]  # remove social media buttons
479
        return {
480
            'title': title,
481
            'author': author,
482
            'month': day.month,
483
            'year': day.year,
484
            'day': day.day,
485
            'description': desc,
486
            'img': [i['src'] for i in imgs],
487
        }
488
489