Code Duplication    Length = 24-29 lines in 12 locations

comics.py 12 locations

@@ 2454-2482 (lines=29) @@
2451
        }
2452
2453
2454
class MisterAndMe(GenericNavigableComic):
2455
    """Class to retrieve Mister & Me Comics."""
2456
    # Also on http://www.gocomics.com/mister-and-me
2457
    # Also on https://tapastic.com/series/Mister-and-Me
2458
    name = 'mister'
2459
    long_name = 'Mister & Me'
2460
    url = 'http://www.mister-and-me.com'
2461
    get_first_comic_link = get_a_comicnavbase_comicnavfirst
2462
    get_navi_link = get_link_rel_next
2463
2464
    @classmethod
2465
    def get_comic_info(cls, soup, link):
2466
        """Get information about a particular comics."""
2467
        title = soup.find('h2', class_='post-title').string
2468
        author = soup.find("span", class_="post-author").find("a").string
2469
        date_str = soup.find("span", class_="post-date").string
2470
        day = string_to_date(date_str, "%B %d, %Y")
2471
        imgs = soup.find("div", id="comic").find_all("img")
2472
        assert all(i['alt'] == i['title'] for i in imgs)
2473
        assert len(imgs) <= 1
2474
        alt = imgs[0]['alt'] if imgs else ""
2475
        return {
2476
            'img': [i['src'] for i in imgs],
2477
            'title': title,
2478
            'alt': alt,
2479
            'author': author,
2480
            'day': day.day,
2481
            'month': day.month,
2482
            'year': day.year
2483
        }
2484
2485
@@ 2516-2543 (lines=28) @@
2513
        }
2514
2515
2516
class TalesOfAbsurdity(GenericNavigableComic):
2517
    """Class to retrieve Tales Of Absurdity comics."""
2518
    # Also on http://tapastic.com/series/Tales-Of-Absurdity
2519
    # Also on http://talesofabsurdity.tumblr.com
2520
    name = 'absurdity'
2521
    long_name = 'Tales of Absurdity'
2522
    url = 'http://talesofabsurdity.com'
2523
    get_first_comic_link = get_a_navi_navifirst
2524
    get_navi_link = get_a_navi_comicnavnext_navinext
2525
2526
    @classmethod
2527
    def get_comic_info(cls, soup, link):
2528
        """Get information about a particular comics."""
2529
        title = soup.find('h2', class_='post-title').string
2530
        author = soup.find("span", class_="post-author").find("a").string
2531
        date_str = soup.find("span", class_="post-date").string
2532
        day = string_to_date(date_str, "%B %d, %Y")
2533
        imgs = soup.find("div", id="comic").find_all("img")
2534
        assert all(i['alt'] == i['title'] for i in imgs)
2535
        alt = imgs[0]['alt'] if imgs else ""
2536
        return {
2537
            'img': [i['src'] for i in imgs],
2538
            'title': title,
2539
            'alt': alt,
2540
            'author': author,
2541
            'day': day.day,
2542
            'month': day.month,
2543
            'year': day.year
2544
        }
2545
2546
@@ 2486-2512 (lines=27) @@
2483
        }
2484
2485
2486
class LastPlaceComics(GenericNavigableComic):
2487
    """Class to retrieve Last Place Comics."""
2488
    name = 'lastplace'
2489
    long_name = 'Last Place Comics'
2490
    url = "http://lastplacecomics.com"
2491
    get_first_comic_link = get_a_comicnavbase_comicnavfirst
2492
    get_navi_link = get_link_rel_next
2493
2494
    @classmethod
2495
    def get_comic_info(cls, soup, link):
2496
        """Get information about a particular comics."""
2497
        title = soup.find('h2', class_='post-title').string
2498
        author = soup.find("span", class_="post-author").find("a").string
2499
        date_str = soup.find("span", class_="post-date").string
2500
        day = string_to_date(date_str, "%B %d, %Y")
2501
        imgs = soup.find("div", id="comic").find_all("img")
2502
        assert all(i['alt'] == i['title'] for i in imgs)
2503
        assert len(imgs) <= 1
