I've been looking into json-rpc because I need to make a script that will a) update videolibrary b) update videolibrary with a specified file
I know that I can telnet 9090 and write
{ "jsonrpc": "2.0", "method": "VideoLibrary.Scan", "id": 1 }
and it will update library, so I would think something like
echo { "jsonrpc": "2.0", "method": "VideoLibrary.Scan", "id": 1 } > localhost:9090
from a .bat file would do the same, but it doesn't seem to work.
Any idea what is needed for this to work ?
Also if someone could help me with the code needed for it to parse only one spesified file, you know, I want a script that tells xbmc "hey, I added abc.avi to \\medialibrary\avi-files, please add it to your database"
And I want to do this from a windows .bat file or other script file that runs on windows. I would be thankfull for any help, but pls remember, I am no programmer
Try:
echo { "jsonrpc": "2.0", "method": "VideoLibrary.Scan", "id": 1 } > telnet localhost:9090
Away from my machine right now, but I think that's what you're missing
does not seem to work, afaik you don't need to use telnet, you just need to send the raw data to port 9090. I assume echo don't support outputting to tcp port.
Well that was my bright idea lol
What about a python script?
Thanks for trying anyway, I'm just trying to find the most noob friendly solution. I have a solution for linux that uses http:
wget -q -O/dev/null --header='Content-Type: application/json' --post-data='{"jsonrpc": "2.0", "method": "VideoLibrary.Scan"}'
http://xbmc:[email protected]:8050/jsonrpc
This is also an option, but to do it on windows I would need something similar to wget.
Yeah, but unfortunatly it's not as easy as to download wget for windows, the same command doesn't work
Same command as in still sending to /dev/null? Try %temp% instead
First thing I tried was simply removing the output option, but that didn't work, then I tried with %temp% and the result:
C:/Users/Kay/AppData/Local/Temp: Permission denied
Even running cmd in administrator mode gives same permission denied
Finally got it to run with
wget -q -Oc:\users\kay\jsonrpc.log --header='Content-Type: application/json' --post-data='{"jsonrpc": "2.0", "method": "VideoLibrary.Scan"}'
http://xbmc:[email protected]:8050/jsonrpc
Unfortunatly it returns:
{"error":{"code":-32700,"message":"Parse error."},"id":null,"jsonrpc":"2.0"}
Tried adding a ID
wget -q -Oc:\users\kay\jsonrpc.log --header='Content-Type: application/json' --post-data='{"jsonrpc": "2.0", "method": "VideoLibrary.Scan", "id": 1 }'
http://xbmc:[email protected]:8050/jsonrpc
Still same error...
(2012-05-12, 19:30)KRA77 Wrote: [ -> ]C:/Users/Kay/AppData/Local/Temp: Permission denied
And that is a good thing. You cannot redirect the output to a folder, you have to specify a file.
However - this should fix your problem:
Code:
wget -q -Oc:\users\kay\jsonrpc.log --header='Content-Type: application/json' --post-data="{\"jsonrpc\": \"2.0\", \"method\": \"VideoLibrary.Scan\", \"id\":1}" http://xbmc:[email protected]:8050/jsonrpc
success !!
Thanks for sticking with it, I kindo figured the spaces was making problems, didn't know how to solve it, thank you.
Now the tricky part doing a single file update, and not full library update.
I'm thinking of doing this with a batfile with filename arguments, so just hardcode the path in bat file, and use
%~nx1
as code inside that bat file do add filename to the code.
I though I could use VideoLibrary.OnUpdate for that, but looking into it, I'm not so sure anymore.
I believe you can only update a specific path if you are using Frodo.