LuqueDaniel / pybooru

Pybooru is a Python package to access to the API of Danbooru/Moebooru based sites
MIT License
111 stars 21 forks source link

Danbooru CSFR problem #60

Open Magos-Errant opened 2 years ago

Magos-Errant commented 2 years ago

Thank you for your work on the development of this very useful code! I have recently encountered an error (it was working fine before, I think that Danbooru changed something in their API)

When using two tags to access random picture:

danbo_client = Danbooru('danbooru')
picture = danbo_client.post_list(tags=_tags, limit=1, random=True)

The following error occurs: In _request: 422 - Locked, The resource is locked and cannot be modified - URL

After checking what is happening with the link it provides, it actually contains the requested list with a JSON object. But when fetched with python results in the following error:

{
    "backtrace": [],
    "message": "Can't verify CSRF token authenticity.",
    "success": false
}

Expected Behavior

Return of list containing JSON object

Actual Behavior

Proper behavior for 1 tag and 1 tag with rating tag. Error when inputting more than one tag.

Steps to Reproduce

  1. Input more than 2 tags into post_list().

Context

The issue prevents from using more than one tag, excluding rating tag.

Environment

Pybooru Version: 4.2.2 Python Version: 3.8 Operating system: Windows 10 Link to your project: https://github.com/Magos-Errant/Shinsha

LuqueDaniel commented 2 years ago

Thank you very much. I will check it out.

ShibePlanet commented 2 years ago

Has any fix to this been found? It's still a very big issue.