Code Duplication    Length = 37-39 lines in 2 locations

comics.py 2 locations

@@ 763-799 (lines=37) @@
760
    # Also on http://www.gocomics.com/garfield
761
    name = 'garfield'
762
    long_name = 'Garfield'
763
    url = 'https://garfield.com'
764
765
    @classmethod
766
    def get_first_comic_link(cls):
767
        """Get link to first comics."""
768
        return {'href': 'https://garfield.com/comic/1978/06/19'}
769
770
    @classmethod
771
    def get_navi_link(cls, last_soup, next_):
772
        return last_soup.find('a', class_='comic-arrow-right' if next_ else 'comic-arrow-left')
773
774
    @classmethod
775
    def get_comic_info(cls, soup, link):
776
        """Get information about a particular comics."""
777
        url = cls.get_url_from_link(link)
778
        date_re = re.compile('^%s/comic/([0-9]*)/([0-9]*)/([0-9]*)' % cls.url)
779
        year, month, day = [int(s) for s in date_re.match(url).groups()]
780
        imgs = soup.find('div', class_='comic-display').find_all('img', class_='img-responsive')
781
        return {
782
            'month': month,
783
            'year': year,
784
            'day': day,
785
            'img': [i['src'] for i in imgs],
786
        }
787
788
789
class Dilbert(GenericNavigableComic):
790
    """Class to retrieve Dilbert comics."""
791
    # Also on http://www.gocomics.com/dilbert-classics
792
    name = 'dilbert'
793
    long_name = 'Dilbert'
794
    url = 'http://dilbert.com'
795
    get_url_from_link = join_cls_url_to_href
796
797
    @classmethod
798
    def get_first_comic_link(cls):
799
        """Get link to first comics."""
800
        return {'href': 'http://dilbert.com/strip/1989-04-16'}
801
802
    @classmethod
@@ 2902-2940 (lines=39) @@
2899
    url = 'http://www.ahammaday.com'
2900
    get_url_from_link = join_cls_url_to_href
2901
2902
    @classmethod
2903
    def get_first_comic_link(cls):
2904
        """Get link to first comics."""
2905
        return {'href': 'http://www.ahammaday.com/today/3/6/french'}
2906
2907
    @classmethod
2908
    def get_navi_link(cls, last_soup, next_):
2909
        # prev is next / next is prev
2910
        return last_soup.find('li', class_='previous' if next_ else 'next').find('a')
2911
2912
    @classmethod
2913
    def get_comic_info(cls, soup, link):
2914
        """Get information about a particular comics."""
2915
        date_str = soup.find('time', class_='published')['datetime']
2916
        day = string_to_date(date_str, "%Y-%m-%d")
2917
        author = soup.find('span', class_='blog-author').find('a').string
2918
        title = soup.find('meta', property='og:title')['content']
2919
        imgs = soup.find_all('meta', itemprop='image')
2920
        return {
2921
            'img': [i['content'] for i in imgs],
2922
            'title': title,
2923
            'author': author,
2924
            'day': day.day,
2925
            'month': day.month,
2926
            'year': day.year,
2927
        }
2928
2929
2930
class LittleLifeLines(GenericNavigableComic):
2931
    """Class to retrieve Little Life Lines comics."""
2932
    name = 'life'
2933
    long_name = 'Little Life Lines'
2934
    url = 'http://www.littlelifelines.com'
2935
    get_url_from_link = join_cls_url_to_href
2936
2937
    @classmethod
2938
    def get_first_comic_link(cls):
2939
        """Get link to first comics."""
2940
        return {'href': 'http://www.littlelifelines.com/comics/well-done'}
2941
2942
    @classmethod
2943
    def get_navi_link(cls, last_soup, next_):