Closed SuuSucksAtCoding closed 6 years ago
It's not you, I just tested it on both the latest in master and on the classes branch, both fail to return posts like they should.
Seems like the module isn't getting back valid data from gelbooru.
Not sure what's wrong right now since trying the api url on my browser returns JSON as expected, but I'll look into this further when I get the chance.
From testing, this is what I figured out:
GET
the api endpoint with page
in the query param (Why???)https://gelbooru.com/index.php?page=dapi&s=post&q=index&json=1&tags=cat&limit=100&page=0
-> 302 Moved Temporarily
to the main page
https://gelbooru.com/index.php?page=dapi&s=post&q=index&json=1&tags=cat&limit=100&dummy=0
-> JSON returned
:
(like rating:s
) and returns an empty string in the bodyhttps://gelbooru.com/index.php?page=dapi&s=post&q=index&json=1&tags=rating:s&limit=100&dummy=0
-> Broken
I've been able to "fix" the first issue by not using page
(which should only affect the classes
branch), but I can't really fix either issue since they're on Gelbooru's end.
Let me know if there's anything else on Gelbooru that's breaking my code (and which branch), this is something that I (or someone else) have to contact them to fix.
re: redirect to main page -- you're using the "page" query param twice -- the second one needs to be "pid", not "page" https://gelbooru.com/index.php?page=dapi&s=post&q=index&json=1&tags=cat&limit=100&pid=0
re: colon-seperated tags
it seems like they're using a case sensitive url encoding for colon
https://gelbooru.com/index.php?page=dapi&s=post&q=index&json=1&tags=rating%3Asafe&limit=100&dummy=0
should work, but it doesn't. the following does work:
https://gelbooru.com/index.php?page=dapi&s=post&q=index&json=1&tags=rating%3asafe&limit=100&dummy=0
edit: actually, they're both working? probably just be an encoding issue in general on our side then
Well I feel a little dumb for the first part, didn't notice it.
It's not the case-sensitive url encoding, the following does work:
https://gelbooru.com/index.php?page=dapi&s=post&q=index&json=1&tags=cat+rating:safe&limit=100&pid=0
However, using rating:s
instead of rating:safe
returns no content at all:
https://gelbooru.com/index.php?page=dapi&s=post&q=index&json=1&tags=cat+rating:s&limit=100&pid=0
Seems like if there's no matching image for the tags it returns no content rather than an empty array (Which would actually make sense 😒):
https://gelbooru.com/index.php?page=dapi&s=post&q=index&json=1&tags=does_not_exist&limit=100&pid=0
I'll write up something to alias rating:s
to rating:safe
for gelbooru and so on, although returning no content with a 200 status and content-type of application/json
is really bad API-design wise.
(Also I found out gelbooru/safebooru/etc now use this directory
attribute in APIs for the image urls, so I fixed that as well)
Everything should be fixed in c17bfa1e97de01dad717ff7501e94892dff96a7e, I'll keep this issue up for a few days to be sure
I'll be merging the classes
branch into master
to avoid having to (painfully) backport all these changes (classes
should be 99% backwards-compatible to the current version)
nothing broke so far yay
Whenever I try searching on gelbooru, it always says "This function should only recieve images: TypeError: Cannot set property 'file_url' of undefined" whenever I try logging the file url, i've even tried the example code to make sure I wasn't just being dumb, am I still being dumb or is there something wrong?