I agree that running it every xx hours should suffice.
That aside could something like this work cross platform?:
date = os.path.getmtime( base_path )
date = 0
# we only refresh if it's been more than a day, 24hr * 60min * 60sec
refresh = ( ( time.time() - ( 24 * 60 * 60 ) ) >= date )
Found it in a script somewhere
From what I can see that would flag a folder to be refreshed in the event that its modified date was greater than a day. I'm guessing you could then code the refresh value to trigger if the folder should be scanned or not?
I found the following related to how the "os.path" module in Python functions:
Quote:The os.path module is always the path module suitable for the operating system Python is running on, and therefore usable for local paths.
So while it would probably work for local paths, sources that are connected via samba, nfs, etc probably wouldn't return the right values. The docs I found even said that unc paths on windows systems wouldn't work.
Thinking about it I'm still not sure if doing separate polling of the individual paths and then specifying (via the updatelibrary() function) that path to update is worth the extra effort. The built in xbmc scanner seems to do a good job of detecting new files very quickly; maybe if you had lots of sources it would be worth only scanning folders that have changed.
I think ideally it would be nice if the built in XBMC scanner had a cross platform way of checking for changed files so that it could selectively know what folders to scan, this would put the burden on the core xbmc process rather than having something like an addon do the work. Again, I'm sure the problem is the cross platform piece of it.
Nice find with that piece of code. I'm by no means a Python expert so I'll have to remember that function in case I ever need something similar.