Code Duplication    Length = 24-27 lines in 13 locations

comics.py 13 locations

@@ 2734-2760 (lines=27) @@
2731
        }
2732
2733
2734
class Optipess(GenericNavigableComic):
2735
    """Class to retrieve Optipess comics."""
2736
    name = 'optipess'
2737
    long_name = 'Optipess'
2738
    url = 'http://www.optipess.com'
2739
    get_first_comic_link = get_a_navi_navifirst
2740
    get_navi_link = get_link_rel_next
2741
2742
    @classmethod
2743
    def get_comic_info(cls, soup, link):
2744
        """Get information about a particular comics."""
2745
        title = soup.find('h2', class_='post-title').string
2746
        author = soup.find("span", class_="post-author").find("a").string
2747
        comic = soup.find('div', id='comic')
2748
        imgs = comic.find_all('img') if comic else []
2749
        alt = imgs[0]['title'] if imgs else ""
2750
        assert all(i['alt'] == i['title'] == alt for i in imgs)
2751
        date_str = soup.find('span', class_='post-date').string
2752
        day = string_to_date(date_str, "%B %d, %Y")
2753
        return {
2754
            'title': title,
2755
            'alt': alt,
2756
            'author': author,
2757
            'img': [i['src'] for i in imgs],
2758
            'month': day.month,
2759
            'year': day.year,
2760
            'day': day.day,
2761
        }
2762
2763
@@ 2484-2510 (lines=27) @@
2481
        }
2482
2483
2484
class LastPlaceComics(GenericNavigableComic):
2485
    """Class to retrieve Last Place Comics."""
2486
    name = 'lastplace'
2487
    long_name = 'LastPlaceComics'
2488
    url = "http://lastplacecomics.com"
2489
    get_first_comic_link = get_a_comicnavbase_comicnavfirst
2490
    get_navi_link = get_link_rel_next
2491
2492
    @classmethod
2493
    def get_comic_info(cls, soup, link):
2494
        """Get information about a particular comics."""
2495
        title = soup.find('h2', class_='post-title').string
2496
        author = soup.find("span", class_="post-author").find("a").string
2497
        date_str = soup.find("span", class_="post-date").string
2498
        day = string_to_date(date_str, "%B %d, %Y")
2499
        imgs = soup.find("div", id="comic").find_all("img")
2500
        assert all(i['alt'] == i['title'] for i in imgs)
2501
        assert len(imgs) <= 1
2502
        alt = imgs[0]['alt'] if imgs else ""
2503
        return {
2504
            'img': [i['src'] for i in imgs],
2505
            'title': title,
2506
            'alt': alt,
2507
            'author': author,
2508
            'day': day.day,
2509
            'month': day.month,
2510
            'year': day.year
2511
        }
2512
2513
@@ 2545-2570 (lines=26) @@
2542
        }
2543
2544
2545
class EndlessOrigami(GenericNavigableComic):
2546
    """Class to retrieve Endless Origami Comics."""
2547
    name = "origami"
2548
    long_name = "Endless Origami"
2549
    url = "http://endlessorigami.com"
2550
    get_first_comic_link = get_a_navi_navifirst
2551
    get_navi_link = get_link_rel_next
2552
2553
    @classmethod
2554
    def get_comic_info(cls, soup, link):
2555
        """Get information about a particular comics."""
2556
        title = soup.find('h2', class_='post-title').string
2557
        author = soup.find("span", class_="post-author").find("a").string
2558
        date_str = soup.find("span", class_="post-date").string
2559
        day = string_to_date(date_str, "%B %d, %Y")
2560
        imgs = soup.find("div", id="comic").find_all("img")
2561
        assert all(i['alt'] == i['title'] for i in imgs)
2562
        alt = imgs[0]['alt'] if imgs else ""
2563
        return {
2564
            'img': [i['src'] for i in imgs],
2565
            'title': title,
2566
            'alt': alt,
2567
            'author': author,
2568
            'day': day.day,
2569
            'month': day.month,
2570
            'year': day.year
2571
        }
