From 9e9f61f9ba64f5601c9750c1e0a3afe46310b5cb Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Thu, 3 Mar 2016 10:11:32 +0100 Subject: [PATCH] Added refresh Playlist and videonodes. Removed some Setting topics --- resources/lib/entrypoint.py | 40 ++++++++---------------------------- resources/lib/librarysync.py | 30 ++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 32 deletions(-) diff --git a/resources/lib/entrypoint.py b/resources/lib/entrypoint.py index aac8759a..06c27d20 100644 --- a/resources/lib/entrypoint.py +++ b/resources/lib/entrypoint.py @@ -187,15 +187,15 @@ def doMainListing(): "?mode=switchuser") #experimental live tv nodes - addDirectoryItem("Live Tv Channels (experimental)", "plugin://plugin.video.plexkodiconnect/?mode=browsecontent&type=tvchannels&folderid=root") - addDirectoryItem("Live Tv Recordings (experimental)", "plugin://plugin.video.plexkodiconnect/?mode=browsecontent&type=recordings&folderid=root") + # addDirectoryItem("Live Tv Channels (experimental)", "plugin://plugin.video.plexkodiconnect/?mode=browsecontent&type=tvchannels&folderid=root") + # addDirectoryItem("Live Tv Recordings (experimental)", "plugin://plugin.video.plexkodiconnect/?mode=browsecontent&type=recordings&folderid=root") # some extra entries for settings and stuff. TODO --> localize the labels - addDirectoryItem("Network credentials", "plugin://plugin.video.plexkodiconnect/?mode=passwords") addDirectoryItem("Settings", "plugin://plugin.video.plexkodiconnect/?mode=settings") - addDirectoryItem("Add user to session", "plugin://plugin.video.plexkodiconnect/?mode=adduser") - addDirectoryItem("Refresh Emby playlists/nodes", "plugin://plugin.video.plexkodiconnect/?mode=refreshplaylist") - addDirectoryItem("Perform manual sync", "plugin://plugin.video.plexkodiconnect/?mode=manualsync") + addDirectoryItem("Network credentials", "plugin://plugin.video.plexkodiconnect/?mode=passwords") + # addDirectoryItem("Add user to session", "plugin://plugin.video.plexkodiconnect/?mode=adduser") + addDirectoryItem("Refresh Plex playlists/nodes", "plugin://plugin.video.plexkodiconnect/?mode=refreshplaylist") + addDirectoryItem("Perform manual library sync", "plugin://plugin.video.plexkodiconnect/?mode=manualsync") addDirectoryItem("Repair local database (force update all content)", "plugin://plugin.video.plexkodiconnect/?mode=repair") addDirectoryItem("Perform local database reset (full resync)", "plugin://plugin.video.plexkodiconnect/?mode=reset") addDirectoryItem("Cache all images to Kodi texture cache", "plugin://plugin.video.plexkodiconnect/?mode=texturecache") @@ -370,7 +370,7 @@ def switchPlexUser(): # Log out currently signed in user: utils.window('emby_serverStatus', value="401") # Request lib sync to get user view data (e.g. watched/unwatched) - utils.window('plex_runLibScan', value='true') + utils.window('plex_runLibScan', value='full') ##### THEME MUSIC/VIDEOS ##### @@ -531,31 +531,9 @@ def getThemeMedia(): ##### REFRESH EMBY PLAYLISTS ##### def refreshPlaylist(): + utils.logMsg(addonName, 'Requesting playlist/nodes refresh', 0) + utils.window('plex_runLibScan', value="views") - lib = librarysync.LibrarySync() - dialog = xbmcgui.Dialog() - try: - # First remove playlists - utils.deletePlaylists() - # Remove video nodes - utils.deleteNodes() - # Refresh views - lib.refreshViews() - dialog.notification( - heading="Emby for Kodi", - message="Emby playlists/nodes refreshed", - icon="special://home/addons/plugin.video.plexkodiconnect/icon.png", - time=1000, - sound=False) - - except Exception as e: - utils.logMsg("EMBY", "Refresh playlists/nodes failed: %s" % e, 1) - dialog.notification( - heading="Emby for Kodi", - message="Emby playlists/nodes refresh failed", - icon=xbmcgui.NOTIFICATION_ERROR, - time=1000, - sound=False) #### SHOW SUBFOLDERS FOR NODE ##### def GetSubFolders(nodeindex): diff --git a/resources/lib/librarysync.py b/resources/lib/librarysync.py index ddd67512..49634699 100644 --- a/resources/lib/librarysync.py +++ b/resources/lib/librarysync.py @@ -1212,13 +1212,41 @@ class LibrarySync(Thread): # Currently no db scan, so we can start a new scan elif window('emby_dbScan') != "true": # Full scan was requested from somewhere else, e.g. userclient - if window('plex_runLibScan') == "true": + if window('plex_runLibScan') == "full": log('Full library scan requested, starting', 0) window('emby_dbScan', value="true") window('plex_runLibScan', clear=True) self.fullSync(manualrun=True) window('emby_dbScan', clear=True) count = 0 + # Reset views was requested from somewhere else + elif window('plex_runLibScan') == "views": + log('Refresh playlist and nodes requested, starting', 0) + window('emby_dbScan', value="true") + window('plex_runLibScan', clear=True) + + # First remove playlists + utils.deletePlaylists() + # Remove video nodes + utils.deleteNodes() + # Kick off refresh + dialog = xbmcgui.Dialog() + if self.maintainViews(): + dialog.notification( + heading=self.addonName, + message="Plex playlists/nodes refreshed", + icon="special://home/addons/plugin.video.plexkodiconnect/icon.png", + time=3000, + sound=True) + else: + self.logMsg("Refresh playlists/nodes failed", -1) + dialog.notification( + heading=self.addonName, + message="Plex playlists/nodes refresh failed", + icon=xbmcgui.NOTIFICATION_ERROR, + time=3000, + sound=True) + window('emby_dbScan', clear=True) else: # Run full lib scan approx every 30min if count >= 1800: