add some more notification options

This commit is contained in:
faush01 2015-03-24 10:02:46 +11:00
parent cf03ca9f4f
commit 0c92e86b39
2 changed files with 70 additions and 38 deletions

View file

@ -77,13 +77,14 @@ class LibrarySync():
addon = xbmcaddon.Addon(id='plugin.video.mb3sync') addon = xbmcaddon.Addon(id='plugin.video.mb3sync')
WINDOW = xbmcgui.Window( 10000 ) WINDOW = xbmcgui.Window( 10000 )
pDialog = None pDialog = None
startedSync = datetime.today()
try: try:
dbSyncIndication = addon.getSetting("dbSyncIndication") dbSyncIndication = addon.getSetting("dbSyncIndication")
if(addon.getSetting("SyncFirstMovieRunDone") != 'true'): if(addon.getSetting("SyncFirstMovieRunDone") != "true" or dbSyncIndication == "Dialog Progress"):
pDialog = xbmcgui.DialogProgress() pDialog = xbmcgui.DialogProgress()
elif(dbSyncIndication == "Progress"): elif(dbSyncIndication == "BG Progress"):
pDialog = xbmcgui.DialogProgressBG() pDialog = xbmcgui.DialogProgressBG()
if(pDialog != None): if(pDialog != None):
@ -217,18 +218,28 @@ class LibrarySync():
addon.setSetting("SyncFirstMovieRunDone", "true") addon.setSetting("SyncFirstMovieRunDone", "true")
if(dbSyncIndication == "Notification"): # display notification if set up
notificationString = "" notificationString = ""
if(totalItemsAdded > 0): if(totalItemsAdded > 0):
notificationString += "Added:" + str(totalItemsAdded) + " " notificationString += "Added:" + str(totalItemsAdded) + " "
if(totalItemsUpdated > 0): if(totalItemsUpdated > 0):
notificationString += "Updated:" + str(totalItemsUpdated) + " " notificationString += "Updated:" + str(totalItemsUpdated) + " "
if(totalItemsDeleted > 0): if(totalItemsDeleted > 0):
notificationString += "Deleted:" + str(totalItemsDeleted) + " " notificationString += "Deleted:" + str(totalItemsDeleted) + " "
timeTaken = datetime.today() - startedSync
timeTakenString = str(int(timeTaken.seconds / 60)) + ":" + str(timeTaken.seconds % 60)
utils.logMsg("Sync Movies", "Finished " + timeTakenString + " " + notificationString, 0)
if(dbSyncIndication == "Notify OnChange" and notificationString != ""):
notificationString = "(" + timeTakenString + ") " + notificationString
xbmc.executebuiltin("XBMC.Notification(Movie Sync: " + notificationString + ",)")
elif(dbSyncIndication == "Notify OnFinish"):
if(notificationString == ""): if(notificationString == ""):
notificationString = "Done" notificationString = "Done"
notificationString = "(" + timeTakenString + ") " + notificationString
xbmc.executebuiltin("XBMC.Notification(Movie Sync: " + notificationString + ",)") xbmc.executebuiltin("XBMC.Notification(Movie Sync: " + notificationString + ",)")
finally: finally:
if(pDialog != None): if(pDialog != None):
pDialog.close() pDialog.close()
@ -240,13 +251,14 @@ class LibrarySync():
addon = xbmcaddon.Addon(id='plugin.video.mb3sync') addon = xbmcaddon.Addon(id='plugin.video.mb3sync')
WINDOW = xbmcgui.Window( 10000 ) WINDOW = xbmcgui.Window( 10000 )
pDialog = None pDialog = None
startedSync = datetime.today()
try: try:
dbSyncIndication = addon.getSetting("dbSyncIndication") dbSyncIndication = addon.getSetting("dbSyncIndication")
if(addon.getSetting("SyncFirstTVRunDone") != 'true'): if(addon.getSetting("SyncFirstTVRunDone") != "true" or dbSyncIndication == "Dialog Progress"):
pDialog = xbmcgui.DialogProgress() pDialog = xbmcgui.DialogProgress()
elif(dbSyncIndication == "Progress"): elif(dbSyncIndication == "BG Progress"):
pDialog = xbmcgui.DialogProgressBG() pDialog = xbmcgui.DialogProgressBG()
if(pDialog != None): if(pDialog != None):
@ -562,19 +574,29 @@ class LibrarySync():
self.doKodiLibraryUpdate(True, pDialog) self.doKodiLibraryUpdate(True, pDialog)
addon.setSetting("SyncFirstTVRunDone", "true") addon.setSetting("SyncFirstTVRunDone", "true")
# display notification if set up
notificationString = ""
if(totalItemsAdded > 0):
notificationString += "Added:" + str(totalItemsAdded) + " "
if(totalItemsUpdated > 0):
notificationString += "Updated:" + str(totalItemsUpdated) + " "
if(totalItemsDeleted > 0):
notificationString += "Deleted:" + str(totalItemsDeleted) + " "
timeTaken = datetime.today() - startedSync
timeTakenString = str(int(timeTaken.seconds / 60)) + ":" + str(timeTaken.seconds % 60)
utils.logMsg("Sync Episodes", "Finished " + timeTakenString + " " + notificationString, 0)
if(dbSyncIndication == "Notification"): if(dbSyncIndication == "Notify OnChange" and notificationString != ""):
notificationString = "" notificationString = "(" + timeTakenString + ") " + notificationString
if(totalItemsAdded > 0): xbmc.executebuiltin("XBMC.Notification(Episode Sync: " + notificationString + ",)")
notificationString += "Added:" + str(totalItemsAdded) + " " elif(dbSyncIndication == "Notify OnFinish"):
if(totalItemsUpdated > 0):
notificationString += "Updated:" + str(totalItemsUpdated) + " "
if(totalItemsDeleted > 0):
notificationString += "Deleted:" + str(totalItemsDeleted) + " "
if(notificationString == ""): if(notificationString == ""):
notificationString = "Done" notificationString = "Done"
xbmc.executebuiltin("XBMC.Notification(TV Sync: " + notificationString + ",)") notificationString = "(" + timeTakenString + ") " + notificationString
xbmc.executebuiltin("XBMC.Notification(Episode Sync: " + notificationString + ",)")
finally: finally:
if(pDialog != None): if(pDialog != None):
pDialog.close() pDialog.close()
@ -590,9 +612,9 @@ class LibrarySync():
try: try:
dbSyncIndication = addon.getSetting("dbSyncIndication") dbSyncIndication = addon.getSetting("dbSyncIndication")
if(addon.getSetting("SyncFirstMusicVideoRunDone") != 'true'): if(addon.getSetting("SyncFirstMusicVideoRunDone") != "true" or dbSyncIndication == "Dialog Progress"):
pDialog = xbmcgui.DialogProgress() pDialog = xbmcgui.DialogProgress()
elif(dbSyncIndication == "Progress"): elif(dbSyncIndication == "BG Progress"):
pDialog = xbmcgui.DialogProgressBG() pDialog = xbmcgui.DialogProgressBG()
if(pDialog != None): if(pDialog != None):
@ -732,16 +754,16 @@ class LibrarySync():
addon = xbmcaddon.Addon(id='plugin.video.mb3sync') addon = xbmcaddon.Addon(id='plugin.video.mb3sync')
WINDOW = xbmcgui.Window( 10000 ) WINDOW = xbmcgui.Window( 10000 )
pDialog = None pDialog = None
startedSync = datetime.today()
processMovies = True processMovies = True
processTvShows = True processTvShows = True
try: try:
playCountSyncIndication = addon.getSetting("playCountSyncIndication") playCountSyncIndication = addon.getSetting("playCountSyncIndication")
if(addon.getSetting("SyncFirstCountsRunDone") != 'true'): if(addon.getSetting("SyncFirstCountsRunDone") != "true" or playCountSyncIndication == "Dialog Progress"):
pDialog = xbmcgui.DialogProgress() pDialog = xbmcgui.DialogProgress()
elif(playCountSyncIndication == "Progress"): elif(playCountSyncIndication == "BG Progress"):
pDialog = xbmcgui.DialogProgressBG() pDialog = xbmcgui.DialogProgressBG()
if(pDialog != None): if(pDialog != None):
@ -869,17 +891,27 @@ class LibrarySync():
showCurrent += 1 showCurrent += 1
addon.setSetting("SyncFirstCountsRunDone", "true") addon.setSetting("SyncFirstCountsRunDone", "true")
# display notification if set up
notificationString = ""
if(totalPositionsUpdated > 0):
notificationString += "Pos:" + str(totalPositionsUpdated) + " "
if(totalCountsUpdated > 0):
notificationString += "Counts:" + str(totalCountsUpdated) + " "
timeTaken = datetime.today() - startedSync
timeTakenString = str(int(timeTaken.seconds / 60)) + ":" + str(timeTaken.seconds % 60)
utils.logMsg("Sync PlayCount", "Finished " + timeTakenString + " " + notificationString, 0)
if(playCountSyncIndication == "Notification"): if(playCountSyncIndication == "Notify OnChange" and notificationString != ""):
notificationString = "" notificationString = "(" + timeTakenString + ") " + notificationString
if(totalPositionsUpdated > 0): xbmc.executebuiltin("XBMC.Notification(PlayCount Sync: " + notificationString + ",)")
notificationString += "Pos:" + str(totalPositionsUpdated) + " " elif(playCountSyncIndication == "Notify OnFinish"):
if(totalCountsUpdated > 0):
notificationString += "Counts:" + str(totalCountsUpdated) + " "
if(notificationString == ""): if(notificationString == ""):
notificationString = "Done" notificationString = "Done"
xbmc.executebuiltin("XBMC.Notification(Play Sync: " + notificationString + ",)") notificationString = "(" + timeTakenString + ") " + notificationString
xbmc.executebuiltin("XBMC.Notification(PlayCount Sync: " + notificationString + ",)")
finally: finally:
if(pDialog != None): if(pDialog != None):
pDialog.close() pDialog.close()