2572
2573
@@ 2317-2342 (lines=26) @@
2314
        }
2315
2316
2317
class GerbilWithAJetpack(GenericNavigableComic):
2318
    """Class to retrieve GerbilWithAJetpack comics."""
2319
    name = 'gerbil'
2320
    long_name = 'Gerbil With A Jetpack'
2321
    url = 'http://gerbilwithajetpack.com'
2322
    get_first_comic_link = get_a_navi_navifirst
2323
    get_navi_link = get_a_rel_next
2324
2325
    @classmethod
2326
    def get_comic_info(cls, soup, link):
2327
        """Get information about a particular comics."""
2328
        title = soup.find('h2', class_='post-title').string
2329
        author = soup.find("span", class_="post-author").find("a").string
2330
        date_str = soup.find("span", class_="post-date").string
2331
        day = string_to_date(date_str, "%B %d, %Y")
2332
        imgs = soup.find("div", id="comic").find_all("img")
2333
        alt = imgs[0]['alt']
2334
        assert all(i['alt'] == i['title'] == alt for i in imgs)
2335
        return {
2336
            'img': [i['src'] for i in imgs],
2337
            'title': title,
2338
            'alt': alt,
2339
            'author': author,
2340
            'day': day.day,
2341
            'month': day.month,
2342
            'year': day.year
2343
        }
2344
2345
@@ 1781-1806 (lines=26) @@
1778
        }
1779
1780
1781
class SafelyEndangered(GenericNavigableComic):
1782
    """Class to retrieve Safely Endangered comics."""
1783
    # Also on http://tumblr.safelyendangered.com
1784
    name = 'endangered'
1785
    long_name = 'Safely Endangered'
1786
    url = 'http://www.safelyendangered.com'
1787
    get_navi_link = get_link_rel_next
1788
    get_first_comic_link = simulate_first_link
1789
    first_url = 'http://www.safelyendangered.com/comic/ignored/'
1790
1791
    @classmethod
1792
    def get_comic_info(cls, soup, link):
1793
        """Get information about a particular comics."""
1794
        title = soup.find('h2', class_='post-title').string
1795
        date_str = soup.find('span', class_='post-date').string
1796
        day = string_to_date(date_str, '%B %d, %Y')
1797
        imgs = soup.find('div', id='comic').find_all('img')
1798
        alt = imgs[0]['alt']
1799
        assert all(i['alt'] == i['title'] for i in imgs)
1800
        return {
1801
            'day': day.day,
1802
            'month': day.month,
1803
            'year': day.year,
1804
            'img': [i['src'] for i in imgs],
1805
            'title': title,
1806
            'alt': alt,
1807
        }
1808
1809
@@ 2017-2041 (lines=25) @@
2014
        }
2015
2016
2017
class ChuckleADuck(GenericNavigableComic):
2018
    """Class to retrieve Chuckle-A-Duck comics."""
2019
    name = 'chuckleaduck'
2020
    long_name = 'Chuckle-A-duck'
2021
    url = 'http://chuckleaduck.com'
2022
    get_first_comic_link = get_div_navfirst_a
2023
    get_navi_link = get_link_rel_next
2024
2025
    @classmethod
2026
    def get_comic_info(cls, soup, link):
2027
        """Get information about a particular comics."""
2028
        date_str = soup.find('span', class_='post-date').string
2029
        day = string_to_date(remove_st_nd_rd_th_from_date(date_str), "%B %d, %Y")
2030
        author = soup.find('span', class_='post-author').string
2031
        div = soup.find('div', id='comic')
2032
        imgs = div.find_all('img') if div else []
2033
        title = imgs[0]['title'] if imgs else ""
2034
        assert all(i['title'] == i['alt'] == title for i in imgs)
2035
        return {
2036
            'month': day.month,
2037
            'year': day.year,
2038
            'day': day.day,
2039
            'img': [i['src'] for i in imgs],
2040
            'title': title,
2041
            'author': author,
2042
        }
