Code Duplication    Length = 30-31 lines in 2 locations

comics.py 2 locations

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