reluce / szurubooru-toolkit

Python package and script collection to manage your szurubooru image board.
GNU General Public License v3.0
43 stars 14 forks source link

Auto-tagger error: Name must satisfy regex '^\\S+$' #26

Closed nateify closed 2 years ago

nateify commented 2 years ago

The auto-tagger generates an error and does not actually update the post. Deepdanbooru itself is working, I can see via the debug logs that it actually generated tags. Here is what I see in the console:

$ auto-tagger.exe "tagme"
[INFO] [30.10.2022, 00:34:30 Eastern Daylight Time]: Initializing script...
[INFO] [30.10.2022, 00:34:34 Eastern Daylight Time]: Retrieving posts from XXXX with query "tagme"...
[INFO] [30.10.2022, 00:34:37 Eastern Daylight Time]: Found 2 posts. Start tagging...
  0%|                                                     | 0/2 [00:00<?, ?it/s]
[INFO] [30.10.2022, 00:34:38 Eastern Daylight Time]: Your daily SauceNAO limit has been reached. Consider upgrading your account.
[INFO] [30.10.2022, 00:34:38 Eastern Daylight Time]: Continuing tagging with Deepbooru only...

[WARNING] [30.10.2022, 00:34:48 Eastern Daylight Time] [szurubooru.update_post]: Could not edit your post: Name must satisfy regex '^\\S+$'.
 50%|██████████████████████▌                      | 1/2 [00:10<00:10, 10.65s/it]
[WARNING] [30.10.2022, 00:34:54 Eastern Daylight Time] [szurubooru.update_post]: Could not edit your post: Name must satisfy regex '^\\S+$'.
[SUCCESS] [30.10.2022, 00:34:54 Eastern Daylight Time]: Script has finished tagging.
[SUCCESS] [30.10.2022, 00:34:54 Eastern Daylight Time]: Total:     2
[SUCCESS] [30.10.2022, 00:34:54 Eastern Daylight Time]: Tagged:    0
[SUCCESS] [30.10.2022, 00:34:54 Eastern Daylight Time]: Deepbooru: 2
[SUCCESS] [30.10.2022, 00:34:54 Eastern Daylight Time]: Untagged:  0
[SUCCESS] [30.10.2022, 00:34:54 Eastern Daylight Time]: Skipped:

Here is a scrubbed log file:

[95m[DEBUG][0m [92m[30.10.2022, 00:39:19 Eastern Daylight Time][0m [93m[szurubooru.__init__][0m: szuru_user = XXXX
[95m[DEBUG][0m [92m[30.10.2022, 00:39:19 Eastern Daylight Time][0m [93m[szurubooru.__init__][0m: szuru_url = XXXX
[95m[DEBUG][0m [92m[30.10.2022, 00:39:19 Eastern Daylight Time][0m [93m[szurubooru.__init__][0m: szuru_api_url = XXXX
[95m[DEBUG][0m [92m[30.10.2022, 00:39:19 Eastern Daylight Time][0m [93m[szurubooru.__init__][0m: szuru_user = XXXX
[95m[DEBUG][0m [92m[30.10.2022, 00:39:19 Eastern Daylight Time][0m [93m[szurubooru.__init__][0m: szuru_url = XXXX
[95m[DEBUG][0m [92m[30.10.2022, 00:39:19 Eastern Daylight Time][0m [93m[szurubooru.__init__][0m: szuru_api_url = XXXX
[95m[INFO][0m [92m[30.10.2022, 00:39:19 Eastern Daylight Time][0m [93m[auto_tagger.main][0m: Initializing script...
[95m[DEBUG][0m [92m[30.10.2022, 00:39:19 Eastern Daylight Time][0m [93m[auto_tagger.parse_args][0m: sankaku_url = None
[95m[DEBUG][0m [92m[30.10.2022, 00:39:19 Eastern Daylight Time][0m [93m[auto_tagger.parse_args][0m: query = tagme
[95m[DEBUG][0m [92m[30.10.2022, 00:39:19 Eastern Daylight Time][0m [93m[saucenao.__init__][0m: Using SauceNAO API token
[95m[DEBUG][0m [92m[30.10.2022, 00:39:19 Eastern Daylight Time][0m [93m[danbooru.__init__][0m: Using Danbooru user XXXX with API key
[95m[DEBUG][0m [92m[30.10.2022, 00:39:19 Eastern Daylight Time][0m [93m[gelbooru.__init__][0m: Using Gelbooru without user and API key
[95m[INFO][0m [92m[30.10.2022, 00:39:23 Eastern Daylight Time][0m [93m[auto_tagger.main][0m: Retrieving posts from XXXX with query "tagme"...
[95m[DEBUG][0m [92m[30.10.2022, 00:39:23 Eastern Daylight Time][0m [93m[szurubooru.get_posts][0m: Getting post from query_url: XXXX
[95m[DEBUG][0m [92m[30.10.2022, 00:39:26 Eastern Daylight Time][0m [93m[szurubooru.get_posts][0m: Got a total of 2 results
[95m[DEBUG][0m [92m[30.10.2022, 00:39:26 Eastern Daylight Time][0m [93m[szurubooru.get_posts][0m: Searching across 1 pages
[95m[INFO][0m [92m[30.10.2022, 00:39:26 Eastern Daylight Time][0m [93m[auto_tagger.main][0m: Found 2 posts. Start tagging...
[95m[DEBUG][0m [92m[30.10.2022, 00:39:27 Eastern Daylight Time][0m [93m[saucenao.get_metadata][0m: Returning tags: []
[95m[DEBUG][0m [92m[30.10.2022, 00:39:27 Eastern Daylight Time][0m [93m[saucenao.get_metadata][0m: Returning sources: 
[95m[DEBUG][0m [92m[30.10.2022, 00:39:27 Eastern Daylight Time][0m [93m[saucenao.get_metadata][0m: Returning rating: safe
[95m[INFO][0m [92m[30.10.2022, 00:39:27 Eastern Daylight Time][0m [93m[auto_tagger.parse_saucenao_results][0m: Your daily SauceNAO limit has been reached. Consider upgrading your account.
[95m[INFO][0m [92m[30.10.2022, 00:39:27 Eastern Daylight Time][0m [93m[auto_tagger.parse_saucenao_results][0m: Continuing tagging with Deepbooru only...
[95m[DEBUG][0m [92m[30.10.2022, 00:39:34 Eastern Daylight Time][0m [93m[deepbooru.tag_image][0m: Guessed following tags: ['XXXX']
[95m[DEBUG][0m [92m[30.10.2022, 00:39:34 Eastern Daylight Time][0m [93m[utils.convert_rating][0m: Converted rating rating:questionable to sketchy
[95m[DEBUG][0m [92m[30.10.2022, 00:39:34 Eastern Daylight Time][0m [93m[deepbooru.tag_image][0m: Guessed rating sketchy
[95m[DEBUG][0m [92m[30.10.2022, 00:39:35 Eastern Daylight Time][0m [93m[szurubooru.update_post][0m: Updating following post: Post(id: XXXX, source: Deepbooru, content_url: XXXX, version: 3, relations: [{'id': XXXX, 'thumbnailUrl': 'XXXX'}], tags: ['XXXX'], safety: sketchy
[95m[DEBUG][0m [92m[30.10.2022, 00:39:35 Eastern Daylight Time][0m [93m[szurubooru.update_post][0m: Using query_url: XXXX
[95m[DEBUG][0m [92m[30.10.2022, 00:39:35 Eastern Daylight Time][0m [93m[szurubooru.update_post][0m: Using payload: {"version": 3, "tags": ["XXXX"], "source": "Deepbooru", "safety": "sketchy"}
[95m[WARNING][0m [92m[30.10.2022, 00:39:36 Eastern Daylight Time][0m [93m[szurubooru.update_post][0m: Could not edit your post: Name must satisfy regex '^\\S+$'.
[95m[DEBUG][0m [92m[30.10.2022, 00:39:41 Eastern Daylight Time][0m [93m[deepbooru.tag_image][0m: Guessed following tags: ['XXXX']
[95m[DEBUG][0m [92m[30.10.2022, 00:39:41 Eastern Daylight Time][0m [93m[utils.convert_rating][0m: Converted rating rating:safe to safe
[95m[DEBUG][0m [92m[30.10.2022, 00:39:41 Eastern Daylight Time][0m [93m[deepbooru.tag_image][0m: Guessed rating safe
[95m[DEBUG][0m [92m[30.10.2022, 00:39:41 Eastern Daylight Time][0m [93m[szurubooru.update_post][0m: Updating following post: Post(id: XXXX, source: Deepbooru\nXXXX\n, content_url: XXXX, version: 4, relations: [], tags: ['XXXX'], safety: safe
[95m[DEBUG][0m [92m[30.10.2022, 00:39:41 Eastern Daylight Time][0m [93m[szurubooru.update_post][0m: Using query_url: XXXX
[95m[DEBUG][0m [92m[30.10.2022, 00:39:41 Eastern Daylight Time][0m [93m[szurubooru.update_post][0m: Using payload: {"version": 4, "tags": ["XXXX"], "source": "Deepbooru\nXXXX\n", "safety": "safe"}
[95m[WARNING][0m [92m[30.10.2022, 00:39:42 Eastern Daylight Time][0m [93m[szurubooru.update_post][0m: Could not edit your post: Name must satisfy regex '^\\S+$'.
[95m[SUCCESS][0m [92m[30.10.2022, 00:39:42 Eastern Daylight Time][0m [93m[auto_tagger.main][0m: Script has finished tagging.
[95m[SUCCESS][0m [92m[30.10.2022, 00:39:42 Eastern Daylight Time][0m [93m[auto_tagger.main][0m: Total:     2
[95m[SUCCESS][0m [92m[30.10.2022, 00:39:42 Eastern Daylight Time][0m [93m[auto_tagger.main][0m: Tagged:    0
[95m[SUCCESS][0m [92m[30.10.2022, 00:39:42 Eastern Daylight Time][0m [93m[auto_tagger.main][0m: Deepbooru: 2
[95m[SUCCESS][0m [92m[30.10.2022, 00:39:42 Eastern Daylight Time][0m [93m[auto_tagger.main][0m: Untagged:  0
[95m[SUCCESS][0m [92m[30.10.2022, 00:39:42 Eastern Daylight Time][0m [93m[auto_tagger.main][0m: Skipped:   0

For what it's worth I am tagging a post with pre-existing tags. If it is significant, although redacted in the the log above I noticed that on the lines containing "Updating following post" and "Using payload" the tags array appears to contain some tags with spaces and some with underscores between words.

reluce commented 2 years ago

Yes, the error implies that the tags are not "formatted" correctly. I guess that in your generated tags, you somewhere have ["foo bar"]. Can you confirm that these tags were generated by Deepbooru?

As the SauceNao limit is exhausted, I believe that everything usually works?

reluce commented 2 years ago

I went ahead and pushed a fix to this (https://github.com/reluce/szurubooru-toolkit/commit/bad400f9b36c378b3a66afdf565a0f25f2ef0523). Every tag generated by Deepbooru will now be checked if any whitespaces are present, and if so, be replaced with an underscore. I'll close this issue, but if the error still persists, let me know by reopening it 😉.