reluce / szurubooru-toolkit

Python package and script collection to manage your szurubooru image board.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SauceNao rate limit of 4 searches every 30 seconds

nateify opened this issue · comments

After the first run of this command I get a rate limit error instantly:
Command: auto-tagger.exe --remove-tags "tagme" "id:208"
Scrubbed log shows 5 requests to Saucenao in a short time frame:

[DEBUG] [24.11.2022, 22:34:50 Eastern Standard Time] [szurubooru.__init__]: szuru_user = exampleuser
[DEBUG] [24.11.2022, 22:34:50 Eastern Standard Time] [szurubooru.__init__]: szuru_url = https://example.com
[DEBUG] [24.11.2022, 22:34:50 Eastern Standard Time] [szurubooru.__init__]: szuru_api_url = https://example.com/api
[DEBUG] [24.11.2022, 22:34:50 Eastern Standard Time] [szurubooru.__init__]: szuru_user = exampleuser
[DEBUG] [24.11.2022, 22:34:50 Eastern Standard Time] [szurubooru.__init__]: szuru_url = https://example.com
[DEBUG] [24.11.2022, 22:34:50 Eastern Standard Time] [szurubooru.__init__]: szuru_api_url = https://example.com/api
[INFO] [24.11.2022, 22:34:50 Eastern Standard Time] [auto_tagger.main]: Initializing script...
[DEBUG] [24.11.2022, 22:34:50 Eastern Standard Time] [auto_tagger.parse_args]: sankaku_url = None
[DEBUG] [24.11.2022, 22:34:50 Eastern Standard Time] [auto_tagger.parse_args]: query = id:208
[DEBUG] [24.11.2022, 22:34:50 Eastern Standard Time] [auto_tagger.parse_args]: remove_tags = ['tagme']
[DEBUG] [24.11.2022, 22:34:50 Eastern Standard Time] [saucenao.__init__]: Using SauceNAO API token
[DEBUG] [24.11.2022, 22:34:50 Eastern Standard Time] [danbooru.__init__]: Using Danbooru user exampleuser with API key
[DEBUG] [24.11.2022, 22:34:50 Eastern Standard Time] [gelbooru.__init__]: Using Gelbooru without user and API key
[INFO] [24.11.2022, 22:34:50 Eastern Standard Time] [auto_tagger.main]: Retrieving posts from https://example.com with query "id:208"...
[DEBUG] [24.11.2022, 22:34:50 Eastern Standard Time] [szurubooru.get_posts]: Getting post from query_url: https://example.com/api/posts/?query=type%3Aimage%2Canimation+id%3A208
[DEBUG] [24.11.2022, 22:34:52 Eastern Standard Time] [szurubooru.get_posts]: Got a total of 1 results
[DEBUG] [24.11.2022, 22:34:52 Eastern Standard Time] [szurubooru.get_posts]: Searching across 1 pages
[INFO] [24.11.2022, 22:34:52 Eastern Standard Time] [auto_tagger.main]: Found 1 posts. Start tagging...
[DEBUG] [24.11.2022, 22:34:52 Eastern Standard Time] [saucenao.get_result]: Trying to get result from content_url: https://example.com/data/posts/208_xxx.png
[DEBUG] [24.11.2022, 22:34:53 Eastern Standard Time] [saucenao.get_result]: Trying to get result from content_url: https://example.com/data/posts/208_xxx.png
[DEBUG] [24.11.2022, 22:34:53 Eastern Standard Time] [saucenao.get_result]: Trying to get result from content_url: https://example.com/data/posts/208_xxx.png
[DEBUG] [24.11.2022, 22:34:54 Eastern Standard Time] [saucenao.get_result]: Trying to get result from content_url: https://example.com/data/posts/208_xxx.png
[DEBUG] [24.11.2022, 22:34:55 Eastern Standard Time] [saucenao.get_result]: Trying to get result from content_url: https://example.com/data/posts/208_xxx.png
[WARNING] [24.11.2022, 22:34:55 Eastern Standard Time] [saucenao.get_result]: Could not get result from SauceNAO with image URL "https://example.com/data/posts/208_xxx.png": <strong>Search Rate Too High.</strong><br /><br />exampleuser, basic accounts share an IP based usage pool. Your IP (x.x.x.x) has exceeded the basic account type's rate limit of 4 searches every 30 seconds.<br />Account upgrades provide a per-user usage pool, and can be used to increase this limit.<br /><br />Please check the <a href='user.php?page=account-upgrades'>upgrades page</a> to find available upgrades.
[DEBUG] [24.11.2022, 22:34:55 Eastern Standard Time] [saucenao.get_metadata]: Returning tags: []
[DEBUG] [24.11.2022, 22:34:55 Eastern Standard Time] [saucenao.get_metadata]: Returning sources: 
[DEBUG] [24.11.2022, 22:34:55 Eastern Standard Time] [saucenao.get_metadata]: Returning rating: safe
[DEBUG] [24.11.2022, 22:34:55 Eastern Standard Time] [szurubooru.update_post]: Updating following post: Post(id: 208, source: https://example.org, content_url: https://example.com/data/posts/208_xxx.png, version: 3, relations: [], tags: ['highres', 'tagme'], safety: safe
[DEBUG] [24.11.2022, 22:34:55 Eastern Standard Time] [szurubooru.update_post]: Using query_url: https://example.com/api/post/208
[DEBUG] [24.11.2022, 22:34:55 Eastern Standard Time] [szurubooru.update_post]: Using payload: {"version": 3, "tags": ["highres", "tagme"], "source": "https://example.org", "safety": "safe"}
[SUCCESS] [24.11.2022, 22:34:59 Eastern Standard Time] [auto_tagger.main]: Script has finished tagging.
[SUCCESS] [24.11.2022, 22:34:59 Eastern Standard Time] [auto_tagger.main]: Total:     1
[SUCCESS] [24.11.2022, 22:34:59 Eastern Standard Time] [auto_tagger.main]: Tagged:    0
[SUCCESS] [24.11.2022, 22:34:59 Eastern Standard Time] [auto_tagger.main]: Deepbooru: 0
[SUCCESS] [24.11.2022, 22:34:59 Eastern Standard Time] [auto_tagger.main]: Untagged:  1
[SUCCESS] [24.11.2022, 22:34:59 Eastern Standard Time] [auto_tagger.main]: Skipped:   0

Hey, I just checked the code and the problem should be that a break was missing in the for loop. I pushed the fix to the linked branch in this issue. Can you test if it works for you?

Thanks, it seems to work now