Code Duplication    Length = 25-30 lines in 6 locations

comics.py 6 locations

@@ 1822-1851 (lines=30) @@
1819
        }
1820
1821
1822
class PicturesInBoxes(GenericNavigableComic):
1823
    """Class to retrieve Pictures In Boxes comics."""
1824
    # Also on http://picturesinboxescomic.tumblr.com
1825
    name = 'picturesinboxes'
1826
    long_name = 'Pictures in Boxes'
1827
    url = 'http://www.picturesinboxes.com'
1828
    get_navi_link = get_a_navi_navinext
1829
1830
    @classmethod
1831
    def get_first_comic_link(cls):
1832
        """Get link to first comics."""
1833
        return {'href': 'http://www.picturesinboxes.com/2013/10/26/tetris/'}
1834
1835
    @classmethod
1836
    def get_comic_info(cls, soup, link):
1837
        """Get information about a particular comics."""
1838
        title = soup.find('h2', class_='post-title').string
1839
        author = soup.find("span", class_="post-author").find("a").string
1840
        date_str = soup.find('span', class_='post-date').string
1841
        day = string_to_date(date_str, '%B %d, %Y')
1842
        imgs = soup.find('div', class_='comicpane').find_all('img')
1843
        assert imgs
1844
        assert all(i['title'] == i['alt'] == title for i in imgs)
1845
        return {
1846
            'day': day.day,
1847
            'month': day.month,
1848
            'year': day.year,
1849
            'img': [i['src'] for i in imgs],
1850
            'title': title,
1851
            'author': author,
1852
        }
1853
1854
@@ 1790-1818 (lines=29) @@
1787
        }
1788
1789
1790
class SafelyEndangered(GenericNavigableComic):
1791
    """Class to retrieve Safely Endangered comics."""
1792
    # Also on http://tumblr.safelyendangered.com
1793
    name = 'endangered'
1794
    long_name = 'Safely Endangered'
1795
    url = 'http://www.safelyendangered.com'
1796
    get_navi_link = get_link_rel_next
1797
1798
    @classmethod
1799
    def get_first_comic_link(cls):
1800
        """Get link to first comics."""
1801
        return {'href': 'http://www.safelyendangered.com/comic/ignored/'}
1802
1803
    @classmethod
1804
    def get_comic_info(cls, soup, link):
1805
        """Get information about a particular comics."""
1806
        title = soup.find('h2', class_='post-title').string
1807
        date_str = soup.find('span', class_='post-date').string
1808
        day = string_to_date(date_str, '%B %d, %Y')
1809
        imgs = soup.find('div', id='comic').find_all('img')
1810
        alt = imgs[0]['alt']
1811
        assert all(i['alt'] == i['title'] for i in imgs)
1812
        return {
1813
            'day': day.day,
1814
            'month': day.month,
1815
            'year': day.year,
1816
            'img': [i['src'] for i in imgs],
1817
            'title': title,
1818
            'alt': alt,
1819
        }
1820
1821
@@ 908-933 (lines=26) @@
905
        }
906
907
908
class MyExtraLife(GenericNavigableComic):
909
    """Class to retrieve My Extra Life comics."""
910
    name = 'extralife'
911
    long_name = 'My Extra Life'
912
    url = 'http://www.myextralife.com'
913
    get_navi_link = get_link_rel_next
914
915
    @classmethod
916
    def get_first_comic_link(cls):
917
        """Get link to first comics."""
918
        return get_soup_at_url(cls.url).find('a', class_='comic_nav_link first_comic_link')
919
920
    @classmethod
921
    def get_comic_info(cls, soup, link):
922
        """Get information about a particular comics."""
923
        title = soup.find("h1", class_="comic_title").string
924
        date_str = soup.find("span", class_="comic_date").string
925
        day = string_to_date(date_str, "%B %d, %Y")
926
        imgs = soup.find_all("img", class_="comic")
927
        assert all(i['alt'] == i['title'] == title for i in imgs)
928
        return {
929
            'title': title,
930
            'img': [i['src'] for i in imgs if i["src"]],
931
            'day': day.day,
932
            'month': day.month,
933
            'year': day.year
934
        }
935
936
@@ 2428-2452 (lines=25) @@
2425
        }
2426
2427
2428
class TheAwkwardYeti(GenericNavigableComic):
2429
    """Class to retrieve The Awkward Yeti comics."""
2430
    # Also on http://www.gocomics.com/the-awkward-yeti
2431
    # Also on http://larstheyeti.tumblr.com
2432
    # Also on https://tapastic.com/series/TheAwkwardYeti
2433
    name = 'yeti'
2434
    long_name = 'The Awkward Yeti'
2435
    url = 'http://theawkwardyeti.com'
2436
    get_first_comic_link = get_a_navi_navifirst
2437
    get_navi_link = get_link_rel_next
2438
2439
    @classmethod
2440
    def get_comic_info(cls, soup, link):
2441
        """Get information about a particular comics."""
2442
        title = soup.find('h2', class_='post-title').string
2443
        date_str = soup.find("span", class_="post-date").string
2444
        day = string_to_date(date_str, "%B %d, %Y")
2445
        imgs = soup.find("div", id="comic").find_all("img")
2446
        assert all(idx > 0 or i['alt'] == i['title'] for idx, i in enumerate(imgs))
2447
        return {
2448
            'img': [i['src'] for i in imgs],
2449
            'title': title,
2450
            'day': day.day,
2451
            'month': day.month,
2452
            'year': day.year
2453
        }
2454
2455
@@ 2269-2294 (lines=26) @@
2266
        }
2267
2268
2269
class LinsEditions(GenericNavigableComic):
2270
    """Class to retrieve L.I.N.S. Editions comics."""
2271
    # Also on http://linscomics.tumblr.com
2272
    name = 'lins'
2273
    long_name = 'L.I.N.S. Editions'
2274
    url = 'https://linsedition.com'
2275
    get_navi_link = get_link_rel_next
2276
2277
    @classmethod
2278
    def get_first_comic_link(cls):
2279
        """Get link to first comics."""
2280
        return {'href': 'https://linsedition.com/2011/09/07/l-i-n-s/'}
2281
2282
    @classmethod
2283
    def get_comic_info(cls, soup, link):
2284
        """Get information about a particular comics."""
2285
        title = soup.find('meta', property='og:title')['content']
2286
        imgs = soup.find_all('meta', property='og:image')
2287
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
2288
        day = string_to_date(date_str, "%Y-%m-%d")
2289
        return {
2290
            'title': title,
2291
            'img': [i['content'] for i in imgs],
2292
            'month': day.month,
2293
            'year': day.year,
2294
            'day': day.day,
2295
        }
2296
2297
@@ 1705-1729 (lines=25) @@
1702
        }
1703
1704
1705
class MouseBearComedy(GenericNavigableComic):
1706
    """Class to retrieve Mouse Bear Comedy comics."""
1707
    # Also on http://mousebearcomedy.tumblr.com
1708
    name = 'mousebear'
1709
    long_name = 'Mouse Bear Comedy'
1710
    url = 'http://www.mousebearcomedy.com'
1711
    get_first_comic_link = get_a_navi_navifirst
1712
    get_navi_link = get_a_navi_comicnavnext_navinext
1713
1714
    @classmethod
1715
    def get_comic_info(cls, soup, link):
1716
        """Get information about a particular comics."""
1717
        title = soup.find('h2', class_='post-title').string
1718
        author = soup.find("span", class_="post-author").find("a").string
1719
        date_str = soup.find("span", class_="post-date").string
1720
        day = string_to_date(date_str, '%B %d, %Y')
1721
        imgs = soup.find("div", id="comic").find_all("img")
1722
        assert all(i['alt'] == i['title'] == title for i in imgs)
1723
        return {
1724
            'day': day.day,
1725
            'month': day.month,
1726
            'year': day.year,
1727
            'img': [i['src'] for i in imgs],
1728
            'title': title,
1729
            'author': author,
1730
        }
1731
1732