How to automatically update library?

Hi Dave,

I also got your email a couple of days ago about this but didn’t have a chance to reply to it yet.

There are some improvements in the next update that should improve the stability of the eMMC due to unexpected power loss.


To dillthedog:

Yes, I know that - I spent most of my my career in IT working on systems where an outage could cost £Ms.

The fact remains that for a device that is intended to sit behind a TV and used by the family (perhaps when the techy is away on business) it’s not good. Perhaps If the internal PSU in the vero had a small backup battery, then it could detect a power failure and shutdown gracefully? I don’t know how long the hold-up would need to be to achieve this…

I’ve designed hardware and software like that in the past.

The only way to guarantee with high certainty that there wouldn’t be corruption would be to have a read-only root filesystem; as well as a copy stored in a separate portion of the eMMC for restoring if there’s a failure.

You can then mount an overlay to allow RW changes; but then you have the possibility of user data loss again, which is likely the biggest concern, as the OS itself can be reinstalled trivially.

Could the user data be stored (or automatically backed up) remotely - ie on the UPS protected NAS where all the movies are? Then if lost locally a simple menu item could be provided to restore it.

There’s a backup tool in My OSMC -> Updates that would probably meet your requirements.

I guess I’m a no one then :stuck_out_tongue: , as my Vero is on a UPS, along with the TV, Amp, etc. I had lost a TV and laptop to lightning years ago, and since I’ve put everything on UPS (and we get around 2 outages a week where I live)

I won’t comment about the probability of corruption, as @dillthedog already covered it.


An UPS that can gracefully shutdown devices over ssh… such thing exists? :slight_smile:

You got me to thinking. I use OpenMediaVault as my file server which monitors the UPS. It would be trivial to have it issue a graceful shutdown to osmc as part of its shutdown process. :wink:

So after having the same issue I found a solution I am happy with, I found a screensaver called Logout, and it logs the user out but doesnt turn off or do anything else so when you go to the device you just hit ok and you login as the master user, by doing that you can set it to scan library on login and disable watchdog.

With it that way the device is on ready to go and you just have to wait 15 seconds for the library to finish scanning and your good to go and no constant polling of the NAS and it can go to sleep.

I’m very sorry to revive this thread, but I was wondering, if anyone got watchdog to work.

My files are connected via SMB (via fstab and not via the Kodi interface). But for some reason watchdog does not update the library when new files are available.
I do not turn off my Vero4k and I do not want to update the entire library via a cronjob.

watchdog seems like a great solution, but it just doesn’t trigger the scan for new content for the directory where new files are added.

It is impossible for the Watchdog to know when files change on a remote SMB share. There is no protocol established for informing clients of file changes.

Thanks for the info. I was afraid of that, since inotify has issues with remote file systems.

However, I think I read somewhere that watchdog can build a file list during polling and compare it to a previous run. The differences show the path which could be used to update the library.

But I guess that part is not working or not implemented correctly.

I’m sorry, if the following question is a Kodi question and not an OSMC one (I don’t really know Kodi and neither do I know, if OSMC has additional features):

Let’s say I have a mount point /mnt/Movies and that a new directory /mnt/Movies/New_Movie was created.
How can I add this new directory to the library (without having to scan for new content on /mnt/Movies) via the command line? Is there an API or script that I can use?
Something like addToLibrary('/mnt/Movies/New_Movie')

Just set /mnt/Movies as the source and allow recursive scanning. Then anything added below Movies will be picked up as a movie.

Where would I do that? I did that in watchdog and it does not work.

Watchdog will not work. You just do it the normal Kodi way. Add /mnt/Movies as a movie source.

It’s not difficult to run a scan from cron, and you will never notice that it’s running.

I have several sources and I do not want all of them to be scanned. Also, I don’t see anything in the UI to set this up. Nor do I know how to update the library for only /mnt/Movies via the command line. Your script in this thread updates the entire library.

That’s the only way to do it. Kodi does not support what you are trying to do. Even if you use the Kodi interface to scan a directory, it still does a complete scan.

Why don’t you want all the sources scanned? As I said you will never notice that the scan is running.

To set what up? A source? That’s just the basic way in Kodi, nothing special.

I doubt that. If I select a Season for a show and use Scan for new content it is much faster than if I did the same on /mnt/Shows. This suggests that underneath it really only scans that particular directory.

A cron job to scan the directory /mnt/aaa/bbb.

Hmm, I looked at the API, there’s a parameter to specify the directory. I will experiment with that. The following should do the trick:

curl --data-binary '{ "jsonrpc": "2.0", "method": "VideoLibrary.Scan", "params": { "showdialogs": false, "directory": "/mnt/Movies/New_Movie" }, "id": "scan"}' -H 'content-type: application/json;' http://osmc:osmc@vero4k.local:8080/jsonrpc

Kodi checks folder timestamps when it is updating the library so it shouldn’t really be always checking everything when you scan. I would suggest keeping separate shares for current TV shows and new movies. On all other sources once you have them scanned in set Kodi to skip those during library scans. I started doing this a long time ago back when I was using an original x-box to run xbmc on and it took ten min or more to run a library update.

The Watchdog library has known to be problematic.
What about an option (supported by OSMC); that allows you to schedule an automatic library re-scan based on an interval: 15 mins; 30 mins; 1hr; 2hrs.