diff --git a/docs/configuration.rst b/docs/configuration.rst index 6ae9e419..73570e3f 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -1027,13 +1027,22 @@ Description extractor.danbooru.metadata --------------------------- Type - ``bool`` + * ``bool`` + * ``string`` + * ``list`` of ``strings`` Default ``false`` +Example + * ``replacements,comments,ai_tags`` + * ``["replacements", "comments", "ai_tags"]`` Description Extract additional metadata (notes, artist commentary, parent, children, uploader) + It is possible to specify a custom list of metadata includes. + See `available_includes `__ + for possible field names. ``aibooru`` also supports ``ai_metadata``. + Note: This requires 1 additional HTTP request per post. diff --git a/gallery_dl/extractor/danbooru.py b/gallery_dl/extractor/danbooru.py index 4c936042..7b0e5722 100644 --- a/gallery_dl/extractor/danbooru.py +++ b/gallery_dl/extractor/danbooru.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2014-2022 Mike Fährmann +# Copyright 2014-2023 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as @@ -40,7 +40,17 @@ class DanbooruExtractor(BaseExtractor): self.ugoira = self.config("ugoira", False) self.external = self.config("external", False) - self.extended_metadata = self.config("metadata", False) + + metadata = self.config("metadata", False) + if metadata: + if isinstance(metadata, (list, tuple)): + metadata = ",".join(metadata) + elif not isinstance(metadata, str): + metadata = "artist_commentary,children,notes,parent,uploader" + self.metadata_includes = metadata + else: + self.metadata_includes = None + threshold = self.config("threshold") if isinstance(threshold, int): self.threshold = 1 if threshold < 1 else threshold @@ -99,13 +109,10 @@ class DanbooruExtractor(BaseExtractor): url = post["large_file_url"] post["extension"] = "webm" - if self.extended_metadata: - template = ( - "{}/posts/{}.json?only=artist_commentary,children,notes," - "parent,uploader" - ) - resp = self.request(template.format(self.root, post["id"])) - post.update(resp.json()) + if self.metadata_includes: + meta_url = "{}/posts/{}.json?only={}".format( + self.root, post["id"], self.metadata_includes) + post.update(self.request(meta_url).json()) if url[0] == "/": url = self.root + url