View file

@ -11,8 +11,8 @@
<setting id="enablePlayCountSync" type="bool" label="Enable watched/resume status sync" default="true" visible="true" enable="true" /> <setting id="enablePlayCountSync" type="bool" label="Enable watched/resume status sync" default="true" visible="true" enable="true" />
<setting id="syncSettingStartup" type="labelenum" label="Startup Sync:" values="Full Sync|Incremental Sync|None" default="Full Sync" /> <setting id="syncSettingStartup" type="labelenum" label="Startup Sync:" values="Full Sync|Incremental Sync|None" default="Full Sync" />
<setting id="syncSettingBackground" type="labelenum" label="Scheduled Sync:" values="Full Sync|Incremental Sync|None" default="Full Sync" visible="true" enable="true" /> <setting id="syncSettingBackground" type="labelenum" label="Scheduled Sync:" values="Full Sync|Incremental Sync|None" default="Full Sync" visible="true" enable="true" />
<setting id="dbSyncIndication" type="labelenum" label="DB Sync Indication:" values="None|Notification|Progress" default="None" /> <setting id="dbSyncIndication" type="labelenum" label="DB Sync Indication:" values="None|Notify OnChange|Notify OnFinish|BG Progress|Dialog Progress" default="None" />
<setting id="playCountSyncIndication" type="labelenum" label="Play Count Sync Indication:" values="None|Notification|Progress" default="None" /> <setting id="playCountSyncIndication" type="labelenum" label="Play Count Sync Indication:" values="None|Notify OnChange|Notify OnFinish|BG Progress|Dialog Progress" default="None" />
</category> </category>
<category label="30014"> <!-- MediaBrowser --> <category label="30014"> <!-- MediaBrowser -->