From ca4b2a0760c88d02ab93f5e5cf1969f6eb91a476 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Sun, 17 Nov 2024 16:20:20 +0100 Subject: [PATCH] [danbooru] add 'artist' extractor (#5348) --- gallery_dl/extractor/danbooru.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/gallery_dl/extractor/danbooru.py b/gallery_dl/extractor/danbooru.py index cc75f8e9..815efbce 100644 --- a/gallery_dl/extractor/danbooru.py +++ b/gallery_dl/extractor/danbooru.py @@ -294,3 +294,23 @@ class DanbooruPopularExtractor(DanbooruExtractor): def posts(self): return self._pagination("/explore/posts/popular.json", self.params) + + +class DanbooruArtistExtractor(DanbooruExtractor): + """Extractor for danbooru artists""" + subcategory = "artist" + pattern = BASE_PATTERN + r"/artists/(\d+)" + example = "https://danbooru.donmai.us/artists/12345" + + def items(self): + url = "{}/artists/{}.json".format(self.root, self.groups[-1]) + artist = self.request(url).json() + + url = "{}/posts?tags={}".format( + self.root, text.quote(artist["name"])) + data = { + "_extractor": DanbooruTagExtractor, + "artist" : artist, + } + yield Message.Directory, data + yield Message.Queue, url, data