我正在尝试编写一个脚本,它将在我的 XBMC 上运行“更新库”命令。
当我尝试运行时:
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)
但它似乎不起作用,这意味着我没有看到图书馆更新。
我做错了什么?