Show menu item only for appropriate Kodi library

This commit is contained in:
tomkat83 2017-03-19 14:32:01 +01:00
parent 9391d10d44
commit d6bb806440
2 changed files with 24 additions and 22 deletions

View file

@ -165,7 +165,7 @@ class Main():
entrypoint.getVideoFiles(plexId, params) entrypoint.getVideoFiles(plexId, params)
else: else:
entrypoint.doMainListing() entrypoint.doMainListing(content_type=params.get('content_type'))
def play(self): def play(self):
""" """

View file

@ -116,7 +116,8 @@ def addDirectoryItem(label, path, folder=True):
xbmcplugin.addDirectoryItem(handle=HANDLE, url=path, listitem=li, isFolder=folder) xbmcplugin.addDirectoryItem(handle=HANDLE, url=path, listitem=li, isFolder=folder)
def doMainListing(): def doMainListing(content_type=None):
log.debug('Do main listing with content_type: %s' % content_type)
xbmcplugin.setContent(HANDLE, 'files') xbmcplugin.setContent(HANDLE, 'files')
# Get emby nodes from the window props # Get emby nodes from the window props
plexprops = window('Plex.nodes.total') plexprops = window('Plex.nodes.total')
@ -126,37 +127,38 @@ def doMainListing():
path = window('Plex.nodes.%s.index' % i) path = window('Plex.nodes.%s.index' % i)
if not path: if not path:
path = window('Plex.nodes.%s.content' % i) path = window('Plex.nodes.%s.content' % i)
if not path:
continue
label = window('Plex.nodes.%s.title' % i) label = window('Plex.nodes.%s.title' % i)
node_type = window('Plex.nodes.%s.type' % i) node_type = window('Plex.nodes.%s.type' % i)
#because we do not use seperate entrypoints for each content type, we need to figure out which items to show in each listing. # because we do not use seperate entrypoints for each content type,
#for now we just only show picture nodes in the picture library video nodes in the video library and all nodes in any other window # we need to figure out which items to show in each listing. for
if path and getCondVisibility("Window.IsActive(Pictures)") and node_type == "photos": # now we just only show picture nodes in the picture library video
# nodes in the video library and all nodes in any other window
if node_type == 'photos' and content_type == 'image':
addDirectoryItem(label, path) addDirectoryItem(label, path)
elif path and getCondVisibility("Window.IsActive(VideoLibrary)") and node_type != "photos": elif (node_type != 'photos' and
addDirectoryItem(label, path) content_type not in ('image', 'audio')):
elif path and not getCondVisibility("Window.IsActive(VideoLibrary) | Window.IsActive(Pictures) | Window.IsActive(MusicLibrary)"):
addDirectoryItem(label, path) addDirectoryItem(label, path)
# Plex Watch later # Plex Watch later
if content_type not in ('image', 'audio'):
addDirectoryItem(lang(39211), addDirectoryItem(lang(39211),
"plugin://plugin.video.plexkodiconnect/?mode=watchlater") "plugin://%s?mode=watchlater" % v.ADDON_ID)
# Plex Channels # Plex Channels
addDirectoryItem(lang(30173), addDirectoryItem(lang(30173),
"plugin://plugin.video.plexkodiconnect/?mode=channels") "plugin://%s?mode=channels" % v.ADDON_ID)
# Plex user switch # Plex user switch
addDirectoryItem(lang(39200) + window('plex_username'), addDirectoryItem(lang(39200) + window('plex_username'),
"plugin://plugin.video.plexkodiconnect/" "plugin://%s?mode=switchuser" % v.ADDON_ID)
"?mode=switchuser")
#experimental live tv nodes # some extra entries for settings and stuff
# addDirectoryItem("Live Tv Channels (experimental)", "plugin://plugin.video.plexkodiconnect/?mode=browsecontent&type=tvchannels&folderid=root") addDirectoryItem(lang(39201),
# addDirectoryItem("Live Tv Recordings (experimental)", "plugin://plugin.video.plexkodiconnect/?mode=browsecontent&type=recordings&folderid=root") "plugin://%s?mode=settings" % v.ADDON_ID)
addDirectoryItem(lang(39203),
# some extra entries for settings and stuff. TODO --> localize the labels "plugin://%s?mode=refreshplaylist" % v.ADDON_ID)
addDirectoryItem(lang(39201), "plugin://plugin.video.plexkodiconnect/?mode=settings") addDirectoryItem(lang(39204),
# addDirectoryItem("Add user to session", "plugin://plugin.video.plexkodiconnect/?mode=adduser") "plugin://%s?mode=manualsync" % v.ADDON_ID)
addDirectoryItem(lang(39203), "plugin://plugin.video.plexkodiconnect/?mode=refreshplaylist")
addDirectoryItem(lang(39204), "plugin://plugin.video.plexkodiconnect/?mode=manualsync")
xbmcplugin.endOfDirectory(HANDLE) xbmcplugin.endOfDirectory(HANDLE)