2504
        alt = imgs[0]['alt'] if imgs else ""
2505
        return {
2506
            'img': [i['src'] for i in imgs],
2507
            'title': title,
2508
            'alt': alt,
2509
            'author': author,
2510
            'day': day.day,
2511
            'month': day.month,
2512
            'year': day.year
2513
        }
2514
2515
@@ 2376-2402 (lines=27) @@
2373
        }
2374
2375
2376
class BiterComics(GenericNavigableComic):
2377
    """Class to retrieve Biter Comics."""
2378
    name = "biter"
2379
    long_name = "Biter Comics"
2380
    url = "http://www.bitercomics.com"
2381
    get_first_comic_link = get_a_navi_navifirst
2382
    get_navi_link = get_link_rel_next
2383
2384
    @classmethod
2385
    def get_comic_info(cls, soup, link):
2386
        """Get information about a particular comics."""
2387
        title = soup.find("h1", class_="entry-title").string
2388
        author = soup.find("span", class_="author vcard").find("a").string
2389
        date_str = soup.find("span", class_="entry-date").string
2390
        day = string_to_date(date_str, "%B %d, %Y")
2391
        imgs = soup.find("div", id="comic").find_all("img")
2392
        assert all(i['alt'] == i['title'] for i in imgs)
2393
        assert len(imgs) == 1
2394
        alt = imgs[0]['alt']
2395
        return {
2396
            'img': [i['src'] for i in imgs],
2397
            'title': title,
2398
            'alt': alt,
2399
            'author': author,
2400
            'day': day.day,
2401
            'month': day.month,
2402
            'year': day.year
2403
        }
2404
2405
@@ 1808-1834 (lines=27) @@
1805
        }
1806
1807
1808
class PicturesInBoxes(GenericNavigableComic):
1809
    """Class to retrieve Pictures In Boxes comics."""
1810
    # Also on http://picturesinboxescomic.tumblr.com
1811
    name = 'picturesinboxes'
1812
    long_name = 'Pictures in Boxes'
1813
    url = 'http://www.picturesinboxes.com'
1814
    get_navi_link = get_a_navi_navinext
1815
    get_first_comic_link = simulate_first_link
1816
    first_url = 'http://www.picturesinboxes.com/2013/10/26/tetris/'
1817
1818
    @classmethod
1819
    def get_comic_info(cls, soup, link):
1820
        """Get information about a particular comics."""
1821
        title = soup.find('h2', class_='post-title').string
1822
        author = soup.find("span", class_="post-author").find("a").string
1823
        date_str = soup.find('span', class_='post-date').string
1824
        day = string_to_date(date_str, '%B %d, %Y')
1825
        imgs = soup.find('div', class_='comicpane').find_all('img')
1826
        assert imgs
1827
        assert all(i['title'] == i['alt'] == title for i in imgs)
1828
        return {
1829
            'day': day.day,
1830
            'month': day.month,
1831
            'year': day.year,
1832
            'img': [i['src'] for i in imgs],
1833
            'title': title,
1834
            'author': author,
1835
        }
1836
1837
@@ 2547-2572 (lines=26) @@
2544
        }
2545
2546
2547
class EndlessOrigami(GenericNavigableComic):
2548
    """Class to retrieve Endless Origami Comics."""
2549
    name = "origami"
2550
    long_name = "Endless Origami"
2551
    url = "http://endlessorigami.com"
2552
    get_first_comic_link = get_a_navi_navifirst
2553
    get_navi_link = get_link_rel_next
2554
2555
    @classmethod
2556
    def get_comic_info(cls, soup, link):
2557
        """Get information about a particular comics."""
2558
        title = soup.find('h2', class_='post-title').string
2559
        author = soup.find("span", class_="post-author").find("a").string
2560
        date_str = soup.find("span", class_="post-date").string
2561
        day = string_to_date(date_str, "%B %d, %Y")
2562
        imgs = soup.find("div", id="comic").find_all("img")
2563
        assert all(i['alt'] == i['title'] for i in imgs)
2564
        alt = imgs[0]['alt'] if imgs else ""
