dosage/dosagelib/plugins/c.py

290 lines
10 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
2016-10-28 22:21:41 +00:00
# Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs
2014-01-05 15:50:57 +00:00
# Copyright (C) 2012-2014 Bastian Kleineidam
2017-01-12 01:01:10 +00:00
# Copyright (C) 2015-2017 Tobias Gruetzmacher
2015-11-03 22:40:45 +00:00
from __future__ import absolute_import, division, print_function
2012-11-21 20:57:26 +00:00
from re import compile, escape
2012-06-20 19:58:13 +00:00
2015-05-20 10:58:13 +00:00
from ..scraper import _BasicScraper, _ParserScraper
2017-02-13 21:41:17 +00:00
from ..helpers import bounceStarter, indirectStarter, xpath_class
2012-12-04 06:02:40 +00:00
from ..util import tagre
2017-02-13 21:41:17 +00:00
from .common import _TumblrScraper, _WordPressScraper
2012-06-20 19:58:13 +00:00
2014-01-06 04:05:00 +00:00
class CampComic(_BasicScraper):
url = 'http://campcomic.com/comic/'
rurl = escape(url)
stripUrl = url + '%s'
firstStripUrl = stripUrl % '6'
imageSearch = compile(tagre("img", "src", r'(http://hw1\.pa-cdn\.com/camp/assets/img/katie/comics/[^"]+)'))
prevSearch = compile(tagre("a", "href", r'(%s[^"]+)' % rurl, before="btn btnPrev"))
help = 'Index Format: number'
2013-02-21 18:47:21 +00:00
2012-06-20 19:58:13 +00:00
class CaptainSNES(_BasicScraper):
url = 'http://www.captainsnes.com/'
rurl = escape(url)
stripUrl = url + '%s/'
2013-04-10 21:57:09 +00:00
firstStripUrl = stripUrl % '2001/07/10/the-mistake'
imageSearch = compile(tagre("img", "src", r"(%scomics/[^']+)" % rurl,
quote="'"))
prevSearch = compile(tagre("a", "href", r'(%s[^"]+)' % rurl) +
tagre("span", "class", "prev"))
2012-12-02 17:35:06 +00:00
multipleImagesPerStrip = True
2012-11-21 20:57:26 +00:00
help = 'Index format: yyyy/mm/dd/nnn-stripname'
2012-06-20 19:58:13 +00:00
2012-12-08 20:30:51 +00:00
class CaseyAndAndy(_BasicScraper):
url = 'http://www.galactanet.com/comic/'
stripUrl = url + 'view.php?strip=%s'
firstStripUrl = stripUrl % '1'
2012-12-08 20:30:51 +00:00
imageSearch = compile(tagre("img", "src", r'(Strip\d+\.gif)'))
prevSearch = compile(tagre("a", "href", r'(view\.php\?strip=\d+)') +
tagre("img", "src", r'previous\.gif'))
2012-12-08 20:30:51 +00:00
help = 'Index format: number'
2013-04-10 16:36:33 +00:00
class CasuallyKayla(_BasicScraper):
url = 'http://casuallykayla.com/'
stripUrl = url + '?p=%s'
firstStripUrl = stripUrl % '89'
imageSearch = compile(tagre("img", "src",
r'(http://casuallykayla\.com/comics/[^"]+)'))
prevSearch = compile(tagre("div", "class", r'nav-previous') +
tagre("a", "href", r'([^"]+)'))
2013-04-10 16:36:33 +00:00
help = 'Index format: nnn'
2012-12-07 23:45:18 +00:00
class Catalyst(_BasicScraper):
baseUrl = "http://catalyst.spiderforest.com/"
rurl = escape(baseUrl)
url = baseUrl + "comic.php?comic_id=415"
2012-12-07 23:45:18 +00:00
stripUrl = baseUrl + "comic.php?comic_id=%s"
firstStripUrl = stripUrl % '1'
imageSearch = compile(tagre("img", "src", r'((?:%s)?comics/[^"]+)' % rurl))
prevSearch = compile("<center>" +
tagre("a", "href",
r'(%scomic\.php\?comic_id=\d+)' % rurl))
2012-12-07 23:45:18 +00:00
help = 'Index format: number'
2017-05-14 22:27:28 +00:00
class CatAndGirl(_ParserScraper):
2013-04-10 16:36:33 +00:00
url = 'http://catandgirl.com/'
2017-05-14 22:27:28 +00:00
imageSearch = '//div[@id="comic"]//img'
prevSearch = '//a[@rel="prev"]'
2013-11-12 17:33:14 +00:00
class Catena(_WordPressScraper):
url = 'http://catenamanor.com/'
class CatsAndCameras(_WordPressScraper):
url = 'http://catsncameras.com/'
2015-07-30 10:16:34 +00:00
class CatVersusHuman(_ParserScraper):
url = 'http://www.catversushuman.com'
imageSearch = '//div[@class="post-body entry-content"]//img'
2016-04-28 22:34:25 +00:00
prevSearch = '//a[@id="Blog1_blog-pager-older-link"]'
latestSearch = '//a[@rel="bookmark"]'
starter = indirectStarter
2015-07-30 10:16:34 +00:00
2013-04-10 16:36:33 +00:00
2017-04-15 23:06:41 +00:00
class ChainsawSuit(_WordPressScraper):
url = 'http://chainsawsuit.com/comic/'
stripUrl = url + 'archive/%s/'
2013-04-10 21:57:09 +00:00
firstStripUrl = stripUrl % '2008/03/12/strip-338'
2015-05-26 07:53:04 +00:00
prevSearch = '//img[@alt="previous"]/..'
2013-02-06 21:08:36 +00:00
help = 'Index format: yyyy/mm/dd/stripname'
2013-04-10 16:36:33 +00:00
class Champ2010(_BasicScraper):
2013-04-13 18:58:00 +00:00
baseUrl = 'http://jedcollins.com/champ2010/'
rurl = escape(baseUrl)
2013-04-10 16:36:33 +00:00
# the latest URL is hard coded since the comic is discontinued
2013-04-13 18:58:00 +00:00
url = baseUrl + 'champ-12-30-10.html'
stripUrl = baseUrl + '%s.html'
2013-04-10 21:57:09 +00:00
firstStripUrl = stripUrl % 'champ1-1-10-fuck'
2013-04-10 16:36:33 +00:00
imageSearch = compile(tagre("img", "src", r'(%scomics/[^"]+)' % rurl))
prevSearch = compile(tagre("a", "href", r'(%s[^"]+)' % rurl,
after="Previous"))
2013-04-10 16:36:33 +00:00
help = 'Index format: yy-dd-mm'
2016-09-29 22:15:45 +00:00
class ChannelAte(_WordPressScraper):
2013-02-06 21:08:36 +00:00
url = 'http://www.channelate.com/'
2016-09-29 22:15:45 +00:00
prevSearch = '//a[%s]' % xpath_class('navi-prev')
2013-02-06 21:08:36 +00:00
2012-06-20 19:58:13 +00:00
class ChasingTheSunset(_BasicScraper):
url = 'http://www.fantasycomic.com/'
stripUrl = url + 'index.php?p=c%s'
2013-04-10 21:57:09 +00:00
firstStripUrl = stripUrl % '1'
2012-06-20 19:58:13 +00:00
imageSearch = compile(r'(/cmsimg/.+?)".+?comic-img')
prevSearch = compile(r'<a href="(.+?)" title="" ><img src="(images/eye-prev.png|images/cn-prev.png)"')
help = 'Index format: n'
2016-04-28 22:34:25 +00:00
class Chester5000XYV(_WordPressScraper):
2013-04-10 16:36:33 +00:00
url = 'http://jessfink.com/Chester5000XYV/'
stripUrl = url + '?p=%s'
2013-04-10 21:57:09 +00:00
firstStripUrl = stripUrl % '34'
2016-04-28 22:34:25 +00:00
prevSearch = '//a[@rel="prev"]'
adult = True
help = 'Index format: n (unpadded)'
def link_modifier(self, fromurl, tourl):
2016-04-28 22:34:25 +00:00
"""Bugfix for link to blog"""
if tourl == self.stripUrl % '714':
2016-04-28 22:34:25 +00:00
return self.stripUrl % '710'
return tourl
2013-04-10 16:36:33 +00:00
2016-04-28 22:34:25 +00:00
class Chisuji(_WordPressScraper):
url = 'http://www.chisuji.com/'
2016-04-28 22:34:25 +00:00
stripUrl = url + '?p=%s'
firstStripUrl = stripUrl % '266'
prevSearch = '//div[@class="nav-previous"]/a'
help = 'Index format: nnn'
2012-06-20 19:58:13 +00:00
2015-05-20 10:58:13 +00:00
class CigarroAndCerveja(_ParserScraper):
url = 'http://www.cigarro.ca/'
2015-05-20 10:58:13 +00:00
stripUrl = url + 'comic/%s/'
firstStripUrl = stripUrl % 'reacquaintance'
imageSearch = '//div[@id="comic"]//img',
prevSearch = '//a[contains(text()," Prev")]',
2012-06-20 19:58:13 +00:00
2016-05-06 23:50:10 +00:00
class Collar6(_TumblrScraper):
2016-04-28 22:34:25 +00:00
url = 'http://collar6.tumblr.com/'
firstStripUrl = url + 'post/138117470810/the-very-first-strip-from-when-i-thought-it-was'
imageSearch = '//figure[@class="photo-hires-item"]//img'
prevSearch = '//a[@class="previous-button"]'
latestSearch = '//li[@class="timestamp"]/a'
adult = True
2013-04-10 16:36:33 +00:00
2012-06-20 19:58:13 +00:00
class Comedity(_BasicScraper):
url = 'http://www.comedity.com/'
stripUrl = url + 'index.php?strip_id=%s'
2013-04-10 21:57:09 +00:00
firstStripUrl = stripUrl % '1'
2012-06-20 19:58:13 +00:00
imageSearch = compile(r'<img src="(Comedity_files/.+?)"')
prevSearch = compile(r'<a href="(/?index.php\?strip_id=\d+?)"> *<img alt=\"Prior Strip')
help = 'Index format: n (no padding)'
2013-04-10 21:57:09 +00:00
class CompanyY(_BasicScraper):
url = 'http://company-y.com/'
rurl = escape(url)
stripUrl = url + '%s/'
firstStripUrl = stripUrl % '2009/08/14/coming-soon'
imageSearch = compile(tagre("img", "src", r'(%scomics/[^"]+)' % rurl))
prevSearch = compile(tagre("div", "class", r"nav-previous") +
tagre("a", "href", r'(%s[^"]+)' % rurl))
2013-04-10 21:57:09 +00:00
help = 'Index format: yyyy/mm/dd/strip-name'
2012-12-07 23:45:18 +00:00
class Concession(_BasicScraper):
url = 'http://concessioncomic.com/'
rurl = escape(url)
stripUrl = url + 'index.php?pid=%s'
2013-04-10 21:57:09 +00:00
firstStripUrl = stripUrl % '20060701'
imageSearch = compile(tagre("img", "src", r'(%scomics/[^"]+)' % rurl, after="Comic"))
prevSearch = compile(tagre("a", "href", r'(%sindex\.php\?pid=\d+)' % rurl, after="nav-prev"))
2012-12-07 23:45:18 +00:00
help = 'Index format: number'
2015-05-26 09:32:25 +00:00
class CorydonCafe(_ParserScraper):
2013-04-10 16:36:33 +00:00
url = 'http://corydoncafe.com/'
2015-05-26 09:32:25 +00:00
imageSearch = "//center[2]//img"
prevSearch = '//a[@title="prev"]'
2017-05-14 22:27:28 +00:00
multipleImagesPerStrip = True
2013-04-10 16:36:33 +00:00
class CourtingDisaster(_WordPressScraper):
url = 'http://www.courting-disaster.com/'
firstStripUrl = 'http://www.courting-disaster.com/comic/courting-disaster-17/'
class CraftedFables(_WordPressScraper):
url = 'http://www.caf-fiends.net/comicpress/'
prevSearch = '//a[@rel="prev"]'
2012-06-20 19:58:13 +00:00
class CrapIDrewOnMyLunchBreak(_BasicScraper):
url = 'http://crap.jinwicked.com/'
2013-04-10 21:57:09 +00:00
stripUrl = url + '%s/'
firstStripUrl = stripUrl % '2003/07/30/jin-and-josh-decide-to-move'
2012-11-14 19:23:30 +00:00
imageSearch = compile(tagre("img", "src", r'(http://crap\.jinwicked\.com/comics/[^"]+)'))
prevSearch = compile(tagre("a", "href", r'([^"]+)', after="prev"))
2012-06-20 19:58:13 +00:00
help = 'Index format: yyyy/mm/dd/name'
class CrimsonDark(_BasicScraper):
url = 'http://www.davidcsimon.com/crimsondark/'
stripUrl = url + 'index.php?view=comic&strip_id=%s'
firstStripUrl = stripUrl % '1'
imageSearch = compile(r'src="(.+?strips/.+?)"')
prevSearch = compile(r'<a href=[\'"](/crimsondark/index\.php\?view=comic&amp;strip_id=\d+)[\'"]><img src=[\'"]themes/cdtheme/images/active_prev.png[\'"]')
help = 'Index format: n (unpadded)'
2013-04-10 16:36:33 +00:00
class CucumberQuest(_BasicScraper):
url = 'http://cucumber.gigidigi.com/'
rurl = escape(url)
2013-04-28 17:58:38 +00:00
stripUrl = url + 'cq/%s/'
2013-04-10 16:36:33 +00:00
firstStripUrl = stripUrl % 'page-1'
startUrl = url + 'recent.html'
starter = indirectStarter
2013-04-28 17:58:38 +00:00
imageSearch = (
compile(tagre("img", "src", r'(%swp-content/uploads/\d+/\d+/\d+[^"]+)' % rurl)),
compile(tagre("img", "src", r'(%swp-content/uploads/\d+/\d+/ch\d+[^"]+)' % rurl)),
compile(tagre("img", "src", r'(%swp-content/uploads/\d+/\d+/bonus[^"]+)' % rurl)),
)
prevSearch = compile(tagre("a", "href", r'(%scq/[^"]+/)' % rurl, after="previous"))
latestSearch = compile(r'window\.location="(/cq/[^"]+/)"')
2013-04-10 16:36:33 +00:00
help = 'Index format: stripname'
2016-04-28 22:34:25 +00:00
class Curtailed(_WordPressScraper):
2013-04-25 18:46:05 +00:00
url = 'http://curtailedcomic.com/'
2016-04-28 22:34:25 +00:00
firstStripUrl = url + 'comic/001-sneeze/'
2013-04-25 18:46:05 +00:00
2017-05-14 22:27:28 +00:00
def shouldSkipUrl(self, url, data):
"""Skip pages without images."""
return 'comic/sitrep-1' in url
2013-04-25 18:46:05 +00:00
2015-05-26 07:47:31 +00:00
class Curvy(_ParserScraper):
url = 'http://www.c.urvy.org/'
stripUrl = url + '?date=%s'
2013-04-10 21:57:09 +00:00
firstStripUrl = stripUrl % '20080329'
2015-05-26 07:47:31 +00:00
imageSearch = '//div[@id="theActualComic"]//img'
prevSearch = '//div[@class="aNavbar"]//p[2]/a'
2012-06-20 19:58:13 +00:00
help = 'Index format: yyyymmdd'
class CyanideAndHappiness(_BasicScraper):
url = 'http://www.explosm.net/comics/'
starter = bounceStarter
stripUrl = url + '%s/'
2013-04-10 21:57:09 +00:00
firstStripUrl = stripUrl % '15'
imageSearch = compile(tagre("img", "src", r'(//files.explosm.net/comics/[^"]+)', before="main-comic"))
prevSearch = compile(tagre("a", "href", r'(/comics/\d+/)', after="previous-comic"))
nextSearch = compile(tagre("a", "href", r"(/comics/\d+/)", after="next-comic"))
2012-06-20 19:58:13 +00:00
help = 'Index format: n (unpadded)'
2014-02-10 20:58:26 +00:00
def shouldSkipUrl(self, url, data):
"""Skip pages without images."""
return "/comics/play-button.png" in data[0]
def namer(self, image_url, page_url):
imgname = image_url.split('/')[-1]
# only get the first 100 chars for the image name
imgname = imgname[:100]
imgnum = page_url.split('/')[-2]
return '%s_%s' % (imgnum, imgname)