Code Duplication    Length = 24-28 lines in 14 locations

comics.py 14 locations

@@ 2516-2543 (lines=28) @@
2513
            'year': day.year
2514
        }
2515
2516
2517
class TalesOfAbsurdity(GenericNavigableComic):
2518
    """Class to retrieve Tales Of Absurdity comics."""
2519
    # Also on http://tapastic.com/series/Tales-Of-Absurdity
2520
    # Also on http://talesofabsurdity.tumblr.com
2521
    name = 'absurdity'
2522
    long_name = 'Tales of Absurdity'
2523
    url = 'http://talesofabsurdity.com'
2524
    get_first_comic_link = get_a_navi_navifirst
2525
    get_navi_link = get_a_navi_comicnavnext_navinext
2526
2527
    @classmethod
2528
    def get_comic_info(cls, soup, link):
2529
        """Get information about a particular comics."""
2530
        title = soup.find('h2', class_='post-title').string
2531
        author = soup.find("span", class_="post-author").find("a").string
2532
        date_str = soup.find("span", class_="post-date").string
2533
        day = string_to_date(date_str, "%B %d, %Y")
2534
        imgs = soup.find("div", id="comic").find_all("img")
2535
        assert all(i['alt'] == i['title'] for i in imgs)
2536
        alt = imgs[0]['alt'] if imgs else ""
2537
        return {
2538
            'img': [i['src'] for i in imgs],
2539
            'title': title,
2540
            'alt': alt,
2541
            'author': author,
2542
            'day': day.day,
2543
            'month': day.month,
2544
            'year': day.year
2545
        }
2546
@@ 2486-2512 (lines=27) @@
2483
            'year': day.year
2484
        }
2485
2486
2487
class LastPlaceComics(GenericNavigableComic):
2488
    """Class to retrieve Last Place Comics."""
2489
    name = 'lastplace'
2490
    long_name = 'Last Place Comics'
2491
    url = "http://lastplacecomics.com"
2492
    get_first_comic_link = get_a_comicnavbase_comicnavfirst
2493
    get_navi_link = get_link_rel_next
2494
2495
    @classmethod
2496
    def get_comic_info(cls, soup, link):
2497
        """Get information about a particular comics."""
2498
        title = soup.find('h2', class_='post-title').string
2499
        author = soup.find("span", class_="post-author").find("a").string
2500
        date_str = soup.find("span", class_="post-date").string
2501
        day = string_to_date(date_str, "%B %d, %Y")
2502
        imgs = soup.find("div", id="comic").find_all("img")
2503
        assert all(i['alt'] == i['title'] for i in imgs)
2504
        assert len(imgs) <= 1
2505
        alt = imgs[0]['alt'] if imgs else ""
2506
        return {
2507
            'img': [i['src'] for i in imgs],
2508
            'title': title,
2509
            'alt': alt,
2510
            'author': author,
2511
            'day': day.day,
2512
            'month': day.month,
2513
            'year': day.year
2514
        }
2515
@@ 2376-2402 (lines=27) @@
2373
            'year': day.year
2374
        }
2375
2376
2377
class BiterComics(GenericNavigableComic):
2378
    """Class to retrieve Biter Comics."""
2379
    name = "biter"
2380
    long_name = "Biter Comics"
2381
    url = "http://www.bitercomics.com"
2382
    get_first_comic_link = get_a_navi_navifirst
2383
    get_navi_link = get_link_rel_next
2384
2385
    @classmethod
2386
    def get_comic_info(cls, soup, link):
2387
        """Get information about a particular comics."""
2388
        title = soup.find("h1", class_="entry-title").string
2389
        author = soup.find("span", class_="author vcard").find("a").string
2390
        date_str = soup.find("span", class_="entry-date").string
2391
        day = string_to_date(date_str, "%B %d, %Y")
2392
        imgs = soup.find("div", id="comic").find_all("img")
2393
        assert all(i['alt'] == i['title'] for i in imgs)
2394
        assert len(imgs) == 1
2395
        alt = imgs[0]['alt']
2396
        return {
2397
            'img': [i['src'] for i in imgs],
2398
            'title': title,
2399
            'alt': alt,
2400
            'author': author,
2401
            'day': day.day,
2402
            'month': day.month,
2403
            'year': day.year
2404
        }
2405
@@ 1808-1834 (lines=27) @@
1805
            'alt': alt,
1806
        }
1807
1808
1809
class PicturesInBoxes(GenericNavigableComic):
1810
    """Class to retrieve Pictures In Boxes comics."""
1811
    # Also on http://picturesinboxescomic.tumblr.com
1812
    name = 'picturesinboxes'
1813
    long_name = 'Pictures in Boxes'
1814
    url = 'http://www.picturesinboxes.com'
1815
    get_navi_link = get_a_navi_navinext
1816
    get_first_comic_link = simulate_first_link
1817
    first_url = 'http://www.picturesinboxes.com/2013/10/26/tetris/'
1818
1819
    @classmethod
1820
    def get_comic_info(cls, soup, link):
1821
        """Get information about a particular comics."""
1822
        title = soup.find('h2', class_='post-title').string
1823
        author = soup.find("span", class_="post-author").find("a").string
1824
        date_str = soup.find('span', class_='post-date').string
1825
        day = string_to_date(date_str, '%B %d, %Y')
1826
        imgs = soup.find('div', class_='comicpane').find_all('img')
1827
        assert imgs
1828
        assert all(i['title'] == i['alt'] == title for i in imgs)
1829
        return {
1830
            'day': day.day,
1831
            'month': day.month,
1832
            'year': day.year,
1833
            'img': [i['src'] for i in imgs],
1834
            'title': title,
1835
            'author': author,
1836
        }
1837
@@ 2319-2344 (lines=26) @@
2316
            'description': description,
2317
        }
2318
2319
2320
class GerbilWithAJetpack(GenericNavigableComic):
2321
    """Class to retrieve GerbilWithAJetpack comics."""
2322
    name = 'gerbil'
2323
    long_name = 'Gerbil With A Jetpack'
2324
    url = 'http://gerbilwithajetpack.com'
2325
    get_first_comic_link = get_a_navi_navifirst
2326
    get_navi_link = get_a_rel_next
2327
2328
    @classmethod
2329
    def get_comic_info(cls, soup, link):
2330
        """Get information about a particular comics."""
2331
        title = soup.find('h2', class_='post-title').string
2332
        author = soup.find("span", class_="post-author").find("a").string
2333
        date_str = soup.find("span", class_="post-date").string
2334
        day = string_to_date(date_str, "%B %d, %Y")
2335
        imgs = soup.find("div", id="comic").find_all("img")
2336
        alt = imgs[0]['alt']
2337
        assert all(i['alt'] == i['title'] == alt for i in imgs)
2338
        return {
2339
            'img': [i['src'] for i in imgs],
2340
            'title': title,
2341
            'alt': alt,
2342
            'author': author,
2343
            'day': day.day,
2344
            'month': day.month,
2345
            'year': day.year
2346
        }
2347
@@ 2117-2142 (lines=26) @@
2114
        archive_url = urljoin_wrapper(cls.url, 'archive-2')
2115
        return reversed(get_soup_at_url(archive_url).find('tbody').find_all('tr'))
2116
2117
2118
class HappleTea(GenericNavigableComic):
2119
    """Class to retrieve Happle Tea Comics."""
2120
    name = 'happletea'
2121
    long_name = 'Happle Tea'
2122
    url = 'http://www.happletea.com'
2123
    get_first_comic_link = get_a_navi_navifirst
2124
    get_navi_link = get_link_rel_next
2125
2126
    @classmethod
2127
    def get_comic_info(cls, soup, link):
2128
        """Get information about a particular comics."""
2129
        imgs = soup.find('div', id='comic').find_all('img')
2130
        post = soup.find('div', class_='post-content')
2131
        title = post.find('h2', class_='post-title').string
2132
        author = post.find('a', rel='author').string
2133
        date_str = post.find('span', class_='post-date').string
2134
        day = string_to_date(date_str, "%B %d, %Y")
2135
        assert all(i['alt'] == i['title'] for i in imgs)
2136
        return {
2137
            'title': title,
2138
            'img': [i['src'] for i in imgs],
2139
            'alt': ''.join(i['alt'] for i in imgs),
2140
            'month': day.month,
2141
            'year': day.year,
2142
            'day': day.day,
2143
            'author': author,
2144
        }
2145
@@ 2657-2681 (lines=25) @@
2654
    url = 'http://www.commitstrip.com/en'
2655
    first_url = 'http://www.commitstrip.com/en/2012/02/22/interview/'
2656
2657
2658
class GenericBoumerie(GenericNavigableComic):
2659
    """Generic class to retrieve Boumeries comics in different languages."""
2660
    get_first_comic_link = get_a_navi_navifirst
2661
    get_navi_link = get_link_rel_next
2662
    date_format = NotImplemented
2663
    lang = NotImplemented
2664
2665
    @classmethod
2666
    def get_comic_info(cls, soup, link):
2667
        """Get information about a particular comics."""
2668
        title = soup.find('h2', class_='post-title').string
2669
        short_url = soup.find('link', rel='shortlink')['href']
2670
        author = soup.find("span", class_="post-author").find("a").string
2671
        date_str = soup.find('span', class_='post-date').string
2672
        day = string_to_date(date_str, cls.date_format, cls.lang)
2673
        imgs = soup.find('div', id='comic').find_all('img')
2674
        assert all(i['alt'] == i['title'] for i in imgs)
2675
        return {
2676
            'short_url': short_url,
2677
            'img': [i['src'] for i in imgs],
2678
            'title': title,
2679
            'author': author,
2680
            'month': day.month,
2681
            'year': day.year,
2682
            'day': day.day,
2683
        }
2684
@@ 2348-2372 (lines=25) @@
2345
            'year': day.year
2346
        }
2347
2348
2349
class EveryDayBlues(GenericNavigableComic):
2350
    """Class to retrieve EveryDayBlues Comics."""
2351
    name = "blues"
2352
    long_name = "Every Day Blues"
2353
    url = "http://everydayblues.net"
2354
    get_first_comic_link = get_a_navi_navifirst
2355
    get_navi_link = get_link_rel_next
2356
2357
    @classmethod
2358
    def get_comic_info(cls, soup, link):
2359
        """Get information about a particular comics."""
2360
        title = soup.find("h2", class_="post-title").string
2361
        author = soup.find("span", class_="post-author").find("a").string
2362
        date_str = soup.find("span", class_="post-date").string
2363
        day = string_to_date(date_str, "%d. %B %Y", "de_DE.utf8")
2364
        imgs = soup.find("div", id="comic").find_all("img")
2365
        assert all(i['alt'] == i['title'] == title for i in imgs)
2366
        assert len(imgs) <= 1
2367
        return {
2368
            'img': [i['src'] for i in imgs],
2369
            'title': title,
2370
            'author': author,
2371
            'day': day.day,
2372
            'month': day.month,
2373
            'year': day.year
2374
        }
2375
@@ 1697-1721 (lines=25) @@
1694
            'alt': alt,
1695
        }
1696
1697
1698
class MouseBearComedy(GenericNavigableComic):
1699
    """Class to retrieve Mouse Bear Comedy comics."""
1700
    # Also on http://mousebearcomedy.tumblr.com
1701
    name = 'mousebear'
1702
    long_name = 'Mouse Bear Comedy'
1703
    url = 'http://www.mousebearcomedy.com'
1704
    get_first_comic_link = get_a_navi_navifirst
1705
    get_navi_link = get_a_navi_comicnavnext_navinext
1706
1707
    @classmethod
1708
    def get_comic_info(cls, soup, link):
1709
        """Get information about a particular comics."""
1710
        title = soup.find('h2', class_='post-title').string
1711
        author = soup.find("span", class_="post-author").find("a").string
1712
        date_str = soup.find("span", class_="post-date").string
1713
        day = string_to_date(date_str, '%B %d, %Y')
1714
        imgs = soup.find("div", id="comic").find_all("img")
1715
        assert all(i['alt'] == i['title'] == title for i in imgs)
1716
        return {
1717
            'day': day.day,
1718
            'month': day.month,
1719
            'year': day.year,
1720
            'img': [i['src'] for i in imgs],
1721
            'title': title,
1722
            'author': author,
1723
        }
1724
@@ 1104-1127 (lines=24) @@
1101
    long_name = 'Boulet Corp English'
1102
    url = 'http://english.bouletcorp.com'
1103
1104
1105
class AmazingSuperPowers(GenericNavigableComic):
1106
    """Class to retrieve Amazing Super Powers comics."""
1107
    name = 'asp'
1108
    long_name = 'Amazing Super Powers'
1109
    url = 'http://www.amazingsuperpowers.com'
1110
    get_first_comic_link = get_a_navi_navifirst
1111
    get_navi_link = get_a_navi_navinext
1112
1113
    @classmethod
1114
    def get_comic_info(cls, soup, link):
1115
        """Get information about a particular comics."""
1116
        author = soup.find("span", class_="post-author").find("a").string
1117
        date_str = soup.find('span', class_='post-date').string
1118
        day = string_to_date(date_str, "%B %d, %Y")
1119
        imgs = soup.find('div', id='comic').find_all('img')
1120
        title = ' '.join(i['title'] for i in imgs)
1121
        assert all(i['alt'] == i['title'] for i in imgs)
1122
        return {
1123
            'title': title,
1124
            'author': author,
1125
            'img': [img['src'] for img in imgs],
1126
            'day': day.day,
1127
            'month': day.month,
1128
            'year': day.year
1129
        }
1130
@@ 2736-2762 (lines=27) @@
2733
            'day': day.day,
2734
        }
2735
2736
2737
class Optipess(GenericNavigableComic):
2738
    """Class to retrieve Optipess comics."""
2739
    name = 'optipess'
2740
    long_name = 'Optipess'
2741
    url = 'http://www.optipess.com'
2742
    get_first_comic_link = get_a_navi_navifirst
2743
    get_navi_link = get_link_rel_next
2744
2745
    @classmethod
2746
    def get_comic_info(cls, soup, link):
2747
        """Get information about a particular comics."""
2748
        title = soup.find('h2', class_='post-title').string
2749
        author = soup.find("span", class_="post-author").find("a").string
2750
        comic = soup.find('div', id='comic')
2751
        imgs = comic.find_all('img') if comic else []
2752
        alt = imgs[0]['title'] if imgs else ""
2753
        assert all(i['alt'] == i['title'] == alt for i in imgs)
2754
        date_str = soup.find('span', class_='post-date').string
2755
        day = string_to_date(date_str, "%B %d, %Y")
2756
        return {
2757
            'title': title,
2758
            'alt': alt,
2759
            'author': author,
2760
            'img': [i['src'] for i in imgs],
2761
            'month': day.month,
2762
            'year': day.year,
2763
            'day': day.day,
2764
        }
2765
@@ 1930-1956 (lines=27) @@
1927
    long_name = 'Tubey Toons'
1928
    url = 'http://tubeytoons.com'
1929
1930
1931
class CompletelySeriousComics(GenericNavigableComic):
1932
    """Class to retrieve Completely Serious comics."""