2565
        return {
2566
            'img': [i['src'] for i in imgs],
2567
            'title': title,
2568
            'alt': alt,
2569
            'author': author,
2570
            'day': day.day,
2571
            'month': day.month,
2572
            'year': day.year
2573
        }
2574
2575
@@ 2319-2344 (lines=26) @@
2316
        }
2317
2318
2319
class GerbilWithAJetpack(GenericNavigableComic):
2320
    """Class to retrieve GerbilWithAJetpack comics."""
2321
    name = 'gerbil'
2322
    long_name = 'Gerbil With A Jetpack'
2323
    url = 'http://gerbilwithajetpack.com'
2324
    get_first_comic_link = get_a_navi_navifirst
2325
    get_navi_link = get_a_rel_next
2326
2327
    @classmethod
2328
    def get_comic_info(cls, soup, link):
2329
        """Get information about a particular comics."""
2330
        title = soup.find('h2', class_='post-title').string
2331
        author = soup.find("span", class_="post-author").find("a").string
2332
        date_str = soup.find("span", class_="post-date").string
2333
        day = string_to_date(date_str, "%B %d, %Y")
2334
        imgs = soup.find("div", id="comic").find_all("img")
2335
        alt = imgs[0]['alt']
2336
        assert all(i['alt'] == i['title'] == alt for i in imgs)
2337
        return {
2338
            'img': [i['src'] for i in imgs],
2339
            'title': title,
2340
            'alt': alt,
2341
            'author': author,
2342
            'day': day.day,
2343
            'month': day.month,
2344
            'year': day.year
2345
        }
2346
2347
@@ 2117-2142 (lines=26) @@
2114
        return reversed(get_soup_at_url(archive_url).find('tbody').find_all('tr'))
2115
2116
2117
class HappleTea(GenericNavigableComic):
2118
    """Class to retrieve Happle Tea Comics."""
2119
    name = 'happletea'
2120
    long_name = 'Happle Tea'
2121
    url = 'http://www.happletea.com'
2122
    get_first_comic_link = get_a_navi_navifirst
2123
    get_navi_link = get_link_rel_next
2124
2125
    @classmethod
2126
    def get_comic_info(cls, soup, link):
2127
        """Get information about a particular comics."""
2128
        imgs = soup.find('div', id='comic').find_all('img')
2129
        post = soup.find('div', class_='post-content')
2130
        title = post.find('h2', class_='post-title').string
2131
        author = post.find('a', rel='author').string
2132
        date_str = post.find('span', class_='post-date').string
2133
        day = string_to_date(date_str, "%B %d, %Y")
2134
        assert all(i['alt'] == i['title'] for i in imgs)
2135
        return {
2136
            'title': title,
2137
            'img': [i['src'] for i in imgs],
2138
            'alt': ''.join(i['alt'] for i in imgs),
2139
            'month': day.month,
2140
            'year': day.year,
2141
            'day': day.day,
2142
            'author': author,
2143
        }
2144
2145
@@ 2657-2681 (lines=25) @@
2654
    first_url = 'http://www.commitstrip.com/en/2012/02/22/interview/'
2655
2656
2657
class GenericBoumerie(GenericNavigableComic):
2658
    """Generic class to retrieve Boumeries comics in different languages."""
2659
    get_first_comic_link = get_a_navi_navifirst
2660
    get_navi_link = get_link_rel_next
2661
    date_format = NotImplemented
2662
    lang = NotImplemented
2663
2664
    @classmethod
2665
    def get_comic_info(cls, soup, link):
2666
        """Get information about a particular comics."""
2667
        title = soup.find('h2', class_='post-title').string
2668
        short_url = soup.find('link', rel='shortlink')['href']
2669
        author = soup.find("span", class_="post-author").find("a").string
2670
        date_str = soup.find('span', class_='post-date').string
2671
        day = string_to_date(date_str, cls.date_format, cls.lang)
2672
        imgs = soup.find('div', id='comic').find_all('img')
2673
        assert all(i['alt'] == i['title'] for i in imgs)
