reluce / szurubooru-toolkit

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: cannot unpack non-iterable NoneType object

bokerlol opened this issue · comments

Through some trial and error, we have gotten most of everything work but I'm still having some difficulty getting a specific command to work.

Running this command

python3 auto_tagger.py 'date:today'

outputs the following error

Z:\Misc\szurubooru\szurubooru-scripts-main>python3 auto_tagger.py 'date:today'
Could not process your query: 'total'.
Traceback (most recent call last):
  File "auto_tagger.py", line 129, in <module>
    main()
  File "auto_tagger.py", line 28, in main
    post_ids, total = api.get_post_ids(user_input.query)
TypeError: cannot unpack non-iterable NoneType object

Specifying a post ID does work, allowing it to find the exact image and updating the tags. It just seems that specifying a date does not.

Current config:

{
    "szurubooru": {
        "url": "https://booru.mydomain.com",
        "api_token": "[redacted]",
        "public": "False"
    },
    "auto_tagger": {
        "saucenao_api_key": "[redacted]",
        "hide_progress": "False",
        "local_temp_path": "Z:/Misc/szurubooru/szurubooru-scripts-main/tmp",
        "use_saucenao": "True",
        "deepbooru_enabled": "False",
        "deepbooru_model": "Z:/Misc/szurubooru/szurubooru-scripts-main/misc/deepbooru/model-resnet_custom_v3.h5",
        "deepbooru_threshold": "0.7",
        "boorus": {
            "danbooru": {
                "user": "None",
                "api_key": "None"
            },
            "gelbooru": {
                "user": "None",
                "api_key": "None"
            },
            "konachan": {
                "user": "None",
                "password": "None"
            },
            "yandere": {
                "user": "None",
                "password": "None"
            },
            "pixiv": {
                "user": "None",
                "password": "None",
                "token": "None"
            }
        }
    },
    "upload_images": {
        "upload_dir": "I:/Images/Importing",
        "hide_progress": "False",
        "cleanup": "False",
        "tags": ["tagme"]
    }
}

If you search for date:today in you szurubooru, does it return any posts? If so, how many are there in total?

In the file classes/api.py, you can insert on line 38 print(response.json()). What's the output now?

When searching for date:today, I do get images in return. So the search is working on the szuru side.

After adding the line of code, this is the output:

Z:\Misc\szurubooru\szurubooru-scripts-main>python3 auto_tagger.py 'date:today'
{'name': 'SearchError', 'title': 'Search error', 'description': 'Unknown named token: "\'date". Available named tokens: [\'ar\', \'area\', \'aspect-ratio\', \'comment\', \'comment-count\', \'comment-date\', \'comment-time\', \'content-checksum\', \'creation-date\', \'creation-time\', \'date\', \'disliked\', \'edit-date\', \'edit-time\', \'fav\', \'fav-count\', \'fav-date\', \'fav-time\', \'feature-count\', \'feature-date\', \'feature-time\', \'file-size\', \'flag\', \'height\', \'id\', \'image-ar\', \'image-area\', \'image-aspect-ratio\', \'image-height\', \'image-width\', \'last-edit-date\', \'last-edit-time\', \'liked\', \'md5\', \'note-count\', \'note-text\', \'pool\', \'rating\', \'relation-count\', \'safety\', \'score\', \'sha1\', \'source\', \'submit\', \'tag\', \'tag-count\', \'time\', \'type\', \'upload\', \'uploader\', \'width\'].'}
Could not process your query: 'total'.
Traceback (most recent call last):
  File "auto_tagger.py", line 129, in <module>
    main()
  File "auto_tagger.py", line 28, in main
    post_ids, total = api.get_post_ids(user_input.query)
TypeError: cannot unpack non-iterable NoneType object

Interesting, so either argparse or your command line tries to escape the single quotes. Can you replace the single quotes with double quotes or try it even without quotes?

Also, which command line are you using? Just cmd?

Just CMD.

Also yay! Double quotes/no quotes seemed to fix it. Can't believe I didn't try that.

Must've been some odd behavior going on with the quotes being there.

Glad to hear it's working now!

I'm trying to push an update during the next few days/weeks which addresses the few issues we had today and some QoL features, so thank you for testing 😉.