HOW-TO:Remotely update library: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
<section begin="intro" />Some quick methods to updating the Kodi library outside of the Kodi interface. There are also several [[supplemental tools]] and [[smartphone remotes]] that can remotely update the library as well. | <section begin="intro" />Some quick methods to updating the Kodi library outside of the Kodi interface. There are also several [[supplemental tools]] and [[smartphone remotes]] that can remotely update the library as well. These methods require Settings>Services>Control>Allow remote control via HTTP to be enabled.<section end="intro" /> | ||
==Command line== | ==Command line== | ||
Line 21: | Line 10: | ||
* '''Video:''' <code><nowiki>curl --data-binary '{ "jsonrpc": "2.0", "method": "VideoLibrary.Clean", "id": "mybash"}' -H 'content-type: application/json;' http://<User>:<Password>@<hostname>:<port>/jsonrpc</nowiki></code> | * '''Video:''' <code><nowiki>curl --data-binary '{ "jsonrpc": "2.0", "method": "VideoLibrary.Clean", "id": "mybash"}' -H 'content-type: application/json;' http://<User>:<Password>@<hostname>:<port>/jsonrpc</nowiki></code> | ||
* '''Audio:''' <code><nowiki>curl --data-binary '{ "jsonrpc": "2.0", "method": "AudioLibrary.Clean", "id": "mybash"}' -H 'content-type: application/json;' http://<User>:<Password>@<hostname>:<port>/jsonrpc</nowiki></code> | * '''Audio:''' <code><nowiki>curl --data-binary '{ "jsonrpc": "2.0", "method": "AudioLibrary.Clean", "id": "mybash"}' -H 'content-type: application/json;' http://<User>:<Password>@<hostname>:<port>/jsonrpc</nowiki></code> | ||
==Python== | |||
To add new content to the video library (Update): | |||
import urllib, urllib2 | |||
data = urllib.urlencode({"jsonrpc": "2.0", "method": "VideoLibrary.Scan", "id": "1"}) | |||
passman = urllib2.HTTPPasswordMgrWithDefaultRealm() | |||
passman.add_password(None, "hostname:port", 'username', 'password') | |||
urllib2.install_opener(urllib2.build_opener(urllib2.HTTPBasicAuthHandler(passman))) | |||
<nowiki>req = urllib2.Request('http://hostname:port/jsonrpc', headers={ "Content-Type" : "application/json"})</nowiki> | |||
f = urllib2.urlopen(req, data='{"jsonrpc": "2.0", "method": "VideoLibrary.Scan", "id": "1"}').read() | |||
Replace the "VideoLibrary.Scan" in the second line with "AudioLibrary.Scan", "VideoLibrary.Clean" or "AudioLibrary.Clean" to perform other actions. | |||
Line 39: | Line 40: | ||
Replace "user:pass" with your username and password, localhost can remain unless doing it remotely in which case replace with IP address, replace "port" with the port number you have configured in your settings. The " > NUL 2>&1" stops the command from displaying any output (for instance, when running a batch file). You can leave that out if you want. | Replace "user:pass" with your username and password, localhost can remain unless doing it remotely in which case replace with IP address, replace "port" with the port number you have configured in your settings. The " > NUL 2>&1" stops the command from displaying any output (for instance, when running a batch file). You can leave that out if you want. | ||
==HTTP (does not work in v18 Leia)== | |||
To add new content to the library (Update): | |||
* '''Video:''' <nowiki>http://<User>:<Password>@<hostname>:<port>/jsonrpc?request={"jsonrpc":"2.0","method":"VideoLibrary.Scan"}</nowiki> | |||
* '''Audio:''' <nowiki>http://<User>:<Password>@<hostname>:<port>/jsonrpc?request={"jsonrpc":"2.0","method":"AudioLibrary.Scan"}</nowiki> | |||
To remove content from library (Clean): | |||
* '''Video:''' <nowiki>http://<User>:<Password>@<hostname>:<port>/jsonrpc?request={"jsonrpc":"2.0","method":"VideoLibrary.Clean"}</nowiki> | |||
* '''Audio:''' <nowiki>http://<User>:<Password>@<hostname>:<port>/jsonrpc?request={"jsonrpc":"2.0","method":"AudioLibrary.Clean"}</nowiki> | |||
==See also== | ==See also== | ||
*[[JSON-RPC]] | *[[JSON-RPC]] | ||
{{Updated| | {{Updated|18}} | ||
[[Category:How-to]] | [[Category:How-to]] | ||
[[Category:Advanced topics]] | [[Category:Advanced topics]] |
Revision as of 18:03, 26 May 2018
Some quick methods to updating the Kodi library outside of the Kodi interface. There are also several supplemental tools and smartphone remotes that can remotely update the library as well. These methods require Settings>Services>Control>Allow remote control via HTTP to be enabled.
Command line
To add new content to the library (Update):
- Video:
curl --data-binary '{ "jsonrpc": "2.0", "method": "VideoLibrary.Scan", "id": "mybash"}' -H 'content-type: application/json;' http://<User>:<Password>@<hostname>:<port>/jsonrpc
- Audio:
curl --data-binary '{ "jsonrpc": "2.0", "method": "AudioLibrary.Scan", "id": "mybash"}' -H 'content-type: application/json;' http://<User>:<Password>@<hostname>:<port>/jsonrpc
To remove content from library (Clean):
- Video:
curl --data-binary '{ "jsonrpc": "2.0", "method": "VideoLibrary.Clean", "id": "mybash"}' -H 'content-type: application/json;' http://<User>:<Password>@<hostname>:<port>/jsonrpc
- Audio:
curl --data-binary '{ "jsonrpc": "2.0", "method": "AudioLibrary.Clean", "id": "mybash"}' -H 'content-type: application/json;' http://<User>:<Password>@<hostname>:<port>/jsonrpc
Python
To add new content to the video library (Update):
import urllib, urllib2 data = urllib.urlencode({"jsonrpc": "2.0", "method": "VideoLibrary.Scan", "id": "1"}) passman = urllib2.HTTPPasswordMgrWithDefaultRealm() passman.add_password(None, "hostname:port", 'username', 'password') urllib2.install_opener(urllib2.build_opener(urllib2.HTTPBasicAuthHandler(passman))) req = urllib2.Request('http://hostname:port/jsonrpc', headers={ "Content-Type" : "application/json"}) f = urllib2.urlopen(req, data='{"jsonrpc": "2.0", "method": "VideoLibrary.Scan", "id": "1"}').read()
Replace the "VideoLibrary.Scan" in the second line with "AudioLibrary.Scan", "VideoLibrary.Clean" or "AudioLibrary.Clean" to perform other actions.
Windows Command Line
You will need the Win32 2000/XP binary version of cURL by Günter Knauf. Download it here: http://curl.haxx.se/ Create a cURL folder in the Program Files directory and place the contents of the zip file in the root of that folder. (You can put it elsewhere if you like just make sure you modify the code to reflect the location of the exe file)
To add new content to the library (Update):
- Video:
"C:\Program Files (x86)\cURL\curl.exe" -i -X POST -d "{\"jsonrpc\": \"2.0\", \"method\": \"VideoLibrary.Scan\", \"id\": \"mybash\"}" -H "content-type:application/json" http://user:pass@localhost:port/jsonrpc > NUL 2>&1
- Audio:
"C:\Program Files (x86)\cURL\curl.exe" -i -X POST -d "{\"jsonrpc\": \"2.0\", \"method\": \"AudioLibrary.Scan\", \"id\": \"mybash\"}" -H "content-type:application/json" http://user:pass@localhost:port/jsonrpc > NUL 2>&1
To remove content from library (Clean):
- Video:
"C:\Program Files (x86)\cURL\curl.exe" -i -X POST -d "{\"jsonrpc\": \"2.0\", \"method\": \"VideoLibrary.Clean\", \"id\": \"mybash\"}" -H "content-type:application/json" http://user:pass@localhost:port/jsonrpc > NUL 2>&1
- Audio:
"C:\Program Files (x86)\cURL\curl.exe" -i -X POST -d "{\"jsonrpc\": \"2.0\", \"method\": \"AudioLibrary.Clean\", \"id\": \"mybash\"}" -H "content-type:application/json" http://user:pass@localhost:port/jsonrpc > NUL 2>&1
Replace "user:pass" with your username and password, localhost can remain unless doing it remotely in which case replace with IP address, replace "port" with the port number you have configured in your settings. The " > NUL 2>&1" stops the command from displaying any output (for instance, when running a batch file). You can leave that out if you want.
HTTP (does not work in v18 Leia)
To add new content to the library (Update):
- Video: http://<User>:<Password>@<hostname>:<port>/jsonrpc?request={"jsonrpc":"2.0","method":"VideoLibrary.Scan"}
- Audio: http://<User>:<Password>@<hostname>:<port>/jsonrpc?request={"jsonrpc":"2.0","method":"AudioLibrary.Scan"}
To remove content from library (Clean):
- Video: http://<User>:<Password>@<hostname>:<port>/jsonrpc?request={"jsonrpc":"2.0","method":"VideoLibrary.Clean"}
- Audio: http://<User>:<Password>@<hostname>:<port>/jsonrpc?request={"jsonrpc":"2.0","method":"AudioLibrary.Clean"}