Support delete keymap

This commit is contained in:
angelblue05 2018-09-13 02:07:08 -05:00
parent 3ac5c4ebb0
commit eb83cfb6a4
2 changed files with 39 additions and 11 deletions

View file

@ -35,12 +35,22 @@ class Context(object):
_selected_option = None _selected_option = None
def __init__(self, transcode=False): def __init__(self, transcode=False, delete=False):
self.kodi_id = sys.listitem.getVideoInfoTag().getDbId() or None try:
self.media = self.get_media_type() self.kodi_id = sys.listitem.getVideoInfoTag().getDbId() or None
self.server = sys.listitem.getProperty('embyserver') or None self.media = self.get_media_type()
item_id = sys.listitem.getProperty('embyid') self.server = sys.listitem.getProperty('embyserver') or None
item_id = sys.listitem.getProperty('embyid')
except AttributeError:
self.server = None
if xbmc.getInfoLabel('ListItem.Property(embyid)'):
item_id = xbmc.getInfoLabel('ListItem.Property(embyid)')
else:
self.kodi_id = xbmc.getInfoLabel('ListItem.DBID')
self.media = xbmc.getInfoLabel('ListItem.DBTYPE')
item_id = None
if self.server or item_id: if self.server or item_id:
self.item = TheVoid('GetItem', {'ServerId': self.server, 'Id': item_id}).get() self.item = TheVoid('GetItem', {'ServerId': self.server, 'Id': item_id}).get()
@ -52,6 +62,9 @@ class Context(object):
if transcode: if transcode:
self.transcode() self.transcode()
elif delete:
self.delete_item()
elif self.select_menu(): elif self.select_menu():
self.action_menu() self.action_menu()
@ -143,15 +156,20 @@ class Context(object):
xbmc.executebuiltin('Addon.OpenSettings(plugin.video.emby)') xbmc.executebuiltin('Addon.OpenSettings(plugin.video.emby)')
elif selected == OPTIONS['Delete']: elif selected == OPTIONS['Delete']:
delete = True self.delete_item()
if not settings('skipContextMenu.bool'): def delete_item(self):
if not dialog("yesno", heading="{emby}", line1=_(33015)): delete = True
delete = False
if delete: if not settings('skipContextMenu.bool'):
TheVoid('DeleteItem', {'ServerId': self.server, 'Id': self.item['Id']})
if not dialog("yesno", heading="{emby}", line1=_(33015)):
delete = False
if delete:
LOG.info("fake deleted %s", self.item['Id'])
#TheVoid('DeleteItem', {'ServerId': self.server, 'Id': self.item['Id']})
def transcode(self): def transcode(self):

View file

@ -77,6 +77,8 @@ class Events(object):
client.reset_device_id() client.reset_device_id()
elif mode == 'reset': elif mode == 'reset':
reset() reset()
elif mode == 'delete':
delete_item()
elif mode == 'refreshboxsets': elif mode == 'refreshboxsets':
event('SyncLibrary', {'Id': "Boxsets:Refresh"}) event('SyncLibrary', {'Id': "Boxsets:Refresh"})
elif mode == 'nextepisodes': elif mode == 'nextepisodes':
@ -676,3 +678,11 @@ def get_themes():
tvtunes_nfo(nfo_file, paths) tvtunes_nfo(nfo_file, paths)
dialog("notification", heading="{emby}", message=_(33153), icon="{emby}", time=1000, sound=False) dialog("notification", heading="{emby}", message=_(33153), icon="{emby}", time=1000, sound=False)
def delete_item():
''' Delete keymap action.
'''
import context
context.Context(delete=True)