Code Duplication    Length = 22-25 lines in 4 locations

comics.py 4 locations

@@ 2285-2309 (lines=25) @@
2282
        }
2283
2284
2285
class LinsEditions(GenericNavigableComic):
2286
    """Class to retrieve L.I.N.S. Editions comics."""
2287
    # Also on http://linscomics.tumblr.com
2288
    # Now on https://warandpeas.com
2289
    name = 'lins'
2290
    long_name = 'L.I.N.S. Editions'
2291
    url = 'https://linsedition.com'
2292
    _categories = ('LINS', )
2293
    get_navi_link = get_link_rel_next
2294
    get_first_comic_link = simulate_first_link
2295
    first_url = 'https://linsedition.com/2011/09/07/l-i-n-s/'
2296
2297
    @classmethod
2298
    def get_comic_info(cls, soup, link):
2299
        """Get information about a particular comics."""
2300
        title = soup.find('meta', property='og:title')['content']
2301
        imgs = soup.find_all('meta', property='og:image')
2302
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
2303
        day = string_to_date(date_str, "%Y-%m-%d")
2304
        return {
2305
            'title': title,
2306
            'img': [i['content'] for i in imgs],
2307
            'month': day.month,
2308
            'year': day.year,
2309
            'day': day.day,
2310
        }
2311
2312
@@ 1020-1044 (lines=25) @@
1017
        }
1018
1019
1020
class Mercworks(GenericNavigableComic):
1021
    """Class to retrieve Mercworks comics."""
1022
    # Also on http://mercworks.tumblr.com
1023
    name = 'mercworks'
1024
    long_name = 'Mercworks'
1025
    url = 'http://mercworks.net'
1026
    get_first_comic_link = get_a_comicnavbase_comicnavfirst
1027
    get_navi_link = get_link_rel_next
1028
1029
    @classmethod
1030
    def get_comic_info(cls, soup, link):
1031
        """Get information about a particular comics."""
1032
        title = soup.find('meta', property='og:title')['content']
1033
        metadesc = soup.find('meta', property='og:description')
1034
        desc = metadesc['content'] if metadesc else ""
1035
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
1036
        day = string_to_date(date_str, "%Y-%m-%d")
1037
        imgs = soup.find_all('meta', property='og:image')
1038
        return {
1039
            'img': [i['content'] for i in imgs],
1040
            'title': title,
1041
            'desc': desc,
1042
            'day': day.day,
1043
            'month': day.month,
1044
            'year': day.year
1045
        }
1046
1047
@@ 355-377 (lines=23) @@
352
        return []
353
354
355
class ExtraFabulousComics(GenericNavigableComic):
356
    """Class to retrieve Extra Fabulous Comics."""
357
    name = 'efc'
358
    long_name = 'Extra Fabulous Comics'
359
    url = 'http://extrafabulouscomics.com'
360
    get_first_comic_link = get_a_navi_navifirst
361
    get_navi_link = get_link_rel_next
362
363
    @classmethod
364
    def get_comic_info(cls, soup, link):
365
        """Get information about a particular comics."""
366
        img_src_re = re.compile('^%s/wp-content/uploads/' % cls.url)
367
        imgs = soup.find_all('img', src=img_src_re)
368
        title = soup.find('meta', property='og:title')['content']
369
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
370
        day = string_to_date(date_str, "%Y-%m-%d")
371
        return {
372
            'title': title,
373
            'img': [i['src'] for i in imgs],
374
            'month': day.month,
375
            'year': day.year,
376
            'day': day.day,
377
            'prefix': title + '-'
378
        }
379
380
@@ 3194-3215 (lines=22) @@
3191
        }
3192
3193
3194
class MarketoonistComics(GenericNavigableComic):
3195
    """Class to retrieve Marketoonist Comics."""
3196
    name = 'marketoonist'
3197
    long_name = 'Marketoonist'
3198
    url = 'https://marketoonist.com/cartoons'
3199
    get_first_comic_link = simulate_first_link
3200
    get_navi_link = get_link_rel_next
3201
    first_url = 'https://marketoonist.com/2002/10/the-8-types-of-brand-managers-2.html'
3202
3203
    @classmethod
3204
    def get_comic_info(cls, soup, link):
3205
        """Get information about a particular comics."""
3206
        imgs = soup.find_all('meta', property='og:image')
3207
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
3208
        day = string_to_date(date_str, "%Y-%m-%d")
3209
        title = soup.find('meta', property='og:title')['content']
3210
        return {
3211
            'img': [i['content'] for i in imgs],
3212
            'day': day.day,
3213
            'month': day.month,
3214
            'year': day.year,
3215
            'title': title,
3216
        }
3217
3218