Of course..
Main handler:
def MainMenu():
Plugin.AddViewGroup('InfoList', viewMode='InfoList', mediaType='items')
oc = ObjectContainer(title1=TEXT_TITLE, view_group = ‘InfoList’)
token = getToken(“test”)
Only process if we got a valid token.
if token != “”:
result = getChannels(token)
if debug == True: Log("Token to use for api calls: " + token)
for channel in result['channels']['elements']:
oc.add(createTVChannelObject(channel))
oc.add(PrefsObject(title=TEXT_PREFERENCES, thumb=R(ICON_SETTINGS)))
if len(oc) < 1:
failoc = ObjectContainer(header=“Fehler!”, message=“API Zugriff nicht möglich.”)
failoc.add(PrefsObject(title=TEXT_PREFERENCES, thumb=R(ICON_SETTINGS)))
return failoc
return oc
Videoobjects are created the following way:
def createTVChannelObject(channel, container = False):
uniqid = channel['vodkatvChannelId']
name = channel['name']
thumb = channel['logo']
url = channel['urls'][1].replace('http-interoud','http')
summary = ""
epg_title = ""
epg_description = ""
epg_start = ""
epg_end = ""
epg_length = 0
if channel[‘currentNext’].has_key(‘current’):
if channel[‘currentNext’][‘current’].has_key(‘title’):
epg_title = channel[‘currentNext’][‘current’][‘title’]
epg_description = channel[‘currentNext’][‘current’][‘description’]
epg_start = datetime.datetime.fromtimestamp(channel[‘currentNext’][‘current’][‘start’]/1000).strftime(’%H:%M’)
epg_end = datetime.datetime.fromtimestamp(channel[‘currentNext’][‘current’][‘finish’]/1000).strftime(’%H:%M’)
epg_length = int(channel[‘currentNext’][‘current’][‘length’])
if container == False:
summary = epg_title
else:
summary = epg_start + " - " + epg_end + "
" + epg_title +"
" + epg_description
vco = VideoClipObject(
key = Callback(createTVChannelObject, channel = channel, container = True),
rating_key = uniqid,
title = name,
summary = summary,
duration = epg_length,
thumb = thumb,
items = [
MediaObject(
video_codec = VideoCodec.H264,
audio_codec = AudioCodec.AAC,
audio_channels = 2,
optimized_for_streaming = True,
parts = [PartObject(key = url)]
)
]
)
if container:
return ObjectContainer(objects = [vco])
else:
return vco
return vco
Hope this helps...