Code Duplication    Length = 21-22 lines in 3 locations

comics.py 3 locations

@@ 694-715 (lines=22) @@
691
            'img': [i['content'] for i in imgs],
692
        }
693
694
695
class NeDroid(GenericNavigableComic):
696
    """Class to retrieve NeDroid comics."""
697
    name = 'nedroid'
698
    long_name = 'NeDroid'
699
    url = 'http://nedroid.com'
700
    get_first_comic_link = get_div_navfirst_a
701
    get_navi_link = get_link_rel_next
702
    get_url_from_link = join_cls_url_to_href
703
704
    @classmethod
705
    def get_comic_info(cls, soup, link):
706
        """Get information about a particular comics."""
707
        short_url_re = re.compile('^%s/\\?p=([0-9]*)' % cls.url)
708
        comic_url_re = re.compile('//nedroid.com/comics/([0-9]*)-([0-9]*)-([0-9]*).*')
709
        short_url = cls.get_url_from_link(soup.find('link', rel='shortlink'))
710
        num = int(short_url_re.match(short_url).groups()[0])
711
        imgs = soup.find('div', id='comic').find_all('img')
712
        year, month, day = [int(s) for s in comic_url_re.match(imgs[0]['src']).groups()]
713
        assert len(imgs) == 1
714
        title = imgs[0]['alt']
715
        title2 = imgs[0]['title']
716
        return {
717
            'short_url': short_url,
718
            'title': title,
@@ 643-664 (lines=22) @@
640
            'day': day.day,
641
        }
642
643
644
class OneOneOneOneComic(GenericNavigableComic):
645
    """Class to retrieve 1111 Comics."""
646
    # Also on http://comics1111.tumblr.com
647
    # Also on https://tapastic.com/series/1111-Comics
648
    name = '1111'
649
    long_name = '1111 Comics'
650
    url = 'http://www.1111comics.me'
651
    get_first_comic_link = get_div_navfirst_a
652
    get_navi_link = get_link_rel_next
653
654
    @classmethod
655
    def get_comic_info(cls, soup, link):
656
        """Get information about a particular comics."""
657
        title = soup.find('h1', class_='comic-title').find('a').string
658
        date_str = soup.find('header', class_='comic-meta entry-meta').find('a').string
659
        day = string_to_date(date_str, "%B %d, %Y")
660
        imgs = soup.find_all('meta', property='og:image')
661
        return {
662
            'title': title,
663
            'month': day.month,
664
            'year': day.year,
665
            'day': day.day,
666
            'img': [i['content'] for i in imgs],
667
        }
@@ 2600-2620 (lines=21) @@
2597
        }
2598
2599
2600
class BuniComic(GenericNavigableComic):
2601
    """Class to retrieve Buni Comics."""
2602
    name = 'buni'
2603
    long_name = 'BuniComics'
2604
    url = 'http://www.bunicomic.com'
2605
    get_first_comic_link = get_a_comicnavbase_comicnavfirst
2606
    get_navi_link = get_link_rel_next
2607
2608
    @classmethod
2609
    def get_comic_info(cls, soup, link):
2610
        """Get information about a particular comics."""
2611
        imgs = soup.find('div', id='comic').find_all('img')
2612
        assert all(i['alt'] == i['title'] for i in imgs)
2613
        assert len(imgs) == 1
2614
        return {
2615
            'img': [i['src'] for i in imgs],
2616
            'title': imgs[0]['title'],
2617
        }
2618
2619
2620
class GenericCommitStrip(GenericNavigableComic):
2621
    """Generic class to retrieve Commit Strips in different languages."""
2622
    get_navi_link = get_a_rel_next
2623
    get_first_comic_link = simulate_first_link