Skip to content

Commit

Permalink
[mangadex] add 'author' extractor (#6372)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Oct 24, 2024
1 parent c243a7b commit 0fd98f6
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/supportedsites.md
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ Consider all listed sites to potentially be NSFW.
<tr>
<td>MangaDex</td>
<td>https://mangadex.org/</td>
<td>Chapters, Followed Feed, Lists, Manga</td>
<td>Authors, Chapters, Followed Feed, Lists, Manga</td>
<td>Supported</td>
</tr>
<tr>
Expand Down
21 changes: 21 additions & 0 deletions gallery_dl/extractor/mangadex.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,23 @@ def _items_titles(self):
yield Message.Queue, url, data


class MangadexAuthorExtractor(MangadexExtractor):
"""Extractor for mangadex authors"""
subcategory = "author"
pattern = BASE_PATTERN + r"/author/([0-9a-f-]+)"
example = ("https://mangadex.org/author"
"/01234567-89ab-cdef-0123-456789abcdef/NAME")

def items(self):
author = self.api.author(self.uuid)
author["_extractor"] = MangadexMangaExtractor

for item in author["relationships"]:
if item["type"] == "manga":
url = "{}/title/{}".format(self.root, item["id"])
yield Message.Queue, url, author


class MangadexAPI():
"""Interface for the MangaDex API v5
Expand All @@ -195,6 +212,10 @@ def __init__(self, extr):
def athome_server(self, uuid):
return self._call("/at-home/server/" + uuid)

def author(self, uuid, manga=False):
params = {"includes[]": ("manga",)} if manga else None
return self._call("/author/" + uuid, params)["data"]

def chapter(self, uuid):
params = {"includes[]": ("scanlation_group",)}
return self._call("/chapter/" + uuid, params)["data"]
Expand Down
18 changes: 18 additions & 0 deletions test/results/mangadex.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,22 @@
),
},

{
"#url" : "https://mangadex.org/author/7222d0d5-836c-4bf3-9174-72bceade8c87/kotoyama",
"#class" : mangadex.MangadexAuthorExtractor,
"#urls" : (
"https://mangadex.org/title/f48bbb5f-8a23-4dea-8177-eb2dbbcbf4fa",
"https://mangadex.org/title/00b68132-4e69-4ff9-ad4b-29138b377dc8",
"https://mangadex.org/title/41cd6fa7-3e53-4900-88e6-4a06cd7df9ad",
"https://mangadex.org/title/f1b70bba-3873-4c22-afa3-1d1c78299cd9",
"https://mangadex.org/title/259dfd8a-f06a-4825-8fa6-a2dcd7274230",
"https://mangadex.org/title/d0c88e3b-ea64-4e07-9841-c1d2ac982f4a",
),

"id": "7222d0d5-836c-4bf3-9174-72bceade8c87",
"type": "author",
"attributes": dict,
"relationships": list,
},

)

0 comments on commit 0fd98f6

Please sign in to comment.