diff --git a/resources/lib/PlexAPI.py b/resources/lib/PlexAPI.py index a381bf08..04f87659 100644 --- a/resources/lib/PlexAPI.py +++ b/resources/lib/PlexAPI.py @@ -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 { diff --git a/resources/lib/librarysync.py b/resources/lib/librarysync.py index 63c3d72b..86592001 100644 --- a/resources/lib/librarysync.py +++ b/resources/lib/librarysync.py @@ -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 diff --git a/resources/lib/player.py b/resources/lib/player.py index e494fe4a..4611e764 100644 --- a/resources/lib/player.py +++ b/resources/lib/player.py @@ -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) diff --git a/resources/lib/websocket_client.py b/resources/lib/websocket_client.py index a544620c..c5d543cc 100644 --- a/resources/lib/websocket_client.py +++ b/resources/lib/websocket_client.py @@ -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)