(2016-04-23, 17:28)braz Wrote: Thanks spoyser, will try that out when I get a chance. Here's what I'm using right now, I'm sure it can be improved though.
https://github.com/braz96/script.mimic.e...r/addon.py
That's a lot of code!
Okay, here goes.
First add the menu handling method:
Code:
def handleMenu(menu):
list = []
for item in menu:
list.append(item[0])
param = xbmcgui.Dialog().contextmenu(list)
if param < 0:
return None
return menu[param][1]
Now build the menu (we need to get rid of some of the or statements too and handle them all separately, makes like easier at the end), so
Code:
#build menu
isMovie = xbmc.getCondVisibility("String.IsEqual(ListItem.DBTYPE,movie)")
isTVShow = xbmc.getCondVisibility("String.IsEqual(ListItem.DBTYPE,tvshow)")
isEpisode = xbmc.getCondVisibility("String.IsEqual(ListItem.DBTYPE,episode)")
isMusic = xbmc.getCondVisibility("String.IsEqual(ListItem.DBTYPE,musicvideo)")
options = []
options.append([LANGUAGE(32000), "SetFocus(90400)"])
if xbmc.getCondVisibility("System.HasAddon(script.extendedinfo)"):
if isMovie:
options.append([LANGUAGE(32001), "RunScript(script.extendedinfo,info=extendedinfo,dbid=%s,id=%s)" % (xbmc.getInfoLabel("ListItem.DBID"), xbmc.getInfoLabel("ListItem.Property(id)"))])
elif isTVShow:
options.append([LANGUAGE(32001), "RunScript(script.extendedinfo,info=extendedtvinfo,dbid=%s,id=%s)" % (xbmc.getInfoLabel("ListItem.DBID"), xbmc.getInfoLabel("ListItem.Property(id)"))])
if xbmc.getCondVisibility("System.HasAddon(script.simpleplaylists)"):
if isMovie or isTVShow:
options.append([LANGUAGE(32002), "RunPlugin(plugin://script.simpleplaylists/?mode=addCurrentUrl)"])
if xbmc.getCondVisibility("System.HasAddon(script.artwork.downloader)"):
if isMovie:
options.append([LANGUAGE(32003), "RunScript(script.artwork.downloader,mediatype=movie,dbid=%s)" % xbmc.getInfoLabel("ListItem.DBID")])
options.append([LANGUAGE(32004), "RunScript(script.artwork.downloader,mode=gui,mediatype=movie,dbid=%s)" % xbmc.getInfoLabel("ListItem.DBID")])
elif isTVShow:
options.append([LANGUAGE(32003), "RunScript(script.artwork.downloader,mediatype=tvshow,dbid=%s)" % xbmc.getInfoLabel("ListItem.DBID")])
options.append([LANGUAGE(32004), "RunScript(script.artwork.downloader,mode=gui,mediatype=tvshow,dbid=%s)" % xbmc.getInfoLabel("ListItem.DBID")])
if xbmc.getCondVisibility("System.HasAddon(script.ratingupdate)"):
if isMovie or isTVShow:
options.append([LANGUAGE(32005), "RunScript(script.ratingupdate,Single=Movie)"])
if xbmc.getCondVisibility('String.IsEmpty(Window(movieinformation).Property("TvTunes_HideVideoInfoButton"))'):
if isMovie or isTVShow or isMusic:
options.append([LANGUAGE(32006), "RunScript(script.tvtunes,mode=solo)"])
if xbmc.getCondVisibility("System.HasAddon(script.cinemavision)"):
if isMovie or isTVShow or isEpisode:
options.append([LANGUAGE(32007), "SPECIALCASE1"]) #because it does 2 things
if xbmc.getCondVisibility("System.HasAddon(script.videoextras)"):
if isMovie or isEpisode or isMusic:
options.append([LANGUAGE(32008), "RunScript(script.videoextras,display,%s)" % (xbmc.getInfoLabel("ListItem.FilenameAndPath"))])
elif isTVShow:
options.append([LANGUAGE(32008), "RunScript(script.videoextras,display,%s)" % (xbmc.getInfoLabel("ListItem.Path"))])
Finally, show the menu and deal with the result:
Code:
action = handleMenu(options)
if not action:
return
if action == 'SPECIALCASE1':
xbmc.executebuiltin("Dialog.Close(movieinformation)")
xbmc.executebuiltin("RunScript(script.cinemavision,experience)")
else:
xbmc.executebuiltin('%s' % action)
Obviously, would have been more elegant without the special case (this could be handled using a list of actions to perform when building the menu array, but I thought that was a bit OTT for a single case).
HTH