diff --git a/resources/lib/artwork.py b/resources/lib/artwork.py index b1d408e6..035a89f0 100644 --- a/resources/lib/artwork.py +++ b/resources/lib/artwork.py @@ -170,10 +170,9 @@ class Artwork(): if not xbmcgui.Dialog().yesno("Image Texture Cache", "Running the image cache process can take some time.", "Are you sure you want continue?"): return - self.logMsg("Doing Image Cache Sync", 1) - dialog = xbmcgui.DialogProgressBG() + dialog = xbmcgui.DialogProgress() dialog.create("Emby for Kodi", "Image Cache Sync") # ask to rest all existing or not @@ -213,9 +212,11 @@ class Artwork(): percentage = 0 self.logMsg("Image cache sync about to process " + str(total) + " images", 1) for url in result: + if dialog.iscanceled(): + break percentage = int((float(count) / float(total))*100) textMessage = str(count) + " of " + str(total) + " (" + str(len(self.imageCacheThreads)) + ")" - dialog.update(percentage, message="Updating Image Cache: " + textMessage) + dialog.update(percentage, "Updating Image Cache: " + textMessage) self.CacheTexture(url[0]) count += 1 cursor.close() @@ -230,20 +231,22 @@ class Artwork(): percentage = 0 self.logMsg("Image cache sync about to process " + str(total) + " images", 1) for url in result: + if dialog.iscanceled(): + break percentage = int((float(count) / float(total))*100) textMessage = str(count) + " of " + str(total) - dialog.update(percentage, message="Updating Image Cache: " + textMessage) + dialog.update(percentage, "Updating Image Cache: " + textMessage) self.CacheTexture(url[0]) count += 1 cursor.close() - dialog.update(100, message="Waiting for all threads to exit: " + str(len(self.imageCacheThreads))) + dialog.update(100, "Waiting for all threads to exit: " + str(len(self.imageCacheThreads))) self.logMsg("Waiting for all threads to exit", 1) while len(self.imageCacheThreads) > 0: for thread in self.imageCacheThreads: if thread.isFinished: self.imageCacheThreads.remove(thread) - dialog.update(100, message="Waiting for all threads to exit: " + str(len(self.imageCacheThreads))) + dialog.update(100, "Waiting for all threads to exit: " + str(len(self.imageCacheThreads))) self.logMsg("Waiting for all threads to exit: " + str(len(self.imageCacheThreads)), 1) xbmc.sleep(500) diff --git a/resources/lib/kodimonitor.py b/resources/lib/kodimonitor.py index e4f25a6f..05ecf8a5 100644 --- a/resources/lib/kodimonitor.py +++ b/resources/lib/kodimonitor.py @@ -200,6 +200,5 @@ class KodiMonitor(xbmc.Monitor): utils.window('emby_onWake', value="true") elif method == "Playlist.OnClear": - utils.window('emby_customPlaylist', clear=True, windowid=10101) - #xbmcgui.Window(10101).clearProperties() + utils.window('emby_customPlaylist', clear=True) self.logMsg("Clear playlist properties.") \ No newline at end of file diff --git a/resources/lib/librarysync.py b/resources/lib/librarysync.py index be3dc9a3..07d1c218 100644 --- a/resources/lib/librarysync.py +++ b/resources/lib/librarysync.py @@ -251,6 +251,9 @@ class LibrarySync(threading.Thread): self.logMsg( "SyncDatabase (finished %s in: %s)" % (itemtype, str(elapsedTime).split('.')[0]), 1) + else: + # Close the Kodi cursor + kodicursor.close() # sync music if music_enabled: @@ -282,7 +285,6 @@ class LibrarySync(threading.Thread): pDialog.close() embycursor.close() - kodicursor.close() utils.settings('SyncInstallRunDone', value="true") utils.settings("dbCreatedWithVersion", self.clientInfo.getVersion()) diff --git a/resources/lib/playbackutils.py b/resources/lib/playbackutils.py index affa2b81..4ab5ba0f 100644 --- a/resources/lib/playbackutils.py +++ b/resources/lib/playbackutils.py @@ -74,7 +74,7 @@ class PlaybackUtils(): sizePlaylist = playlist.size() currentPosition = startPos - propertiesPlayback = utils.window('emby_playbackProps', windowid=10101) == "true" + propertiesPlayback = utils.window('emby_playbackProps') == "true" introsPlaylist = False dummyPlaylist = False @@ -91,11 +91,11 @@ class PlaybackUtils(): # Otherwise we get a loop. if not propertiesPlayback: - utils.window('emby_playbackProps', value="true", windowid=10101) + utils.window('emby_playbackProps', value="true") self.logMsg("Setting up properties in playlist.", 1) if (not homeScreen and not seektime and - utils.window('emby_customPlaylist', windowid=10101) != "true"): + utils.window('emby_customPlaylist') != "true"): self.logMsg("Adding dummy file to playlist.", 2) dummyPlaylist = True @@ -182,7 +182,7 @@ class PlaybackUtils(): # We just skipped adding properties. Reset flag for next time. elif propertiesPlayback: self.logMsg("Resetting properties playback flag.", 2) - utils.window('emby_playbackProps', clear=True, windowid=10101) + utils.window('emby_playbackProps', clear=True) #self.pl.verifyPlaylist() ########## SETUP MAIN ITEM ########## @@ -202,7 +202,7 @@ class PlaybackUtils(): self.setListItem(listitem) xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem) - elif ((introsPlaylist and utils.window('emby_customPlaylist', windowid=10101) == "true") or + elif ((introsPlaylist and utils.window('emby_customPlaylist') == "true") or (homeScreen and not sizePlaylist)): # Playlist was created just now, play it. self.logMsg("Play playlist.", 1) diff --git a/resources/lib/player.py b/resources/lib/player.py index b6d25e19..7972edec 100644 --- a/resources/lib/player.py +++ b/resources/lib/player.py @@ -400,8 +400,9 @@ class Player(xbmc.Player): def onPlayBackStopped( self ): # Will be called when user stops xbmc playing a file self.logMsg("ONPLAYBACK_STOPPED", 2) - xbmcgui.Window(10101).clearProperties() - self.logMsg("Clear playlist properties.") + utils.window('emby_customPlaylist', clear=True) + utils.window('emby_playbackProps', clear=True) + self.logMsg("Clear playlist properties.", 1) self.stopAll() def onPlayBackEnded( self ): diff --git a/resources/lib/playlist.py b/resources/lib/playlist.py index 03d07d39..c869f288 100644 --- a/resources/lib/playlist.py +++ b/resources/lib/playlist.py @@ -51,7 +51,7 @@ class Playlist(): playlist.clear() started = False - utils.window('emby_customplaylist', value="true", windowid=10101) + utils.window('emby_customplaylist', value="true") position = 0 diff --git a/resources/lib/read_embyserver.py b/resources/lib/read_embyserver.py index 665972fc..78e0bd91 100644 --- a/resources/lib/read_embyserver.py +++ b/resources/lib/read_embyserver.py @@ -240,18 +240,12 @@ class Read_EmbyServer(): "MediaSources" ) result = doUtils.downloadUrl(url, parameters=params) - try: - items['Items'].extend(result['Items']) - except TypeError: - # Connection timed out, reduce the number - jump -= 50 - self.limitindex = jump - self.logMsg("New throttle for items requested: %s" % jump, 1) - else: - index += jump - if dialog: - percentage = int((float(index) / float(total))*100) - dialog.update(percentage) + items['Items'].extend(result['Items']) + + index += jump + if dialog: + percentage = int((float(index) / float(total))*100) + dialog.update(percentage) return items def getViews(self, type, root=False): @@ -429,18 +423,12 @@ class Read_EmbyServer(): ) } result = doUtils.downloadUrl(url, parameters=params) - try: - items['Items'].extend(result['Items']) - except TypeError: - # Connection timed out, reduce the number - jump -= 50 - self.limitindex = jump - self.logMsg("New throttle for items requested: %s" % jump, 1) - else: - index += jump - if dialog: - percentage = int((float(index) / float(total))*100) - dialog.update(percentage) + items['Items'].extend(result['Items']) + + index += jump + if dialog: + percentage = int((float(index) / float(total))*100) + dialog.update(percentage) return items def getAlbums(self, basic=False, dialog=None): diff --git a/service.py b/service.py index cfd36fdb..b68145f2 100644 --- a/service.py +++ b/service.py @@ -71,13 +71,11 @@ class Service(): "emby_online", "emby_serverStatus", "emby_onWake", "emby_syncRunning", "emby_dbCheck", "emby_kodiScan", "emby_shouldStop", "emby_currUser", "emby_dbScan", "emby_sessionId", - "emby_initialScan" + "emby_initialScan", "emby_customplaylist", "emby_playbackProps" ] for prop in properties: utils.window(prop, clear=True) - # Clear playlist properties - xbmcgui.Window(10101).clearProperties() # Clear video nodes properties videonodes.VideoNodes().clearProperties()