mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-25 10:16:11 +00:00
add Notification as an UI indication option for syns actions
This commit is contained in:
parent
263500da34
commit
59cdfcd922
3 changed files with 90 additions and 33 deletions
|
@ -79,18 +79,20 @@ class LibrarySync():
|
|||
pDialog = None
|
||||
|
||||
try:
|
||||
enableProgress = False
|
||||
if addon.getSetting("enableProgressFullSync") == 'true':
|
||||
enableProgress = True
|
||||
dbSyncIndication = addon.getSetting("dbSyncIndication")
|
||||
|
||||
if(addon.getSetting("SyncFirstMovieRunDone") != 'true'):
|
||||
pDialog = xbmcgui.DialogProgress()
|
||||
elif(enableProgress):
|
||||
elif(dbSyncIndication == "Progress"):
|
||||
pDialog = xbmcgui.DialogProgressBG()
|
||||
|
||||
if(pDialog != None):
|
||||
pDialog.create('Sync DB', 'Sync DB')
|
||||
|
||||
totalItemsAdded = 0
|
||||
totalItemsUpdated = 0
|
||||
totalItemsDeleted = 0
|
||||
|
||||
allEmbyMovieIds = list()
|
||||
|
||||
views = ReadEmbyDB().getCollections("movies")
|
||||
|
@ -128,6 +130,7 @@ class LibrarySync():
|
|||
if item["Id"] not in allKodiIds:
|
||||
WriteKodiDB().addMovieToKodiLibrary(item)
|
||||
updateNeeded = True
|
||||
totalItemsAdded += 1
|
||||
|
||||
if(self.ShouldStop(pDialog)):
|
||||
return True
|
||||
|
@ -171,7 +174,9 @@ class LibrarySync():
|
|||
kodimovie = allKodiMovies.get(item["Id"], None)
|
||||
if(kodimovie != None):
|
||||
#WriteKodiDB().updateMovieToKodiLibrary(item, kodimovie)
|
||||
WriteKodiDB().updateMovieToKodiLibrary_Batched(item, kodimovie)
|
||||
updated = WriteKodiDB().updateMovieToKodiLibrary_Batched(item, kodimovie)
|
||||
if(updated):
|
||||
totalItemsUpdated += 1
|
||||
|
||||
if(self.ShouldStop(pDialog)):
|
||||
return True
|
||||
|
@ -201,6 +206,7 @@ class LibrarySync():
|
|||
if not kodiId in allEmbyMovieIds:
|
||||
WriteKodiDB().deleteMovieFromKodiLibrary(kodiId)
|
||||
cleanNeeded = True
|
||||
totalItemsDeleted += 1
|
||||
|
||||
if(self.ShouldStop(pDialog)):
|
||||
return True
|
||||
|
@ -211,6 +217,18 @@ class LibrarySync():
|
|||
|
||||
addon.setSetting("SyncFirstMovieRunDone", "true")
|
||||
|
||||
if(dbSyncIndication == "Notification"):
|
||||
notificationString = ""
|
||||
if(totalItemsAdded > 0):
|
||||
notificationString += "Added:" + str(totalItemsAdded) + " "
|
||||
if(totalItemsUpdated > 0):
|
||||
notificationString += "Updated:" + str(totalItemsUpdated) + " "
|
||||
if(totalItemsDeleted > 0):
|
||||
notificationString += "Deleted:" + str(totalItemsDeleted) + " "
|
||||
if(notificationString == ""):
|
||||
notificationString = "Done"
|
||||
xbmc.executebuiltin("XBMC.Notification(Movie Sync: " + notificationString + ",)")
|
||||
|
||||
finally:
|
||||
if(pDialog != None):
|
||||
pDialog.close()
|
||||
|
@ -224,17 +242,19 @@ class LibrarySync():
|
|||
pDialog = None
|
||||
|
||||
try:
|
||||
enableProgress = False
|
||||
if addon.getSetting("enableProgressFullSync") == 'true':
|
||||
enableProgress = True
|
||||
dbSyncIndication = addon.getSetting("dbSyncIndication")
|
||||
|
||||
if(addon.getSetting("SyncFirstTVRunDone") != 'true'):
|
||||
pDialog = xbmcgui.DialogProgress()
|
||||
elif(enableProgress):
|
||||
elif(dbSyncIndication == "Progress"):
|
||||
pDialog = xbmcgui.DialogProgressBG()
|
||||
|
||||
if(pDialog != None):
|
||||
pDialog.create('Sync DB', 'Sync DB')
|
||||
|
||||
totalItemsAdded = 0
|
||||
totalItemsUpdated = 0
|
||||
totalItemsDeleted = 0
|
||||
|
||||
progressTitle = "Sync DB : Processing Episodes"
|
||||
|
||||
|
@ -276,6 +296,7 @@ class LibrarySync():
|
|||
WriteKodiDB().addEpisodeToKodiLibrary(episode)
|
||||
updateNeeded = True
|
||||
progressAction = "Adding"
|
||||
totalItemsAdded += 1
|
||||
|
||||
if(self.ShouldStop(pDialog)):
|
||||
return True
|
||||
|
@ -353,6 +374,7 @@ class LibrarySync():
|
|||
if item["Id"] not in allKodiIds:
|
||||
WriteKodiDB().addTVShowToKodiLibrary(item)
|
||||
updateNeeded = True
|
||||
totalItemsAdded += 1
|
||||
|
||||
if(self.ShouldStop(pDialog)):
|
||||
return True
|
||||
|
@ -399,6 +421,7 @@ class LibrarySync():
|
|||
WriteKodiDB().addEpisodeToKodiLibrary(item)
|
||||
updateNeeded = True
|
||||
progressAction = "Adding"
|
||||
totalItemsAdded += 1
|
||||
|
||||
if(self.ShouldStop(pDialog)):
|
||||
return True
|
||||
|
@ -439,7 +462,9 @@ class LibrarySync():
|
|||
kodishow = allKodiTVShows.get(item["Id"],None)
|
||||
|
||||
if(kodishow != None):
|
||||
WriteKodiDB().updateTVShowToKodiLibrary(item,kodishow)
|
||||
updated = WriteKodiDB().updateTVShowToKodiLibrary(item,kodishow)
|
||||
if(updated):
|
||||
totalItemsUpdated += 1
|
||||
|
||||
if(self.ShouldStop(pDialog)):
|
||||
return True
|
||||
|
@ -477,7 +502,9 @@ class LibrarySync():
|
|||
if kodiEpisodes != None:
|
||||
KodiItem = kodiEpisodes.get(comparestring1, None)
|
||||
if(KodiItem != None):
|
||||
WriteKodiDB().updateEpisodeToKodiLibrary(item, KodiItem)
|
||||
updated = WriteKodiDB().updateEpisodeToKodiLibrary(item, KodiItem)
|
||||
if(updated):
|
||||
totalItemsUpdated += 1
|
||||
|
||||
if(self.ShouldStop(pDialog)):
|
||||
return True
|
||||
|
@ -514,6 +541,8 @@ class LibrarySync():
|
|||
for episode in allKodiEpisodeIds:
|
||||
if episode.get('episodeid') not in allMB3EpisodeIds:
|
||||
WriteKodiDB().deleteEpisodeFromKodiLibrary(episode.get('episodeid'),episode.get('tvshowid'))
|
||||
cleanneeded = True
|
||||
totalItemsDeleted += 1
|
||||
|
||||
# DELETES -- TV SHOWS
|
||||
if fullsync:
|
||||
|
@ -523,6 +552,7 @@ class LibrarySync():
|
|||
if not dir in allMB3TVShows:
|
||||
WriteKodiDB().deleteTVShowFromKodiLibrary(dir)
|
||||
cleanneeded = True
|
||||
totalItemsDeleted += 1
|
||||
|
||||
if(self.ShouldStop(pDialog)):
|
||||
return True
|
||||
|
@ -533,6 +563,18 @@ class LibrarySync():
|
|||
|
||||
addon.setSetting("SyncFirstTVRunDone", "true")
|
||||
|
||||
if(dbSyncIndication == "Notification"):
|
||||
notificationString = ""
|
||||
if(totalItemsAdded > 0):
|
||||
notificationString += "Added:" + str(totalItemsAdded) + " "
|
||||
if(totalItemsUpdated > 0):
|
||||
notificationString += "Updated:" + str(totalItemsUpdated) + " "
|
||||
if(totalItemsDeleted > 0):
|
||||
notificationString += "Deleted:" + str(totalItemsDeleted) + " "
|
||||
if(notificationString == ""):
|
||||
notificationString = "Done"
|
||||
xbmc.executebuiltin("XBMC.Notification(TV Sync: " + notificationString + ",)")
|
||||
|
||||
finally:
|
||||
if(pDialog != None):
|
||||
pDialog.close()
|
||||
|
@ -546,13 +588,11 @@ class LibrarySync():
|
|||
pDialog = None
|
||||
|
||||
try:
|
||||
enableProgress = False
|
||||
if addon.getSetting("enableProgressFullSync") == 'true':
|
||||
enableProgress = True
|
||||
dbSyncIndication = addon.getSetting("dbSyncIndication")
|
||||
|
||||
if(addon.getSetting("SyncFirstMusicVideoRunDone") != 'true'):
|
||||
pDialog = xbmcgui.DialogProgress()
|
||||
elif(enableProgress):
|
||||
elif(dbSyncIndication == "Progress"):
|
||||
pDialog = xbmcgui.DialogProgressBG()
|
||||
|
||||
if(pDialog != None):
|
||||
|
@ -697,18 +737,19 @@ class LibrarySync():
|
|||
processTvShows = True
|
||||
|
||||
try:
|
||||
enableProgress = False
|
||||
if addon.getSetting("enableProgressPlayCountSync") == 'true':
|
||||
enableProgress = True
|
||||
playCountSyncIndication = addon.getSetting("playCountSyncIndication")
|
||||
|
||||
if(addon.getSetting("SyncFirstCountsRunDone") != 'true'):
|
||||
pDialog = xbmcgui.DialogProgress()
|
||||
elif(enableProgress):
|
||||
elif(playCountSyncIndication == "Progress"):
|
||||
pDialog = xbmcgui.DialogProgressBG()
|
||||
|
||||
if(pDialog != None):
|
||||
pDialog.create('Sync PlayCounts', 'Sync PlayCounts')
|
||||
|
||||
totalCountsUpdated = 0
|
||||
totalPositionsUpdated = 0
|
||||
|
||||
#process movies
|
||||
if processMovies:
|
||||
if(pDialog != None):
|
||||
|
@ -734,7 +775,7 @@ class LibrarySync():
|
|||
progressTitle = "Sync PlayCounts: Processing " + view.get('title') + " " + str(viewCurrent) + " of " + str(viewCount)
|
||||
pDialog.update(0, progressTitle)
|
||||
totalCount = len(allMB3Movies) + 1
|
||||
count = 1
|
||||
count = 1
|
||||
|
||||
for item in allMB3Movies:
|
||||
|
||||
|
@ -745,12 +786,15 @@ class LibrarySync():
|
|||
timeInfo = API().getTimeInfo(item)
|
||||
|
||||
if kodiItem != None:
|
||||
WriteKodiDB().updateProperty(kodiItem,"playcount",int(userData.get("PlayCount")),"movie")
|
||||
updated = WriteKodiDB().updateProperty(kodiItem,"playcount",int(userData.get("PlayCount")), "movie")
|
||||
if(updated):
|
||||
totalCountsUpdated += 1
|
||||
kodiresume = int(round(kodiItem['resume'].get("position")))
|
||||
resume = int(round(float(timeInfo.get("ResumeTime"))))*60
|
||||
total = int(round(float(timeInfo.get("TotalTime"))))*60
|
||||
if kodiresume != resume:
|
||||
WriteKodiDB().setKodiResumePoint(kodiItem['movieid'],resume,total,"movie")
|
||||
totalPositionsUpdated += 1
|
||||
|
||||
if(self.ShouldStop(pDialog)):
|
||||
return True
|
||||
|
@ -803,12 +847,15 @@ class LibrarySync():
|
|||
timeInfo = API().getTimeInfo(episode)
|
||||
if kodiItem != None:
|
||||
if kodiItem['playcount'] != int(userData.get("PlayCount")):
|
||||
WriteKodiDB().updateProperty(kodiItem,"playcount",int(userData.get("PlayCount")),"episode")
|
||||
updated = WriteKodiDB().updateProperty(kodiItem,"playcount",int(userData.get("PlayCount")),"episode")
|
||||
if(updated):
|
||||
totalCountsUpdated += 1
|
||||
kodiresume = int(round(kodiItem['resume'].get("position")))
|
||||
resume = int(round(float(timeInfo.get("ResumeTime"))))*60
|
||||
total = int(round(float(timeInfo.get("TotalTime"))))*60
|
||||
if kodiresume != resume:
|
||||
WriteKodiDB().setKodiResumePoint(kodiItem['episodeid'],resume,total,"episode")
|
||||
totalPositionsUpdated += 1
|
||||
|
||||
if(self.ShouldStop(pDialog)):
|
||||
return True
|
||||
|
@ -823,6 +870,16 @@ class LibrarySync():
|
|||
|
||||
addon.setSetting("SyncFirstCountsRunDone", "true")
|
||||
|
||||
if(playCountSyncIndication == "Notification"):
|
||||
notificationString = ""
|
||||
if(totalPositionsUpdated > 0):
|
||||
notificationString += "Pos:" + str(totalPositionsUpdated) + " "
|
||||
if(totalCountsUpdated > 0):
|
||||
notificationString += "Counts:" + str(totalCountsUpdated) + " "
|
||||
if(notificationString == ""):
|
||||
notificationString = "Done"
|
||||
xbmc.executebuiltin("XBMC.Notification(Play Sync: " + notificationString + ",)")
|
||||
|
||||
finally:
|
||||
if(pDialog != None):
|
||||
pDialog.close()
|
||||
|
|
|
@ -170,6 +170,8 @@ class WriteKodiDB():
|
|||
if(changes):
|
||||
utils.logMsg("Updated item to Kodi Library", MBitem["Id"] + " - " + MBitem["Name"], level=0)
|
||||
|
||||
return changes
|
||||
|
||||
def updateMusicVideoToKodiLibrary_Batched(self, MBitem, KodiItem):
|
||||
addon = xbmcaddon.Addon(id='plugin.video.mb3sync')
|
||||
port = addon.getSetting('port')
|
||||
|
@ -365,6 +367,8 @@ class WriteKodiDB():
|
|||
|
||||
if changes:
|
||||
utils.logMsg("Updated item to Kodi Library", MBitem["Id"] + " - " + MBitem["Name"])
|
||||
|
||||
return changes
|
||||
|
||||
def updateEpisodeToKodiLibrary( self, MBitem, KodiItem ):
|
||||
|
||||
|
@ -418,6 +422,8 @@ class WriteKodiDB():
|
|||
if changes:
|
||||
utils.logMsg("Updated item to Kodi Library", MBitem["Id"] + " - " + MBitem["Name"])
|
||||
|
||||
return changes
|
||||
|
||||
def getArtworkParam_Batched(self, KodiItem, MBitem, params):
|
||||
|
||||
'''
|
||||
|
|
|
@ -9,14 +9,10 @@
|
|||
|
||||
<category label="Automatic sync"> <!-- Auto sync optionss -->
|
||||
<setting id="enablePlayCountSync" type="bool" label="Enable watched/resume status sync" default="true" visible="true" enable="true" />
|
||||
<setting id="syncSettingStartup" type="labelenum" label="Run at startup:" values="Full Sync|Incremental Sync|None" default="Full Sync" />
|
||||
<setting id="syncSettingBackground" type="labelenum" label="Enable continuous background sync:" values="Full Sync|Incremental Sync|None" default="Full Sync" visible="true" enable="true" />
|
||||
<setting type="lsep"/>
|
||||
<setting label="[B]Full Sync:[/B] Performs full compare including deletes" type="lsep"/>
|
||||
<setting label="[B]Incremental Sync:[/B] Processes only new items" type="lsep"/>
|
||||
<setting label="Watched/resume status is always synced in the background." type="lsep"/>
|
||||
<setting type="lsep"/>
|
||||
<setting label="Run manual full sync now" type="action" action="RunScript(plugin.video.mbsync, fullsync)" />
|
||||
<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="dbSyncIndication" type="labelenum" label="DB Sync Indication:" values="None|Notification|Progress" default="None" />
|
||||
<setting id="playCountSyncIndication" type="labelenum" label="Play Count Sync Indication:" values="None|Notification|Progress" default="None" />
|
||||
</category>
|
||||
|
||||
<category label="30014"> <!-- MediaBrowser -->
|
||||
|
@ -27,9 +23,7 @@
|
|||
</category>
|
||||
|
||||
<category label="30022"> <!-- Advanced -->
|
||||
<setting id="logLevel" type="enum" label="30004" values="None|Info|Debug" default="0" />
|
||||
<setting id="enableProgressPlayCountSync" type="bool" label="Show load progress for Watched/resume status sync" default="false" visible="true" enable="true" />
|
||||
<setting id="enableProgressFullSync" type="bool" label="Show load progress for full/incremental sync" default="false" visible="true" enable="true" />
|
||||
<setting id="logLevel" type="enum" label="30004" values="None|Info|Debug" default="0" />
|
||||
<setting id="smbusername" type="text" label="30007" default="" visible="true" enable="true" />
|
||||
<setting id="smbpassword" type="text" label="30008" default="" option="hidden" visible="true" enable="true" />
|
||||
</category>
|
||||
|
|
Loading…
Reference in a new issue