XBMC Library Updater Addon

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
robweber Online
Posting Freak
Posts: 815
Joined: Sep 2009
Reputation: 26
Post: #286
Yes, as long as all the clients connect to your shared library they will be updated. I currently do this at my house with 1 main xbmc box that runs 24/7 and several clients around the house that I just turn on as needed. The image caching system takes care of the images so each machine will update it's image cache as needed with the new content.
find quote
tknorris Offline
Member
Posts: 63
Joined: May 2012
Reputation: 1
Post: #287
I think I found a long-standing rounding error in this addon. I've been using it forever (and it's great btw) but for the longest time I've gotten the occasional duplicate library update that I couldn't explain. Tonight I finally decided to look into it and I think the problem comes in with this line (line 104 of service.py):
Code:
self.last_run = time.time() - (time.time() % 60)

That code is intended to capture the minute of the last run, but sometimes the float expression result will be just before the actual minute and thus croniter.get_next returns the next run as the one that just completed rather than the one that should next be scheduled. This then triggers the addon to update library again on the next minute click.

you can see some examples of what I'm talking about in this code snippet:
Code:
>>> print time.time();time.time() - (time.time() % 60);ceil(time.time() - (time.time() % 60));(time.time()+1) - (time.time() %60)
1394598973.24
1394598959.999999
1394598960.0
1394598960.9999962

This also shows the potential fixes. You can either add 1 to time.time() (if you don't want to import math) or you can take the ceiling of the existing result to force it to round up

Also, here's a log snippet that shows the problem occurring (in my case my cron expression is */15 * * * *). Note, I added some logging to see when last_run was read and written.
Code:
00:15:00 T:139895397181184  NOTICE: service.libraryautoupdate: Starting network check
00:15:00 T:139895397181184  NOTICE: service.libraryautoupdate: Update Video Library
00:15:00 T:139895397181184  NOTICE: Next Run: 1394598600.0
00:15:00 T:139895380395776  NOTICE: Thread CVideoInfoScanner start, auto delete: false
00:15:00 T:139895380395776  NOTICE: VideoInfoScanner: Starting scan ..
00:15:01 T:139895380395776  NOTICE: VideoInfoScanner: Finished scan. Scanning for video info took 00:00
00:15:01 T:139895397181184  NOTICE: Writing Last Run: 1394597699.999999
00:15:02 T:139895397181184  NOTICE: service.libraryautoupdate: update timers
00:15:02 T:139895397181184  NOTICE: Next Run: 1394597700.0
00:15:09 T:139894118627072  NOTICE: AddOnLog: MythTV cmyth PVR Client: Process - Event unknown, databuf:
00:16:00 T:139895397181184  NOTICE: Previous line repeats 5 times.
00:16:00 T:139895397181184  NOTICE: service.libraryautoupdate: Starting network check
00:16:00 T:139895397181184  NOTICE: service.libraryautoupdate: Update Video Library
00:16:00 T:139895397181184  NOTICE: Next Run: 1394598600.0
00:16:00 T:139895388788480  NOTICE: Thread CVideoInfoScanner start, auto delete: false
00:16:00 T:139895388788480  NOTICE: VideoInfoScanner: Starting scan ..
00:16:00 T:139895388788480  NOTICE: VideoInfoScanner: Finished scan. Scanning for video info took 00:00
00:16:00 T:139895388788480  NOTICE: Thread Jobworker start, auto delete: true
00:16:01 T:139895397181184  NOTICE: Previous line repeats 1 times.
00:16:01 T:139895397181184  NOTICE: Writing Last Run: 1394597760.000000
00:16:02 T:139895397181184  NOTICE: service.libraryautoupdate: update timers
00:16:02 T:139895397181184  NOTICE: Next Run: 1394598600.0

Hope this helps fix this issue. I'm just glad at this point I finally understand why it happens as it's driven me crazy for the longest time.
(This post was last modified: 2014-03-12 08:11 by tknorris.)
find quote
robweber Online
Posting Freak
Posts: 815
Joined: Sep 2009
Reputation: 26
Post: #288
That is great, thanks for taking the time to actually dig in to why this is happening. I'll be honest I've never noticed this myself but I'm probably just not being very observant. The line of code you have identified has been in the addon since practically the beginning so I'm sure this is a long-standing bug as you've indicated.

Out of the two ways you've specified to fix it, which do you think is the best? Adding 1 seems the easiest without doing a lot of extra computations. I'll try to update this and get a fix out for Frodo and Gotham this week. I'll make sure you get the credit in the changelog too!
find quote
tknorris Offline
Member
Posts: 63
Joined: May 2012
Reputation: 1
Post: #289
After thinking about this last night, I think the reason this is happening in the 2nd call to time.time() sometimes returns a slightly larger result than the first call since a tiny bit of time has clicked away. If that theory is correct then neither the +1 nor the ceiling is really required and this code change would fix it:

Code:
now = time.time()
self.last_run = now - (now % 60)

I've been running this change for the last hour on my HTPC and haven't gotten any duplicate runs. So that's probably the best fix.
find quote
robweber Online
Posting Freak
Posts: 815
Joined: Sep 2009
Reputation: 26
Post: #290
That makes some sense. Even though those calls are very close together there would be some tiny fraction of time that would have gone by. If you hit the marks just right you'd get the wrong minute. I'll implement your proposed change and run it on my system fora while too. I'll bump up my scan rate to every 15 minutes for a few hours and keep an eye on it.
find quote
GTHvidsten Offline
Junior Member
Posts: 3
Joined: Mar 2014
Reputation: 0
Post: #291
In Gotham Beta 2 it seems that cleaning libraries doesn't quite work. The add-on updates the library with new content, but I also have content that is not removed when the files are removed.
find quote
robweber Online
Posting Freak
Posts: 815
Joined: Sep 2009
Reputation: 26
Post: #292
Can you confirm that the clean command is even being issued? Library cleaning from Frodo to Gotham changed in the XBMC core, could be a bug in Gotham. Can you do a manual clean under Settings->Video and see if your items still remain? If this happens then it's a problem with the cleaning function of xbmc.
find quote
Post Reply