dosage/dosagelib/plugins/r.py

188 lines
6.6 KiB
Python
Raw Permalink Normal View History

# SPDX-License-Identifier: MIT
2024-03-17 20:44:46 +00:00
# SPDX-FileCopyrightText: © 2004 Tristan Seligmann and Jonathan Jacobs
# SPDX-FileCopyrightText: © 2012 Bastian Kleineidam
# SPDX-FileCopyrightText: © 2015 Tobias Gruetzmacher
# SPDX-FileCopyrightText: © 2019 Daniel Ring
2016-05-05 18:55:14 +00:00
from re import compile
from urllib.parse import urljoin
from ..helpers import bounceStarter
2023-06-07 06:42:10 +00:00
from ..scraper import ParserScraper, _BasicScraper, _ParserScraper
2012-11-21 20:57:26 +00:00
from ..util import tagre
from .common import WordPressScraper, WordPressNavi, WordPressWebcomic
2012-06-20 19:58:13 +00:00
2023-06-07 06:42:10 +00:00
class Rainburn(ParserScraper):
url = 'https://rainburn.virmir.com/'
stripUrl = url + 'comic.php?page=%s'
firstStripUrl = stripUrl % '1'
imageSearch = '//div[@class="comic"]//img'
prevSearch = '//a[contains(@class, "prev")]'
class RalfTheDestroyer(WordPressScraper):
2015-04-21 17:12:40 +00:00
url = 'http://ralfthedestroyer.com/'
2012-06-20 19:58:13 +00:00
class RayFox(WordPressNavi):
2020-05-21 06:08:43 +00:00
url = 'https://www.rayfoxthecomic.com/'
stripUrl = url + 'comic/%s/'
firstStripUrl = stripUrl % 'not-a-super-hero/it-begins'
def namer(self, imageUrl, pageUrl):
filename = imageUrl.rsplit('/', 1)[-1].split('.', 1)[0]
ext = imageUrl.rsplit('.', 1)[-1]
if filename == 'j':
filename = 'RF_E3_P52'
elif filename == '46' or filename == '55' or filename == '61':
filename = 'RF_E3_P' + filename
elif 'chapter-3-cover' in filename:
filename = 'RF_E3_Cover'
elif 'Cover2' in filename:
filename = 'RF_E1_' + filename
elif 'Volume-1-Cover' in filename:
filename = filename.replace('Ray-Fox-Volume-1-', 'RF_E1_')
elif filename[0] == '0':
filename = 'RF_E1_P' + filename
return filename + '.' + ext
class RaynaOnTheRiver(WordPressScraper):
2016-05-16 21:55:41 +00:00
url = 'http://www.catomix.com/rayna/'
firstStripUrl = url + 'archives/comic/teaser-poster'
class RealLife(WordPressScraper):
url = 'https://reallifecomics.com/'
2013-07-18 18:39:53 +00:00
stripUrl = url + 'comic.php?comic=%s'
2016-05-05 18:55:14 +00:00
firstStripUrl = stripUrl % 'title-1'
help = 'Index format: monthname-dd-yyyy'
2019-07-14 00:16:28 +00:00
def namer(self, imageUrl, pageUrl):
# Fix inconsisntent filenames
filename = imageUrl.rsplit('/', 1)[-1]
if pageUrl.rsplit('=', 1)[-1] == 'may-27-2014':
filename = filename.replace('20140219_3121', '20140527')
filename = filename.replace('5-Finished', '20140623_3161')
filename = filename.replace('520140722', '20140722')
filename = filename.replace('520140724', '20140724')
return filename
2016-05-05 18:55:14 +00:00
def getPrevUrl(self, url, data):
# "Parse" JavaScript
prevtag = data.find_class('comic-nav-previous')
if not prevtag:
return None
target = prevtag[0].get('onclick').split("'")[1]
return urljoin(url, target)
2012-06-20 19:58:13 +00:00
class RealmOfAtland(_ParserScraper):
url = 'https://web.archive.org/web/20201225151926/http://www.realmofatland.com/'
2013-04-09 17:37:47 +00:00
stripUrl = url + '?p=%s'
firstStripUrl = stripUrl % '1'
prevSearch = '//a[@id="cg_back"]'
imageSearch = '//p[@id="cg_img"]//img'
endOfLife = True
2013-04-09 17:37:47 +00:00
help = 'Index format: nnn'
2021-01-29 02:14:08 +00:00
class Recursion(_ParserScraper):
url = 'https://recursioncomic.com/'
stripUrl = url + '%s'
firstStripUrl = stripUrl % '0001'
imageSearch = '//div[@class="content"]//img'
prevSearch = '//link[@rel="prev"]'
def namer(self, imageUrl, pageUrl):
# Fix inconsistent filenames
filename = imageUrl.rsplit('/', 1)[-1]
filename = filename.replace('0bf62e92-2c98-4fb2-8ed7-4584980beb17', 'page0005')
filename = filename.replace('76112837-c5cd-4df7-8c53-3ed5c25194cf', 'page0003')
filename = filename.replace('ed271080-6b1b-4d7a-8509-b2d8a15da805', 'page0002')
filename = filename.replace('7b194ef7-ac77-4b5c-aed0-826901d13d04', 'page0001')
return filename
2016-05-05 18:55:14 +00:00
class RedMeat(_ParserScraper):
url = 'http://www.redmeat.com/max-cannon/FreshMeat'
imageSearch = '//div[@class="comicStrip"]//img'
prevSearch = '//a[@class="prev"]'
2013-03-06 19:21:10 +00:00
2016-05-05 18:55:14 +00:00
def namer(self, image_url, page_url):
parts = image_url.rsplit('/', 2)
return '_'.join(parts[1:3])
2013-03-06 19:21:10 +00:00
class Requiem(WordPressScraper):
2021-08-14 15:17:38 +00:00
baseUrl = 'http://requiem.spiderforest.com/'
url = baseUrl + '?latest'
stripUrl = baseUrl + 'comic/%s'
firstStripUrl = stripUrl % '2004-06-07-3'
2024-03-17 20:44:46 +00:00
class Replay(ParserScraper):
2019-06-28 07:32:04 +00:00
url = 'http://replaycomic.com/'
stripUrl = url + 'comic/%s/'
firstStripUrl = stripUrl % 'red-desert'
2022-04-06 09:43:47 +00:00
imageSearch = '//div[@id="comic"]//img[@alt]'
2019-06-28 07:32:04 +00:00
prevSearch = '//a[contains(@class, "comic-nav-previous")]'
nextSearch = '//a[contains(@class, "comic-nav-next")]'
def starter(self):
# Retrieve archive page to identify chapters
archivePage = self.getPage(self.url + 'archive')
2024-03-17 20:44:46 +00:00
archive = self.match(archivePage, '//div[d:class("comic-archive-chapter-wrap")]')
2019-06-28 07:32:04 +00:00
self.chapter = len(archive) - 1
self.startOfChapter = []
for archiveChapter in archive:
2024-03-17 20:44:46 +00:00
self.startOfChapter.append(self.match(archiveChapter, './/a')[0].get('href'))
2019-06-28 07:32:04 +00:00
return bounceStarter(self)
def namer(self, imageUrl, pageUrl):
# Name pages based on chapter, index, and post title
name = pageUrl.rstrip('/').rsplit('/', 1)[-1]
page = imageUrl.rsplit('/', 1)[-1].rsplit('.', 1)
# Fix inconsistent page number formatting
if page[0].isdigit() and len(page[0]) > 2 and self.chapter == 1 and name != 'through-the-woods':
page[0] = page[0][:2] + '-' + page[0][2:]
name = '%d-%s-%s.%s' % (self.chapter, page[0], name, page[1])
if pageUrl in self.startOfChapter:
self.chapter -= 1
return name
class RiversideExtras(WordPressWebcomic):
url = 'https://riversidecomics.com/'
2016-05-05 18:55:14 +00:00
class RomanticallyApocalyptic(_ParserScraper):
url = 'http://romanticallyapocalyptic.com/'
2016-05-05 18:55:14 +00:00
stripUrl = url + '%s'
firstStripUrl = stripUrl % '0'
imageSearch = '//div[d:class("comicpanel")]/center//img'
2016-05-05 18:55:14 +00:00
prevSearch = '//a[@accesskey="p"]'
help = 'Index format: n'
adult = True
2016-05-05 18:55:14 +00:00
class Roza(_ParserScraper):
url = 'http://www.junglestudio.com/roza/index.php'
stripUrl = url + '?date=%s'
2013-04-10 21:57:09 +00:00
firstStripUrl = stripUrl % '2007-05-01'
2016-05-05 18:55:14 +00:00
imageSearch = '//img[contains(@src, "pages/")]'
prevSearch = '//a[img[contains(@src, "navtable_01.gif")]]'
2012-06-20 19:58:13 +00:00
help = 'Index format: yyyy-mm-dd'
2013-03-12 19:49:46 +00:00
class Ruthe(_BasicScraper):
url = 'http://ruthe.de/'
2016-05-05 18:55:14 +00:00
stripUrl = url + 'cartoon/%s/datum/asc/'
2013-03-12 19:49:46 +00:00
firstStripUrl = stripUrl % '1'
lang = 'de'
2014-07-31 19:27:49 +00:00
imageSearch = compile(tagre("img", "src", r'(/?cartoons/strip_\d+[^"]+)'))
prevSearch = compile(tagre("a", "href", r'(/cartoon/\d+/datum/asc/)'))
2013-03-12 19:49:46 +00:00
help = 'Index format: number'