XBMC Library Updater Addon

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
Martijn Offline
Team-XBMC
Posts: 7,787
Joined: Jul 2011
Reputation: 115
Location: Dawn of time
Post: #11
@robweber

I agree that running it every xx hours should suffice.
That aside could something like this work cross platform?:

PHP Code:
try:
                    
date os.path.getmtimebase_path )
                    print 
date
                except
:
                    
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

Always read the XBMC online-manual, FAQ and search the forums before posting.
Do NOT e-mail Team-XBMC members asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting, make sure you read this first


For your mediacenter artwork go to
[Image: fanarttv.png]
find quote
robweber Offline
Fan
Posts: 612
Joined: Sep 2009
Reputation: 16
Post: #12
Martijn Wrote:@robweber

I agree that running it every xx hours should suffice.
That aside could something like this work cross platform?:

PHP Code:
try:
                    
date os.path.getmtimebase_path )
                    print 
date
                except
:
                    
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.
find quote
Martijn Offline
Team-XBMC
Posts: 7,787
Joined: Jul 2011
Reputation: 115
Location: Dawn of time
Post: #13
That was my guess also that it only works for local path.
I don't find it useless to update on every 'change'. Once or two times a day would be more than sufficient in my case.
Once you made is a service/program they also run it theirselves if they want.
Same as we did with Artwork Downloader.

Maybe you can even trigger it when you finished the library update Wink
On the other hand we offer a one time a day run and they can start it manually
I already looked into it briefly once but couldn't find a way to detect if it finished the update.

Always read the XBMC online-manual, FAQ and search the forums before posting.
Do NOT e-mail Team-XBMC members asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting, make sure you read this first


For your mediacenter artwork go to
[Image: fanarttv.png]
(This post was last modified: 2012-01-12 23:02 by Martijn.)
find quote
GJones Offline
Fan
Posts: 438
Joined: Nov 2009
Reputation: 0
Post: #14
I notice that the service is running an update on startup. Is there any way that we could delay the scan so that it does not run at startup? In particular, I am using the watchlist script and it hits the database heavily at startup. It would be nice to have an option to delay the first run of this script for 1,2 or 5 minutes after startup to let the user get settled into the interface before running the update.
find quote
GJones Offline
Fan
Posts: 438
Joined: Nov 2009
Reputation: 0
Post: #15
GJones Wrote:I notice that the service is running an update on startup. Is there any way that we could delay the scan so that it does not run at startup? In particular, I am using the watchlist script and it hits the database heavily at startup. It would be nice to have an option to delay the first run of this script for 1,2 or 5 minutes after startup to let the user get settled into the interface before running the update.

As a suggestion, the last_run could be written to file for comparison so that when the service started (like on an xbmc restart), it could determine if there was a need to update the library on startup.

Additionally, a sleep time after startup could be specified in service.py at the beginning of the first while loop. This would allow the user to specify a period after xbmc startup to wait before updating the library. This would allow less contention between the library update, watchlist and recentlyadded scripts. On large libraries, the impact of all 3 running simultaneously is somewhat disruptive.
find quote
robweber Offline
Fan
Posts: 612
Joined: Sep 2009
Reputation: 16
Post: #16
GJones Wrote:As a suggestion, the last_run could be written to file for comparison so that when the service started (like on an xbmc restart), it could determine if there was a need to update the library on startup.

Additionally, a sleep time after startup could be specified in service.py at the beginning of the first while loop. This would allow the user to specify a period after xbmc startup to wait before updating the library. This would allow less contention between the library update, watchlist and recentlyadded scripts. On large libraries, the impact of all 3 running simultaneously is somewhat disruptive.

I think adding a startup delay is a reasonable request. For most users it is probably unneeded so the default would just be 0 but for people running a variety of startup tasks it would be nice to offset them.

I've also been toying with the idea of writing the last_run variable to a file to allow for a better means of communication between the 'program' aspect of the addon and the 'service' piece. Currently the service does not know about manually run updates; which in theory should probably reset the last_run timer back to 0 instead of running the next scheduled update.

