diff --git a/default.py b/default.py index b4adddee..5137b56a 100644 --- a/default.py +++ b/default.py @@ -59,7 +59,8 @@ class Main: 'channelsfolder': entrypoint.BrowseChannels, 'nextup': entrypoint.getNextUpEpisodes, 'inprogressepisodes': entrypoint.getInProgressEpisodes, - 'recentepisodes': entrypoint.getRecentEpisodes + 'recentepisodes': entrypoint.getRecentEpisodes, + 'refreshplaylist': entrypoint.refreshPlaylist } if modes.get(mode): @@ -87,10 +88,12 @@ class Main: xbmc.executebuiltin('Addon.OpenSettings(plugin.video.emby)') elif mode in ("manualsync", "repair"): import librarysync + lib = librarysync.LibrarySync() if mode == "manualsync": - librarysync.LibrarySync().fullSync(manualrun=True) + lib.fullSync(manualrun=True) else: - librarysync.LibrarySync().fullSync(repair=True) + lib.fullSync(repair=True) + elif mode == "texturecache": import artwork artwork.Artwork().FullTextureCacheSync() diff --git a/resources/lib/entrypoint.py b/resources/lib/entrypoint.py index 489cf8bc..7f679276 100644 --- a/resources/lib/entrypoint.py +++ b/resources/lib/entrypoint.py @@ -74,6 +74,10 @@ def doMainListing(): addDirectoryItem("Settings", "plugin://plugin.video.emby/?mode=settings", False) addDirectoryItem("Add user to session", "plugin://plugin.video.emby/?mode=adduser", False) #addDirectoryItem("Cache all images to Kodi texture cache (advanced)", "plugin://plugin.video.emby/?mode=texturecache") + addDirectoryItem( + label="Refresh Emby playlists", + path="plugin://plugin.video.emby/?mode=refreshplaylist", + folder=False) addDirectoryItem("Perform manual sync", "plugin://plugin.video.emby/?mode=manualsync", False) addDirectoryItem( label="Repair local database (force update all content)", @@ -370,6 +374,31 @@ def getThemeMedia(): time=1000, sound=False) +##### REFRESH EMBY PLAYLISTS ##### +def refreshPlaylist(): + + lib = librarysync.LibrarySync() + dialog = xbmcgui.Dialog() + try: + # First remove playlists + utils.deletePlaylists() + # Refresh views + lib.refreshViews() + dialog.notification( + heading="Emby for Kodi", + message="Emby playlist refreshed!", + icon="special://home/addons/plugin.video.emby/icon.png", + time=1000, + sound=False) + except Exception as e: + utils.logMsg("EMBY", "Refresh playlist failed: %s" % e, 1) + dialog.notification( + heading="Emby for Kodi", + message="Emby playlist refresh failed!", + icon="special://home/addons/plugin.video.emby/icon.png", + time=1000, + sound=False) + ##### BROWSE EMBY CHANNELS ##### def BrowseChannels(itemid, folderid=None): diff --git a/resources/lib/utils.py b/resources/lib/utils.py index 0f3c0466..01adfb72 100644 --- a/resources/lib/utils.py +++ b/resources/lib/utils.py @@ -132,11 +132,7 @@ def reset(): xbmc.sleep(1000) # Clean up the playlists - path = xbmc.translatePath("special://profile/playlists/video/").decode('utf-8') - dirs, files = xbmcvfs.listdir(path) - for file in files: - if file.startswith('Emby'): - xbmcvfs.delete("%s%s" % (path, file)) + deletePlaylists() # Clean up the video nodes import shutil @@ -492,4 +488,13 @@ def playlistXSP(mediatype, tagname, viewtype="", delete=False): '' % (itemtypes.get(mediatype, mediatype), plname, tagname)) f.close() - logMsg("EMBY", "Successfully added playlist: %s" % tagname) \ No newline at end of file + logMsg("EMBY", "Successfully added playlist: %s" % tagname) + +def deletePlaylists(): + + # Clean up the playlists + path = xbmc.translatePath("special://profile/playlists/video/").decode('utf-8') + dirs, files = xbmcvfs.listdir(path) + for file in files: + if file.startswith('Emby'): + xbmcvfs.delete("%s%s" % (path, file)) \ No newline at end of file