Code Duplication    Length = 30-31 lines in 2 locations

comics.py 2 locations

@@ 2890-2920 (lines=31) @@
2887
2888
class UnearthedComics(GenericNavigableComic):
2889
    """Class to retrieve Unearthed comics."""
2890
    # Also on http://tapastic.com/series/UnearthedComics
2891
    # Also on https://unearthedcomics.tumblr.com
2892
    name = 'unearthed'
2893
    long_name = 'Unearthed Comics'
2894
    url = 'http://unearthedcomics.com'
2895
    _categories = ('UNEARTHED', )
2896
    get_navi_link = get_link_rel_next
2897
    get_first_comic_link = simulate_first_link
2898
    first_url = 'http://unearthedcomics.com/comics/world-with-turn-signals/'
2899
2900
    @classmethod
2901
    def get_comic_info(cls, soup, link):
2902
        """Get information about a particular comics."""
2903
        short_url = soup.find('link', rel='shortlink')['href']
2904
        title_elt = soup.find('h1') or soup.find('h2')
2905
        title = title_elt.string if title_elt else ""
2906
        desc = soup.find('meta', property='og:description')
2907
        date_str = soup.find('time', class_='published updated hidden')['datetime']
2908
        day = string_to_date(date_str, "%Y-%m-%d")
2909
        post = soup.find('div', class_="entry content entry-content type-portfolio")
2910
        imgs = post.find_all('img')
2911
        return {
2912
            'title': title,
2913
            'description': desc,
2914
            'url2': short_url,
2915
            'img': [i['src'] for i in imgs],
2916
            'month': day.month,
2917
            'year': day.year,
2918
            'day': day.day,
2919
        }
2920
2921
2922
class Optipess(GenericNavigableComic):
2923
    """Class to retrieve Optipess comics."""
@@ 505-534 (lines=30) @@
502
    first_url = "http://uneanneeaulycee.blog.lemonde.fr/2016/06/13/la-semaine-du-bac-est-arrivee/"
503
504
505
class Rall(GenericComicNotWorking, GenericNavigableComic):
506
    """Class to retrieve Ted Rall comics."""
507
    # Also on http://www.gocomics.com/tedrall
508
    name = 'rall'
509
    long_name = "Ted Rall"
510
    url = "http://rall.com/comic"
511
    _categories = ('RALL', )
512
    get_navi_link = get_link_rel_next
513
    get_first_comic_link = simulate_first_link
514
    # Not the first but I didn't find an efficient way to retrieve it
515
    first_url = "http://rall.com/2014/01/30/los-angeles-times-cartoon-well-miss-those-california-flowers"
516
517
    @classmethod
518
    def get_comic_info(cls, soup, link):
519
        """Get information about a particular comics."""
520
        title = soup.find('meta', property='og:title')['content']
521
        author = soup.find("span", class_="author vcard").find("a").string
522
        date_str = soup.find("span", class_="entry-date").string
523
        day = string_to_date(date_str, "%B %d, %Y")
524
        desc = soup.find('meta', property='og:description')['content']
525
        imgs = soup.find('div', class_='entry-content').find_all('img')
526
        imgs = imgs[:-7]  # remove social media buttons
527
        return {
528
            'title': title,
529
            'author': author,
530
            'month': day.month,
531
            'year': day.year,
532
            'day': day.day,
533
            'description': desc,
534
            'img': [i['src'] for i in imgs],
535
        }
536
537