[kissmanga] fix edge-case

This commit is contained in:
Mike Fährmann
2017-04-30 11:02:32 +02:00
parent ffd72424bf
commit e41efbd2d9
3 changed files with 20 additions and 23 deletions

View File

@@ -118,35 +118,32 @@ class KissmangaChapterExtractor(KissmangaExtractor):
return [] return []
def build_aes_key(self, page): def build_aes_key(self, page):
chko = "" chko = self._chko_from_external_script()
for script in self._scripts(page):
for part in [p.strip() for p in script.split(";")]:
if part.startswith("var _"): for script in self._scripts(page):
name, _, value = part[4:].partition(" = ") for stmt in [s.strip() for s in script.split(";")]:
if stmt.startswith("var _"):
name, _, value = stmt[4:].partition(" = ")
name += "[0]" name += "[0]"
value = ast.literal_eval(value)[0] value = ast.literal_eval(value)[0]
elif part.startswith("chko = "): elif stmt.startswith("chko = "):
part = part[7:] stmt = stmt[7:]
if part == name: if stmt == name:
chko = value chko = value
elif part == "chko + " + name: elif stmt == "chko + " + name:
if not chko:
chko = self._chko_from_external_script()
chko = chko + value chko = chko + value
elif part == name + " + chko": elif stmt == name + " + chko":
if not chko:
chko = self._chko_from_external_script()
chko = value + chko chko = value + chko
else: else:
self.log.warning("unrecognized expression: '%s'", part) self.log.warning("unrecognized expression: '%s'", stmt)
elif part.startswith("key = "): elif stmt.startswith("key = "):
pass pass
else: else:
self.log.warning("unrecognized statement: '%s'", part) self.log.warning("unrecognized statement: '%s'", stmt)
return list(hashlib.sha256(chko.encode("ascii")).digest()) return list(hashlib.sha256(chko.encode("ascii")).digest())

View File

@@ -56,8 +56,8 @@ class PawooAccountExtractor(PawooExtractor):
pattern = [r"(?:https?://)?pawoo\.net/(@[^/]+)/?$"] pattern = [r"(?:https?://)?pawoo\.net/(@[^/]+)/?$"]
test = [ test = [
("https://pawoo.net/@kuroda", { ("https://pawoo.net/@kuroda", {
"url": "1507de8fe69a35d9ceb837c7082e25425eeed593", "url": "a3f9e7555f2b024554c0e9b6cbcc7991af13cf99",
"keyword": "ece8ba650f6f1519949bc94fd06c37721fc2f65e", "keyword": "9ef830113658fa15ed0b931bc3c650c417613162",
}), }),
("https://pawoo.net/@zZzZz/", { ("https://pawoo.net/@zZzZz/", {
"exception": exception.NotFoundError, "exception": exception.NotFoundError,
@@ -84,8 +84,8 @@ class PawooStatusExtractor(PawooExtractor):
pattern = [r"(?:https?://)?pawoo\.net/@[^/]+/(\d+)"] pattern = [r"(?:https?://)?pawoo\.net/@[^/]+/(\d+)"]
test = [ test = [
("https://pawoo.net/@takehana_note/559043", { ("https://pawoo.net/@takehana_note/559043", {
"url": "bff6f435c0101a911eebd985d6b752c2b61721ef", "url": "f95cc8c0274c4143e7e21dbdc693b90c65b596e3",
"keyword": "752615b20fb9490f18da69ce3822343e03ec61ff", "keyword": "4fa98754e1bee4be244fd72d01a1cefdc12f9fbb",
"content": "3b148cf90174173355fe34179741ce476921b2fc", "content": "3b148cf90174173355fe34179741ce476921b2fc",
}), }),
("https://pawoo.net/@zZzZz/12346", { ("https://pawoo.net/@zZzZz/12346", {

View File

@@ -25,6 +25,6 @@ class YonkouprodMangaExtractor(foolslide.FoolslideMangaExtractor):
"""Extractor for manga from yonkouprod.com""" """Extractor for manga from yonkouprod.com"""
category = "yonkouprod" category = "yonkouprod"
pattern = foolslide.manga_pattern(r"(?:www\.)?yonkouprod\.com/reader") pattern = foolslide.manga_pattern(r"(?:www\.)?yonkouprod\.com/reader")
test = [("https://yonkouprod.com/reader/series/attack-on-titan/", { test = [("https://yonkouprod.com/reader/series/one-punch-man/", {
"url": "33bc7a08a6fbf41cf609bdd000d16893d55a3f29", "url": "e17ed7a2098e2f18e50b64a28a810f62687d05e2",
})] })]