Win need help with simple json-rpc script
#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
Reply
#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
Reply
#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 ?
Reply
#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
Reply
#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.
Reply
#6
Well that was my bright idea lol

What about a python script?
Reply
#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:[email protected]:8050/jsonrpc

This is also an option, but to do it on windows I would need something similar to wget.
Reply
#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
Reply
#9
Yeah, but unfortunatly it's not as easy as to download wget for windows, the same command doesn't work Sad
Reply
#10
Same command as in still sending to /dev/null? Try %temp% instead
Reply
#11
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

Sad

Even running cmd in administrator mode gives same permission denied
Reply
#12
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...
Reply
#13
(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

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

Image
Reply
#14
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.
Reply
#15
I believe you can only update a specific path if you are using Frodo.
Image
AWXi - Ajax web interface. Wiki
Reply

Logout Mark Read Team Forum Stats Members Help
need help with simple json-rpc script0