Code Duplication    Length = 22-26 lines in 7 locations

comics.py 7 locations

@@ 387-412 (lines=26) @@
384
    _categories = ('DELETED', )
385
386
387
class ExtraFabulousComics(GenericNavigableComic):
388
    """Class to retrieve Extra Fabulous Comics."""
389
    # Also on https://extrafabulouscomics.tumblr.com
390
    name = 'efc'
391
    long_name = 'Extra Fabulous Comics'
392
    url = 'http://extrafabulouscomics.com'
393
    _categories = ('EFC', )
394
    get_navi_link = get_link_rel_next
395
    get_first_comic_link = simulate_first_link
396
    first_url = 'http://extrafabulouscomics.com/comic/buttfly/'
397
398
    @classmethod
399
    def get_comic_info(cls, soup, link):
400
        """Get information about a particular comics."""
401
        img_src_re = re.compile('^%s/wp-content/uploads/' % cls.url)
402
        imgs = soup.find_all('img', src=img_src_re)
403
        title = soup.find('meta', property='og:title')['content']
404
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
405
        day = string_to_date(date_str, "%Y-%m-%d")
406
        return {
407
            'title': title,
408
            'img': [i['src'] for i in imgs],
409
            'month': day.month,
410
            'year': day.year,
411
            'day': day.day,
412
            'prefix': title + '-'
413
        }
414
415
@@ 1074-1098 (lines=25) @@
1071
        }
1072
1073
1074
class Mercworks(GenericNavigableComic):
1075
    """Class to retrieve Mercworks comics."""
1076
    # Also on http://mercworks.tumblr.com
1077
    name = 'mercworks'
1078
    long_name = 'Mercworks'
1079
    url = 'http://mercworks.net'
1080
    get_first_comic_link = get_a_comicnavbase_comicnavfirst
1081
    get_navi_link = get_link_rel_next
1082
1083
    @classmethod
1084
    def get_comic_info(cls, soup, link):
1085
        """Get information about a particular comics."""
1086
        title = soup.find('meta', property='og:title')['content']
1087
        metadesc = soup.find('meta', property='og:description')
1088
        desc = metadesc['content'] if metadesc else ""
1089
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
1090
        day = string_to_date(date_str, "%Y-%m-%d")
1091
        imgs = soup.find_all('meta', property='og:image')
1092
        return {
1093
            'img': [i['content'] for i in imgs],
1094
            'title': title,
1095
            'desc': desc,
1096
            'day': day.day,
1097
            'month': day.month,
1098
            'year': day.year
1099
        }
1100
1101
@@ 416-437 (lines=22) @@
413
        }
414
415
416
class GenericLeMondeBlog(GenericNavigableComic):
417
    """Generic class to retrieve comics from Le Monde blogs."""
418
    _categories = ('LEMONDE', 'FRANCAIS')
419
    get_navi_link = get_link_rel_next
420
    get_first_comic_link = simulate_first_link
421
    first_url = NotImplemented
422
423
    @classmethod
424
    def get_comic_info(cls, soup, link):
425
        """Get information about a particular comics."""
426
        url2 = soup.find('link', rel='shortlink')['href']
427
        title = soup.find('meta', property='og:title')['content']
428
        date_str = soup.find("span", class_="entry-date").string
429
        day = string_to_date(date_str, "%d %B %Y", "fr_FR.utf8")
430
        imgs = soup.find_all('meta', property='og:image')
431
        return {
432
            'title': title,
433
            'url2': url2,
434
            'img': [convert_iri_to_plain_ascii_uri(i['content']) for i in imgs],
435
            'month': day.month,
436
            'year': day.year,
437
            'day': day.day,
438
        }
439
440
@@ 986-1011 (lines=26) @@
983
        }
984
985
986
class MyExtraLife(GenericNavigableComic):
987
    """Class to retrieve My Extra Life comics."""
988
    name = 'extralife'
989
    long_name = 'My Extra Life'
990
    url = 'http://www.myextralife.com'
991
    get_navi_link = get_link_rel_next
992
993
    @classmethod
994
    def get_first_comic_link(cls):
995
        """Get link to first comics."""
996
        return get_soup_at_url(cls.url).find('a', class_='comic_nav_link first_comic_link')
997
998
    @classmethod
999
    def get_comic_info(cls, soup, link):
