From 6e5ae63331a6993d64946ba96023fdfb0e91bbec Mon Sep 17 00:00:00 2001 From: Techwolf Date: Tue, 28 Dec 2021 00:40:45 -0800 Subject: [PATCH] Fix Wrongside and add side stories --- dosagelib/plugins/w.py | 6 --- dosagelib/plugins/wrongside.py | 75 ++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 6 deletions(-) create mode 100644 dosagelib/plugins/wrongside.py diff --git a/dosagelib/plugins/w.py b/dosagelib/plugins/w.py index e061c0a3a..63d5657cc 100644 --- a/dosagelib/plugins/w.py +++ b/dosagelib/plugins/w.py @@ -224,9 +224,3 @@ class WormWorldSagaGerman(WormWorldSaga): class WormWorldSagaSpanish(WormWorldSaga): lang = 'es' - - -class Wrongside(_WPNavi): - url = 'http://www.ayzewi.com/comic/' - stripUrl = url + '?comic=%s' - firstStripUrl = stripUrl % 'intro-2' diff --git a/dosagelib/plugins/wrongside.py b/dosagelib/plugins/wrongside.py new file mode 100644 index 000000000..785ed7ec5 --- /dev/null +++ b/dosagelib/plugins/wrongside.py @@ -0,0 +1,75 @@ +# SPDX-License-Identifier: MIT +# Copyright (C) 2019-2020 Tobias Gruetzmacher +# Copyright (C) 2019-2022 Daniel Ring +from ..scraper import _ParserScraper +from ..helpers import indirectStarter + + +class Wrongside(_ParserScraper): + baseUrl = 'http://ayzewi.com/maingallery3/' + url = baseUrl + 'index.php?/category/5' + stripUrl = baseUrl + 'picture.php?%s' + firstStripUrl = stripUrl % '/175/category/21' + imageSearch = '//img[@id="theMainImage"]/@src' + prevSearch = '//a[contains(@title, "Previous :")]' + + def starter(self): + archivePage = self.getPage(self.url) + chapterUrls = archivePage.xpath('//ul[@class="albThumbs"]//a/@href') + self.archive = [] + for chapterUrl in chapterUrls: + chapterPage = self.getPage(chapterUrl) + self.archive.append(chapterPage.xpath('(//ul[@id="thumbnails"]//a/@href)[last()]')[0]) + return self.archive[0] + + def getPrevUrl(self, url, data): + if data.xpath(self.prevSearch) == [] and len(self.archive) > 0: + return self.archive.pop() + return super(Wrongside, self).getPrevUrl(url, data) + + def namer(self, imageUrl, pageUrl): + page = self.getPage(pageUrl) + title = page.xpath('//div[@class="browsePath"]/h2/text()')[0] + return title.replace('"', '') + '.' + imageUrl.rsplit('.', 1)[-1] + + +class WrongsideBeginnings(Wrongside): + name = 'Wrongside/Beginnings' + baseUrl = 'http://ayzewi.com/maingallery3/' + url = baseUrl + 'index.php?/category/4' + stripUrl = baseUrl + 'picture.php?%s' + firstStripUrl = stripUrl % '/2/category/18' + + +class WrongsideSideStories(_ParserScraper): + baseUrl = 'http://ayzewi.com/maingallery3/' + stripUrl = baseUrl + 'picture.php?%s' + imageSearch = '//img[@id="theMainImage"]/@src' + prevSearch = '//a[contains(@title, "Previous :")]' + latestSearch = '(//ul[@id="thumbnails"]//a/@href)[last()]' + starter = indirectStarter + + def __init__(self, name, category, first, last=None): + super().__init__('Wrongside/' + name) + self.url = self.baseUrl + 'index.php?/category/' + category + self.firstStripUrl = self.stripUrl % ('/' + first + '/category/' + category) + + if last: + self.endOfLife = True + + @classmethod + def getmodules(cls): + return ( + cls('AnarkisRising', '7', '302'), + cls('CommonsDreams', '9', '324'), + cls('Faith', '11', '349'), + cls('Sarah', '10', '337'), + cls('ThereAreNoAviansHere', '8', '313'), + cls('TheScientificProphet', '13', '358'), + cls('TheStrangers', '12', '361'), + ) + + def namer(self, imageUrl, pageUrl): + page = self.getPage(pageUrl) + title = page.xpath('//div[@class="browsePath"]/h2/text()')[0] + return title.replace('"', '') + '.' + imageUrl.rsplit('.', 1)[-1]