[danbooru] add 'artist-search' extractor (#5348)
This commit is contained in:
@@ -1138,25 +1138,25 @@ Consider all listed sites to potentially be NSFW.
|
|||||||
<tr>
|
<tr>
|
||||||
<td>Danbooru</td>
|
<td>Danbooru</td>
|
||||||
<td>https://danbooru.donmai.us/</td>
|
<td>https://danbooru.donmai.us/</td>
|
||||||
<td>Pools, Popular Images, Posts, Tag Searches</td>
|
<td>Artists, Artist Searches, Pools, Popular Images, Posts, Tag Searches</td>
|
||||||
<td>Supported</td>
|
<td>Supported</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>ATFBooru</td>
|
<td>ATFBooru</td>
|
||||||
<td>https://booru.allthefallen.moe/</td>
|
<td>https://booru.allthefallen.moe/</td>
|
||||||
<td>Pools, Popular Images, Posts, Tag Searches</td>
|
<td>Artists, Artist Searches, Pools, Popular Images, Posts, Tag Searches</td>
|
||||||
<td>Supported</td>
|
<td>Supported</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Aibooru</td>
|
<td>Aibooru</td>
|
||||||
<td>https://aibooru.online/</td>
|
<td>https://aibooru.online/</td>
|
||||||
<td>Pools, Popular Images, Posts, Tag Searches</td>
|
<td>Artists, Artist Searches, Pools, Popular Images, Posts, Tag Searches</td>
|
||||||
<td>Supported</td>
|
<td>Supported</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Booruvar</td>
|
<td>Booruvar</td>
|
||||||
<td>https://booru.borvar.art/</td>
|
<td>https://booru.borvar.art/</td>
|
||||||
<td>Pools, Popular Images, Posts, Tag Searches</td>
|
<td>Artists, Artist Searches, Pools, Popular Images, Posts, Tag Searches</td>
|
||||||
<td>Supported</td>
|
<td>Supported</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
|||||||
@@ -108,6 +108,13 @@ class DanbooruExtractor(BaseExtractor):
|
|||||||
yield Message.Directory, post
|
yield Message.Directory, post
|
||||||
yield Message.Url, url, post
|
yield Message.Url, url, post
|
||||||
|
|
||||||
|
def items_artists(self):
|
||||||
|
for artist in self.artists():
|
||||||
|
artist["_extractor"] = DanbooruTagExtractor
|
||||||
|
url = "{}/posts?tags={}".format(
|
||||||
|
self.root, text.quote(artist["name"]))
|
||||||
|
yield Message.Queue, url, artist
|
||||||
|
|
||||||
def metadata(self):
|
def metadata(self):
|
||||||
return ()
|
return ()
|
||||||
|
|
||||||
@@ -302,15 +309,31 @@ class DanbooruArtistExtractor(DanbooruExtractor):
|
|||||||
pattern = BASE_PATTERN + r"/artists/(\d+)"
|
pattern = BASE_PATTERN + r"/artists/(\d+)"
|
||||||
example = "https://danbooru.donmai.us/artists/12345"
|
example = "https://danbooru.donmai.us/artists/12345"
|
||||||
|
|
||||||
def items(self):
|
items = DanbooruExtractor.items_artists
|
||||||
url = "{}/artists/{}.json".format(self.root, self.groups[-1])
|
|
||||||
artist = self.request(url).json()
|
|
||||||
|
|
||||||
url = "{}/posts?tags={}".format(
|
def artists(self):
|
||||||
self.root, text.quote(artist["name"]))
|
url = "{}/artists/{}.json".format(self.root, self.groups[-1])
|
||||||
data = {
|
return (self.request(url).json(),)
|
||||||
"_extractor": DanbooruTagExtractor,
|
|
||||||
"artist" : artist,
|
|
||||||
}
|
class DanbooruArtistSearchExtractor(DanbooruExtractor):
|
||||||
yield Message.Directory, data
|
"""Extractor for danbooru artist searches"""
|
||||||
yield Message.Queue, url, data
|
subcategory = "artist-search"
|
||||||
|
pattern = BASE_PATTERN + r"/artists/?\?([^#]+)"
|
||||||
|
example = "https://danbooru.donmai.us/artists?QUERY"
|
||||||
|
|
||||||
|
items = DanbooruExtractor.items_artists
|
||||||
|
|
||||||
|
def artists(self):
|
||||||
|
url = self.root + "/artists.json"
|
||||||
|
params = text.parse_query(self.groups[-1])
|
||||||
|
params["page"] = text.parse_int(params.get("page"), 1)
|
||||||
|
|
||||||
|
while True:
|
||||||
|
artists = self.request(url, params=params).json()
|
||||||
|
|
||||||
|
yield from artists
|
||||||
|
|
||||||
|
if len(artists) < 20:
|
||||||
|
return
|
||||||
|
params["page"] += 1
|
||||||
|
|||||||
@@ -217,6 +217,9 @@ SUBCATEGORY_MAP = {
|
|||||||
"discord-server": "",
|
"discord-server": "",
|
||||||
"posts" : "",
|
"posts" : "",
|
||||||
},
|
},
|
||||||
|
"Danbooru": {
|
||||||
|
"artist-search": "Artist Searches",
|
||||||
|
},
|
||||||
"desktopography": {
|
"desktopography": {
|
||||||
"site": "",
|
"site": "",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -231,4 +231,40 @@ __tests__ = (
|
|||||||
"#count" : 120,
|
"#count" : 120,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"#url" : "https://danbooru.donmai.us/artists/288683",
|
||||||
|
"#category": ("Danbooru", "danbooru", "artist"),
|
||||||
|
"#class" : danbooru.DanbooruArtistExtractor,
|
||||||
|
"#urls" : "https://danbooru.donmai.us/posts?tags=kaori_%28vuoian_appxv%29",
|
||||||
|
|
||||||
|
"created_at" : "2022-05-12T16:00:40.852-04:00",
|
||||||
|
"updated_at" : "2022-05-12T22:10:51.917-04:00",
|
||||||
|
"group_name" : "",
|
||||||
|
"id" : 288683,
|
||||||
|
"is_banned" : False,
|
||||||
|
"is_deleted" : False,
|
||||||
|
"name" : "kaori_(vuoian_appxv)",
|
||||||
|
"other_names": [
|
||||||
|
"香",
|
||||||
|
"vuoian_appxv",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"#url" : "https://danbooru.donmai.us/artists?commit=Search&search%5Bany_name_matches%5D=yu&search%5Border%5D=created_at",
|
||||||
|
"#category": ("Danbooru", "danbooru", "artist-search"),
|
||||||
|
"#class" : danbooru.DanbooruArtistSearchExtractor,
|
||||||
|
"#pattern" : danbooru.DanbooruTagExtractor.pattern,
|
||||||
|
"#count" : "> 50",
|
||||||
|
|
||||||
|
"created_at" : str,
|
||||||
|
"updated_at" : str,
|
||||||
|
"group_name" : str,
|
||||||
|
"id" : int,
|
||||||
|
"is_banned" : bool,
|
||||||
|
"is_deleted" : bool,
|
||||||
|
"name" : str,
|
||||||
|
"other_names": list,
|
||||||
|
},
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user