从 Python 脚本更新 XBMC 库
Update XBMC library from Python script
我正在尝试编写一个脚本,它将 运行 我的 XBMC 上的 'update library' 命令。
当我尝试 运行:
url = 'http://root:libreelec@%IP_ADDRESS%:12345/jsonrpc?request={"jsonrpc": "2.0", "method": "VideoLibrary.Scan"}'
r = requests.get(url)
我看到库已更新,但出现以下错误:
Traceback (most recent call last):
File "<input>", line 2, in <module>
File "C:\Python27\lib\site-packages\requests\api.py", line 70, in get
return request('get', url, params=params, **kwargs)
File "C:\Python27\lib\site-packages\requests\api.py", line 56, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 475, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 596, in send
r = adapter.send(request, **kwargs)
File "C:\Python27\lib\site-packages\requests\adapters.py", line 473, in send
raise ConnectionError(err, request=request)
ConnectionError: ('Connection aborted.', BadStatusLine("''",))
我尝试修改代码为:
url = 'http://root:libreelec@%IP_ADDRESS%:12345/jsonrpc?'
data = json.dumps({"request": {"jsonrpc": "2.0", "method": "VideoLibrary.Scan"}})
r = requests.get(url, params=data)
但它似乎不起作用,这意味着我没有看到库更新。
我做错了什么?
谁'root'在URL?一切都很简单:
url = 'http://libreelec:12345/jsonrpc'
data = {"jsonrpc": "2.0", "method": "VideoLibrary.Scan", "id": "1"}
r = requests.post(url, json=data)
/json
端点也接受 POST,并且 request.post
将为您将 dict
处理为适当的 JSON 请求。
我正在尝试编写一个脚本,它将 运行 我的 XBMC 上的 'update library' 命令。
当我尝试 运行:
url = 'http://root:libreelec@%IP_ADDRESS%:12345/jsonrpc?request={"jsonrpc": "2.0", "method": "VideoLibrary.Scan"}'
r = requests.get(url)
我看到库已更新,但出现以下错误:
Traceback (most recent call last):
File "<input>", line 2, in <module>
File "C:\Python27\lib\site-packages\requests\api.py", line 70, in get
return request('get', url, params=params, **kwargs)
File "C:\Python27\lib\site-packages\requests\api.py", line 56, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 475, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 596, in send
r = adapter.send(request, **kwargs)
File "C:\Python27\lib\site-packages\requests\adapters.py", line 473, in send
raise ConnectionError(err, request=request)
ConnectionError: ('Connection aborted.', BadStatusLine("''",))
我尝试修改代码为:
url = 'http://root:libreelec@%IP_ADDRESS%:12345/jsonrpc?'
data = json.dumps({"request": {"jsonrpc": "2.0", "method": "VideoLibrary.Scan"}})
r = requests.get(url, params=data)
但它似乎不起作用,这意味着我没有看到库更新。
我做错了什么?
谁'root'在URL?一切都很简单:
url = 'http://libreelec:12345/jsonrpc'
data = {"jsonrpc": "2.0", "method": "VideoLibrary.Scan", "id": "1"}
r = requests.post(url, json=data)
/json
端点也接受 POST,并且 request.post
将为您将 dict
处理为适当的 JSON 请求。