Code Duplication    Length = 21-23 lines in 3 locations

comics.py 3 locations

@@ 645-667 (lines=23) @@
642
            'day': day.day,
643
        }
644
645
646
class OneOneOneOneComic(GenericNavigableComic):
647
    """Class to retrieve 1111 Comics."""
648
    # Also on http://comics1111.tumblr.com
649
    # Also on https://tapastic.com/series/1111-Comics
650
    name = '1111'
651
    long_name = '1111 Comics'
652
    url = 'http://www.1111comics.me'
653
    get_first_comic_link = get_div_navfirst_a
654
    get_navi_link = get_link_rel_next
655
656
    @classmethod
657
    def get_comic_info(cls, soup, link):
658
        """Get information about a particular comics."""
659
        title = soup.find('h1', class_='comic-title').find('a').string
660
        date_str = soup.find('header', class_='comic-meta entry-meta').find('a').string
661
        day = string_to_date(date_str, "%B %d, %Y")
662
        imgs = soup.find_all('meta', property='og:image')
663
        return {
664
            'title': title,
665
            'month': day.month,
666
            'year': day.year,
667
            'day': day.day,
668
            'img': [i['content'] for i in imgs],
669
        }
670
@@ 620-641 (lines=22) @@
617
            'tags': tags,
618
        }
619
620
621
class PenelopeBagieu(GenericNavigableComic):
622
    """Class to retrieve comics from Penelope Bagieu's blog."""
623
    name = 'bagieu'
624
    long_name = 'Ma vie est tout a fait fascinante (Bagieu)'
625
    url = 'http://www.penelope-jolicoeur.com'
626
    get_navi_link = get_link_rel_next
627
    get_first_comic_link = simulate_first_link
628
    first_url = 'http://www.penelope-jolicoeur.com/2007/02/ma-vie-mon-oeuv.html'
629
630
    @classmethod
631
    def get_comic_info(cls, soup, link):
632
        """Get information about a particular comics."""
633
        date_str = soup.find('h2', class_='date-header').string
634
        day = string_to_date(date_str, "%A %d %B %Y", "fr_FR.utf8")
635
        imgs = soup.find('div', class_='entry-body').find_all('img')
636
        title = soup.find('h3', class_='entry-header').string
637
        return {
638
            'title': title,
639
            'img': [i['src'] for i in imgs],
640
            'month': day.month,
641
            'year': day.year,
642
            'day': day.day,
643
        }
644
@@ 1650-1670 (lines=21) @@
1647
            'alt': alt,
1648
            'tags': ' '.join(t.string for t in soup.find('div', class_='postmeta').find_all('a', rel='tag')),
1649
        }
1650
1651
1652
class WarehouseComic(GenericNavigableComic):
1653
    """Class to retrieve Warehouse Comic comics."""
1654
    name = 'warehouse'
1655
    long_name = 'Warehouse Comic'
1656
    url = 'http://warehousecomic.com'
1657
    get_first_comic_link = get_a_navi_navifirst
1658
    get_navi_link = get_link_rel_next
1659
1660
    @classmethod
1661
    def get_comic_info(cls, soup, link):
1662
        """Get information about a particular comics."""
1663
        title = soup.find('h2', class_='post-title').string
1664
        date_str = soup.find('span', class_='post-date').string
1665
        day = string_to_date(date_str, "%B %d, %Y")
1666
        imgs = soup.find('div', id='comic').find_all('img')
1667
        return {
1668
            'img': [i['src'] for i in imgs],
1669
            'title': title,
1670
            'day': day.day,
1671
            'month': day.month,
1672
            'year': day.year,
1673
        }