From a5d74c8a17a374b571376fe56c1ebf2bd1717a55 Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Wed, 9 Mar 2016 17:05:35 -0600 Subject: [PATCH] Add delete keymap entrypoint RunPlugin(plugin://plugin.video.emby?mode=delete) --- default.py | 3 ++- resources/lib/entrypoint.py | 50 +++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/default.py b/default.py index 724e7303..94117d69 100644 --- a/default.py +++ b/default.py @@ -62,7 +62,8 @@ class Main: 'inprogressepisodes': entrypoint.getInProgressEpisodes, 'recentepisodes': entrypoint.getRecentEpisodes, 'refreshplaylist': entrypoint.refreshPlaylist, - 'deviceid': entrypoint.resetDeviceId + 'deviceid': entrypoint.resetDeviceId, + 'delete': entrypoint.deleteItem } if "/extrafanart" in sys.argv[0]: diff --git a/resources/lib/entrypoint.py b/resources/lib/entrypoint.py index af69a251..12ed547a 100644 --- a/resources/lib/entrypoint.py +++ b/resources/lib/entrypoint.py @@ -118,6 +118,56 @@ def resetDeviceId(): line1=language(33033)) xbmc.executebuiltin('RestartApp') +##### Delete Item, like the context menu action +def deleteItem(): + + # Serves as a keymap action + dbid = xbmc.getInfoLabel('ListItem.DBID') + itemtype = xbmc.getInfoLabel('ListItem.DBTYPE') + + if not itemtype: + + if xbmc.getCondVisibility('Container.Content(albums)'): + itemtype = "album" + elif xbmc.getCondVisibility('Container.Content(artists)'): + itemtype = "artist" + elif xbmc.getCondVisibility('Container.Content(songs)'): + itemtype = "song" + elif xbmc.getCondVisibility('Container.Content(pictures)'): + itemtype = "picture" + else: + utils.logMsg("EMBY delete", "Unknown type, unable to proceed.", 1) + return + + if xbmc.getInfoLabel('ListItem.Property(embyid)'): # If we already have the embyid + embyid = xbmc.getInfoLabel('ListItem.Property(embyid)') + else: + embyconn = utils.kodiSQL('emby') + embycursor = embyconn.cursor() + emby_db = embydb.Embydb_Functions(embycursor) + item = emby_db.getItem_byKodiId(dbid, itemtype) + embycursor.close() + + try: + embyid = item[0] + except TypeError: + utils.logMsg("EMBY delete", "Unknown embyId, unable to proceed.", 1) + return + + 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: + utils.logMsg("EMBY delete", "User skipped deletion for: %s." % embyid, 1) + return + + doUtils = downloadutils.DownloadUtils() + url = "{server}/emby/Items/%s?format=json" % embyid + utils.logMsg("EMBY delete", "Deleting request: %s" % embyid, 0) + doUtils.downloadUrl(url, type="DELETE") + ##### ADD ADDITIONAL USERS ##### def addUser():