2043
2044
@@ 1931-1957 (lines=27) @@
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
1960
@@ 1810-1836 (lines=27) @@
1807
        }
1808
1809
1810
class PicturesInBoxes(GenericNavigableComic):
1811
    """Class to retrieve Pictures In Boxes comics."""
1812
    # Also on http://picturesinboxescomic.tumblr.com
1813
    name = 'picturesinboxes'
1814
    long_name = 'Pictures in Boxes'
1815
    url = 'http://www.picturesinboxes.com'
1816
    get_navi_link = get_a_navi_navinext
1817
    get_first_comic_link = simulate_first_link
1818
    first_url = 'http://www.picturesinboxes.com/2013/10/26/tetris/'
1819
1820
    @classmethod
1821
    def get_comic_info(cls, soup, link):
1822
        """Get information about a particular comics."""
1823
        title = soup.find('h2', class_='post-title').string
1824
        author = soup.find("span", class_="post-author").find("a").string
1825
        date_str = soup.find('span', class_='post-date').string
1826
        day = string_to_date(date_str, '%B %d, %Y')
1827
        imgs = soup.find('div', class_='comicpane').find_all('img')
1828
        assert imgs
1829
        assert all(i['title'] == i['alt'] == title for i in imgs)
1830
        return {
1831
            'day': day.day,
1832
            'month': day.month,
1833
            'year': day.year,
1834
            'img': [i['src'] for i in imgs],
1835
            'title': title,
1836
            'author': author,
1837
        }
1838
1839
@@ 1699-1723 (lines=25) @@
1696
        }
1697
1698
1699
class MouseBearComedy(GenericNavigableComic):
1700
    """Class to retrieve Mouse Bear Comedy comics."""
1701
    # Also on http://mousebearcomedy.tumblr.com
1702
    name = 'mousebear'
1703
    long_name = 'Mouse Bear Comedy'
1704
    url = 'http://www.mousebearcomedy.com'
1705
    get_first_comic_link = get_a_navi_navifirst
1706
    get_navi_link = get_a_navi_comicnavnext_navinext
1707
1708
    @classmethod
1709
    def get_comic_info(cls, soup, link):
1710
        """Get information about a particular comics."""
1711
        title = soup.find('h2', class_='post-title').string
1712
        author = soup.find("span", class_="post-author").find("a").string
1713
        date_str = soup.find("span", class_="post-date").string
1714
        day = string_to_date(date_str, '%B %d, %Y')
1715
        imgs = soup.find("div", id="comic").find_all("img")
1716
        assert all(i['alt'] == i['title'] == title for i in imgs)
1717
        return {
1718
            'day': day.day,
1719
            'month': day.month,
1720
            'year': day.year,
1721
            'img': [i['src'] for i in imgs],
1722
            'title': title,
1723
            'author': author,
1724
        }
1725
1726
@@ 1114-1137 (lines=24) @@
1111
    url = 'http://english.bouletcorp.com'
1112
1113
1114
class AmazingSuperPowers(GenericNavigableComic):
1115
    """Class to retrieve Amazing Super Powers comics."""
1116
    name = 'asp'
1117
    long_name = 'Amazing Super Powers'
1118
    url = 'http://www.amazingsuperpowers.com'
1119
    get_first_comic_link = get_a_navi_navifirst
1120
    get_navi_link = get_a_navi_navinext
1121
1122
    @classmethod
1123
    def get_comic_info(cls, soup, link):
1124
        """Get information about a particular comics."""
1125
        author = soup.find("span", class_="post-author").find("a").string
1126
        date_str = soup.find('span', class_='post-date').string
1127
        day = string_to_date(date_str, "%B %d, %Y")
1128
        imgs = soup.find('div', id='comic').find_all('img')
1129
        title = ' '.join(i['title'] for i in imgs)
1130
        assert all(i['alt'] == i['title'] for i in imgs)
1131
        return {
1132
            'title': title,
1133
            'author': author,
1134
            'img': [img['src'] for img in imgs],
1135
            'day': day.day,
1136
            'month': day.month,
1137
            'year': day.year
1138
        }