2674
        return {
2675
            'short_url': short_url,
2676
            'img': [i['src'] for i in imgs],
2677
            'title': title,
2678
            'author': author,
2679
            'month': day.month,
2680
            'year': day.year,
2681
            'day': day.day,
2682
        }
2683
2684
@@ 2348-2372 (lines=25) @@
2345
        }
2346
2347
2348
class EveryDayBlues(GenericNavigableComic):
2349
    """Class to retrieve EveryDayBlues Comics."""
2350
    name = "blues"
2351
    long_name = "Every Day Blues"
2352
    url = "http://everydayblues.net"
2353
    get_first_comic_link = get_a_navi_navifirst
2354
    get_navi_link = get_link_rel_next
2355
2356
    @classmethod
2357
    def get_comic_info(cls, soup, link):
2358
        """Get information about a particular comics."""
2359
        title = soup.find("h2", class_="post-title").string
2360
        author = soup.find("span", class_="post-author").find("a").string
2361
        date_str = soup.find("span", class_="post-date").string
2362
        day = string_to_date(date_str, "%d. %B %Y", "de_DE.utf8")
2363
        imgs = soup.find("div", id="comic").find_all("img")
2364
        assert all(i['alt'] == i['title'] == title for i in imgs)
2365
        assert len(imgs) <= 1
2366
        return {
2367
            'img': [i['src'] for i in imgs],
2368
            'title': title,
2369
            'author': author,
2370
            'day': day.day,
2371
            'month': day.month,
2372
            'year': day.year
2373
        }
2374
2375
@@ 1697-1721 (lines=25) @@
1694
        }
1695
1696
1697
class MouseBearComedy(GenericNavigableComic):
1698
    """Class to retrieve Mouse Bear Comedy comics."""
1699
    # Also on http://mousebearcomedy.tumblr.com
1700
    name = 'mousebear'
1701
    long_name = 'Mouse Bear Comedy'
1702
    url = 'http://www.mousebearcomedy.com'
1703
    get_first_comic_link = get_a_navi_navifirst
1704
    get_navi_link = get_a_navi_comicnavnext_navinext
1705
1706
    @classmethod
1707
    def get_comic_info(cls, soup, link):
1708
        """Get information about a particular comics."""
1709
        title = soup.find('h2', class_='post-title').string
1710
        author = soup.find("span", class_="post-author").find("a").string
1711
        date_str = soup.find("span", class_="post-date").string
1712
        day = string_to_date(date_str, '%B %d, %Y')
1713
        imgs = soup.find("div", id="comic").find_all("img")
1714
        assert all(i['alt'] == i['title'] == title for i in imgs)
1715
        return {
1716
            'day': day.day,
1717
            'month': day.month,
1718
            'year': day.year,
1719
            'img': [i['src'] for i in imgs],
1720
            'title': title,
1721
            'author': author,
1722
        }
1723
1724
@@ 1104-1127 (lines=24) @@
1101
    url = 'http://english.bouletcorp.com'
1102
1103
1104
class AmazingSuperPowers(GenericNavigableComic):
1105
    """Class to retrieve Amazing Super Powers comics."""
1106
    name = 'asp'
1107
    long_name = 'Amazing Super Powers'
1108
    url = 'http://www.amazingsuperpowers.com'
1109
    get_first_comic_link = get_a_navi_navifirst
1110
    get_navi_link = get_a_navi_navinext
1111
1112
    @classmethod
1113
    def get_comic_info(cls, soup, link):
1114
        """Get information about a particular comics."""
1115
        author = soup.find("span", class_="post-author").find("a").string
1116
        date_str = soup.find('span', class_='post-date').string
1117
        day = string_to_date(date_str, "%B %d, %Y")
1118
        imgs = soup.find('div', id='comic').find_all('img')
1119
        title = ' '.join(i['title'] for i in imgs)
1120
        assert all(i['alt'] == i['title'] for i in imgs)
1121
        return {
1122
            'title': title,
1123
            'author': author,
1124
            'img': [img['src'] for img in imgs],
1125
            'day': day.day,
1126
            'month': day.month,
1127
            'year': day.year
1128
        }
1129
1130