Code Duplication    Length = 22-26 lines in 2 locations

comics.py 2 locations

@@ 381-402 (lines=22) @@
378
        }
379
380
381
class GenericLeMondeBlog(GenericNavigableComic):
382
    """Generic class to retrieve comics from Le Monde blogs."""
383
    _categories = ('LEMONDE', 'FRANCAIS')
384
    get_navi_link = get_link_rel_next
385
    get_first_comic_link = simulate_first_link
386
    first_url = NotImplemented
387
388
    @classmethod
389
    def get_comic_info(cls, soup, link):
390
        """Get information about a particular comics."""
391
        url2 = soup.find('link', rel='shortlink')['href']
392
        title = soup.find('meta', property='og:title')['content']
393
        date_str = soup.find("span", class_="entry-date").string
394
        day = string_to_date(date_str, "%d %B %Y", "fr_FR.utf8")
395
        imgs = soup.find_all('meta', property='og:image')
396
        return {
397
            'title': title,
398
            'url2': url2,
399
            'img': [convert_iri_to_plain_ascii_uri(i['content']) for i in imgs],
400
            'month': day.month,
401
            'year': day.year,
402
            'day': day.day,
403
        }
404
405
@@ 926-951 (lines=26) @@
923
        }
924
925
926
class MyExtraLife(GenericNavigableComic):
927
    """Class to retrieve My Extra Life comics."""
928
    name = 'extralife'
929
    long_name = 'My Extra Life'
930
    url = 'http://www.myextralife.com'
931
    get_navi_link = get_link_rel_next
932
933
    @classmethod
934
    def get_first_comic_link(cls):
935
        """Get link to first comics."""
936
        return get_soup_at_url(cls.url).find('a', class_='comic_nav_link first_comic_link')
937
938
    @classmethod
939
    def get_comic_info(cls, soup, link):
940
        """Get information about a particular comics."""
941
        title = soup.find("h1", class_="comic_title").string
942
        date_str = soup.find("span", class_="comic_date").string
943
        day = string_to_date(date_str, "%B %d, %Y")
944
        imgs = soup.find_all("img", class_="comic")
945
        assert all(i['alt'] == i['title'] == title for i in imgs)
946
        return {
947
            'title': title,
948
            'img': [i['src'] for i in imgs if i["src"]],
949
            'day': day.day,
950
            'month': day.month,
951
            'year': day.year
952
        }
953
954