Code Duplication    Length = 25-30 lines in 6 locations

comics.py 6 locations

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