dosage/dosagelib/plugins/p.py

275 lines
11 KiB
Python
Raw Normal View History

# -*- coding: iso-8859-1 -*-
# Copyright (C) 2004-2005 Tristan Seligmann and Jonathan Jacobs
2014-01-05 15:50:57 +00:00
# Copyright (C) 2012-2014 Bastian Kleineidam
2012-06-20 19:58:13 +00:00
from re import compile, escape
2015-04-16 23:20:14 +00:00
from ..scraper import _BasicScraper, _ParserScraper
2012-11-21 20:57:26 +00:00
from ..helpers import bounceStarter, queryNamer, indirectStarter
from ..util import tagre
2012-06-20 19:58:13 +00:00
2012-12-28 04:37:08 +00:00
class PandyLand(_BasicScraper):
url = 'http://pandyland.net/'
rurl = escape(url)
stripUrl = url + '%s/'
2013-04-10 21:57:09 +00:00
firstStripUrl = stripUrl % '1'
imageSearch = compile(tagre("img", "src", r'(%scomics/[^"]+)' % rurl))
prevSearch = compile(tagre("a", "href", r'(%s\d+/)' % rurl, after="prev"))
2012-12-28 04:37:08 +00:00
help = 'Index format: number'
class ParadigmShift(_BasicScraper):
url = 'http://www.paradigmshiftmanga.com/'
starter = indirectStarter(url, compile(tagre("a", "href", r'([^"]+)', after="next-comic-link")))
2013-02-18 19:55:54 +00:00
stripUrl = url + 'ps/%s.html'
imageSearch = compile(tagre("img", "src", r'([^"]*comics/ps/[^"]*)'))
prevSearch = compile(tagre("a", "href", r'([^"]+)', after="previous-comic-link"))
help = 'Index format: custom'
class ParallelUniversum(_BasicScraper):
url = 'http://www.paralleluniversum.net/'
rurl = escape(url)
stripUrl = url + '%s/'
firstStripUrl = stripUrl % '001-der-comic-ist-tot'
imageSearch = compile(tagre("img", "src", r'(%scomics/\d+-\d+-\d+[^"]+)' % rurl))
prevSearch = compile(tagre("a", "href", r'(%s[^"]+/)' % rurl) +
tagre("span", "class", "prev"))
help = 'Index format: number-stripname'
lang = 'de'
2012-06-20 19:58:13 +00:00
class PartiallyClips(_BasicScraper):
url = 'http://partiallyclips.com/'
rurl = escape(url)
stripUrl = url + '%s/'
2013-04-10 21:57:09 +00:00
firstStripUrl = stripUrl % '2001/10/28/screaming-woman'
imageSearch = compile(tagre("img", "src", r'(%scomics/[^"]+)' % rurl))
prevSearch = compile(tagre("a", "href", r'(%s[^"]+)' % rurl, after="prev"))
2012-11-21 20:57:26 +00:00
help = 'Index format: yyyy/mm/dd/stripname'
2012-06-20 19:58:13 +00:00
class PastelDefender(_BasicScraper):
2013-04-13 18:58:00 +00:00
baseUrl = 'http://www.pasteldefender.com/'
url = baseUrl + 'coverbackcover.html'
stripUrl = baseUrl + '%s.html'
2013-04-10 21:57:09 +00:00
firstStripUrl = stripUrl % 'cover'
2012-06-20 19:58:13 +00:00
imageSearch = compile(r'<IMG SRC="(images/.+?)" WIDTH="742"')
prevSearch = compile(r'<A HREF="([^"]+)"><IMG SRC="images/back\.gif"')
help = 'Index format: nnn'
class PebbleVersion(_BasicScraper):
url = 'http://www.pebbleversion.com/'
stripUrl = url + 'Archives/Strip%s.html'
2012-06-20 19:58:13 +00:00
imageSearch = compile(r'<img src="(ComicStrips/.+?|../ComicStrips/.+?)"')
prevSearch = compile(r'<a href="((?!.+?">First Comic)Archives/Strip.+?|(?=.+?">Previous Comic)(?!.+?">First Comic)Strip.+?)"')
help = 'Index format: n (unpadded)'
class PennyAndAggie(_BasicScraper):
2013-04-11 16:27:43 +00:00
url = 'http://pennyandaggie.com/'
rurl = escape(url)
stripUrl = url + 'index.php?p=%s'
2013-04-11 16:27:43 +00:00
imageSearch = compile(tagre("img", "src", r'(http://www\.pennyandaggie\.com/comics/[^"]+)'))
prevSearch = compile(tagre("a", "href", r"(index\.php\?p\=\d+)", quote="'") +
tagre("img", "src", r'%simages/previous_day\.gif' % rurl, quote=""))
starter = indirectStarter(url, prevSearch)
2012-06-20 19:58:13 +00:00
help = 'Index format: n (unpadded)'
class PennyArcade(_BasicScraper):
url = 'http://penny-arcade.com/comic/'
rurl = escape(url)
stripUrl = url + '%s'
2013-04-10 21:57:09 +00:00
firstStripUrl = stripUrl % '1998/11/18'
2012-11-21 20:57:26 +00:00
imageSearch = compile(tagre("img", "src", r'(http://art\.penny-arcade\.com/photos/[^"]+)'))
prevSearch = compile(tagre("a", "href", r'(%s[^"]+)' % rurl, before="btnPrev"))
2014-03-26 18:59:42 +00:00
nextSearch = compile(tagre("a", "href", r'(%s[^"]+)' % rurl, before="btnNext"))
help = 'Index format: yyyy/mm/dd/'
@classmethod
def prevUrlModifier(cls, prevUrl):
if prevUrl:
dummy, yyyy, mm, dd = prevUrl.rsplit('/', 3)
try:
int(dd)
except ValueError:
# URL has form yyyy/mm/dd/stripname
prevUrl = "%s/%s/%s" % (dummy, yyyy, mm)
return prevUrl
@classmethod
def starter(cls):
"""Get bounced start URL."""
data = cls.getPage(cls.url)
url1 = cls.fetchUrl(cls.url, data, cls.prevSearch)
data = cls.getPage(url1)
url2 = cls.fetchUrl(url1, data, cls.nextSearch)
2014-03-26 18:59:42 +00:00
return cls.prevUrlModifier(url2)
2012-06-20 19:58:13 +00:00
@classmethod
def namer(cls, imageUrl, pageUrl):
p = pageUrl.split('/')
return '%04d%02d%02d' % (int(p[4]), int(p[5]), int(p[6]))
2012-06-20 19:58:13 +00:00
class PeppermintSaga(_BasicScraper):
url = 'http://www.pepsaga.com/'
rurl = escape(url)
stripUrl = url + '?p=%s'
2013-04-10 21:57:09 +00:00
firstStripUrl = stripUrl % '3'
imageSearch = compile(tagre("img", "src", r'(%scomics/[^"]+)' % rurl))
prevSearch = compile(tagre("a", "href", r'(%s\?p=\d+)' % rurl, after="prev"))
2012-11-21 20:57:26 +00:00
help = 'Index format: number'
2013-04-14 07:02:14 +00:00
adult = True
2012-06-20 19:58:13 +00:00
class PHDComics(_BasicScraper):
2013-04-13 18:58:00 +00:00
baseUrl = 'http://phdcomics.com/'
url = baseUrl + 'comics.php'
stripUrl = baseUrl + 'comics/archive.php?comicid=%s'
firstStripUrl = stripUrl % '1'
imageSearch = compile(tagre("img", "src", r'(http://www\.phdcomics\.com/comics/archive/phd[^ ]+)', quote=""))
prevSearch = compile(tagre("a", "href", r'((?:comics/)?archive\.php\?comicid=\d+)', quote="") +
tagre("img", "src", r'(?:comics/)?images/prev_button\.gif', quote=""))
help = 'Index format: number'
def shouldSkipUrl(self, url, data):
2014-01-06 07:20:58 +00:00
"""Skip pages without images."""
return url in (
self.stripUrl % '1669', # video
)
2012-12-08 20:30:51 +00:00
class PicPakDog(_BasicScraper):
url = 'http://www.picpak.net/'
rurl = escape(url)
2013-02-22 18:43:33 +00:00
stripUrl = url + 'comic/%s/'
2013-04-10 21:57:09 +00:00
firstStripUrl = stripUrl % 'dogs-cant-spell'
imageSearch = compile(tagre("img", "src", r'(%swp-content/uploads/\d+/\d+/\d+-\d+-\d+-[^"]+\.png)' % rurl))
2013-05-25 21:24:33 +00:00
prevSearch = compile(tagre("a", "href", r'(%scomic/[^"]+)' % rurl, after="nav-prev"))
2013-02-21 18:47:37 +00:00
help = 'Index format: stripname'
2012-12-08 20:30:51 +00:00
2012-06-20 19:58:13 +00:00
class Pixel(_BasicScraper):
url = 'http://pixelcomic.net/'
rurl = escape(url)
2013-04-10 21:57:09 +00:00
stripUrl = url + '%s'
firstStripUrl = stripUrl % '000.shtml'
2012-11-21 20:57:26 +00:00
imageSearch = compile(tagre("img", "src", r'(\d+\.png)'))
2013-04-10 21:57:09 +00:00
prevSearch = compile(tagre("a", "href", r'(%s\d+\.(?:php|shtml))' % rurl, before="prev"))
2012-06-20 19:58:13 +00:00
help = 'Index format: nnn'
class PiledHigherAndDeeper(_BasicScraper):
url = 'http://www.phdcomics.com/comics.php'
starter = bounceStarter(url, compile(r'<a href=(archive\.php\?comicid=\d+)>.*<img [^>]*next_button\.gif'))
stripUrl = url + '?comicid=%s'
2013-04-10 21:57:09 +00:00
firstStripUrl = stripUrl % '1'
imageSearch = compile(tagre("img", "src", r'(http://www\.phdcomics\.com/comics/archive/phd\d+s\d?\.\w{3,4})', quote=""))
prevSearch = compile(r'<a href=((comics/)?archive\.php\?comicid=\d+)>.*<img [^>]*prev_button\.gif')
2012-06-20 19:58:13 +00:00
help = 'Index format: n (unpadded)'
namer = queryNamer('comicid', usePageUrl=True)
2012-12-08 20:30:51 +00:00
class Pimpette(_BasicScraper):
url = 'http://pimpette.ca/'
stripUrl = url + 'index.php?date=%s'
2013-04-10 21:57:09 +00:00
firstStripUrl = stripUrl % '20030905'
2012-12-08 20:30:51 +00:00
imageSearch = compile(tagre("img", "src", r'(strips/[^"]+)'))
prevSearch = compile(tagre("a", "href", r'(index\.php\?date=\d+)') + "Previous")
help = 'Index format: yyyymmdd'
2013-03-06 19:21:10 +00:00
# Broken navigation: prev link at http://planescapecomic.com/201.html points to same URL.
class _PlanescapeSurvival(_BasicScraper):
url = 'http://planescapecomic.com/'
stripUrl = url + '%s.html'
imageSearch = compile(r'src="(comics/.+?)"')
prevSearch = compile(r'<a href="(.+?)"><img alt="Previous" ')
help = 'Index format: nnn'
class PokeyThePenguin(_BasicScraper):
2013-04-13 18:58:00 +00:00
baseUrl = 'http://www.yellow5.com/pokey/archive/'
url = baseUrl + 'index558.html'
stripUrl = baseUrl + 'index%s.html'
firstStripUrl = stripUrl % '1'
imageSearch = compile(tagre("img", "src", r'(pokey\d+[^"]+)'))
2013-03-06 19:23:43 +00:00
prevSearch = True
multipleImagesPerStrip = True
help = 'Index format: number'
def getPrevUrl(self, url, data, baseUrl):
"""Decrease index.html number."""
mo = compile(r"index(\d+)\.html").search(url)
num = int(mo.group(1)) - 1
prefix = url.rsplit('/', 1)[0]
return "%s/index%d.html" % (prefix, num)
class PoorlyDrawnLines(_BasicScraper):
url = 'http://poorlydrawnlines.com/comic/'
rurl = escape(url)
stripUrl = url + '%s'
firstStripUrl = stripUrl % 'campus-characters/'
imageSearch = compile(tagre("img", "src", r'(http://poorlydrawnlines\.com/wp-content/uploads/\d+/\d+/[^"]+)'))
prevSearch = compile(tagre("li", "class", r'previous') + tagre("a", "href", r'(%s[^"]+)' % rurl))
help = 'Index Format: name'
2012-06-20 19:58:13 +00:00
class Precocious(_BasicScraper):
url = 'http://www.precociouscomic.com/'
starter = indirectStarter(url,
2012-11-21 20:57:26 +00:00
compile(tagre("a", "href", r'(/archive/comic/[^"]+)') + tagre("img", "src", r"/templates/precocious_main/images/next_arrow\.png"))
)
stripUrl = url + 'archive/comic/%s'
2013-04-04 16:30:02 +00:00
imageSearch = compile(tagre("img", "src", r'(/comics/\d+[^"]*\.(?:jpg|gif))'))
2012-11-21 20:57:26 +00:00
prevSearch = compile(tagre("a", "href", r'(/archive/comic/[^"]+)') + tagre("img", "src", r"/templates/precocious_main/images/back_arrow\.png"))
help = 'Index format: yyyy/mm/dd'
2012-06-20 19:58:13 +00:00
2015-04-16 23:20:14 +00:00
class PS238(_ParserScraper):
url = 'http://ps238.nodwick.com/'
stripUrl = url + '/comic/%s/'
starter = bounceStarter(url, '//a[@class="comic-nav-base comic-nav-next"]')
imageSearch = '//div[@id="comic"]//img'
prevSearch = '//a[@class="comic-nav-base comic-nav-previous"]'
help = 'Index format: yyyy-mm-dd'
2012-06-20 19:58:13 +00:00
class ProperBarn(_BasicScraper):
url = 'http://www.nitrocosm.com/go/gag/'
stripUrl = url + '%s/'
2013-04-10 21:57:09 +00:00
firstStripUrl = stripUrl % '1'
2012-12-04 06:02:40 +00:00
imageSearch = compile(tagre("img", "src", r'(http://content\.nitrocosm\.com/gag/\d+\.[^"]+)'))
2012-11-21 20:57:26 +00:00
prevSearch = compile(tagre("a", "href", r'(http://www\.nitrocosm\.com/go/gag/\d+/)', after="nav_btn_previous"))
2012-06-20 19:58:13 +00:00
help = 'Index format: nnn'
class PunksAndNerds(_BasicScraper):
url = 'http://www.punksandnerds.com/'
rurl = escape(url)
stripUrl = url + '?p=%s'
2013-04-10 21:57:09 +00:00
firstStripUrl = stripUrl % '15'
imageSearch = compile(tagre("img", "src", r'(%scomics/[^"]+)' % rurl))
prevSearch = compile(tagre("a", "href", r'(%s\?p=\d+)' % rurl, after="navi-prev"))
2012-06-20 19:58:13 +00:00
help = 'Index format: nnn'
class PunksAndNerdsOld(_BasicScraper):
url = 'http://original.punksandnerds.com/'
stripUrl = url + 'd/%s.html'
2012-06-20 19:58:13 +00:00
imageSearch = compile(r' src="(/comics/.+?)"')
prevSearch = compile(r'><strong><a href="(.+?)"[^>]+?><img[^>]+?src="/previouscomic.gif">')
help = 'Index format: yyyymmdd'
2013-04-10 16:36:33 +00:00
class PvPonline(_BasicScraper):
url = 'http://pvponline.com/comic'
stripUrl = url + '%s'
imageSearch = compile(tagre("img", "src", r'(http://s3[^"]+\.amazonaws\.com/pvponlinenew/img/comic/\d+/\d+/pvp[^"]+\.jpg)'))
prevSearch = compile(tagre("a", "href", r'(/comic/[^"]+)', after="left divider"))
2013-04-10 16:36:33 +00:00
help = 'Index format: yyyy/mm/dd/stripname'