rachmadaniHaryono / iqdb_tagger

Search IQDB from CLI
MIT License
19 stars 2 forks source link

Client Error: Bad Request #8

Open AkiBismarck opened 4 years ago

AkiBismarck commented 4 years ago

Hi, thanks to the other user, who asked the runtime error question, I at least could make it basically run. But when I try running the command i get this error:

2020-09-19 10:18.20 Metadata hash=74d725726d9da7f14f718d48bb0a94826286167c6d5594fc52e81c07db271fd7 id=23408617 idx=0 total=16 2020-09-19 10:18.20 Converting to JPEG for error fix err=cannot write mode RGBA as JPEG

tags found and so on

2020-09-19 10:18.48 match parser=<class 'iqdb_tagger.custom_parser.ChanSankakuParser'> 2020-09-19 10:18.48 34 tag(s) founds Traceback (most recent call last): File "c:\python38\lib\site-packages\hydrus__init__.py", line 191, in _api_request response.raise_for_status() File "c:\python38\lib\site-packages\requests\models.py", line 941, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://127.0.0.1:45869/add_tags/add_tags

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "c:\python38\lib\runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "c:\python38\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Python38\Scripts\iqdb-tagger.exe__main.py", line 7, in File "c:\python38\lib\site-packages\click\core.py", line 829, in call return self.main(*args, kwargs) File "c:\python38\lib\site-packages\flask\cli.py", line 586, in main return super(FlaskGroup, self).main(args, kwargs) File "c:\python38\lib\site-packages\click\core.py", line 782, in main rv = self.invoke(ctx) File "c:\python38\lib\site-packages\click\core.py", line 1259, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "c:\python38\lib\site-packages\click\core.py", line 1066, in invoke return ctx.invoke(self.callback, ctx.params) File "c:\python38\lib\site-packages\click\core.py", line 610, in invoke return callback(args, kwargs) File "c:\python38\lib\site-packages\click\decorators.py", line 21, in new_func return f(get_current_context(), *args, kwargs) File "c:\python38\lib\site-packages\flask\cli.py", line 426, in decorator return __ctx.invoke(f, *args, *kwargs) File "c:\python38\lib\site-packages\click\core.py", line 610, in invoke return callback(args, kwargs) File "c:\python38\lib\site-packages\iqdb_tagger__main__.py", line 566, in search_hydrus_and_send_tag cl.add_tags([f_hash], service_to_tags={tag_repo: full_name_tags}) File "c:\python38\lib\site-packages\hydrus__init__.py", line 319, in add_tags self._api_request("POST", self._ADD_TAGSROUTE, json=json) File "c:\python38\lib\site-packages\hydrus\init__.py", line 194, in _api_request raise MissingParameter(response) hydrus.MissingParameter: Could not find the service "local tags"!

rachmadaniHaryono commented 4 years ago

first try to go to http://127.0.0.1:45869/add_tags/get_tag_services

you may get response like below

    {
        "local_tags" : [ "my tags" ]
        "tag_repositories" : [ "public tag repository", "mlp fanfic tagging server" ]
    }

if your local_tags is ["my tags"] you may have to add that as --tag_repo option

so your command should be similar to below

iqdb-tagger search-hydrus-and-send-tag --tag_repo 'my tags' ...

e: docs on hdyrus api docs https://hydrusnetwork.github.io/hydrus/help/client_api.html#add_tags_get_tag_services

AkiBismarck commented 4 years ago

Okay after some trying i made it work. I realized after a while "my tags" in the command line has to be "my_tags" or it won't take it. It didn't work at first since I had to also rename "my tags" in Hydrus into "my_tags" logically. It works kinda now, but not for all files. I made some test runs and it only finds the tags for some files. When it didn't find a source, i guess, it just writes "Number of valid result n=0" even tho all those files were from the same site. Can i do something about that?

Also is this "Converting to JPEG for error fix err=cannot write mode RGBA as JPEG" a problem? dont really know what it tries to do there.

rachmadaniHaryono commented 4 years ago

I realized after a while "my tags" in the command line has to be "my_tags" or it won't take it. It didn't work at first since I had to also rename "my tags" in Hydrus into "my_tags" logically.

is it not caused by windows argument not escaping space character?

It works kinda now, but not for all files. I made some test runs and it only finds the tags for some files. When it didn't find a source, i guess, it just writes "Number of valid result n=0" even tho all those files were from the same site.... Can i do something about that?

search-hydrus-and-send-tag will upload resized image to save bandwith so maybe there will be miss by iqdb.

some booru from iqdb also don't have tag parser because the site have javascript page or login requirement

i'm planning not only it upload the image but it also use url data on that image and send it to iqdb.

if you are running from source you can edit argument resize to False so iqdb-tagger will upload full image instead resized one

https://github.com/rachmadaniHaryono/iqdb_tagger/blob/20151f2bd68bafae654a478e6738a284a4238959/iqdb_tagger/__main__.py#L485

if it is from the same site, rather than send tag maybe send url. if hydrus can match the url it should not download the image but only parse the tag using hydrus parser

Also is this "Converting to JPEG for error fix err=cannot write mode RGBA as JPEG" a problem? dont really know what it tries to do there.

it is a temp fix from old commit. i will set that as debug message to decrease the program verbosity in future commit

e: error message is skipped on new commits. i also add --no-resize flag so user can upload full image to iqdb, but it is untested and will put heavy load to iqdb, so use it with care

AkiBismarck commented 4 years ago

is it not caused by windows argument not escaping space character?

no idea about that. but changing the name worked fine enough.

if it is from the same site, rather than send tag maybe send url. if hydrus can match the url it should not download the image but only parse the tag using hydrus parser

how is the line supposed to look? I tried it with just: iqdb-tagger search-hydrus-and-send-url --tag_repo my_tags --access_key 123key thread:cat what do i have to change?

rachmadaniHaryono commented 4 years ago

how is the line supposed to look? I tried it with just:

iqdb-tagger search-hydrus-and-send-url --tag_repo my_tags --access_key 123key thread:cat

what do i have to change?

that is the correct subcommand