[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
This commit is contained in:
@@ -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
|
||||
----------------------------
|
||||
|
||||
@@ -49,7 +49,8 @@
|
||||
{
|
||||
"username": null,
|
||||
"password": null,
|
||||
"ugoira": false
|
||||
"ugoira": false,
|
||||
"metadata": false
|
||||
},
|
||||
"derpibooru":
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user