前两天尝试写一个给jellyfin服务器添加演员信息的程序,读issue和参考别人的代码的时候发现很多验证的步骤比较过时,故自己写一点留档参考。
swagger api文档 http://localhost:8096/api-docs/swagger
在请求头添加验证 https://gist.github.com/nielsvanvelzen/ea047d9028f676185832e51ffaf12a6f
服务端创建api密钥 http://localhost:8096/web/#/dashboard/keys
userId获取 http://localhost:8096/web/#/dashboard/users 点击你想获得userId的用户并在url的query部分查看
例如 http://192.168.2.202:8096/web/#/dashboard/users/profile?userId=99e7058d92d34f74bd369728f432a0e2
代码参考
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| import requests import json
jellyfin_apiKey = "3287930a2ab9422eaa6e1dc4a5f23c24" jellyfin_host = "http://192.168.2.202:8096" jellyfin_userId = "99e7058d92d34f74bd369728f432a0e2"
jellyfin_headers = { 'accept': '*/*', "Authorization": f'MediaBrowser Token="{jellyfin_apiKey}"', "Content-Type": "application/json", }
response = requests.get(f'{jellyfin_host}/Persons?userId={jellyfin_userId}',headers=jellyfin_headers) dict = response.json() print(dict)
actor_name = '波多野結衣' response = requests.get(f'{jellyfin_host}/Persons/{actor_name}?userId={jellyfin_userId}',headers=jellyfin_headers) dict = response.json() print(dict)
actor_id = dict["Id"]
dict["Overview"] = """1988年5月24日生まれ<br> 身長<b>163cm</b><br> <b>B88cm</b><br> <b>W59cm</b><br> <b>H85cm</b><br> ブラ <b>Eカップ</b>""" response = requests.post(f'{jellyfin_host}/Items/{actor_id}?userId={jellyfin_userId}', headers=jellyfin_headers,json=dict)
print(response.status_code)
|