From 2ef6ebb6f804a9431d4c582817563a9c777bbc2e Mon Sep 17 00:00:00 2001 From: Techwolf Date: Fri, 19 Jun 2020 21:34:49 -0700 Subject: [PATCH] Fix Nightshift and StarfireAgency --- dosagelib/plugins/n.py | 32 +++++++++++++++----------------- dosagelib/plugins/s.py | 40 ++++++++++++++++++++++------------------ 2 files changed, 37 insertions(+), 35 deletions(-) diff --git a/dosagelib/plugins/n.py b/dosagelib/plugins/n.py index 7c86ca0df..2587f4efc 100644 --- a/dosagelib/plugins/n.py +++ b/dosagelib/plugins/n.py @@ -102,31 +102,29 @@ class Nicky510(_WPNavi): endOfLife = True -class Nightshift(_ParserScraper): +class Nightshift(_WPWebcomic): url = 'https://poecatcomix.com/nightshift-static/' - stripUrl = 'https://poecatcomix.com/comic/%s/' - firstStripUrl = stripUrl % 'ns1-page-cover' - imageSearch = '//div[@class="mangapress-media-img"]/img' - prevSearch = '//li[@class="link-prev"]/a' - latestSearch = '//li[@class="link-last"]/a/@href' + stripUrl = 'https://poecatcomix.com/nightshift/%s/' + firstStripUrl = stripUrl % 'ns-cover' + imageSearch = '//div[contains(@class, "webcomic-media")]//img' adult = True def starter(self): - # Build list of chapters for navigation + # Build list of chapters for naming indexPage = self.getPage(self.url) self.chapters = indexPage.xpath('//a[./img[contains(@class, "attachment-large")]]/@href') - chapterPage = self.getPage(self.chapters[-1]) - return chapterPage.xpath(self.latestSearch)[0] - - def getPrevUrl(self, url, data): - # Retrieve previous chapter from list - if url in self.chapters: - chapterPage = self.getPage(self.chapters[self.chapters.index(url) - 1]) - return chapterPage.xpath(self.latestSearch)[0] - return super(Nightshift, self).getPrevUrl(url, data) + latestPage = self.chapters[0] + self.chapters = self.chapters[1:] + self.currentChapter = len(self.chapters) + return latestPage def namer(self, imageUrl, pageUrl): - return pageUrl.rstrip('/').rsplit('/', 1)[-1] + '.' + imageUrl.rsplit('.', 1)[-1] + page = pageUrl.rstrip('/').rsplit('/', 1)[-1] + page = page.replace('blood-brothers', 'bloodbrothers').replace('bb-2', 'bb2').replace('ns7-', 'page-') + filename = 'ns%d-%s.%s' % (self.currentChapter, page, imageUrl.rsplit('.', 1)[-1]) + if pageUrl in self.chapters: + self.currentChapter = self.currentChapter - 1 + return filename class Nimona(_ParserScraper): diff --git a/dosagelib/plugins/s.py b/dosagelib/plugins/s.py index fc4984c3f..6afe3c3b4 100644 --- a/dosagelib/plugins/s.py +++ b/dosagelib/plugins/s.py @@ -500,26 +500,30 @@ class StarCrossdDestiny(_ParserScraper): return directory + '-' + filename -class StarfireAgency(_WordPressScraper): - url = 'http://starfire.poecatcomix.com/' - stripUrl = url + 'comic/%s/' - firstStripUrl = stripUrl % 'sfa-issue-1' +class StarfireAgency(_WPWebcomic): + url = 'https://poecatcomix.com/starfire-agency-static/' + stripUrl = 'https://poecatcomix.com/starfire-agency/%s/' + firstStripUrl = stripUrl % '2005-09-201' + imageSearch = '//div[contains(@class, "webcomic-media")]//img' + + def starter(self): + # Build list of chapters for naming + indexPage = self.getPage(self.url) + self.chapters = indexPage.xpath('//a[./img[contains(@class, "attachment-large")]]/@href') + latestPage = self.chapters[0] + self.chapters = self.chapters[1:] + self.currentChapter = len(self.chapters) + return latestPage def namer(self, imageUrl, pageUrl): - # Prepend chapter title to page filenames - page = self.getPage(pageUrl) - chapter = page.xpath('//div[@class="comic-chapter"]/a') - if len(chapter) > 0: - chapter = chapter[0].text.replace(' ', '-').lower() - else: - chapter = 'chapter-1' - - # Fix inconsistent filenames - filename = imageUrl.rsplit('/', 1)[-1] - if 'cover' not in filename.lower(): - filename = filename.replace('SFA', 'Page') - return chapter + '_' + filename - + page = pageUrl.rstrip('/').rsplit('/', 1)[-1] + page = page.replace('3page00', 'cover3').replace('6429', 'cover7').replace('sfa-6-5-cover', 'cover6') + page = page.replace('sfa01', 'page01').replace('sfa03', 'page03').replace('sfa04', 'page04') + page = page.replace('sfa24', 'page24').replace('sfa07', 'page') + filename = 'sfa%d-%s.%s' % (self.currentChapter, page, imageUrl.rsplit('.', 1)[-1]) + if pageUrl in self.chapters: + self.currentChapter = self.currentChapter - 1 + return filename class StarTrip(_ComicControlScraper): url = 'https://www.startripcomic.com/'