diff --git a/dosagelib/events.py b/dosagelib/events.py index 96c7de774..8cbbb632a 100644 --- a/dosagelib/events.py +++ b/dosagelib/events.py @@ -38,6 +38,10 @@ class EventHandler(object): """Emit a comic downloaded event. Should be overridden in subclass.""" pass + def comicPageLink(self, comic, url, prevUrl): + """Emit an event to inform the handler about links between comic pages. Should be overridden in subclass.""" + pass + def end(self): """Emit an end event. Should be overridden in subclass.""" pass @@ -216,6 +220,11 @@ class MultiHandler(object): for handler in _handlers: handler.comicDownloaded(comic, filename) + def comicPageLink(self, comic, url, prevUrl): + """Emit an event to inform the handler about links between comic pages. Should be overridden in subclass.""" + for handler in _handlers: + handler.comicPageLink(comic, url, prevUrl) + def end(self): """Emit an end event. Should be overridden in subclass.""" for handler in _handlers: diff --git a/dosagelib/scraper.py b/dosagelib/scraper.py index e2c34ab68..6a68bdbe9 100644 --- a/dosagelib/scraper.py +++ b/dosagelib/scraper.py @@ -7,6 +7,7 @@ from . import loader from .util import fetchUrl, fetchUrls, getPageContent from .comic import ComicStrip from .output import out +from .events import getHandler class _BasicScraper(object): @@ -161,6 +162,7 @@ class _BasicScraper(object): else: prevUrl = self.prevUrlModifier(prevUrl) out.debug("Matched previous URL %s" % prevUrl) + getHandler().comicPageLink(self.getName(), url, prevUrl) return prevUrl def getIndexStripUrl(self, index):