Code Duplication    Length = 30-31 lines in 2 locations

comics.py 2 locations

@@ 2617-2647 (lines=31) @@
2614
2615
2616
class BuniComic(GenericNavigableComic):
2617
    """Class to retrieve Buni Comics."""
2618
    name = 'buni'
2619
    long_name = 'BuniComics'
2620
    url = 'http://www.bunicomic.com'
2621
    get_first_comic_link = get_a_comicnavbase_comicnavfirst
2622
    get_navi_link = get_link_rel_next
2623
2624
    @classmethod
2625
    def get_comic_info(cls, soup, link):
2626
        """Get information about a particular comics."""
2627
        imgs = soup.find('div', id='comic').find_all('img')
2628
        assert all(i['alt'] == i['title'] for i in imgs)
2629
        assert len(imgs) == 1
2630
        return {
2631
            'img': [i['src'] for i in imgs],
2632
            'title': imgs[0]['title'],
2633
        }
2634
2635
2636
class GenericCommitStrip(GenericNavigableComic):
2637
    """Generic class to retrieve Commit Strips in different languages."""
2638
    get_navi_link = get_a_rel_next
2639
2640
    @classmethod
2641
    def get_comic_info(cls, soup, link):
2642
        """Get information about a particular comics."""
2643
        desc = soup.find('meta', property='og:description')['content']
2644
        title = soup.find('meta', property='og:title')['content']
2645
        imgs = soup.find('div', class_='entry-content').find_all('img')
2646
        title2 = ' '.join(i.get('title', '') for i in imgs)
2647
        return {
2648
            'title': title,
2649
            'title2': title2,
2650
            'description': desc,
@@ 437-466 (lines=30) @@
434
class UneAnneeAuLycee(GenericLeMondeBlog):
435
    """Class to retrieve Une Annee Au Lycee comics."""
436
    name = 'lycee'
437
    long_name = 'Une Annee au Lycee'
438
    url = 'http://uneanneeaulycee.blog.lemonde.fr'
439
440
    @classmethod
441
    def get_first_comic_url(cls):
442
        return "http://uneanneeaulycee.blog.lemonde.fr/2016/06/13/la-semaine-du-bac-est-arrivee/"
443
444
445
class Rall(GenericNavigableComic):
446
    """Class to retrieve Ted Rall comics."""
447
    # Also on http://www.gocomics.com/tedrall
448
    name = 'rall'
449
    long_name = "Ted Rall"
450
    url = "http://rall.com/comic"
451
    get_navi_link = get_link_rel_next
452
453
    @classmethod
454
    def get_first_comic_link(cls):
455
        """Get link to first comics."""
456
        # Not the first but I didn't find an efficient way to retrieve it
457
        return {'href': "http://rall.com/2014/01/30/los-angeles-times-cartoon-well-miss-those-california-flowers"}
458
459
    @classmethod
460
    def get_comic_info(cls, soup, link):
461
        """Get information about a particular comics."""
462
        title = soup.find('meta', property='og:title')['content']
463
        author = soup.find("span", class_="author vcard").find("a").string
464
        date_str = soup.find("span", class_="entry-date").string
465
        day = string_to_date(date_str, "%B %d, %Y")
466
        desc = soup.find('meta', property='og:description')['content']
467
        imgs = soup.find('div', class_='entry-content').find_all('img')
468
        imgs = imgs[:-7]  # remove social media buttons
469
        return {