Base fast sync on server time

Try to fix music video refresh to prevent cursor from moving up.
This commit is contained in:
angelblue05 2018-09-21 04:11:39 -05:00
parent 6e601b9061
commit 0f38ab9e3d
2 changed files with 8 additions and 8 deletions

View file

@ -160,6 +160,7 @@ class HTTP(object):
else:
try:
self.config['server-time'] = r.headers['Date']
elapsed = int(r.elapsed.total_seconds() * 1000)
response = r.json()
LOG.debug("---<[ http ][%s ms]", elapsed)

View file

@ -180,14 +180,11 @@ class Library(threading.Thread):
not self.writer_threads['userdata'] and not self.writer_threads['removed']):
self.pending_refresh = False
self.save_last_sync()
xbmc.executebuiltin('UpdateLibrary(video)')
"""
if xbmc.getCondVisibility('Window.IsActive(home)'):
xbmc.executebuiltin('UpdateLibrary(video)')
else:
if xbmc.getCondVisibility('Container.Content(musicvideos)'): # Prevent cursor from moving
xbmc.executebuiltin('Container.Refresh')
"""
else:
xbmc.executebuiltin('UpdateLibrary(video)')
def stop_client(self):
self.stop_thread = True
@ -218,6 +215,8 @@ class Library(threading.Thread):
dialog("ok", heading="{emby}", line1=_(33128))
raise Exception("Failed to retrieve latest updates")
LOG.info("--<[ retrieve changes ]")
else:
FullSync(self)
Views().get_nodes()
@ -297,7 +296,7 @@ class Library(threading.Thread):
def save_last_sync(self):
time_now = datetime.utcnow() - timedelta(minutes=2)
time_now = datetime.strptime(self.server['config/server-time'].split(', ', 1)[1], '%d %b %Y %H:%M:%S GMT') - timedelta(minutes=2)
last_sync = time_now.strftime('%Y-%m-%dT%H:%M:%Sz')
settings('LastIncrementalSync', value=last_sync)
LOG.info("--[ sync/%s ]", last_sync)