1000
        """Get information about a particular comics."""
1001
        title = soup.find("h1", class_="comic_title").string
1002
        date_str = soup.find("span", class_="comic_date").string
1003
        day = string_to_date(date_str, "%B %d, %Y")
1004
        imgs = soup.find_all("img", class_="comic")
1005
        assert all(i['alt'] == i['title'] == title for i in imgs)
1006
        return {
1007
            'title': title,
1008
            'img': [i['src'] for i in imgs if i["src"]],
1009
            'day': day.day,
1010
            'month': day.month,
1011
            'year': day.year
1012
        }
1013
1014
@@ 2393-2417 (lines=25) @@
2390
        }
2391
2392
2393
class LinsEditions(GenericNavigableComic):
2394
    """Class to retrieve L.I.N.S. Editions comics."""
2395
    # Also on https://linscomics.tumblr.com
2396
    # Now on https://warandpeas.com
2397
    name = 'lins'
2398
    long_name = 'L.I.N.S. Editions'
2399
    url = 'https://linsedition.com'
2400
    _categories = ('LINS', )
2401
    get_navi_link = get_link_rel_next
2402
    get_first_comic_link = simulate_first_link
2403
    first_url = 'https://linsedition.com/2011/09/07/l-i-n-s/'
2404
2405
    @classmethod
2406
    def get_comic_info(cls, soup, link):
2407
        """Get information about a particular comics."""
2408
        title = soup.find('meta', property='og:title')['content']
2409
        imgs = soup.find_all('meta', property='og:image')
2410
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
2411
        day = string_to_date(date_str, "%Y-%m-%d")
2412
        return {
2413
            'title': title,
2414
            'img': [i['content'] for i in imgs],
2415
            'month': day.month,
2416
            'year': day.year,
2417
            'day': day.day,
2418
        }
2419
2420
@@ 3355-3376 (lines=22) @@
3352
        }
3353
3354
3355
class OffTheLeashDog(GenericNavigableComic):
3356
    """Class to retrieve Off The Leash Dog comics."""
3357
    # Also on http://rupertfawcettsdoggyblog.tumblr.com
3358
    # Also on http://www.rupertfawcettcartoons.com
3359
    name = 'offtheleash'
3360
    long_name = 'Off The Leash Dog'
3361
    url = 'http://offtheleashdogcartoons.com'
3362
    _categories = ('FAWCETT', )
3363
    get_navi_link = get_a_rel_next
3364
    get_first_comic_link = simulate_first_link
3365
    first_url = 'http://offtheleashdogcartoons.com/uncategorized/can-i-help-you/'
3366
3367
    @classmethod
3368
    def get_comic_info(cls, soup, link):
3369
        """Get information about a particular comics."""
3370
        title = soup.find("h1", class_="entry-title").string
3371
        imgs = soup.find('div', class_='entry-content').find_all('img')
3372
        return {
3373
            'title': title,
3374
            'img': [i['src'] for i in imgs],
3375
        }
3376
3377
3378
class MarketoonistComics(GenericNavigableComic):
3379
    """Class to retrieve Marketoonist Comics."""
@@ 2294-2318 (lines=25) @@
2291
        }
2292
2293
2294
class JuliasDrawings(GenericListableComic):
2295
    """Class to retrieve Julia's Drawings."""
2296
    name = 'julia'
2297
    long_name = "Julia's Drawings"
2298
    url = 'https://drawings.jvns.ca'
2299
    get_url_from_archive_element = get_href
2300
2301
    @classmethod
2302
    def get_archive_elements(cls):
2303
        articles = get_soup_at_url(cls.url).find_all('article', class_='li post')
2304
        return [art.find('a') for art in reversed(articles)]
2305
2306
    @classmethod
2307
    def get_comic_info(cls, soup, archive_elt):
2308
        """Get information about a particular comics."""
2309
        date_str = soup.find('meta', property='og:article:published_time')['content'][:10]
2310
        day = string_to_date(date_str, "%Y-%m-%d")
2311
        title = soup.find('h3', class_='p-post-title').string
2312
        imgs = soup.find('section', class_='post-content').find_all('img')
2313
        return {
2314
            'title': title,
2315
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
2316
            'month': day.month,
2317
            'year': day.year,
2318
            'day': day.day,
2319
        }
2320
2321