From 9c98f713e76e114cf3ebcd8e19a3eb9ad3bfadcf Mon Sep 17 00:00:00 2001 From: faush01 Date: Mon, 16 Mar 2015 16:27:23 +1100 Subject: [PATCH] dont do a lib scan or clean until the sync is full done --- resources/lib/LibrarySync.py | 13 ++++++------- service.py | 14 +++++++++++--- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/resources/lib/LibrarySync.py b/resources/lib/LibrarySync.py index 7f4a2caf..ec41d8ba 100644 --- a/resources/lib/LibrarySync.py +++ b/resources/lib/LibrarySync.py @@ -140,7 +140,6 @@ class LibrarySync(): #we have to compare the lists somehow for item in episodeData: - #xbmc.sleep(150) # sleep to not overload system --> can this be replaced by moving the sync to a different thread ? comparestring1 = str(item.get("ParentIndexNumber")) + "-" + str(item.get("IndexNumber")) matchFound = False progMessage = "Processing" @@ -169,8 +168,8 @@ class LibrarySync(): if(pDialog != None): percentage = int(((float(count) / float(total)) * 100)) pDialog.update(percentage, message=progMessage + " Episode: " + str(count)) - count += 1 - + count += 1 + # process deletes # TODO --> process deletes for episodes !!! if(pDialog != None): @@ -201,10 +200,10 @@ class LibrarySync(): return False if cleanNeeded: - xbmc.executebuiltin("CleanLibrary(video)") + WINDOW.setProperty("cleanNeeded", "true") if updateNeeded: - xbmc.executebuiltin("UpdateLibrary(video)") + WINDOW.setProperty("updateNeeded", "true") finally: WINDOW.clearProperty("librarysync") @@ -263,7 +262,7 @@ class LibrarySync(): percentage = int(((float(count) / float(totalCount)) * 100)) pDialog.update(percentage, message="Updating Movie: " + str(count)) count += 1 - + #process Tv shows tvshowData = self.getTVShows(False) @@ -303,7 +302,7 @@ class LibrarySync(): if(pDialog != None): percentage = int(((float(count) / float(totalCount)) * 100)) pDialog.update(percentage, message="Updating Episode: " + str(count)) - count += 1 + count += 1 finally: WINDOW.clearProperty("librarysync") diff --git a/service.py b/service.py index 5570dcfc..95403444 100644 --- a/service.py +++ b/service.py @@ -6,14 +6,11 @@ import threading import json from datetime import datetime - addonSettings = xbmcaddon.Addon(id='plugin.video.mb3sync') cwd = addonSettings.getAddonInfo('path') BASE_RESOURCE_PATH = xbmc.translatePath( os.path.join( cwd, 'resources', 'lib' ) ) sys.path.append(BASE_RESOURCE_PATH) -WINDOW = xbmcgui.Window( 10000 ) - import KodiMonitor import Utils as utils from LibrarySync import LibrarySync @@ -105,6 +102,17 @@ class Service(): cur_seconds_incrsync = interval_IncrementalSync - 10 else: cur_seconds_incrsync += 1 + + # check if we need to run lib updates + WINDOW = xbmcgui.Window( 10000 ) + if(WINDOW.getProperty("cleanNeeded") == "true"): + xbmc.executebuiltin("CleanLibrary(video)") + WINDOW.clearProperty("cleanNeeded") + + if(WINDOW.getProperty("updateNeeded") == "true"): + xbmc.executebuiltin("UpdateLibrary(video)") + WINDOW.clearProperty("updateNeeded") + else: xbmc.log("Not authenticated yet")