Code Duplication    Length = 30-31 lines in 2 locations

comics.py 2 locations

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