Code Duplication    Length = 22-26 lines in 2 locations

comics.py 2 locations

@@ 954-979 (lines=26) @@
951
        }
952
953
954
class MyExtraLife(GenericNavigableComic):
955
    """Class to retrieve My Extra Life comics."""
956
    name = 'extralife'
957
    long_name = 'My Extra Life'
958
    url = 'http://www.myextralife.com'
959
    get_navi_link = get_link_rel_next
960
961
    @classmethod
962
    def get_first_comic_link(cls):
963
        """Get link to first comics."""
964
        return get_soup_at_url(cls.url).find('a', class_='comic_nav_link first_comic_link')
965
966
    @classmethod
967
    def get_comic_info(cls, soup, link):
968
        """Get information about a particular comics."""
969
        title = soup.find("h1", class_="comic_title").string
970
        date_str = soup.find("span", class_="comic_date").string
971
        day = string_to_date(date_str, "%B %d, %Y")
972
        imgs = soup.find_all("img", class_="comic")
973
        assert all(i['alt'] == i['title'] == title for i in imgs)
974
        return {
975
            'title': title,
976
            'img': [i['src'] for i in imgs if i["src"]],
977
            'day': day.day,
978
            'month': day.month,
979
            'year': day.year
980
        }
981
982
@@ 383-404 (lines=22) @@
380
        }
381
382
383
class GenericLeMondeBlog(GenericNavigableComic):
384
    """Generic class to retrieve comics from Le Monde blogs."""
385
    _categories = ('LEMONDE', 'FRANCAIS')
386
    get_navi_link = get_link_rel_next
387
    get_first_comic_link = simulate_first_link
388
    first_url = NotImplemented
389
390
    @classmethod
391
    def get_comic_info(cls, soup, link):
392
        """Get information about a particular comics."""
393
        url2 = soup.find('link', rel='shortlink')['href']
394
        title = soup.find('meta', property='og:title')['content']
395
        date_str = soup.find("span", class_="entry-date").string
396
        day = string_to_date(date_str, "%d %B %Y", "fr_FR.utf8")
397
        imgs = soup.find_all('meta', property='og:image')
398
        return {
399
            'title': title,
400
            'url2': url2,
401
            'img': [convert_iri_to_plain_ascii_uri(i['content']) for i in imgs],
402
            'month': day.month,
403
            'year': day.year,
404
            'day': day.day,
405
        }
406
407