2017-12-10, 15:44
Hey Guys.
I'm new at python and i'm trying to built my first addon.
Source: http://kodi.wiki/view/audio-video_add-on_tutorial
So far so good...
My code:
This code is working. But how to add a xbmcgui.ListItem / addDirectoryItem that opens a function instead of url ?
Simple function example:
I hope there is someone who can explain it. Thanks.
I'm new at python and i'm trying to built my first addon.
Source: http://kodi.wiki/view/audio-video_add-on_tutorial
So far so good...
My code:
python:import sys
import urllib
import urlparse
import xbmcgui
import xbmcplugin
base_url = sys.argv[0]
addon_handle = int(sys.argv[1])
args = urlparse.parse_qs(sys.argv[2][1:])
xbmcplugin.setContent(addon_handle, 'movies')
def build_url(query):
return base_url + '?' + urllib.urlencode(query)
mode = args.get('mode', None)
if mode is None:
url = build_url({'mode': 'folder', 'foldername': 'Folder One'})
li = xbmcgui.ListItem('Folder One', iconImage='DefaultFolder.png')
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url,
listitem=li, isFolder=True)
xbmcplugin.endOfDirectory(addon_handle)
elif mode[0] == 'folder':
foldername = args['foldername'][0]
url = 'http://localhost/some_video.mkv'
li = xbmcgui.ListItem(foldername + ' Video', iconImage='DefaultVideo.png')
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)
url = 'http://localhost/some_audio.mp3'
li = xbmcgui.ListItem(foldername + ' Song', iconImage='DefaultVideo.png')
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)
xbmcplugin.endOfDirectory(addon_handle)
This code is working. But how to add a xbmcgui.ListItem / addDirectoryItem that opens a function instead of url ?
Simple function example:
python:def test:
xbmcgui.Dialog().ok('Test', 'Text.')
test()
I hope there is someone who can explain it. Thanks.