update library using json and curl?
#1
Hi all,
I'm wondering how I can update the video library just for a particular source from a bash script. Any pointers, ideas welcome. I did search the forums but found little help.
TIA
Reply
#2
Hmm, a quick look at http://wiki.xbmc.org/index.php?title=JSON-RPC_API/v4 suggests there is no VideoLibrary.Update method, however there is a VideoLibrary.Scan.

I would just use the HTTP API. Theoretically it's deprecated and scheduled for removal, but this won't happen for a while (not ever if I get my way). You want something like:

curl http://myserver/xbmcCmds/xbmcHttp?comman...ry(video))
Reply
#3
(2012-04-20, 11:11)jhsrennie Wrote: Hmm, a quick look at http://wiki.xbmc.org/index.php?title=JSON-RPC_API/v4 suggests there is no VideoLibrary.Update method, however there is a VideoLibrary.Scan.

I would just use the HTTP API. Theoretically it's deprecated and scheduled for removal, but this won't happen for a while (not ever if I get my way). You want something like:

curl http://myserver/xbmcCmds/xbmcHttp?comman...ry(video))
Thanks for the pointer but how can I tweak the command to update only, say, /dev/sdd1 or a source called "films_on_HDD2"?

Reply
#4
See http://wiki.xbmc.org/?title=List_of_Built_In_Functions for the details on the UpdateLibrary function. You want something like:

Code:
curl http://myserver/xbmcCmds/xbmcHttp?command=ExecBuiltIn(UpdateLibrary(video, /dev/sdd1))

I'm not sure if you can use a source name as the path, but you could try it and see what happens.
Reply
#5
(2012-04-22, 10:22)jhsrennie Wrote: See http://wiki.xbmc.org/?title=List_of_Built_In_Functions for the details on the UpdateLibrary function. You want something like:

Code:
curl http://myserver/xbmcCmds/xbmcHttp?command=ExecBuiltIn(UpdateLibrary(video, /dev/sdd1))

I'm not sure if you can use a source name as the path, but you could try it and see what happens.
Thanks. Will try that and report back.

Reply
#6
This is possible with current master using JSON-RPC's VideoLibrary.Scan as well but it's not possible in Eden. In Eden you can only update the whole video library but in master you can also pass a path to a specific directory/source to only update items from that directory.

I always recommend not to use the HTTP-API if possible because it is deprecated and will be removed in the near future (with 99% certainty before the next stable release). It is not maintained anymore which means there are known bugs that are not and will not be fixed (at least certainly not by me). I don't even keep track of those bugs.

Forgot to mention that the argument needs to be an absolute path, a source name won't work (neither in JSON-RPC nor in HTTP-API).
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#7
(2012-04-22, 13:31)Montellese Wrote: This is possible with current master using JSON-RPC's VideoLibrary.Scan as well but it's not possible in Eden. In Eden you can only update the whole video library but in master you can also pass a path to a specific directory/source to only update items from that directory.

I always recommend not to use the HTTP-API if possible because it is deprecated and will be removed in the near future (with 99% certainty before the next stable release). It is not maintained anymore which means there are known bugs that are not and will not be fixed (at least certainly not by me). I don't even keep track of those bugs.

Forgot to mention that the argument needs to be an absolute path, a source name won't work (neither in JSON-RPC nor in HTTP-API).
So I take it there is, as of now, no way to mimic the "right-click on a given source" => "Scan for new content" that works in the GUI, from the command line...
Guess I'll just have to wait until the nightlies are operational again. Any time frame for that?
Thanks anyway.

Reply
#8
(2012-04-22, 13:31)Montellese Wrote: I always recommend not to use the HTTP-API if possible because it is deprecated and will be removed in the near future (with 99% certainty before the next stable release). It is not maintained anymore which means there are known bugs that are not and will not be fixed (at least certainly not by me). I don't even keep track of those bugs.

I hereby volunteer to maintain the HTTP API.

Why the team want to remove the only API that can be easily used from a batch file escapes me. It would make more sense to remove the EventServer API to leave one easy and one hard API.
Reply
#9
Code:
curl -H "Content-Type: application/json" -u user:pass -d '{"jsonrpc":"2.0","method":"VideoLibrary.Scan","id":"scan"}' http://address:port/jsonrpc

Or, on Windows:

Code:
curl -H "Content-Type: application/json" -u user:pass -d "{\"jsonrpc\":\"2.0\",\"method\":\"VideoLibrary.Scan\",\"id\":\"scan\"}" http://address:port/jsonrpc
Reply
#10
Are there any plans to allow a file path in stead of a directory to be passed as parameter? Right now I am notifying XBMC of new files by passing it the directory, and that works fine, but it seems wasteful to let it rescan the entire directory when I know exactly what file was added. Especially on the Raspberry Pi (Raspbmc) I would like to limit background processing, since the update will take place whenever a download finishes, and I might be watching something while it does...
Reply
#11
It's on my TODO list but it's not that easy to accomplish. Actually it would probably be more like a seperate method which takes a database id instead of a path.
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#12
(2013-01-21, 22:32)Montellese Wrote: It's on my TODO list but it's not that easy to accomplish. Actually it would probably be more like a seperate method which takes a database id instead of a path.

looking forward to that, any ETA? Gotham?
Reply

Logout Mark Read Team Forum Stats Members Help
update library using json and curl?0