dosage/dosagelib/plugins/p.py

342 lines
11 KiB
Python
Raw Normal View History

# SPDX-License-Identifier: MIT
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
# Copyright (C) 2015-2022 Tobias Gruetzmacher
# Copyright (C) 2019-2020 Daniel Ring
from re import compile, escape
from ..scraper import _BasicScraper, _ParserScraper, ParserScraper
from ..helpers import bounceStarter, queryNamer, indirectStarter
from ..util import tagre
from .common import ComicControlScraper, WordPressScraper, WordPressNavi
2022-05-28 13:46:52 +00:00
class PandyLand(_ParserScraper):
url = ('https://web.archive.org/web/20200122163307/'
'http:/pandyland.net/')
stripUrl = url + '%s'
firstStripUrl = stripUrl % '1'
imageSearch = '//div[d:class("comic")]/img'
prevSearch = '//a[contains(text(), "previous")]'
help = 'Index format: number'
endOfLife = True
2012-06-20 19:58:13 +00:00
class ParadigmShift(_BasicScraper):
url = 'http://www.paradigmshiftmanga.com/'
starter = indirectStarter
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"))
latestSearch = compile(tagre("a", "href", r'([^"]+)',
after="next-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'
class ParaNatural(ComicControlScraper):
2020-09-13 14:48:32 +00:00
url = 'https://www.paranatural.net/'
firstStripUrl = url + 'comic/chapter-1'
class PartiallyClips(WordPressScraper):
url = ('https://web.archive.org/web/20180509161332/'
'http://partiallyclips.com/')
firstStripUrl = url + 'comic/screaming-woman/'
endOfLife = True
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'
2019-07-14 06:59:41 +00:00
class PeanutBerrySundae(_ParserScraper):
baseUrl = 'https://foxyverse.com/'
url = baseUrl + 'comics/'
stripUrl = baseUrl + 'peanut-berry-sundae-%s/'
firstStripUrl = stripUrl % '1'
imageSearch = ('//img[contains(@src, "Page")]',
'//img[contains(@src, "page")]')
latestSearch = '//a[contains(@href, "peanut-berry-sundae")]'
starter = indirectStarter
2020-04-19 08:50:00 +00:00
adult = True
2019-07-14 06:59:41 +00:00
def getPrevUrl(self, url, data):
# Replace missing navigation links
pageNum = int(url.replace('-70-2', '-71').rstrip('/').rsplit('-', 1)[-1])
url = self.stripUrl % str(pageNum - 1)
return url.replace('-71', '-70-2')
2015-05-14 10:33:46 +00:00
class PebbleVersion(_ParserScraper):
url = 'http://www.pebbleversion.com/'
stripUrl = url + 'Archives/Strip%s.html'
2015-05-14 10:33:46 +00:00
imageSearch = "//table/tr[2]//img"
prevSearch = '//a[text()="Previous Comic"]'
2012-06-20 19:58:13 +00:00
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=""))
2012-06-20 19:58:13 +00:00
help = 'Index format: n (unpadded)'
2016-05-05 18:55:14 +00:00
class PennyArcade(_ParserScraper):
url = 'https://www.penny-arcade.com/comic/'
stripUrl = url + '%s'
firstStripUrl = stripUrl % '1998/11/18/the-sin-of-long-load-times'
imageSearch = '//div[d:class("comic-panel")]//img'
prevSearch = '//a[d:class("older")]'
nextSearch = '//a[d:class("newer")]'
multipleImagesPerStrip = True
starter = bounceStarter
2016-05-05 18:55:14 +00:00
help = 'Index format: yyyy/mm/dd'
2014-03-26 18:59:42 +00:00
2012-06-20 19:58:13 +00:00
class PeppermintSaga(WordPressNavi):
url = 'http://www.pepsaga.com/'
stripUrl = url + '?p=%s'
2013-04-10 21:57:09 +00:00
firstStripUrl = stripUrl % '3'
2017-05-21 23:17:05 +00:00
help = 'Index format: number'
adult = True
class PeppermintSagaBGR(WordPressNavi):
2017-05-21 23:17:05 +00:00
url = 'http://bgr.pepsaga.com/'
stripUrl = url + '?p=%s'
firstStripUrl = stripUrl % '4'
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
2019-08-27 08:41:28 +00:00
class PeterAndCompany(_ParserScraper):
url = 'http://peterandcompany.com/'
stripUrl = url + '%s'
firstStripUrl = stripUrl % '20050101'
imageSearch = ('//div[@id="page"]//img',
'//div[@id="strip"]//img[contains(@src, "strips/")]')
prevSearch = '//a[./img[contains(@src, "nav_previous")]]'
2019-08-27 08:42:07 +00:00
class PeterAndWhitney(_ParserScraper):
url = 'http://peterandwhitney.com/'
stripUrl = url + '%s'
firstStripUrl = stripUrl % '20160502'
imageSearch = '//div[@id="page"]//img'
prevSearch = '//a[./img[contains(@src, "nav_previous")]]'
2019-08-27 08:41:28 +00:00
2016-05-05 18:55:14 +00:00
class PHDComics(_ParserScraper):
2017-02-12 15:21:36 +00:00
BROKEN_COMMENT_END = compile(r'--!>')
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'
2017-02-12 01:16:38 +00:00
imageSearch = '//img[@id="comic2"]'
2016-05-05 18:55:14 +00:00
prevSearch = '//a[img[contains(@src, "prev_button")]]'
nextSearch = '//a[img[contains(@src, "next_button")]]'
help = 'Index format: n (unpadded)'
2017-02-12 15:21:36 +00:00
# Ugly hack :(
def _parse_page(self, data):
data = self.BROKEN_COMMENT_END.sub('-->', data)
return super(PHDComics, self)._parse_page(data)
def shouldSkipUrl(self, url, data):
2014-01-06 07:20:58 +00:00
"""Skip pages without images."""
return url in (
2016-05-16 21:16:29 +00:00
# video
self.stripUrl % '1880',
self.stripUrl % '1669',
2014-01-06 07:20:58 +00:00
)
class Picklewhistle(ComicControlScraper):
url = 'http://www.picklewhistle.com/'
class PicPakDog(WordPressScraper):
url = 'http://www.picpak.net/'
2016-05-16 21:16:29 +00:00
firstStripUrl = url + 'comic/dogs-cant-spell/'
2012-12-08 20:30:51 +00:00
2016-05-05 18:55:14 +00:00
# Keep, because naming is different to PHDComics...
class PiledHigherAndDeeper(PHDComics):
starter = bounceStarter
namer = queryNamer('comicid', use_page_url=True)
2012-06-20 19:58:13 +00:00
class Pixel(_BasicScraper):
url = 'http://pixelcomic.net/'
rurl = escape(url)
stripUrl = url + '%s'
firstStripUrl = stripUrl % '000.shtml'
imageSearch = compile(tagre("img", "src", r'(\d+\.png)'))
prevSearch = compile(tagre("a", "href", r'(%s\d+\.(?:php|shtml))' % rurl,
before="prev"))
help = 'Index format: nnn'
class PlanescapeSurvival(_BasicScraper):
2013-03-06 19:21:10 +00:00
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'
2019-06-21 08:10:00 +00:00
class PlushAndBlood(_ParserScraper):
url = 'http://www.plushandblood.com/Comic.php'
stripUrl = url + '?strip_id=%s'
firstStripUrl = stripUrl % '1'
imageSearch = '//img[contains(@src, "comics/")]'
prevSearch = '//a[./img[contains(@src, "Nav/Prev")]]'
2015-05-26 10:31:43 +00:00
class PokeyThePenguin(_ParserScraper):
url = 'http://www.yellow5.com/pokey/archive/'
stripUrl = url + 'index%s.html'
firstStripUrl = stripUrl % '1'
2015-05-26 10:31:43 +00:00
imageSearch = '//p/img'
latestSearch = '(//a)[last()]'
multipleImagesPerStrip = True
starter = indirectStarter
help = 'Index format: number'
2015-05-26 10:31:43 +00:00
def getPrevUrl(self, url, data):
"""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)
2017-04-15 23:06:41 +00:00
class PoorlyDrawnLines(_ParserScraper):
url = 'http://poorlydrawnlines.com/comic/'
2017-04-15 23:06:41 +00:00
firstStripUrl = url + 'campus-characters/'
imageSearch = '//div[d:class("comic")]//img'
2017-04-15 23:06:41 +00:00
prevSearch = '//a[@rel="prev"]'
class PoppyOPossum(WordPressScraper):
2019-07-11 07:34:24 +00:00
baseUrl = 'https://www.poppy-opossum.com/'
url = baseUrl + '?latest'
stripUrl = baseUrl + 'comic/%s'
firstStripUrl = stripUrl % 'a-story'
2019-07-16 08:22:50 +00:00
class PowerNap(_ParserScraper):
2020-12-02 07:43:44 +00:00
url = 'https://www.powernapcomic.com/powernap/'
2019-07-16 08:22:50 +00:00
stripUrl = url + 'd/%s.html'
firstStripUrl = stripUrl % '20110617'
2020-12-02 07:43:44 +00:00
imageSearch = '//center/img'
2019-07-16 08:22:50 +00:00
prevSearch = '//a[./img[contains(@src, "previous")]]'
2020-12-02 07:43:44 +00:00
endOfLife = True
2019-07-16 08:22:50 +00:00
def imageUrlModifier(self, url, data):
return url.replace('\n', '').strip()
def link_modifier(self, fromurl, tourl):
return tourl.replace('\n', '').strip()
2016-05-16 21:16:29 +00:00
class Precocious(_ParserScraper):
url = 'http://www.precociouscomic.com/'
stripUrl = url + 'archive/comic/%s'
2016-05-16 21:16:29 +00:00
firstStripUrl = stripUrl % '2009/03/09'
imageSearch = '//img[contains(@src, "/comics/")]'
prevSearch = '//a[img[contains(@src, "/back_arrow")]]'
2012-11-21 20:57:26 +00:00
help = 'Index format: yyyy/mm/dd'
2012-06-20 19:58:13 +00:00
2016-10-31 05:57:47 +00:00
class PrinceOfSartar(WordPressNavi):
2016-08-08 03:30:47 +00:00
url = 'http://www.princeofsartar.com/'
stripUrl = url + 'comic/%s/'
firstStripUrl = stripUrl % 'introduction-chapter-1'
nextSearch = '//a[d:class("navi-next")]'
2016-08-08 03:30:47 +00:00
starter = bounceStarter
help = 'Index format: name'
def namer(self, image_url, page_url):
"""Use page URL to contruct a unique name."""
title = page_url.rsplit('/', 2)[1]
image_ext = image_url.rsplit('.', 1)[1]
return '%s.%s' % (title, image_ext)
2012-06-20 19:58:13 +00:00
2016-10-31 05:57:47 +00:00
class ProphecyOfTheCircle(WordPressNavi):
2019-12-26 00:08:07 +00:00
url = 'https://www.prophecyofthecircle.com/'
stripUrl = url + 'comic/%s/'
firstStripUrl = stripUrl % 'prologue'
def namer(self, imageUrl, pageUrl):
# Fix duplicate filenames
filename = imageUrl.rsplit('/', 1)[-1]
if '2015/12/jamet101' in imageUrl:
filename = filename.replace('101', '10')
elif '2012-02-20-jahrd156' in imageUrl:
filename = filename.replace('156', '157')
elif '2011-10-02-jahrd137' in imageUrl:
filename = filename.replace('137', '137-1')
# Fix inconsistent filenames
if filename[0] == '2':
filename = filename[11:]
if len(filename) >= 9 and filename[8].isdigit():
filename = filename[:8] + '-' + filename[8:]
return filename
2019-11-06 07:35:00 +00:00
class Prototype(_ParserScraper):
stripUrl = 'https://web.archive.org/web/20201030035444/http://planetprototype.com/%s/'
2019-11-06 07:35:00 +00:00
firstStripUrl = stripUrl % '2018/03/30/vol-1-ch-1-front-cover'
url = firstStripUrl
imageSearch = '//img[contains(@class, "wp-post-image")]'
prevSearch = '//a[.//text()="Previous"]'
latestSearch = '//a[.//text()="Latest"]'
starter = indirectStarter
endOfLife = True
2019-11-06 07:35:00 +00:00
2015-04-16 23:20:14 +00:00
class PS238(_ParserScraper):
url = 'http://ps238.nodwick.com/'
2016-05-05 18:55:14 +00:00
stripUrl = url + 'comic/%s/'
2019-06-12 07:05:47 +00:00
firstStripUrl = stripUrl % '12072006'
2015-04-16 23:20:14 +00:00
imageSearch = '//div[@id="comic"]//img'
prevSearch = '//a[@class="comic-nav-base comic-nav-previous"]'
help = 'Index format: yyyy-mm-dd'
class PvPOnline(ParserScraper):
baseUrl = 'https://www.toonhoundstudios.com/'
url = baseUrl + 'pvp/'
stripUrl = baseUrl + 'comic/%s/?sid=372'
firstStripUrl = stripUrl % '19980504'
imageSearch = '//div[@id="spliced-comic"]//img/@data-src-img'
prevSearch = '//div[d:class("comic-nav")]//a[d:class("prev")]'
help = 'Older pages need a Patreon subscription'