Do background sync while playing

But no full sync
This commit is contained in:
tomkat83 2016-03-29 19:45:32 +02:00
parent 9037f65318
commit 9dec68f6d9
4 changed files with 12 additions and 8 deletions

View file

@ -1573,7 +1573,7 @@ class API():
except:
lastPlayedDate = None
userrating = int(item.get('userRating', 0))
userrating = int(float(item.get('userRating', 0)))
resume, runtime = self.getRuntime()
return {

View file

@ -1449,6 +1449,8 @@ class LibrarySync(Thread):
fullSyncInterval = self.fullSyncInterval
lastProcessing = 0
xbmcplayer = xbmc.Player()
dialog = xbmcgui.Dialog()
queue = self.queue
@ -1569,7 +1571,8 @@ class LibrarySync(Thread):
window('emby_dbScan', clear=True)
else:
now = utils.getUnixTimestamp()
if now - self.lastSync > fullSyncInterval:
if (now - self.lastSync > fullSyncInterval and
not xbmcplayer.isPlaying()):
log('Doing scheduled full library scan', 1)
# Recalculate time offset Kodi - PMS
self.syncPMStime()
@ -1589,7 +1592,6 @@ class LibrarySync(Thread):
# See if there is a PMS message we need to handle
try:
message = queue.get(block=False)
# Empty queue
except Queue.Empty:
xbmc.sleep(100)
continue

View file

@ -110,10 +110,6 @@ class Player(xbmc.Player):
window('emby_skipWatched%s' % itemId, value="true")
log("Playing itemtype is: %s" % itemType, 1)
# Suspend library sync thread while movie is playing
if itemType in ('movie', 'episode'):
log("Suspending library sync while playing", 1)
window('suspend_LibraryThread', value='true')
customseek = window('emby_customPlaylist.seektime')
if (window('emby_customPlaylist') == "true" and customseek):
@ -459,7 +455,6 @@ class Player(xbmc.Player):
window('emby_customPlaylist', clear=True)
window('emby_customPlaylist.seektime', clear=True)
window('emby_playbackProps', clear=True)
window('suspend_LibraryThread', clear=True)
window('emby_customPlaylist.seektime', clear=True)
log("Clear playlist properties.", 1)

View file

@ -17,6 +17,7 @@ import utils
@utils.logging
@utils.ThreadMethodsAdditionalSuspend('suspend_LibraryThread')
@utils.ThreadMethods
class WebSocket(threading.Thread):
opcode_data = (websocket.ABNF.OPCODE_TEXT, websocket.ABNF.OPCODE_BINARY)
@ -103,6 +104,12 @@ class WebSocket(threading.Thread):
# In the event the server goes offline
while threadSuspended():
# Set in service.py
if self.ws is not None:
try:
self.ws.shutdown()
except:
pass
self.ws = None
if threadStopped():
# Abort was requested while waiting. We should exit
log("##===---- WebSocketClient Stopped ----===##", 0)