diff options
| author | 2021-10-05 23:30:05 -0400 | |
|---|---|---|
| committer | 2021-10-05 23:30:05 -0400 | |
| commit | 34ba2951b8c523713425c98addb9256ea05c946f (patch) | |
| tree | 6ec7e96d0c6e6f6e94b6b97ecd8c0a414ceef93d /gallery_dl/extractor/mangadex.py | |
| parent | 3f5483df9075ae526f4c54f4cbe80edeabf6d4cc (diff) | |
New upstream version 1.19.0.upstream/1.19.0
Diffstat (limited to 'gallery_dl/extractor/mangadex.py')
| -rw-r--r-- | gallery_dl/extractor/mangadex.py | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/gallery_dl/extractor/mangadex.py b/gallery_dl/extractor/mangadex.py index 53ae76a..634a92d 100644 --- a/gallery_dl/extractor/mangadex.py +++ b/gallery_dl/extractor/mangadex.py @@ -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,11 +118,14 @@ 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"]) - for data["page"], page in enumerate(cattributes["data"], 1): + + enum = util.enumerate_reversed if self.config( + "page-reverse") else enumerate + for data["page"], page in enum(cattributes["data"], 1): text.nameext_from_url(page, data) yield Message.Url, base + page, data @@ -153,6 +156,9 @@ class MangadexMangaExtractor(MangadexExtractor): ("https://mangadex.org/title/7c1e2742-a086-4fd3-a3be-701fd6cf0be9", { "count": 1, }), + ("https://mangadex.org/title/584ef094-b2ab-40ce-962c-bce341fb9d10", { + "count": ">= 20", + }) ) def chapters(self): @@ -189,18 +195,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 @@ -209,6 +215,8 @@ class MangadexAPI(): "order[volume]" : order, "order[chapter]" : order, "translatedLanguage[]": config("lang"), + "contentRating[]" : [ + "safe", "suggestive", "erotica", "pornographic"], } return self._pagination("/manga/" + uuid + "/feed", params) @@ -271,7 +279,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"]: |
