def live_tv_channels(path=None):
if not path:
listing = []
yle_1 = xbmcgui.ListItem(label='[COLOR {0}]{1}[/COLOR]'.format(get_color('menuItemColor'), 'YLE TV1'))
yle_1_url = '{0}?action=live&path={1}'.format(_url, _yle_tv1_live_url)
yle_1.setProperty('IsPlayable', 'true')
listing.append((yle_1_url, yle_1, False))
yle_2 = xbmcgui.ListItem(label='[COLOR {0}]{1}[/COLOR]'.format(get_color('menuItemColor'), 'YLE TV2'))
yle_2_url = '{0}?action=live&path={1}'.format(_url, _yle_tv2_live_url)
yle_2.setProperty('IsPlayable', 'true')
listing.append((yle_2_url, yle_2, False))
for service in _tv_services:
service_name = service.replace('-', ' ').title()
data = get_areena_api_json_data('programs/schedules', 'now.json', ['service=' + service])
for item in data:
content = item['content']
for language_code in get_language_codes():
if language_code in content['title']:
content['title'][language_code] = \
service_name + ': ' + content['title'][language_code]
list_item = create_list_item_from_stream(content)
if list_item:
url = '{0}?action=play&stream={1}'.format(_url, content['id'])
listing.append((url, list_item, False))
else:
title = ''
for language_code in get_language_codes():
if language_code in content['title']:
title = ' - ' + content['title'][language_code]
break
not_available_item = xbmcgui.ListItem(label='[COLOR {0}]{1}[/COLOR]'.format(
get_color('menuItemColor'), get_translation(32072) + title))
not_available_item.setProperty('IsPlayable', 'false')
listing.append((None, not_available_item, False))
xbmcplugin.addDirectoryItems(_handle, listing, len(listing))
xbmcplugin.endOfDirectory(_handle)
else:
xbmcplugin.setResolvedUrl(
_handle, True, listitem=xbmcgui.ListItem(path=get_resolution_specific_url_for_live_tv(path)))
评论列表
文章目录