Code Duplication    Length = 30-31 lines in 2 locations

comics.py 2 locations

@@ 524-553 (lines=30) @@
521
    first_url = "http://uneanneeaulycee.blog.lemonde.fr/2016/06/13/la-semaine-du-bac-est-arrivee/"
522
523
524
class Rall(GenericComicNotWorking, GenericNavigableComic):
525
    """Class to retrieve Ted Rall comics."""
526
    # Also on http://www.gocomics.com/tedrall
527
    name = 'rall'
528
    long_name = "Ted Rall"
529
    url = "http://rall.com/comic"
530
    _categories = ('RALL', )
531
    get_navi_link = get_link_rel_next
532
    get_first_comic_link = simulate_first_link
533
    # Not the first but I didn't find an efficient way to retrieve it
534
    first_url = "http://rall.com/2014/01/30/los-angeles-times-cartoon-well-miss-those-california-flowers"
535
536
    @classmethod
537
    def get_comic_info(cls, soup, link):
538
        """Get information about a particular comics."""
539
        title = soup.find('meta', property='og:title')['content']
540
        author = soup.find("span", class_="author vcard").find("a").string
541
        date_str = soup.find("span", class_="entry-date").string
542
        day = string_to_date(date_str, "%B %d, %Y")
543
        desc = soup.find('meta', property='og:description')['content']
544
        imgs = soup.find('div', class_='entry-content').find_all('img')
545
        imgs = imgs[:-7]  # remove social media buttons
546
        return {
547
            'title': title,
548
            'author': author,
549
            'month': day.month,
550
            'year': day.year,
551
            'day': day.day,
552
            'description': desc,
553
            'img': [i['src'] for i in imgs],
554
        }
555
556
@@ 2944-2974 (lines=31) @@
2941
class UnearthedComics(GenericNavigableComic):
2942
    """Class to retrieve Unearthed comics."""
2943
    # Also on http://tapastic.com/series/UnearthedComics
2944
    # Also on https://unearthedcomics.tumblr.com
2945
    name = 'unearthed'
2946
    long_name = 'Unearthed Comics'
2947
    url = 'http://unearthedcomics.com'
2948
    _categories = ('UNEARTHED', )
2949
    get_navi_link = get_link_rel_next
2950
    get_first_comic_link = simulate_first_link
2951
    first_url = 'http://unearthedcomics.com/comics/world-with-turn-signals/'
2952
2953
    @classmethod
2954
    def get_comic_info(cls, soup, link):
2955
        """Get information about a particular comics."""
2956
        short_url = soup.find('link', rel='shortlink')['href']
2957
        title_elt = soup.find('h1') or soup.find('h2')
2958
        title = title_elt.string if title_elt else ""
2959
        desc = soup.find('meta', property='og:description')
2960
        date_str = soup.find('time', class_='published updated hidden')['datetime']
2961
        day = string_to_date(date_str, "%Y-%m-%d")
2962
        post = soup.find('div', class_="entry content entry-content type-portfolio")
2963
        imgs = post.find_all('img')
2964
        return {
2965
            'title': title,
2966
            'description': desc,
2967
            'url2': short_url,
2968
            'img': [i['src'] for i in imgs],
2969
            'month': day.month,
2970
            'year': day.year,
2971
            'day': day.day,
2972
        }
2973
2974
2975
class Optipess(GenericNavigableComic):
2976
    """Class to retrieve Optipess comics."""
2977
    name = 'optipess'