[Danbooru] add 'media-asset' extractor (#8580)
This commit is contained in:
@@ -1300,25 +1300,25 @@ Consider all listed sites to potentially be NSFW.
|
||||
<tr id="danbooru" title="danbooru">
|
||||
<td>Danbooru</td>
|
||||
<td>https://danbooru.donmai.us/</td>
|
||||
<td>Artists, Artist Searches, Favorite Groups, Pools, Popular Images, Posts, Random Posts, Tag Searches</td>
|
||||
<td>Artists, Artist Searches, Favorite Groups, Media Assets, Pools, Popular Images, Posts, Random Posts, Tag Searches</td>
|
||||
<td>Supported</td>
|
||||
</tr>
|
||||
<tr id="atfbooru" title="atfbooru">
|
||||
<td>ATFBooru</td>
|
||||
<td>https://booru.allthefallen.moe/</td>
|
||||
<td>Artists, Artist Searches, Favorite Groups, Pools, Popular Images, Posts, Random Posts, Tag Searches</td>
|
||||
<td>Artists, Artist Searches, Favorite Groups, Media Assets, Pools, Popular Images, Posts, Random Posts, Tag Searches</td>
|
||||
<td>Supported</td>
|
||||
</tr>
|
||||
<tr id="aibooru" title="aibooru">
|
||||
<td>AIBooru</td>
|
||||
<td>https://aibooru.online/</td>
|
||||
<td>Artists, Artist Searches, Favorite Groups, Pools, Popular Images, Posts, Random Posts, Tag Searches</td>
|
||||
<td>Artists, Artist Searches, Favorite Groups, Media Assets, Pools, Popular Images, Posts, Random Posts, Tag Searches</td>
|
||||
<td>Supported</td>
|
||||
</tr>
|
||||
<tr id="booruvar" title="booruvar">
|
||||
<td>Booruvar</td>
|
||||
<td>https://booru.borvar.art/</td>
|
||||
<td>Artists, Artist Searches, Favorite Groups, Pools, Popular Images, Posts, Random Posts, Tag Searches</td>
|
||||
<td>Artists, Artist Searches, Favorite Groups, Media Assets, Pools, Popular Images, Posts, Random Posts, Tag Searches</td>
|
||||
<td>Supported</td>
|
||||
</tr>
|
||||
|
||||
|
||||
@@ -344,6 +344,32 @@ class DanbooruPostExtractor(DanbooruExtractor):
|
||||
return (post,)
|
||||
|
||||
|
||||
class DanbooruMediaassetExtractor(DanbooruExtractor):
|
||||
"""Extractor for a danbooru media asset"""
|
||||
subcategory = "media-asset"
|
||||
filename_fmt = "{category}_ma{id}_{filename}.{extension}"
|
||||
archive_fmt = "m{id}"
|
||||
pattern = rf"{BASE_PATTERN}/media_assets/(\d+)"
|
||||
example = "https://danbooru.donmai.us/media_assets/12345"
|
||||
|
||||
def posts(self):
|
||||
url = f"{self.root}/media_assets/{self.groups[-1]}.json"
|
||||
asset = self.request_json(url)
|
||||
|
||||
asset["file_url"] = asset["variants"][-1]["url"]
|
||||
asset["tag_string"] = \
|
||||
asset["tag_string_artist"] = \
|
||||
asset["tag_string_character"] = \
|
||||
asset["tag_string_copyright"] = \
|
||||
asset["tag_string_general"] = \
|
||||
asset["tag_string_meta"] = ""
|
||||
|
||||
if self.includes:
|
||||
params = {"only": self.includes}
|
||||
asset.update(self.request_json(url, params=params))
|
||||
return (asset,)
|
||||
|
||||
|
||||
class DanbooruPopularExtractor(DanbooruExtractor):
|
||||
"""Extractor for popular images from danbooru"""
|
||||
subcategory = "popular"
|
||||
|
||||
@@ -402,4 +402,78 @@ __tests__ = (
|
||||
"search_tags": "",
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://danbooru.donmai.us/media_assets/35394309",
|
||||
"#category": ("Danbooru", "danbooru", "media-asset"),
|
||||
"#class" : danbooru.DanbooruMediaassetExtractor,
|
||||
"#results" : "https://cdn.donmai.us/original/4a/ae/4aae24ce57d92c1167910ab068c7514b.jpg",
|
||||
|
||||
"created_at" : "2025-11-06T06:42:00.070-05:00",
|
||||
"date" : "dt:2025-11-06 11:42:00",
|
||||
"duration" : None,
|
||||
"extension" : "jpg",
|
||||
"file_ext" : "jpg",
|
||||
"file_key" : "PyWKmcv0U",
|
||||
"file_size" : 416727,
|
||||
"file_url" : "https://cdn.donmai.us/original/4a/ae/4aae24ce57d92c1167910ab068c7514b.jpg",
|
||||
"filename" : "4aae24ce57d92c1167910ab068c7514b",
|
||||
"id" : 35394309,
|
||||
"image_height" : 2132,
|
||||
"image_width" : 1867,
|
||||
"is_public" : True,
|
||||
"md5" : "4aae24ce57d92c1167910ab068c7514b",
|
||||
"pixel_hash" : "ecfbad5b0bf98b1e8faeef908aba8613",
|
||||
"status" : "active",
|
||||
"tag_string" : "",
|
||||
"tag_string_artist": "",
|
||||
"tag_string_character": "",
|
||||
"tag_string_copyright": "",
|
||||
"tag_string_general": "",
|
||||
"tag_string_meta": "",
|
||||
"tags" : (),
|
||||
"tags_artist" : (),
|
||||
"tags_character" : (),
|
||||
"tags_copyright" : (),
|
||||
"tags_general" : (),
|
||||
"tags_meta" : (),
|
||||
"updated_at" : "2025-11-06T06:42:01.465-05:00",
|
||||
"variants" : [
|
||||
{
|
||||
"file_ext": "jpg",
|
||||
"height" : 180,
|
||||
"type" : "180x180",
|
||||
"url" : "https://cdn.donmai.us/180x180/4a/ae/4aae24ce57d92c1167910ab068c7514b.jpg",
|
||||
"width" : 158,
|
||||
},
|
||||
{
|
||||
"file_ext": "jpg",
|
||||
"height" : 360,
|
||||
"type" : "360x360",
|
||||
"url" : "https://cdn.donmai.us/360x360/4a/ae/4aae24ce57d92c1167910ab068c7514b.jpg",
|
||||
"width" : 315,
|
||||
},
|
||||
{
|
||||
"file_ext": "webp",
|
||||
"height" : 720,
|
||||
"type" : "720x720",
|
||||
"url" : "https://cdn.donmai.us/720x720/4a/ae/4aae24ce57d92c1167910ab068c7514b.webp",
|
||||
"width" : 631,
|
||||
},
|
||||
{
|
||||
"file_ext": "jpg",
|
||||
"height" : 971,
|
||||
"type" : "sample",
|
||||
"url" : "https://cdn.donmai.us/sample/4a/ae/sample-4aae24ce57d92c1167910ab068c7514b.jpg",
|
||||
"width" : 850,
|
||||
},
|
||||
{
|
||||
"file_ext": "jpg",
|
||||
"height" : 2132,
|
||||
"type" : "original",
|
||||
"url" : "https://cdn.donmai.us/original/4a/ae/4aae24ce57d92c1167910ab068c7514b.jpg",
|
||||
"width" : 1867,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user