Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client Error: Bad Request #8

Open
AkiBismarck opened this issue Sep 19, 2020 · 5 comments
Open

Client Error: Bad Request #8

AkiBismarck opened this issue Sep 19, 2020 · 5 comments

Comments

@AkiBismarck
Copy link

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_TAGS_ROUTE, 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
Copy link
Owner

rachmadaniHaryono commented Sep 19, 2020

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
Copy link
Author

AkiBismarck commented Sep 19, 2020

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
Copy link
Owner

rachmadaniHaryono commented Sep 20, 2020

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

f.name, resize=True, place='iqdb',

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
Copy link
Author

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
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants