Library Update Status
#1
I understand I can issue a library update via the API (http://kodi.wiki/view/JSON-RPC_API/v6#VideoLibrary.Scan). But is it possible to get a status update on where the library refresh is currently at?

I'm writing some simple cron jobs to run from my media server. I've got one that updates the library, but I don't want to trigger the next command in the sequence until the library update has been completed.
Reply
#2
(2015-07-27, 09:24)Tyberious Funk Wrote: I understand I can issue a library update via the API (http://kodi.wiki/view/JSON-RPC_API/v6#VideoLibrary.Scan). But is it possible to get a status update on where the library refresh is currently at?

I'm writing some simple cron jobs to run from my media server. I've got one that updates the library, but I don't want to trigger the next command in the sequence until the library update has been completed.

Something like this might work?
http://kodi.wiki/view/JSON-RPC_API/v6#Vi...anFinished
Reply
#3
(2015-07-27, 15:26)Razze Wrote:
(2015-07-27, 09:24)Tyberious Funk Wrote: I understand I can issue a library update via the API (http://kodi.wiki/view/JSON-RPC_API/v6#VideoLibrary.Scan). But is it possible to get a status update on where the library refresh is currently at?

I'm writing some simple cron jobs to run from my media server. I've got one that updates the library, but I don't want to trigger the next command in the sequence until the library update has been completed.

Something like this might work?
http://kodi.wiki/view/JSON-RPC_API/v6#Vi...anFinished

Arrggghhh! How on earth did I miss thatHuh
Reply
#4
I just tried this;

Code:
curl --data-binary '{ "jsonrpc": "2.0", "method": "VideoLibrary.OnScanStarted", "id": "Bash"}' -H 'content-type: application/json;' http://openelec.local/jsonrpc

And received the error "Method not found" ?
Reply
#5
You can use the script in my sig to initiate a video or music library scan (as well as other things), and it will block until the scan is finished.
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
#6
That's really cool and all, but it doesn't exactly answer my question Smile

I'm working on this project as a learning exercise as much as anything else. Am I misunderstanding the JSON documentation? Or is there some other reason the method isn't being found?
Reply
#7
(2015-07-28, 02:58)Tyberious Funk Wrote: That's really cool and all, but it doesn't exactly answer my question Smile

It may not have answered your query, but it solves your immediate problem. From there you might have been able to determine how it works.

(2015-07-28, 02:58)Tyberious Funk Wrote: I'm working on this project as a learning exercise as much as anything else. Am I misunderstanding the JSON documentation? Or is there some other reason the method isn't being found?

The only way to monitor scan progress is to process the JSON RPC library notifications (in the case of scanning: OnScanStarted, OnUpdate, OnScanFinished), or query the infobooleans relating to library scan status.

In your case you need to wait for the "OnScanFinished" notification, or continually poll the "Library.IsScanningMusic" and "Library.IsScanningVideo" infobooleans.

"./texturecache.py status" will show you the music and video library status (whether a scan is in progress or not), and if you enable logging when you run the script you can see the JSON query that is being used to determine the status.
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
(2015-07-28, 03:50)Milhouse Wrote: The only way to monitor scan progress is to process the JSON RPC library notifications (in the case of scanning: OnScanStarted, OnUpdate, OnScanFinished), or query the infobooleans relating to library scan status.

In your case you need to wait for the "OnScanFinished" notification, or continually poll the "Library.IsScanningMusic" and "Library.IsScanningVideo" infobooleans.

FYI, this is my first experience working with Kodi's API, or for that matter, my first experience with JSON... so apologies if my questions don't make sense.

I understand the notion of using OnScanStarted, OnUpdate or OnScanFinished. I just can't understand why my request (in the post above) isn't working. Taking a punt, I'm assuming this is because it's a notification request, which needs to run through TCP... whereas my curl command is running over HTTP.

Thanks for pointing me to the infobooleans, because that's given me what I was searching for...

curl -u xbmc:xbmc -H "Content-Type: application/json" -X POST -d '{"jsonrpc":"2.0","method":"XBMC.GetInfoBooleans","params": { "booleans": ["library.isscanning"]} ,"id":1}' http://openelec.local/jsonrpc

My plan was to basically keep polling Kodi until I got a "false" response... and the query above gives me what I was after.
Reply
#9
You cannot request notifications, they are sent to you by Kodi whenever they make sense (in this case whenever a scan has been started or finished. That's why they are only available on bidirectional transports like TCP and WebSockets.
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply

Logout Mark Read Team Forum Stats Members Help
Library Update Status0