[moebooru] add 'metadata' option (#4646)

for extended 'pool' metadata
pull/4667/head
Mike Fährmann 11 months ago
parent d194ea68a9
commit 2974b8e3c8
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -2247,6 +2247,18 @@ Description
Fetch media from replies to other notes.
extractor.[moebooru].pool.metadata
----------------------------------
Type
``bool``
Default
``false``
Description
Extract extended ``pool`` metadata.
Note: Not supported by all ``moebooru`` instances.
extractor.newgrounds.flash
--------------------------
Type

@ -124,6 +124,11 @@ class MoebooruPoolExtractor(MoebooruExtractor):
self.pool_id = match.group(match.lastindex)
def metadata(self):
if self.config("metadata"):
url = "{}/pool/show/{}.json".format(self.root, self.pool_id)
pool = self.request(url).json()
pool.pop("posts", None)
return {"pool": pool}
return {"pool": text.parse_int(self.pool_id)}
def posts(self):

@ -5,6 +5,7 @@
# published by the Free Software Foundation.
from gallery_dl.extractor import moebooru
from gallery_dl import exception
__tests__ = (
@ -54,6 +55,15 @@ __tests__ = (
"#sha1_content": "cf0546e38a93c2c510a478f8744e60687b7a8426",
},
{
"#url" : "https://konachan.com/pool/show/95",
"#comment" : "'metadata' option (#4646)",
"#category": ("moebooru", "konachan", "pool"),
"#class" : moebooru.MoebooruPoolExtractor,
"#options" : {"metadata": True},
"#exception": exception.HttpError,
},
{
"#url" : "https://konachan.net/pool/show/95",
"#category": ("moebooru", "konachan", "pool"),

@ -62,6 +62,27 @@ __tests__ = (
"#sha1_content": "2a35b9d6edecce11cc2918c6dce4de2198342b68",
},
{
"#url" : "https://yande.re/pool/show/318",
"#comment" : "'metadata' option (#4646)",
"#category": ("moebooru", "yandere", "pool"),
"#class" : moebooru.MoebooruPoolExtractor,
"#options" : {"metadata": True},
"#count" : 3,
"pool": {
"created_at" : "2008-12-13T15:56:10.728Z",
"description": "Dengeki Hime's posts are in pool #97.",
"id" : 318,
"is_public" : True,
"name" : "Galgame_Mag_08",
"post_count" : 3,
"updated_at" : "2012-03-11T14:31:00.935Z",
"user_id" : 1305,
},
},
{
"#url" : "https://yande.re/post/popular_by_month?month=6&year=2014",
"#category": ("moebooru", "yandere", "popular"),

Loading…
Cancel
Save