Solved Trigger library update
#1
Under previous version of xbmc i use the http cmd's to trigger a update from a perl script that was grabbing my movies and tv on a schedule.

With the change in the http component under frodo the following is now depreciated. I couldn't find in the new documentation a replacement

Code:
'http://127.0.0.1:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn&parameter=XBMC.updatelibrary(video)'
Reply
#2
Maybe something like this?
Code:
xbmc-send  --action="XBMC.UpdateLibrary(video)"

If not already installed, you'll need the xbmc-eventclients-xbmc-send package.
Reply
#3
I think this is what im after

Code:
http://wiki.xbmc.org/index.php?title=JSON-RPC_API/v6#VideoLibrary.Scan

Just need to work out how to call it correctly..
Reply
#4
xbmc-send doesn't work for your situation or you'd just rather use JSON-RPC? Just curious.
Reply
#5
i don't think i'm calling it correctly. I tried calling
Code:
http://127.0.0.1:8080/jsonrpc?request=VideoLibrary.Scan
But it errors with
Code:
{"error":{"code":-32700,"message":"Parse error."},"id":null,"jsonrpc":"2.0"}

Do i need to specify the directory to scan? and how would i format the url?

Code:
{
  "params": [
    {
      "name": "directory",
      "type": "string",
      "default": ""
    }
  ],
  "description": "Scans the video sources for new library items",
  "returns": {
    "type": "string"
  }
}

(2013-02-07, 21:11)artrafael Wrote: xbmc-send doesn't work for your situation or you'd just rather use JSON-RPC? Just curious.

Thanks artrafael

i would rather use JASON-RPC but still working out the string to send.

I like to keep my systems clean of unnecessary packages if i can help it. JSON-RPC is capable of doing what i require and included in the base xbmc package.
Reply
#6
Solved, needs to be a post not a get.

Below is the perl sub i created to replace the old sub i was using, if your using perl to grab content this is handy to call at the end to trigger the library scan.

uses these CPAN modules

LWP::UserAgent;
HTTP::Request;

Code:
sub updatexbmclibrary()
{
        # Construct JSON RPC URL.
        my $jsonUrl = sprintf("http://127.0.0.1:8080/jsonrpc");
        my $jsonReq = "\{\"jsonrpc\"\: \"2.0\", \"method\": \"VideoLibrary.Scan\", \"id\"\: 1\}";
        my $http = HTTP::Request->new('POST', $jsonUrl);
        $http->header('Content-Type' => 'application/json');
        $http->content($jsonReq);
        # Fire off the request.
        my $ua = LWP::UserAgent->new;
        my $res = $ua->request($http);
        die "Couldn't post request" unless defined $res;
        # Return the HTTP status and exit.
        printf("Return: %s\n", $res->status_line);
      
        #print $res;
}
Reply
#7
(2013-02-07, 21:23)redstorm Wrote: I like to keep my systems clean of unnecessary packages if i can help it. JSON-RPC is capable of doing what i require and included in the base xbmc package.

OK, that's understandable. I run across various posts from users trying to update their scripts to replace httpapi and, in some of these instances, a simple xbmc-send can do the trick without having to get their arms around JSON-RPC (which can be daunting). However, if there's some inherent problems with using xbmc-send in certain situations, I want to know about it so I will be careful about suggesting this in the future. Thus, my question.

Anyway, I'm glad you figured out your JSON-RPC solution.

Reply

Logout Mark Read Team Forum Stats Members Help
Trigger library update0