1139
1140
@@ 2374-2400 (lines=27) @@
2371
        }
2372
2373
2374
class BiterComics(GenericNavigableComic):
2375
    """Class to retrieve Biter Comics."""
2376
    name = "biter"
2377
    long_name = "Biter Comics"
2378
    url = "http://www.bitercomics.com"
2379
    get_first_comic_link = get_a_navi_navifirst
2380
    get_navi_link = get_link_rel_next
2381
2382
    @classmethod
2383
    def get_comic_info(cls, soup, link):
2384
        """Get information about a particular comics."""
2385
        title = soup.find("h1", class_="entry-title").string
2386
        author = soup.find("span", class_="author vcard").find("a").string
2387
        date_str = soup.find("span", class_="entry-date").string
2388
        day = string_to_date(date_str, "%B %d, %Y")
2389
        imgs = soup.find("div", id="comic").find_all("img")
2390
        assert all(i['alt'] == i['title'] for i in imgs)
2391
        assert len(imgs) == 1
2392
        alt = imgs[0]['alt']
2393
        return {
2394
            'img': [i['src'] for i in imgs],
2395
            'title': title,
2396
            'alt': alt,
2397
            'author': author,
2398
            'day': day.day,
2399
            'month': day.month,
2400
            'year': day.year
2401
        }
2402
2403
@@ 2116-2141 (lines=26) @@
2113
        return reversed(get_soup_at_url(archive_url).find('tbody').find_all('tr'))
2114
2115
2116
class HappleTea(GenericNavigableComic):
2117
    """Class to retrieve Happle Tea Comics."""
2118
    name = 'happletea'
2119
    long_name = 'Happle Tea'
2120
    url = 'http://www.happletea.com'
2121
    get_first_comic_link = get_a_navi_navifirst
2122
    get_navi_link = get_link_rel_next
2123
2124
    @classmethod
2125
    def get_comic_info(cls, soup, link):
2126
        """Get information about a particular comics."""
2127
        imgs = soup.find('div', id='comic').find_all('img')
2128
        post = soup.find('div', class_='post-content')
2129
        title = post.find('h2', class_='post-title').string
2130
        author = post.find('a', rel='author').string
2131
        date_str = post.find('span', class_='post-date').string
2132
        day = string_to_date(date_str, "%B %d, %Y")
2133
        assert all(i['alt'] == i['title'] for i in imgs)
2134
        return {
2135
            'title': title,
2136
            'img': [i['src'] for i in imgs],
2137
            'alt': ''.join(i['alt'] for i in imgs),
2138
            'month': day.month,
2139
            'year': day.year,
2140
            'day': day.day,
2141
            'author': author,
2142
        }
2143
2144
@@ 2346-2370 (lines=25) @@
2343
        }
2344
2345
2346
class EveryDayBlues(GenericNavigableComic):
2347
    """Class to retrieve EveryDayBlues Comics."""
2348
    name = "blues"
2349
    long_name = "Every Day Blues"
2350
    url = "http://everydayblues.net"
2351
    get_first_comic_link = get_a_navi_navifirst
2352
    get_navi_link = get_link_rel_next
2353
2354
    @classmethod
2355
    def get_comic_info(cls, soup, link):
2356
        """Get information about a particular comics."""
2357
        title = soup.find("h2", class_="post-title").string
2358
        author = soup.find("span", class_="post-author").find("a").string
2359
        date_str = soup.find("span", class_="post-date").string
2360
        day = string_to_date(date_str, "%d. %B %Y", "de_DE.utf8")
2361
        imgs = soup.find("div", id="comic").find_all("img")
2362
        assert all(i['alt'] == i['title'] == title for i in imgs)
2363
        assert len(imgs) <= 1
2364
        return {
2365
            'img': [i['src'] for i in imgs],
2366
            'title': title,
2367
            'author': author,
2368
            'day': day.day,
2369
            'month': day.month,
2370
            'year': day.year
2371
        }
2372
2373