From 60f68610f496f8bf3fca92cc410c60c124642d70 Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Mon, 18 Jan 2016 17:47:12 -0600 Subject: [PATCH 1/5] Close the kodi cursor earlier In case music doesn't complete correctly. --- resources/lib/librarysync.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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()) From f3f8c76197173e6f6ecf22642c5bfb61457a537a Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Mon, 18 Jan 2016 19:54:20 -0600 Subject: [PATCH 2/5] Fix progress dialog --- resources/lib/kodimonitor.py | 3 +-- resources/lib/playbackutils.py | 10 +++++----- resources/lib/player.py | 2 +- resources/lib/playlist.py | 2 +- service.py | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/resources/lib/kodimonitor.py b/resources/lib/kodimonitor.py index e4f25a6f..aa9aa79c 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, windowid=10008) self.logMsg("Clear playlist properties.") \ No newline at end of file diff --git a/resources/lib/playbackutils.py b/resources/lib/playbackutils.py index affa2b81..777fe9e6 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', windowid=10008) == "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", windowid=10008) 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', windowid=10008) != "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, windowid=10008) #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', windowid=10008) == "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..1323548b 100644 --- a/resources/lib/player.py +++ b/resources/lib/player.py @@ -400,7 +400,7 @@ 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() + xbmcgui.Window(10008).clearProperties() self.logMsg("Clear playlist properties.") self.stopAll() diff --git a/resources/lib/playlist.py b/resources/lib/playlist.py index 03d07d39..9d2d9a95 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", windowid=10008) position = 0 diff --git a/service.py b/service.py index cfd36fdb..4c65cce5 100644 --- a/service.py +++ b/service.py @@ -77,7 +77,7 @@ class Service(): utils.window(prop, clear=True) # Clear playlist properties - xbmcgui.Window(10101).clearProperties() + xbmcgui.Window(10008).clearProperties() # Clear video nodes properties videonodes.VideoNodes().clearProperties() From d14ecfdc5e12e44b03f4611fbd7aec3133158e1c Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Mon, 18 Jan 2016 21:54:02 -0600 Subject: [PATCH 3/5] Adjust playlist props Instead of using clearProperties, clear individually. --- resources/lib/kodimonitor.py | 2 +- resources/lib/playbackutils.py | 10 +++++----- resources/lib/player.py | 5 +++-- resources/lib/playlist.py | 2 +- service.py | 4 +--- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/resources/lib/kodimonitor.py b/resources/lib/kodimonitor.py index aa9aa79c..05ecf8a5 100644 --- a/resources/lib/kodimonitor.py +++ b/resources/lib/kodimonitor.py @@ -200,5 +200,5 @@ class KodiMonitor(xbmc.Monitor): utils.window('emby_onWake', value="true") elif method == "Playlist.OnClear": - utils.window('emby_customPlaylist', clear=True, windowid=10008) + utils.window('emby_customPlaylist', clear=True) self.logMsg("Clear playlist properties.") \ No newline at end of file diff --git a/resources/lib/playbackutils.py b/resources/lib/playbackutils.py index 777fe9e6..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=10008) == "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=10008) + 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=10008) != "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=10008) + 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=10008) == "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 1323548b..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(10008).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 9d2d9a95..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=10008) + utils.window('emby_customplaylist', value="true") position = 0 diff --git a/service.py b/service.py index 4c65cce5..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(10008).clearProperties() # Clear video nodes properties videonodes.VideoNodes().clearProperties() From bfb893ad8e132c9b2dc2a2a7fae1d227667d58f8 Mon Sep 17 00:00:00 2001 From: Shaun Date: Tue, 19 Jan 2016 18:58:42 +1100 Subject: [PATCH 4/5] use standard progress dialog for progress and add cancel --- resources/lib/artwork.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/resources/lib/artwork.py b/resources/lib/artwork.py index 25860bb4..fd746a55 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) From 81dcd36dc3117ae7e7383c6b1a151c4f18151f1e Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Tue, 19 Jan 2016 04:28:52 -0600 Subject: [PATCH 5/5] Revert throttle Will have to test further with timeout scenario, before reimplementing --- resources/lib/read_embyserver.py | 36 +++++++++++--------------------- 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/resources/lib/read_embyserver.py b/resources/lib/read_embyserver.py index 323745d4..d37d4fbf 100644 --- a/resources/lib/read_embyserver.py +++ b/resources/lib/read_embyserver.py @@ -210,18 +210,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): @@ -399,18 +393,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):