upbit / pixivpy

Pixiv API for Python
https://pypi.org/project/PixivPy3/#files
The Unlicense
1.79k stars 149 forks source link

Automatic tag/term translations #81

Closed rainyroads closed 4 years ago

rainyroads commented 5 years ago

When searching for certain tags in English on the Android app (or directly on the Pixiv website), it will automatically search for results with both English and Japanese tags.

For example, if you search for hestia, on Android and desktop it will also search for ヘスティア

But when searching using the current API implementation, it will only search for hestia, even if the language is set properly using pixiv.set_accept_language('en-US')

Since this does work on Android by default, I assume there's some other magic going on that enables this functionality. I tried to scan the API myself on Android, but since I run Android 7.0+ and am not rooted at the moment, I can no longer use network monitoring tools on it unfortunately.

Any idea how Pixiv is doing this and if it's possible to implement it in pixivpy?

upbit commented 5 years ago

I have not studied the translation of this tag. I will keep this issue and try to analyze it with fiddler.

weilueluo commented 5 years ago

You maybe looking for this: https://app-api.pixiv.net/v2/search/autocomplete?merge_plain_keyword_results=true&word=hestia which returns: {"tags":[{"name":"ヘスティア","translated_name":"hestia"},{"name":"ヘスティア(ダンまち)","translated_name":"Hestia (DanMachi)"},{"name":"例の紐","translated_name":"Hestia's ribbon"}]}

DaRealFreak commented 5 years ago

the search/autocomplete endpoint is only for the suggestions where you can manually select a tag. the android client sends this request when I search for hestia:

GET /v1/search/illust?filter=for_android&include_translated_tag_results=true&merge_plain_keyword_results=true&word=hestia&sort=date_desc&search_target=partial_match_for_tags

include_translated_tag_results and merge_plain_keyword_results are not included in the API request yet. changing these values from true to false doesn't change anything in the results though (except for the next page URI), so the pixiv API probably ignores the argument. I'm also getting the same results using the currently implemented API endpoint and searching in the android client (at least searching for hestia and ヘスティア).