Repair and simplify Derideal (fixes #330)

This commit is contained in:
Tobias Gruetzmacher 2024-07-20 18:36:21 +02:00
parent df1e72e90a
commit 2a650d96e9
No known key found for this signature in database
2 changed files with 36 additions and 41 deletions

View file

@ -1,55 +1,49 @@
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: © 2019 Tobias Gruetzmacher # SPDX-FileCopyrightText: © 2019 Tobias Gruetzmacher
# SPDX-FileCopyrightText: © 2019 Daniel Ring # SPDX-FileCopyrightText: © 2019 Daniel Ring
import itertools
from ..scraper import ParserScraper from ..scraper import ParserScraper
from ..helpers import indirectStarter from ..helpers import indirectStarter, joinPathPartsNamer
class Derideal(ParserScraper): class Derideal(ParserScraper):
baseUrl = 'https://www.derideal.com/' baseUrl = 'https://derideal.com/'
imageSearch = '//img[contains(@class, "comic-page")]' imageSearch = '//img[d:class("comic-page") or d:class("comic-pag")]'
prevSearch = '//a[i[contains(@class, "fa-angle-left")]]' prevSearch = '//a[text()="<"]'
latestSearch = '//a[i[contains(@class, "fa-angle-double-right")]]' starter = indirectStarter
namer = joinPathPartsNamer(imageparts=range(-3, 0))
def __init__(self, name, sub, first, last=None): def __init__(self, name, lang, sub, first, eol=False, multi=False):
if name == 'Derideal': if lang == 'en':
super().__init__(name) base = 'Derideal'
lateststr = 'Read latest update'
else: else:
super().__init__('Derideal/' + name) base = 'DeridealSpanish'
sub = f'{lang}/{sub}'
lateststr = 'Leer última actualización'
self.url = self.baseUrl + sub if not name:
self.stripUrl = self.url + '/%s/' super().__init__(base)
self.firstStripUrl = self.stripUrl % first else:
self.startUrl = self.firstStripUrl super().__init__(f'{base}/{name}')
if last: self.url = f'{self.baseUrl}{sub}'
self.endOfLife = True self.firstStripUrl = f'{self.url}/{first}/'
self.latestSearch = f'//a[contains(text(), "{lateststr}")]'
def starter(self): self.lang = lang
indexPage = self.getPage(self.url) self.endOfLife = eol
self.chapters = self.match(indexPage, '//a[contains(text(), "Read this episode")]/@href') self.multipleImagesPerStrip = multi
self.currentChapter = len(self.chapters)
return indirectStarter(self)
def namer(self, imageUrl, pageUrl):
filename = pageUrl.rstrip('/').rsplit('/', 1)[-1]
filename = filename.replace('espanol-escape-25', 'escape-26')
filename = filename.replace('espanol-w-a-l-l-y', 'w-a-l-l-y')
filename = filename.replace('hogar-prision', 'home-prison')
filename = filename.replace('strip', 'pe').replace('purpurina-effect', 'pe')
filename = filename.replace('sector-de-seguridad', 'security-sector')
filename = 'ch' + str(self.currentChapter) + '-' + filename
if pageUrl in self.chapters:
self.currentChapter -= 1
return filename
@classmethod @classmethod
def getmodules(cls): def getmodules(cls):
return ( return itertools.chain.from_iterable((
cls('Derideal', 'derideal', 'cover-prime'), cls('', lang, 'derideal', 'chimeras-cover'),
cls('Legacy', 'derideal-legacy', 'the-dream-cover', last='derideal-is-on-hiatus'), cls('Legacy', lang, 'derideal-legacy', 'the-dream-cover', eol=True),
cls('LRE', 'RLE', 'the-leyend-of-the-rose-cover'), cls('LostMemories', lang, 'lost-memories', 'lost-memories-pixi', multi=True),
cls('ProjectPrime', 'project-prime', 'custus-part-i-cover'), cls('Nova', lang, 'nova', 'xen-prelude-cover'),
cls('PurpurinaEffect', 'purpurina-effect', 'purpurina-effect-cover'), cls('ProjectPrime', lang, 'project-prime', 'custus-part-i-cover'),
cls('TheVoid', 'the-void', 'the-void-cover'), cls('PurpurinaEffect', lang, 'purpurina-effect', 'purpurina-effect-cover'),
) cls('RLE', lang, 'RLE', 'the-leyend-of-the-rose-cover'),
cls('TheVoid', lang, 'the-void', 'the-void-cover'),
) for lang in ('en', 'es'))

View file

@ -1748,6 +1748,7 @@ class Renamed(Scraper):
# Renamed in 3.1 # Renamed in 3.1
cls('ComicsKingdom/SlylockFoxAndComicsForKids', 'ComicsKingdom/SlylockFox'), cls('ComicsKingdom/SlylockFoxAndComicsForKids', 'ComicsKingdom/SlylockFox'),
cls('ComicsKingdom/SlylockFoxAndComicsForKidsSpanish', 'ComicsKingdom/SlylockFoxSpanish'), cls('ComicsKingdom/SlylockFoxAndComicsForKidsSpanish', 'ComicsKingdom/SlylockFoxSpanish'),
cls('Derideal/LRE', 'Derideal/RLE'),
cls('Exiern', 'ComicFury/Exiern'), cls('Exiern', 'ComicFury/Exiern'),
cls('MaxOveracts', 'OccasionalComicsDisorder'), cls('MaxOveracts', 'OccasionalComicsDisorder'),
cls('SafelyEndangered', 'WebToons/SafelyEndangered'), cls('SafelyEndangered', 'WebToons/SafelyEndangered'),