1933
    name = 'completelyserious'
1934
    long_name = 'Completely Serious Comics'
1935
    url = 'http://completelyseriouscomics.com'
1936
    get_first_comic_link = get_a_navi_navifirst
1937
    get_navi_link = get_a_navi_navinext
1938
1939
    @classmethod
1940
    def get_comic_info(cls, soup, link):
1941
        """Get information about a particular comics."""
1942
        title = soup.find('h2', class_='post-title').string
1943
        author = soup.find('span', class_='post-author').contents[1].string
1944
        date_str = soup.find('span', class_='post-date').string
1945
        day = string_to_date(date_str, '%B %d, %Y')
1946
        imgs = soup.find('div', class_='comicpane').find_all('img')
1947
        assert imgs
1948
        alt = imgs[0]['title']
1949
        assert all(i['title'] == i['alt'] == alt for i in imgs)
1950
        return {
1951
            'month': day.month,
1952
            'year': day.year,
1953
            'day': day.day,
1954
            'img': [i['src'] for i in imgs],
1955
            'title': title,
1956
            'alt': alt,
1957
            'author': author,
1958
        }
1959
@@ 1779-1804 (lines=26) @@
1776
            'img': [i['content'] for i in imgs if i['content'] not in skip_imgs],
1777
        }
1778
1779
1780
class SafelyEndangered(GenericNavigableComic):
1781
    """Class to retrieve Safely Endangered comics."""
1782
    # Also on http://tumblr.safelyendangered.com
1783
    name = 'endangered'
1784
    long_name = 'Safely Endangered'
1785
    url = 'http://www.safelyendangered.com'
1786
    get_navi_link = get_link_rel_next
1787
    get_first_comic_link = simulate_first_link
1788
    first_url = 'http://www.safelyendangered.com/comic/ignored/'
1789
1790
    @classmethod
1791
    def get_comic_info(cls, soup, link):
1792
        """Get information about a particular comics."""
1793
        title = soup.find('h2', class_='post-title').string
1794
        date_str = soup.find('span', class_='post-date').string
1795
        day = string_to_date(date_str, '%B %d, %Y')
1796
        imgs = soup.find('div', id='comic').find_all('img')
1797
        alt = imgs[0]['alt']
1798
        assert all(i['alt'] == i['title'] for i in imgs)
1799
        return {
1800
            'day': day.day,
1801
            'month': day.month,
1802
            'year': day.year,
1803
            'img': [i['src'] for i in imgs],
1804
            'title': title,
1805
            'alt': alt,
1806
        }
1807
@@ 2017-2041 (lines=25) @@
2014
            'day': day.day,
2015
        }
2016
2017
2018
class ChuckleADuck(GenericNavigableComic):
2019
    """Class to retrieve Chuckle-A-Duck comics."""
2020
    name = 'chuckleaduck'
2021
    long_name = 'Chuckle-A-duck'
2022
    url = 'http://chuckleaduck.com'
2023
    get_first_comic_link = get_div_navfirst_a
2024
    get_navi_link = get_link_rel_next
2025
2026
    @classmethod
2027
    def get_comic_info(cls, soup, link):
2028
        """Get information about a particular comics."""
2029
        date_str = soup.find('span', class_='post-date').string
2030
        day = string_to_date(remove_st_nd_rd_th_from_date(date_str), "%B %d, %Y")
2031
        author = soup.find('span', class_='post-author').string
2032
        div = soup.find('div', id='comic')
2033
        imgs = div.find_all('img') if div else []
2034
        title = imgs[0]['title'] if imgs else ""
2035
        assert all(i['title'] == i['alt'] == title for i in imgs)
2036
        return {
2037
            'month': day.month,
2038
            'year': day.year,
2039
            'day': day.day,
2040
            'img': [i['src'] for i in imgs],
2041
            'title': title,
2042
            'author': author,
2043
        }
2044