From d6325865e8bdcdb8949afa9a1b34519b8d8a5614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Sun, 1 Nov 2015 01:46:00 +0100 Subject: [PATCH] [redhawkscans] generalize to allow subclassing --- gallery_dl/extractor/redhawkscans.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/gallery_dl/extractor/redhawkscans.py b/gallery_dl/extractor/redhawkscans.py index 5b0a857e..1e87cf4c 100644 --- a/gallery_dl/extractor/redhawkscans.py +++ b/gallery_dl/extractor/redhawkscans.py @@ -20,7 +20,7 @@ info = { "directory": ["{category}", "{manga}", "c{chapter:>03}{chapter-minor} - {title}"], "filename": "{manga}_c{chapter:>03}{chapter-minor}_{page:>03}.{extension}", "pattern": [ - r"(?:https?://)?manga\.redhawkscans\.com/reader/read/(.+)(?:/page)?.*", + r"(?:https?://)?manga\.redhawkscans\.com/reader/read/(.+)(?:/page)?", ], } @@ -30,6 +30,7 @@ class RedHawkScansExtractor(Extractor): def __init__(self, match): Extractor.__init__(self) + self.category = info["category"] self.part = match.group(1) def items(self): @@ -52,13 +53,13 @@ class RedHawkScansExtractor(Extractor): _ , pos = text.extract(page, '

', '') manga , pos = text.extract(page, 'title="', '"', pos) chapter , pos = text.extract(page, '">', '', pos) - json_data, pos = text.extract(page, 'var pages = ', ';\r\n', pos) - match = re.match(r"(Chapter (\d+)([^:+]*)(?:: (.*))?|[^:]+)", chapter) + json_data, pos = text.extract(page, 'var pages = ', ';', pos) + match = re.match(r"(\w+ (\d+)([^:+]*)(?:: (.*))?|[^:]+)", chapter) return { - "category": info["category"], + "category": self.category, "manga": text.unescape(manga), "chapter": match.group(2) or match.group(1), "chapter-minor": match.group(3) or "", - "language": "English", + "language": "English", #TODO: lookup table for language codes (en, it, ch, ...) "title": text.unescape(match.group(4) or ""), }, json.loads(json_data)