ScanLibrary with URL or Json API from PC
#1
just wanted to know if its possible to send a command from a PC ie a URL or JSOn api that would update a particular folder with an nfo file that exists in the folder and all images etc
Reply
#2
Yep. Look at the JSON XBMC API (AudioLibrary.Scan/VideoLibrary.Scan), or this script has options ascan/vscan that calls those methods (with or without a specific directory) and will work on a PC connecting to a remote XBMC client.
Texture Cache Maintenance Utility: Preload your texture cache for optimal UI performance. Remotely manage media libraries. Purge unused artwork to free up space. Find missing media. Configurable QA check to highlight metadata issues. Aid in diagnosis of library and cache related problems.
Reply
#3
looking at the script i see
def scanDirectory(self, scanMethod, path=None):
if path and path != "":
self.logger.out("Rescanning directory: %s..." % path, newLine=True, log=True)
REQUEST = {"method": scanMethod, "params":{"directory": path}}
else:
self.logger.out("Rescanning library...", newLine=True, log=True)
REQUEST = {"method": scanMethod, "params":{"directory": ""}}

self.sendJSON(REQUEST, "libRescan", callback=self.jsonWaitForScanFinished, checkResult=False)

so could i do:
http://192.168.1.64:8080/jsonrpc?request={"method": scanMethod, "params":{"directory": path}}

I have seen elsewhere something like (below) but have not tried it yet.
http://192.168.1.64:8080/jsonrpc?request={"id":5,"jsonrpc":"2.0","method":"VideoLibrary.Scan","params":{"directory":"smb://nas4free/files2/Movies/"}}

pls let me know what you think would be best.

A little more info. I have created a VB6 program to Organize and get Movie info.
I have successfully made it so i can right click a movie and send to one of the XBMC's in my house.
But at present i have to update the entire library on each device.
What i would like to do is scan the newly created folder and send this info to XBMC to add this new folder to the Library
Is this possible.

(i know some would say create a MySQL, tried it but was unable to get it to work on my TS410 QNAP Nas (think the MySQL was out dated and cannot upgrade)
Did think about making a FreeNas box and having another go.
Reply
#4
(2013-05-04, 18:00)k_zeon Wrote: just wanted to know if its possible to send a command from a PC ie a URL or JSOn api that would update a particular folder with an nfo file that exists in the folder and all images etc
once a movie is on the database you can not retrigger a rescan on that one.
so if it's in and you change the nfo it's not possible to rescan it using JSON
Read/follow the forum rules.
For troubleshooting and bug reporting, read this first
Interested in seeing some YouTube videos about Kodi? Go here and subscribe
Reply
#5
Hi Martijn. Thanks for answering.
Obviously XBMC can do a refresh on a single movie.
Is there no way to tap into that from outside of XBMC (or even in future releases)

But if i did want to add a new movie and not update it, can this be done

tks
Reply
#6
new movies should be fine.
refreshing a movie through JSON will come at some point in time i guess
Read/follow the forum rules.
For troubleshooting and bug reporting, read this first
Interested in seeing some YouTube videos about Kodi? Go here and subscribe
Reply
#7
(2013-05-04, 23:44)k_zeon Wrote: But if i did want to add a new movie and not update it, can this be done

Yes, absolutely, see previous posts.

If you want to update an existing movie, you need to first remove the movie from the library, then scan it back in.
Texture Cache Maintenance Utility: Preload your texture cache for optimal UI performance. Remotely manage media libraries. Purge unused artwork to free up space. Find missing media. Configurable QA check to highlight metadata issues. Aid in diagnosis of library and cache related problems.
Reply
#8
(2013-05-04, 22:44)k_zeon Wrote: looking at the script i see
Code:
def scanDirectory(self, scanMethod, path=None):
    if path and path != "":
      self.logger.out("Rescanning directory: %s..." % path, newLine=True, log=True)
      REQUEST = {"method": scanMethod, "params":{"directory": path}}
    else:
      self.logger.out("Rescanning library...", newLine=True, log=True)
      REQUEST = {"method": scanMethod, "params":{"directory": ""}}

    self.sendJSON(REQUEST, "libRescan", callback=self.jsonWaitForScanFinished, checkResult=False)

so could i do:
http://192.168.1.64:8080/jsonrpc?request={"method": scanMethod, "params":{"directory": path}}

No, that won't work - you've not understood what the Python code is doing. scanmethod and path are both string variables, and their values need to be passed in to the request. For instance, scanmethod might be AudioLibrary.Scan or VideoLibrary.Scan depending on which media type (audio or video) has initiated the scan. In addition, the code you referenced will add additional request properties (id, jsonrpc, etc.) before transmitting the request in sendJSON().

If you run the script with the logfile property enabled, you will see the exact details of all the requests that the script is making (and receiving).

(2013-05-04, 22:44)k_zeon Wrote: I have seen elsewhere something like (below) but have not tried it yet.
http://192.168.1.64:8080/jsonrpc?request={"id":5,"jsonrpc":"2.0","method":"VideoLibrary.Scan","params":{"directory":"smb://nas4free/files2/Movies/"}}

That's the kind of URL you need. Though using sockets rather than HTTP has its advantages - for instance, the aforementioned script uses sockets, and will block until the video/audio library scan is complete (wait for OnScanFinished notification), and will also process the OnUpdate notifications that are received as each new item is added to the library. If you are adding items using VB6, you will want to avoid starting a second scan while the first scan is still in progress, as the request to start a second scan (of a different directory) will cause the first scan to end prematurely, possibly leaving you with new movies/etc. that you think have been added to the library but in fact have not.
Texture Cache Maintenance Utility: Preload your texture cache for optimal UI performance. Remotely manage media libraries. Purge unused artwork to free up space. Find missing media. Configurable QA check to highlight metadata issues. Aid in diagnosis of library and cache related problems.
Reply
#9
the only thing i noticed that i am not really sure about is the ID. What do the different numbers mean.
I have seen some with 1 or 2 and now 5

Also would anyone already have any VB6 code that would allow to call a scan and then wait till its finished

I used the Inet control last time to pass the URL to XBMC and think i used a do while busy
not sure this would work in this instance.

As you say, would need some sort of call back when the scan is finished. Any idea's

many thanks
Reply

Logout Mark Read Team Forum Stats Members Help
ScanLibrary with URL or Json API from PC0