2017-07-11, 01:22
I'm trying to make a context menu option that plays an entire folder as a playlist, but since the listitem has isFolder = True I keep receiving Invalid handle when selecting the menu item. My code where I create the listitem and context menu items for each listitem is below
The listitems/links inside the folder are collected dynamically (aren't always the same since they're scraped) if that makes any difference. I found this thread that covers the issue, but the solution of using ReplaceWindow instead of RunPlugin doesn't work for me.
Any idea what I'm doing wrong? Is it possible to accomplish what I'm wanting to do with the context menu item?
Code:
for subsection in MAIN_MENU[section]:
li = xbmcgui.ListItem(label=subsection)
if section == 'By Animal':
multi_context_url = get_url(action='play', section=section, animal=subsection)
print multi_context_url
single_context_url = get_url(action='play', section=section, animal=subsection, pick_one='true')
li.addContextMenuItems([('Play Random Video', 'RunPlugin('+single_context_url+')'),
('Play Random Continuously', 'RunPlugin('+multi_context_url+')')])
url = get_url(action='listing', animal=subsection)
elif section == 'By Site':
multi_context_url = get_url(action='play', section=section, source=subsection)
single_context_url = get_url(action='play', section=section, source=subsection, pick_one='true')
li.addContextMenuItems([('Play Random Video', 'RunPlugin('+single_context_url+')'),
('Play Random Continuously', 'RunPlugin('+multi_context_url+')')])
url = get_url(action='listing', source=subsection)
elif section == 'By Category':
multi_context_url = get_url(action='play', section=section, category=subsection)
single_context_url = get_url(action='play', section=section, category=subsection, pick_one='true')
li.addContextMenuItems([('Play Random Video', 'RunPlugin('+single_context_url+')'),
('Play Random Continuously', 'RunPlugin('+multi_context_url+')')])
url = get_url(action='listing', category=subsection)
else: #section == 'By Channel'
url = get_url(action='listing', channel=subsection)
xbmcplugin.addDirectoryItem(data._handle, url, li, True)
xbmcplugin.addSortMethod(data._handle, xbmcplugin.SORT_METHOD_NONE)
xbmcplugin.endOfDirectory(data._handle)
The listitems/links inside the folder are collected dynamically (aren't always the same since they're scraped) if that makes any difference. I found this thread that covers the issue, but the solution of using ReplaceWindow instead of RunPlugin doesn't work for me.
Any idea what I'm doing wrong? Is it possible to accomplish what I'm wanting to do with the context menu item?