Windows need help with simple json-rpc script

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
KRA77 Offline
Senior Member
Posts: 192
Joined: Jul 2010
Reputation: 0
Post: #1
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
find quote
HenryFord Offline
Posting Freak
Posts: 1,032
Joined: Jan 2010
Reputation: 15
Post: #2
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

Need help? Check out my XBMC Frodo Guide. It contains full featured guides to Sickbeard and CouchPotato as well.

[Image: all-fanart.jpg]
find quote
KRA77 Offline
Senior Member
Posts: 192
Joined: Jul 2010
Reputation: 0
Post: #3
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/libra...76949.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=JSO...y.OnUpdate but how ?
find quote
Bstrdsmkr Offline
Fan
Posts: 710
Joined: Oct 2010
Reputation: 13
Post: #4
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
find quote
KRA77 Offline
Senior Member
Posts: 192
Joined: Jul 2010
Reputation: 0
Post: #5
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.
find quote
Bstrdsmkr Offline
Fan
Posts: 710
Joined: Oct 2010
Reputation: 13
Post: #6
Well that was my bright idea lol

What about a python script?
find quote
KRA77 Offline
Senior Member
Posts: 192
Joined: Jul 2010
Reputation: 0
Post: #7
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.
find quote
HenryFord Offline
Posting Freak
Posts: 1,032
Joined: Jan 2010
Reputation: 15
Post: #8
You could just use wget then... Wink
http://gnuwin32.sourceforge.net/packages/wget.htm

Need help? Check out my XBMC Frodo Guide. It contains full featured guides to Sickbeard and CouchPotato as well.

[Image: all-fanart.jpg]
find quote
KRA77 Offline
Senior Member
Posts: 192
Joined: Jul 2010
Reputation: 0
Post: #9
Yeah, but unfortunatly it's not as easy as to download wget for windows, the same command doesn't work Sad
find quote
Bstrdsmkr Offline
Fan
Posts: 710
Joined: Oct 2010
Reputation: 13
Post: #10
Same command as in still sending to /dev/null? Try %temp% instead
find quote
Post Reply