Code Duplication    Length = 23-28 lines in 5 locations

comics.py 5 locations

@@ 1092-1119 (lines=28) @@
1089
        }
1090
1091
1092
class Mercworks(GenericDeletedComic):  # Moved to Webtoons
1093
    """Class to retrieve Mercworks comics."""
1094
    # Also on http://mercworks.tumblr.com
1095
    # Also on http://www.webtoons.com/en/comedy/mercworks/list?title_no=426
1096
    # Also on https://tapastic.com/series/MercWorks
1097
    name = 'mercworks'
1098
    long_name = 'Mercworks'
1099
    url = 'http://mercworks.net'
1100
    _categories = ('MERCWORKS', )
1101
    get_first_comic_link = get_a_comicnavbase_comicnavfirst
1102
    get_navi_link = get_link_rel_next
1103
1104
    @classmethod
1105
    def get_comic_info(cls, soup, link):
1106
        """Get information about a particular comics."""
1107
        title = soup.find('meta', property='og:title')['content']
1108
        metadesc = soup.find('meta', property='og:description')
1109
        desc = metadesc['content'] if metadesc else ""
1110
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
1111
        day = string_to_date(date_str, "%Y-%m-%d")
1112
        imgs = soup.find_all('meta', property='og:image')
1113
        return {
1114
            'img': [i['content'] for i in imgs],
1115
            'title': title,
1116
            'desc': desc,
1117
            'day': day.day,
1118
            'month': day.month,
1119
            'year': day.year
1120
        }
1121
1122
@@ 405-430 (lines=26) @@
402
    _categories = ('DELETED', )
403
404
405
class ExtraFabulousComics(GenericNavigableComic):
406
    """Class to retrieve Extra Fabulous Comics."""
407
    # Also on https://extrafabulouscomics.tumblr.com
408
    name = 'efc'
409
    long_name = 'Extra Fabulous Comics'
410
    url = 'http://extrafabulouscomics.com'
411
    _categories = ('EFC', )
412
    get_navi_link = get_link_rel_next
413
    get_first_comic_link = simulate_first_link
414
    first_url = 'http://extrafabulouscomics.com/comic/buttfly/'
415
416
    @classmethod
417
    def get_comic_info(cls, soup, link):
418
        """Get information about a particular comics."""
419
        img_src_re = re.compile('^%s/wp-content/uploads/' % cls.url)
420
        imgs = soup.find_all('img', src=img_src_re)
421
        title = soup.find('meta', property='og:title')['content']
422
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
423
        day = string_to_date(date_str, "%Y-%m-%d")
424
        return {
425
            'title': title,
426
            'img': [i['src'] for i in imgs],
427
            'month': day.month,
428
            'year': day.year,
429
            'day': day.day,
430
            'prefix': title + '-'
431
        }
432
433
@@ 2483-2505 (lines=23) @@
2480
    @classmethod
2481
    def get_comic_info(cls, soup, link):
2482
        """Get information about a particular comics."""
2483
        title = soup.find('h2', class_='post-title').string
2484
        post = soup.find('div', class_='post-content')
2485
        author = post.find("span", class_="post-author").find("a").string
2486
        date_str = post.find("span", class_="post-date").string
2487
        day = string_to_date(date_str, "%B %d, %Y")
2488
        imgs = post.find("div", class_="entry").find_all("img")
2489
        return {
2490
            'title': title,
2491
            'author': author,
2492
            'img': [i['src'] for i in imgs],
2493
            'month': day.month,
2494
            'year': day.year,
2495
            'day': day.day,
2496
        }
2497
2498
2499
class LinsEditions(GenericDeletedComic):  # Permanently moved to warandpeas
2500
    """Class to retrieve L.I.N.S. Editions comics."""
2501
    # Also on https://linscomics.tumblr.com
2502
    # Now on https://warandpeas.com
2503
    name = 'lins'
2504
    long_name = 'L.I.N.S. Editions'
2505
    url = 'https://linsedition.com'
2506
    _categories = ('WARANDPEAS', 'LINS')
2507
2508
@@ 1879-1904 (lines=26) @@
1876
class SafelyEndangered(GenericNavigableComic):
1877
    """Class to retrieve Safely Endangered comics."""
1878
    # Also on http://tumblr.safelyendangered.com
1879
    name = 'endangered'
1880
    long_name = 'Safely Endangered'
1881
    url = 'http://www.safelyendangered.com'
1882
    get_navi_link = get_link_rel_next
1883
    get_first_comic_link = simulate_first_link
1884
    first_url = 'http://www.safelyendangered.com/comic/ignored/'
1885
1886
    @classmethod
1887
    def get_comic_info(cls, soup, link):
1888
        """Get information about a particular comics."""
1889
        title = soup.find('h2', class_='post-title').string
1890
        date_str = soup.find('span', class_='post-date').string
1891
        day = string_to_date(date_str, '%B %d, %Y')
1892
        imgs = soup.find('div', id='comic').find_all('img')
1893
        alt = imgs[0]['alt']
1894
        assert all(i['alt'] == i['title'] for i in imgs)
1895
        return {
1896
            'day': day.day,
1897
            'month': day.month,
1898
            'year': day.year,
1899
            'img': [i['src'] for i in imgs],
1900
            'title': title,
1901
            'alt': alt,
1902
        }
1903
1904
1905
class PicturesInBoxes(GenericNavigableComic):
1906
    """Class to retrieve Pictures In Boxes comics."""
1907
    # Also on https://picturesinboxescomic.tumblr.com
@@ 2371-2396 (lines=26) @@
2368
        }
2369
2370
2371
class RandomCrab(GenericNavigableComic):
2372
    """Class to retrieve Random Crab comics."""
2373
    name = 'randomcrab'
2374
    long_name = 'Random Crab'
2375
    url = 'https://randomcrab.com'
2376
    get_navi_link = get_a_rel_next
2377
    get_first_comic_link = simulate_first_link
2378
    first_url = 'https://randomcrab.com/natural-elephant/'
2379
2380
    @classmethod
2381
    def get_comic_info(cls, soup, link):
2382
        """Get information about a particular comics."""
2383
        title = soup.find('meta', property='og:title')['content']
2384
        desc = soup.find('meta', property='og:description')['content']
2385
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
2386
        day = string_to_date(date_str, "%Y-%m-%d")
2387
        imgs = soup.find_all('meta', property='og:image')
2388
        author = soup.find('a', rel='author').string
2389
        return {
2390
            'title': title,
2391
            'desc': desc,
2392
            'img': [i['content'] for i in imgs],
2393
            'month': day.month,
2394
            'year': day.year,
2395
            'day': day.day,
2396
            'author': author,
2397
        }
2398
2399