Add delete keymap entrypoint

RunPlugin(plugin://plugin.video.emby?mode=delete)
This commit is contained in:
angelblue05 2016-03-09 17:05:35 -06:00
parent 8bde429da4
commit a5d74c8a17
2 changed files with 52 additions and 1 deletions

View File

@ -62,7 +62,8 @@ class Main:
'inprogressepisodes': entrypoint.getInProgressEpisodes, 'inprogressepisodes': entrypoint.getInProgressEpisodes,
'recentepisodes': entrypoint.getRecentEpisodes, 'recentepisodes': entrypoint.getRecentEpisodes,
'refreshplaylist': entrypoint.refreshPlaylist, 'refreshplaylist': entrypoint.refreshPlaylist,
'deviceid': entrypoint.resetDeviceId 'deviceid': entrypoint.resetDeviceId,
'delete': entrypoint.deleteItem
} }
if "/extrafanart" in sys.argv[0]: if "/extrafanart" in sys.argv[0]:

View File

@ -118,6 +118,56 @@ def resetDeviceId():
line1=language(33033)) line1=language(33033))
xbmc.executebuiltin('RestartApp') 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 ##### ##### ADD ADDITIONAL USERS #####
def addUser(): def addUser():