XBMC Community Forum
[Windows] need help with simple json-rpc script - Printable Version

+- XBMC Community Forum (http://forum.xbmc.org)
+-- Forum: Development (/forumdisplay.php?fid=32)
+--- Forum: Python Add-on Development (/forumdisplay.php?fid=26)
+--- Thread: [Windows] need help with simple json-rpc script (/showthread.php?tid=131289)

Pages: 1 2 3


need help with simple json-rpc script - KRA77 - 2012-05-11 12:11

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 Smile


RE: need help with simple json-rpc script - HenryFord - 2012-05-11 13:25

Here is a Powershell-Script that can script telnet with a certain set of commands you input:
http://powershell.com/cs/media/p/13938.aspx


RE: need help with simple json-rpc script - KRA77 - 2012-05-11 14:42

Thank you for your input, will look into this, I was hoping for a simple .bat solution but if this is what it takes.
For future reference http://technet.microsoft.com/en-us/library/ee176949.aspx

Any idea about the command for adding a single file to library.

I assume I need this one http://wiki.xbmc.org/index.php?title=JSON-RPC_API/v4#VideoLibrary.OnUpdate but how ?


RE: need help with simple json-rpc script - Bstrdsmkr - 2012-05-11 20:31

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


RE: need help with simple json-rpc script - KRA77 - 2012-05-12 00:57

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.


RE: need help with simple json-rpc script - Bstrdsmkr - 2012-05-12 05:03

Well that was my bright idea lol

What about a python script?


RE: need help with simple json-rpc script - KRA77 - 2012-05-12 11:55

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:xbmc@192.168.10.120:8050/jsonrpc

This is also an option, but to do it on windows I would need something similar to wget.


RE: need help with simple json-rpc script - HenryFord - 2012-05-12 11:58

You could just use wget then... Wink
http://gnuwin32.sourceforge.net/packages/wget.htm


RE: need help with simple json-rpc script - KRA77 - 2012-05-12 17:11

Yeah, but unfortunatly it's not as easy as to download wget for windows, the same command doesn't work Sad


RE: need help with simple json-rpc script - Bstrdsmkr - 2012-05-12 19:17

Same command as in still sending to /dev/null? Try %temp% instead