[mangadex] fix extraction (fixes #1852)

This commit is contained in:
Mike Fährmann
2021-09-14 17:48:41 +02:00
parent e9bf8d2591
commit 6bbeaac029

View File

@@ -37,7 +37,7 @@ class MangadexExtractor(Extractor):
def items(self):
for chapter in self.chapters():
uuid = chapter["data"]["id"]
uuid = chapter["id"]
data = self._transform(chapter)
data["_extractor"] = MangadexChapterExtractor
self._cache[uuid] = (chapter, data)
@@ -51,8 +51,8 @@ class MangadexExtractor(Extractor):
for item in manga["relationships"]:
relationships[item["type"]].append(item["id"])
cattributes = chapter["data"]["attributes"]
mattributes = manga["data"]["attributes"]
cattributes = chapter["attributes"]
mattributes = manga["attributes"]
lang = cattributes["translatedLanguage"].partition("-")[0]
if cattributes["chapter"]:
@@ -63,12 +63,12 @@ class MangadexExtractor(Extractor):
data = {
"manga" : (mattributes["title"].get("en") or
next(iter(mattributes["title"].values()))),
"manga_id": manga["data"]["id"],
"manga_id": manga["id"],
"title" : cattributes["title"],
"volume" : text.parse_int(cattributes["volume"]),
"chapter" : text.parse_int(chnum),
"chapter_minor": sep + minor,
"chapter_id": chapter["data"]["id"],
"chapter_id": chapter["id"],
"date" : text.parse_datetime(cattributes["publishAt"]),
"lang" : lang,
"language": util.code_to_language(lang),
@@ -77,13 +77,13 @@ class MangadexExtractor(Extractor):
if self.config("metadata"):
data["artist"] = [
self.api.author(uuid)["data"]["attributes"]["name"]
self.api.author(uuid)["attributes"]["name"]
for uuid in relationships["artist"]]
data["author"] = [
self.api.author(uuid)["data"]["attributes"]["name"]
self.api.author(uuid)["attributes"]["name"]
for uuid in relationships["author"]]
data["group"] = [
self.api.group(uuid)["data"]["attributes"]["name"]
self.api.group(uuid)["attributes"]["name"]
for uuid in relationships["scanlation_group"]]
return data
@@ -118,7 +118,7 @@ class MangadexChapterExtractor(MangadexExtractor):
data = self._transform(chapter)
yield Message.Directory, data
cattributes = chapter["data"]["attributes"]
cattributes = chapter["attributes"]
data["_http_headers"] = self._headers
base = "{}/data/{}/".format(
self.api.athome_server(self.uuid)["baseUrl"], cattributes["hash"])
@@ -189,18 +189,18 @@ class MangadexAPI():
@memcache(keyarg=1)
def author(self, uuid):
return self._call("/author/" + uuid)
return self._call("/author/" + uuid)["data"]
def chapter(self, uuid):
return self._call("/chapter/" + uuid)
return self._call("/chapter/" + uuid)["data"]
@memcache(keyarg=1)
def group(self, uuid):
return self._call("/group/" + uuid)
return self._call("/group/" + uuid)["data"]
@memcache(keyarg=1)
def manga(self, uuid):
return self._call("/manga/" + uuid)
return self._call("/manga/" + uuid)["data"]
def manga_feed(self, uuid):
config = self.extractor.config
@@ -271,7 +271,7 @@ class MangadexAPI():
while True:
data = self._call(endpoint, params)
yield from data["results"]
yield from data["data"]
params["offset"] = data["offset"] + data["limit"]
if params["offset"] >= data["total"]: