From 228501d99c493ec65c7394c907fdbe9383840318 Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Tue, 16 Feb 2016 22:13:10 -0600 Subject: [PATCH] Move removal to context menu There was a typo in the delete as well. Remove videolibrary.on.remove due to potential issue if clean database runs and user is using plugin paths. --- contextmenu.py | 25 +++++++++++++++++++++++-- resources/lib/kodimonitor.py | 9 ++++++--- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/contextmenu.py b/contextmenu.py index ab557b9f..febae78d 100644 --- a/contextmenu.py +++ b/contextmenu.py @@ -27,7 +27,7 @@ import musicutils as musicutils import api def logMsg(msg, lvl=1): - utils.logMsg("%s %s" % ("Emby", "Contextmenu"), msg, lvl) + utils.logMsg("%s %s" % ("EMBY", "Contextmenu"), msg, lvl) #Kodi contextmenu item to configure the emby settings @@ -127,11 +127,32 @@ if __name__ == '__main__': if options[ret] == utils.language(30409): #delete item from the server - if xbmcgui.Dialog().yesno("Do you really want to delete this item ?", "This will delete the item from the server and the file(s) from disk!"): + delete = True + if utils.settings('skipContextMenu') != "true": + resp = xbmcgui.Dialog().yesno( + heading="Confirm delete", + line1=("Delete file from Emby Server? This will " + "also delete the file(s) from disk!")) + if not resp: + logMsg("User skipped deletion.", 1) + delete = False + + if delete: import downloadutils doUtils = downloadutils.DownloadUtils() url = "{server}/emby/Items/%s?format=json" % embyid + logMsg("Deleting request: %s" % embyid, 0) doUtils.downloadUrl(url, type="DELETE") + + '''if utils.settings('skipContextMenu') != "true": + if xbmcgui.Dialog().yesno( + heading="Confirm delete", + line1=("Delete file on Emby Server? This will " + "also delete the file(s) from disk!")): + import downloadutils + doUtils = downloadutils.DownloadUtils() + url = "{server}/emby/Items/%s?format=json" % embyid + doUtils.downloadUrl(url, type="DELETE")''' xbmc.sleep(500) xbmc.executebuiltin("Container.Update") \ No newline at end of file diff --git a/resources/lib/kodimonitor.py b/resources/lib/kodimonitor.py index b94befe5..696827cc 100644 --- a/resources/lib/kodimonitor.py +++ b/resources/lib/kodimonitor.py @@ -162,8 +162,11 @@ class KodiMonitor(xbmc.Monitor): elif method == "VideoLibrary.OnRemove": - - try: + # Removed function, because with plugin paths + clean library, it will wipe + # entire library if user has permissions. Instead, use the emby context menu available + # in Isengard and higher version + pass + '''try: kodiid = data['id'] type = data['type'] except (KeyError, TypeError): @@ -192,7 +195,7 @@ class KodiMonitor(xbmc.Monitor): self.logMsg("Deleting request: %s" % itemid) doUtils.downloadUrl(url, type="DELETE") finally: - embycursor.close() + embycursor.close()''' elif method == "System.OnWake":