From 224b883ff4e0b7900c5ec547f0263f0f4702d2b5 Mon Sep 17 00:00:00 2001 From: thatfuckingbird <67429906+thatfuckingbird@users.noreply.github.com> Date: Tue, 13 Apr 2021 23:41:30 +0200 Subject: [PATCH] [danbooru] add option for extended metadata extraction (#1458) * [danbooru] add option for extended metadata extraction * appease linter * [danbooru] update docs/configuration.rst * [danbooru] rename extended-metadata -> metadata --- docs/configuration.rst | 10 ++++++++++ docs/gallery-dl.conf | 3 ++- gallery_dl/extractor/danbooru.py | 9 +++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/docs/configuration.rst b/docs/configuration.rst index ef30d56f..030b2438 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -726,6 +726,16 @@ Description * ``true``: Original ZIP archives * ``false``: Converted video files +extractor.danbooru.metadata +--------------------------- +Type + ``bool`` +Default + ``false`` +Description + Extract additional metadata (notes, artist commentary, parent, children) + + Note: This requires 1 additional HTTP request for each post. extractor.derpibooru.api-key ---------------------------- diff --git a/docs/gallery-dl.conf b/docs/gallery-dl.conf index 8d3a19cb..9334848e 100644 --- a/docs/gallery-dl.conf +++ b/docs/gallery-dl.conf @@ -49,7 +49,8 @@ { "username": null, "password": null, - "ugoira": false + "ugoira": false, + "metadata": false }, "derpibooru": { diff --git a/gallery_dl/extractor/danbooru.py b/gallery_dl/extractor/danbooru.py index 33797f92..1f86ea5e 100644 --- a/gallery_dl/extractor/danbooru.py +++ b/gallery_dl/extractor/danbooru.py @@ -32,6 +32,7 @@ class DanbooruExtractor(Extractor): super().__init__(match) self.root = "https://{}.donmai.us".format(match.group(1)) self.ugoira = self.config("ugoira", False) + self.extended_metadata = self.config("metadata", False) username, api_key = self._get_auth_info() if username: @@ -64,6 +65,14 @@ class DanbooruExtractor(Extractor): url = post["large_file_url"] post["extension"] = "webm" + if self.extended_metadata: + template = ( + "{}/posts/{}.json" + "?only=artist_commentary,children,notes,parent" + ) + resp = self.request(template.format(self.root, post["id"])) + post.update(resp.json()) + post.update(data) yield Message.Directory, post yield Message.Url, url, post