Gelbooru

Notice: We are now selling NEW Gelbooru Merch~! Domestic shipping is free on all orders! Do you have an artist tag on Gelbooru? Let us know so we can properly credit you!

Now Viewing: Issue rendering thumbnail when working with API

Keep it civil, do not flame or bait other users. If you notice anything illegal or inappropriate being discussed, contact an administrator or moderator.

deltaslayer Group: Member - Total Posts: 7
user_avatar
Issue rendering thumbnail when working with API
Posted on: 01/21/18 07:17AM
I am trying to code an application around the API. Retrieving posts in JSON works fine, however, since there's no actual link to the "thumbnail" in the JSON, I did guess to obtain the latter, I would have to replace "images" with "thumbnails" and append "thumbnail_" before the hash and convert the extension to "jpeg".

So far this seems correct but it doesn't work all the time. Sometimes the thumbnail link throws 403.

I tried in the browser to understand what I am missing (also searched the forum, but nothing seems to match). The behavior I have in the browser is the following:
- say I load this in the browser simg3.gelbooru.com/thumbn...4a634357dff2b7da721df.jpg I get 403
- if I access the first result page from search, I will eventually see the thumbnail rendered fine there
- reloading the url after the step above, now works

Can anyone hint me around what I am exactly missing to have this work?

Thanks.

slayerduck Group: Project Sponsor - Total Posts: 153
user_avatar
Posted on: 01/21/18 10:38AM
If the thumb gives you a 403 it means you didn't send a valid referrer, it has to come from gelbooru or it will be blocked by hotlinking protection.

EDIT: Removed hotlinking protection from thumbs, try now.

deltaslayer Group: Member - Total Posts: 7
user_avatar
Posted on: 02/26/18 11:37PM
Sorry for late response. Thanks for the hint, I actually worked around it. Using server side language to request for the file, encrypting in base64 before displaying in app. You may wish to preserve hotlinking on thumbs just in case.

add_replyAdd Reply

1