Code Duplication    Length = 26-28 lines in 2 locations

comics.py 2 locations

@@ 1384-1411 (lines=28) @@
1381
    def get_next_comic(cls, last_comic):
1382
        archive_url = '%s/archive' % cls.url
1383
        last_num = last_comic['num'] if last_comic else 0
1384
        comic_url_re = re.compile('^%s/([0-9]*)$' % cls.url)
1385
        comic_img_re = re.compile('^%s/strips/.*' % cls.url)
1386
        for link in get_soup_at_url(archive_url).find_all('a', href=comic_url_re):
1387
            comic_url = link['href']
1388
            num = int(comic_url_re.match(comic_url).groups()[0])
1389
            if num > last_num:
1390
                yield {
1391
                    'url': comic_url,
1392
                    'num': num,
1393
                    'title': link.string,
1394
                    'img': [get_soup_at_url(comic_url).find('img', src=comic_img_re)['src']]
1395
                }
1396
1397
1398
class PhDComics(GenericNavigableComic):
1399
    """Class to retrieve PHD Comics."""
1400
    name = 'phd'
1401
    long_name = 'PhD Comics'
1402
    url = 'http://phdcomics.com/comics/archive.php'
1403
    get_url_from_link = join_cls_url_to_href
1404
1405
    @classmethod
1406
    def get_first_comic_link(cls):
1407
        """Get link to first comics."""
1408
        return get_soup_at_url(cls.url).find('img', src='images/first_button.gif').parent
1409
1410
    @classmethod
1411
    def get_navi_link(cls, last_soup, next_):
1412
        img = last_soup.find('img', src='images/next_button.gif' if next_ else 'images/prev_button.gif')
1413
        return None if img is None else img.parent
1414
@@ 1922-1947 (lines=26) @@
1919
        assert all(i['title'] == i['alt'] == title for i in imgs)
1920
        return {
1921
            'month': day.month,
1922
            'year': day.year,
1923
            'day': day.day,
1924
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
1925
            'title': title,
1926
        }
1927
1928
1929
class DiscoBleach(GenericEmptyComic):  # Does not work anymore
1930
    """Class to retrieve Disco Bleach Comics."""
1931
    name = 'discobleach'
1932
    long_name = 'Disco Bleach'
1933
    url = 'http://discobleach.com'
1934
1935
1936
class TubeyToons(GenericEmptyComic):  # Does not work anymore
1937
    """Class to retrieve TubeyToons comics."""
1938
    # Also on http://tapastic.com/series/Tubey-Toons
1939
    # Also on http://tubeytoons.tumblr.com
1940
    name = 'tubeytoons'
1941
    long_name = 'Tubey Toons'
1942
    url = 'http://tubeytoons.com'
1943
1944
1945
class CompletelySeriousComics(GenericNavigableComic):
1946
    """Class to retrieve Completely Serious comics."""
1947
    name = 'completelyserious'
1948
    long_name = 'Completely Serious Comics'
1949
    url = 'http://completelyseriouscomics.com'
1950
    get_first_comic_link = get_a_navi_navifirst