I'll get to these soon. Thanks for the input.
find quote
GJones Offline
Fan
Posts: 438
Joined: Nov 2009
Reputation: 0
Post: #17
robweber Wrote:I'll get to these soon. Thanks for the input.

Glad you felt it was helpful.
find quote
amorf Offline
Junior Member
Posts: 6
Joined: Jan 2012
Reputation: 0
Post: #18
I'm a week-old newbie vis a vis XBMC.

I am trying to set it up on a box (PC) that has no regular internet connection.
This player will only be used to play Audio CD's.

I think I can get it to rip the CD's, even when offline. That proved to be not as simple as I had anticipated. Anyway, the names and tracks are generic like 'Unknown Artist', etc.

This box is supposed to be connected to the internet, once in a while, through wireless, via my Samsung Galaxy Android Tablet's WiFi Hotspot feature, so it can update the information from previously ripped CD's and get some nice identifying information that makes more sense than the generic stuff.

Am I understanding correctly that this addon/plugin would come in handy, in this situation that I have outlined above?

If so, I would like to make one more request: make it possible to manually start the update.
That way I can do a manual update any time I bring my Android Tablet and temporarily turn on its Hotspot feature.

In my situation I think I really need this feature. It makes little sense to have to wait an hour (for instance), turn on the Tablet and Hotspot just before that time, let the box run the update, etc. Besides, the box might be currently playing to the entertainment of someone else, and I might be just dropping by to quickly do the library update.

So just an option 'run update now', in addition to or optionally instead of the scheduled runs, would that be possible?
find quote
GJones Offline
Fan
Posts: 438
Joined: Nov 2009
Reputation: 0
Post: #19
amorf Wrote:I'm a week-old newbie vis a vis XBMC.

I am trying to set it up on a box (PC) that has no regular internet connection.
This player will only be used to play Audio CD's.

I think I can get it to rip the CD's, even when offline. That proved to be not as simple as I had anticipated. Anyway, the names and tracks are generic like 'Unknown Artist', etc.

This box is supposed to be connected to the internet, once in a while, through wireless, via my Samsung Galaxy Android Tablet's WiFi Hotspot feature, so it can update the information from previously ripped CD's and get some nice identifying information that makes more sense than the generic stuff.

Am I understanding correctly that this addon/plugin would come in handy, in this situation that I have outlined above?

If so, I would like to make one more request: make it possible to manually start the update.
That way I can do a manual update any time I bring my Android Tablet and temporarily turn on its Hotspot feature.

In my situation I think I really need this feature. It makes little sense to have to wait an hour (for instance), turn on the Tablet and Hotspot just before that time, let the box run the update, etc. Besides, the box might be currently playing to the entertainment of someone else, and I might be just dropping by to quickly do the library update.

So just an option 'run update now', in addition to or optionally instead of the scheduled runs, would that be possible?

You can run an update whenever you wish without the plugin. Go to your movies library, click menu and choose update library.
find quote
amorf Offline
Junior Member
Posts: 6
Joined: Jan 2012
Reputation: 0
Post: #20
GJones Wrote:You can run an update whenever you wish without the plugin. Go to your movies library, click menu and choose update library.

As I said, I'm only using this for Audio CD's, not DVD's. And I don't see a menu entry for movies, just VIDEO. If that's what you meant, there is no option 'Update Library' on the context menu -- possibly because I don't have any video's there.

Anyway, it's totally unclear to me if this is what you're suggesting. I just temporarily activated the hotspot and brought wireless up on xbmc (that works fine), but still the context menu for the ripped audio CD's (ripped while offline; presently they have some generic names and numbered albums and/or tracks) do not have any items that seem to work. I tried 'Scan to Library' but that doesn't do a thing and gives no feedback. Again, there is a wireless connection up, and it's good because I also ripped a new audio CD and it fetched the info correctly from the net.

I'm a bit disappointed at present that it seems such a hassle to get the info for previously ripped audio CD's that were ripped while being offline.
The golden tip is probably yet to come here -- I hope Frown
find quote
Post Reply