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

api.set_accept_language("zh-cn")有什么用吗 #328

Open
ReallySilverBell opened this issue Jan 22, 2024 · 3 comments
Open

api.set_accept_language("zh-cn")有什么用吗 #328

ReallySilverBell opened this issue Jan 22, 2024 · 3 comments
Labels

Comments

@ReallySilverBell
Copy link

image
image
——————————————分割线——————————————
image
image

@ReallySilverBell ReallySilverBell changed the title 求助,使用api.set_accept_language("zh-cn")好像对结果没啥变化 api.set_accept_language("zh-cn")有什么用吗 Jan 22, 2024
@ReallySilverBell
Copy link
Author

image

@Xdynix
Copy link
Collaborator

Xdynix commented Jan 22, 2024

set_accepted_language 会改变返回的结果里的 tag 的翻译文本。

api = get_pixiv_api()

pid = 114518297

print('Without Accepted-Language:')
response = api.illust_detail(pid)
for tag in response.illust.tags[:5]:
    print(tag.name, tag.translated_name)

print('\n')

print('With Accepted-Language:')
api.set_accept_language('zh-hans')
response = api.illust_detail(pid)
for tag in response.illust.tags[:5]:
    print(tag.name, tag.translated_name)

结果如下:

Without Accepted-Language:
初音ミクシンフォニー Hatsune Miku symphony
蓄音機ミク None
初音ミク hatsune miku
VOCALOID10000users入り Vocaloid 10000+ bookmarks
VOCALOID None


With Accepted-Language:
初音ミクシンフォニー Hatsune Miku symphony
蓄音機ミク None
初音ミク 初音未来
VOCALOID10000users入り Vocaloid 10000+ bookmarks
VOCALOID None

可以发现 初音ミク 对应的 translated_name 有不同。

@upbit
Copy link
Owner

upbit commented Jan 22, 2024

对,这个参数只影响 translated_name,取决于Pixiv有没有响应对应的接口参数。
你可以打印 tag 返回出来看看

@upbit upbit added the question label Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants