Skip to content

Commit

Permalink
[moebooru] add 'metadata' option (#4646)
Browse files Browse the repository at this point in the history
for extended 'pool' metadata
  • Loading branch information
mikf committed Oct 12, 2023
1 parent d194ea6 commit 2974b8e
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions gallery_dl/extractor/moebooru.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ def __init__(self, match):
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):
Expand Down
10 changes: 10 additions & 0 deletions test/results/konachan.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# published by the Free Software Foundation.

from gallery_dl.extractor import moebooru
from gallery_dl import exception


__tests__ = (
Expand Down Expand Up @@ -54,6 +55,15 @@
"#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"),
Expand Down
21 changes: 21 additions & 0 deletions test/results/yandere.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,27 @@
"#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"),
Expand Down

0 comments on commit 2974b8e

Please sign in to comment.