From 241732bbbaee76179cfbd6ae504f82cac4dcc1d7 Mon Sep 17 00:00:00 2001 From: Techwolf Date: Fri, 18 Oct 2019 00:49:55 -0700 Subject: [PATCH] Add common handler for mgsisk's Wordpress Webcomic plugin --- dosagelib/plugins/a.py | 6 ++---- dosagelib/plugins/b.py | 7 ++----- dosagelib/plugins/c.py | 6 ++---- dosagelib/plugins/common.py | 7 +++++++ dosagelib/plugins/d.py | 10 +++------- dosagelib/plugins/m.py | 7 ++----- dosagelib/plugins/n.py | 6 ++---- dosagelib/plugins/r.py | 11 +++-------- dosagelib/plugins/s.py | 15 ++++----------- dosagelib/plugins/t.py | 6 ++---- dosagelib/plugins/w.py | 6 +++--- dosagelib/plugins/y.py | 7 ++----- 12 files changed, 34 insertions(+), 60 deletions(-) diff --git a/dosagelib/plugins/a.py b/dosagelib/plugins/a.py index ed4304112..eeca81e52 100644 --- a/dosagelib/plugins/a.py +++ b/dosagelib/plugins/a.py @@ -10,7 +10,7 @@ from re import compile, escape, MULTILINE from ..util import tagre from ..scraper import _BasicScraper, _ParserScraper from ..helpers import regexNamer, bounceStarter, indirectStarter -from .common import _WordPressScraper, _WPNavi, _WPNaviIn +from .common import _WordPressScraper, _WPNavi, _WPNaviIn, _WPWebcomic class AbbysAgency(_WordPressScraper): @@ -391,12 +391,10 @@ class ARedTailsDream(_BasicScraper): help = 'Index format: nn' -class ArtificialIncident(_ParserScraper): +class ArtificialIncident(_WPWebcomic): url = 'https://www.artificialincident.com/' stripUrl = url + 'comic/%s/' firstStripUrl = stripUrl % 'issue-one-life-changing' - imageSearch = '//div[@class="webcomic-image"]//img' - prevSearch = '//a[contains(@class, "previous-webcomic-link")]' class Ashes(_WordPressScraper): diff --git a/dosagelib/plugins/b.py b/dosagelib/plugins/b.py index 88b35b705..dfdbcf8d5 100644 --- a/dosagelib/plugins/b.py +++ b/dosagelib/plugins/b.py @@ -10,7 +10,7 @@ from re import compile, escape from ..util import tagre from ..scraper import _BasicScraper, _ParserScraper from ..helpers import indirectStarter, xpath_class -from .common import _ComicControlScraper, _WordPressScraper, _WPNaviIn +from .common import _ComicControlScraper, _WordPressScraper, _WPNaviIn, _WPWebcomic class BadassMuthas(_BasicScraper): @@ -95,13 +95,10 @@ class Beetlebum(_BasicScraper): return name -class Bethellium(_ParserScraper): +class Bethellium(_WPWebcomic): stripUrl = 'http://dbcomics.darkblueworkshop.com/bethellium/%s/' firstStripUrl = stripUrl % 'chapter-1/webcomic-bethellium-chapter-1-cover' url = firstStripUrl - imageSearch = '//div[@class="webcomic-image"]//img' - prevSearch = '//a[contains(@class, "previous-webcomic-link")]' - latestSearch = '//a[contains(@class, "last-webcomic-link")]' starter = indirectStarter def namer(self, imageUrl, pageUrl): diff --git a/dosagelib/plugins/c.py b/dosagelib/plugins/c.py index a0da4fd7d..9a08d20c6 100644 --- a/dosagelib/plugins/c.py +++ b/dosagelib/plugins/c.py @@ -10,7 +10,7 @@ from re import compile, escape from ..scraper import _BasicScraper, _ParserScraper from ..helpers import bounceStarter, indirectStarter from ..util import tagre -from .common import _WordPressScraper, _WPNavi +from .common import _WordPressScraper, _WPNavi, _WPWebcomic class CampComic(_BasicScraper): @@ -179,12 +179,10 @@ class CatVersusHuman(_ParserScraper): starter = indirectStarter -class CavesAndCritters(_ParserScraper): +class CavesAndCritters(_WPWebcomic): url = 'https://cavesandcritters.com/?ao_confirm' stripUrl = 'https://cavesandcritters.com/cnc_webcomic/%s/' firstStripUrl = stripUrl % '01_000' - imageSearch = '//div[@class="webcomic-image"]//img' - prevSearch = '//a[contains(@class, "previous-webcomic-link")]' adult = True diff --git a/dosagelib/plugins/common.py b/dosagelib/plugins/common.py index 6167ce478..6ad3ccb30 100644 --- a/dosagelib/plugins/common.py +++ b/dosagelib/plugins/common.py @@ -29,6 +29,13 @@ class _WPNaviIn(_WordPressScraper): prevSearch = '//a[%s]' % xpath_class('navi-prev-in') +class _WPWebcomic(_WordPressScraper): + imageSearch = '//div[{}]//img'.format(xpath_class('webcomic-image')) + prevSearch = '//a[{}]'.format(xpath_class('previous-webcomic-link')) + nextSearch = '///a[{}]'.format(xpath_class('next-webcomic-link')) + latestSearch = '//a[{}]'.format(xpath_class('last-webcomic-link')) + + class _ComicControlScraper(_ParserScraper): imageSearch = '//img[@id="cc-comic"]' prevSearch = '//a[@rel="prev"]' diff --git a/dosagelib/plugins/d.py b/dosagelib/plugins/d.py index 4a9b350f0..062f6f95f 100644 --- a/dosagelib/plugins/d.py +++ b/dosagelib/plugins/d.py @@ -10,7 +10,7 @@ from re import compile, escape from ..scraper import _BasicScraper, _ParserScraper from ..helpers import indirectStarter, bounceStarter, xpath_class from ..util import tagre -from .common import _ComicControlScraper, _WordPressScraper, _WPNaviIn +from .common import _ComicControlScraper, _WordPressScraper, _WPNaviIn, _WPWebcomic class Damonk(_BasicScraper): @@ -134,12 +134,10 @@ class DerTodUndDasMaedchen(_ParserScraper): lang = 'de' -class DesertFox(_ParserScraper): +class DesertFox(_WPWebcomic): url = 'https://www.desertfoxcomics.net/' stripUrl = url + 'desertfox/comic/%s/' firstStripUrl = stripUrl % 'origins-1' - imageSearch = '//div[@class="webcomic-image"]//img' - prevSearch = '//a[contains(@class, "previous-webcomic-link")]' def namer(self, imageUrl, pageUrl): # Fix inconsistent filenames @@ -204,12 +202,10 @@ class Dilbert(_ParserScraper): return "%s" % name -class DocRat(_ParserScraper): +class DocRat(_WPWebcomic): url = 'https://www.docrat.com.au/' stripUrl = url + 'comic/%s/' firstStripUrl = stripUrl % 'begin-with-eye-contact' - imageSearch = '//div[@class="webcomic-image"]//img' - prevSearch = '//a[contains(@class, "previous-webcomic-link")]' def namer(self, imageUrl, pageUrl): # Fix inconsistent filenames diff --git a/dosagelib/plugins/m.py b/dosagelib/plugins/m.py index a4324944b..64ba34cc9 100755 --- a/dosagelib/plugins/m.py +++ b/dosagelib/plugins/m.py @@ -11,7 +11,7 @@ from re import compile, escape, IGNORECASE from ..helpers import indirectStarter, xpath_class from ..scraper import _BasicScraper, _ParserScraper from ..util import tagre -from .common import _ComicControlScraper, _WordPressScraper +from .common import _ComicControlScraper, _WordPressScraper, _WPWebcomic class MacHall(_BasicScraper): @@ -175,13 +175,10 @@ class MonsieurLeChien(_BasicScraper): help = 'Index format: n' -class Moonlace(_ParserScraper): +class Moonlace(_WPWebcomic): stripUrl = 'http://dbcomics.darkblueworkshop.com/moonlace/%s/' firstStripUrl = stripUrl % 'prologue/page-1' url = firstStripUrl - imageSearch = '//div[@class="webcomic-image"]//img' - prevSearch = '//a[contains(@class, "previous-webcomic-link")]' - latestSearch = '//a[contains(@class, "last-webcomic-link")]' adult = True def starter(self): diff --git a/dosagelib/plugins/n.py b/dosagelib/plugins/n.py index 84910d114..d5c2d6080 100644 --- a/dosagelib/plugins/n.py +++ b/dosagelib/plugins/n.py @@ -10,7 +10,7 @@ from re import compile, escape from ..scraper import _BasicScraper, _ParserScraper from ..helpers import indirectStarter, xpath_class from ..util import tagre -from .common import _ComicControlScraper, _WordPressScraper, _WPNavi +from .common import _ComicControlScraper, _WordPressScraper, _WPNavi, _WPWebcomic class Namesake(_ComicControlScraper): @@ -180,12 +180,10 @@ class NonPlayerCharacter(_ParserScraper): return pageUrl.rstrip('/').rsplit('/', 1)[-1] -class NotAVillain(_ParserScraper): +class NotAVillain(_WPWebcomic): url = 'http://navcomic.com/' stripUrl = url + 'not-a-villain/%s/' firstStripUrl = stripUrl % 'v1-001' - imageSearch = '//div[@class="webcomic-image"]//img' - prevSearch = '//a[contains(@class, "previous-webcomic-link")]' def namer(self, imageUrl, pageUrl): filename = imageUrl.rsplit('/', 1)[-1] diff --git a/dosagelib/plugins/r.py b/dosagelib/plugins/r.py index 971fa7a71..045f49088 100644 --- a/dosagelib/plugins/r.py +++ b/dosagelib/plugins/r.py @@ -11,7 +11,7 @@ from six.moves.urllib.parse import urljoin from ..helpers import bounceStarter, xpath_class from ..scraper import _BasicScraper, _ParserScraper from ..util import tagre -from .common import _WordPressScraper +from .common import _WordPressScraper, _WPWebcomic class RalfTheDestroyer(_WordPressScraper): @@ -101,10 +101,8 @@ class Replay(_ParserScraper): return name -class RiversideExtras(_ParserScraper): +class RiversideExtras(_WPWebcomic): url = 'https://riversidecomics.com/' - imageSearch = '//div[{}]//img'.format(xpath_class('webcomic-image')) - prevSearch = '//a[{}]'.format(xpath_class('previous-webcomic-link')) class RomanticallyApocalyptic(_ParserScraper): @@ -137,13 +135,10 @@ class Ruthe(_BasicScraper): help = 'Index format: number' -class Ryugou(_ParserScraper): +class Ryugou(_WPWebcomic): url = 'http://ryugou.swashbuckledcomics.com/' stripUrl = url + 'comic/%s/' firstStripUrl = 'ryugou-chapter-1-cover' - imageSearch = '//div[@class="webcomic-image"]//img' - prevSearch = '//a[contains(@class, "previous-webcomic-link")]' - nextSearch = '//a[contains(@class, "next-webcomic-link")]' starter = bounceStarter def namer(self, imageUrl, pageUrl): diff --git a/dosagelib/plugins/s.py b/dosagelib/plugins/s.py index d3cf479ce..3b3a6a0c9 100644 --- a/dosagelib/plugins/s.py +++ b/dosagelib/plugins/s.py @@ -11,7 +11,7 @@ from os.path import splitext from ..scraper import _BasicScraper, _ParserScraper from ..helpers import indirectStarter, bounceStarter, joinPathPartsNamer, xpath_class from ..util import tagre -from .common import _ComicControlScraper, _WordPressScraper, _WPNavi, _WPNaviIn +from .common import _ComicControlScraper, _WordPressScraper, _WPNavi, _WPNaviIn, _WPWebcomic class SabrinaOnline(_BasicScraper): @@ -243,20 +243,16 @@ class SinFest(_BasicScraper): help = 'Index format: yyyy-mm-dd' -class SixPackOfOtters(_ParserScraper): +class SixPackOfOtters(_WPWebcomic): url = 'http://sixpackofotters.com/' stripUrl = url + 'pages/%s/' firstStripUrl = stripUrl % 'chapter-01-tandem' - imageSearch = '//div[contains(@class, "webcomic-image")]//img' - prevSearch = '//a[contains(@class, "previous-webcomic-link")]' -class SkinDeep(_ParserScraper): +class SkinDeep(_WPWebcomic): url = 'http://www.skindeepcomic.com/' stripUrl = url + 'archive/%s/' firstStripUrl = stripUrl % 'issue-1-cover' - imageSearch = '//a[%s]/img' % xpath_class('webcomic-link') - prevSearch = '//a[%s]' % xpath_class('previous-webcomic-link') class SleeplessDomain(_ComicControlScraper): @@ -346,14 +342,11 @@ class SomethingPositive(_ParserScraper): help = 'Index format: mmddyyyy' -class Sorcery101(_ParserScraper): +class Sorcery101(_WPWebcomic): baseUrl = 'http://www.sorcery101.net/sorcery-101/' stripUrl = baseUrl + '%s/' url = stripUrl % 'sorcery101-ch-01' firstStripUrl = url - imageSearch = '//div[@class="webcomic-image"]/img' - prevSearch = '//a[@rel="prev"]' - latestSearch = '//a[%s]' % xpath_class('last-webcomic-link') starter = indirectStarter allow_errors = (500,) help = 'Index format: stripname' diff --git a/dosagelib/plugins/t.py b/dosagelib/plugins/t.py index 915f4d169..df8634052 100644 --- a/dosagelib/plugins/t.py +++ b/dosagelib/plugins/t.py @@ -14,7 +14,7 @@ except ImportError: from ..scraper import _BasicScraper, _ParserScraper from ..helpers import indirectStarter, xpath_class from ..util import tagre -from .common import _ComicControlScraper, _WordPressScraper, _WPNavi, _WPNaviIn +from .common import _ComicControlScraper, _WordPressScraper, _WPNavi, _WPNaviIn, _WPWebcomic class TailsAndTactics(_ParserScraper): @@ -25,13 +25,11 @@ class TailsAndTactics(_ParserScraper): prevSearch = '//a[text()=" Back"]' -class Tamberlane(_ParserScraper): +class Tamberlane(_WPWebcomic): baseUrl = 'https://www.tamberlanecomic.com/' url = baseUrl + 'latest/' stripUrl = baseUrl + 'tamberlane/%s/' firstStripUrl = stripUrl % 'page-1' - imageSearch = '//div[@class="webcomic-image"]//img' - prevSearch = '//a[contains(@class, "previous-webcomic-link")]' def namer(self, imageUrl, pageUrl): # Fix inconsistent filenames diff --git a/dosagelib/plugins/w.py b/dosagelib/plugins/w.py index c2088aa5e..74b5dff80 100644 --- a/dosagelib/plugins/w.py +++ b/dosagelib/plugins/w.py @@ -10,7 +10,7 @@ from re import compile, escape, IGNORECASE from ..scraper import _BasicScraper, _ParserScraper from ..util import tagre from ..helpers import bounceStarter, indirectStarter, xpath_class -from .common import _ComicControlScraper, _WordPressScraper, _WPNavi +from .common import _ComicControlScraper, _WordPressScraper, _WPNavi, _WPWebcomic class WapsiSquare(_WordPressScraper): @@ -93,11 +93,11 @@ class WereIWolf(_ParserScraper): return self.stripUrl % (index[0], index[1]) -class WhiteNoise(_WordPressScraper): +class WhiteNoise(_WPWebcomic): url = 'http://whitenoisecomic.com/' stripUrl = url + 'comic/%s/' firstStripUrl = stripUrl % 'book-one' - prevSearch = '//a[%s]' % xpath_class('previous-webcomic-link') + imageSearch = '//div[@id="comic"]//img' class WhiteNoiseLee(_ComicControlScraper): diff --git a/dosagelib/plugins/y.py b/dosagelib/plugins/y.py index 495503fc3..5a6ffb26d 100644 --- a/dosagelib/plugins/y.py +++ b/dosagelib/plugins/y.py @@ -5,17 +5,14 @@ from __future__ import absolute_import, division, print_function -from ..scraper import _ParserScraper -from .common import _WordPressScraper +from .common import _WordPressScraper, _WPWebcomic class YAFGC(_WordPressScraper): url = 'http://yafgc.net/' -class YoshSaga(_ParserScraper): +class YoshSaga(_WPWebcomic): url = 'https://www.yoshsaga.com/' stripUrl = url + 'comic/%s/' firstStripUrl = stripUrl % 'introduction' - imageSearch = '//div[@class="webcomic-image"]//img' - prevSearch = '//a[contains(@class, "previous-webcomic-link")]'