Support Danbooru "Common Search Parameters" ; at least 'page' and 'limit'
fire-eggs opened this issue · 1 comments
Detailed Description
The Danbooru API docs mention that all searches support a common set of parameters.
None of these common parameters are supported in api_danbooru.py.
I'm specifically interested in the "page" parameter.
Context
I am attempting to use pybooru to fetch notes for all posts [see my project Danbooru2019]. This because qwern doesn't include notes in his dataset.
Anywho, I found the note API will only return 20 notes for a given post. I.e. I'm using pybooru
as follows:
nl = client.note_list(post_id=77, is_active=True)
And this only returns 20 notes, whereas post id 77 actually has 21 notes.
So I need to be able to request pages to get all notes, e.g.:
nl = client.note_list(post_id=77, is_active=True, page=1)
if (len(nl) == 20):
nl = client.note_list(post_id=77, is_active=True, page=2)
Possible Implementation
Reworking api_danbooru.py
, note_list
as follows appears to do the trick [documentation removed for conciseness]:
def note_list(self, body_matches=None, post_id=None, post_tags_match=None,
creator_name=None, creator_id=None, is_active=None, page=1):
params = {
'search[body_matches]': body_matches,
'search[post_id]': post_id,
'search[post_tags_match]': post_tags_match,
'search[creator_name]': creator_name,
'search[creator_id]': creator_id,
'search[is_active]': is_active,
'page' : page
}
return self._get('notes.json', params)
Your Environment
- Pybooru Version: 4.2.2
- Python Version: 3.8.10
- Danbooru / Moebooru site: danbooru
- Operating System and version: Linux Mint 20.1
- Link to your project: Danbooru2019
Mucking about a little more, supporting the "limit" parameter might actually be more useful, as it extends the number of entries returned. E.g.:
def note_list(self, body_matches=None, post_id=None, post_tags_match=None,
creator_name=None, creator_id=None, is_active=None, page=1, limit=20):
params = {
'search[body_matches]': body_matches,
'search[post_id]': post_id,
'search[post_tags_match]': post_tags_match,
'search[creator_name]': creator_name,
'search[creator_id]': creator_id,
'search[is_active]': is_active,
'page' : page,
'limit' : limit
}
return self._get('notes.json', params)