def show_sources(site_id, key): site = all_sites[site_id] sources = [] for url, title in site.get_sources(key): for source in get_sources_for(url): sources.append({ 'label': title, 'path': plugin.url_for('play_source', url=url) }) # if there's only one sources, try to play immediately if len(sources) == 1: return plugin.redirect(sources[0]['path']) return sources
def play_source(url): try: source = get_sources_for(url)[0] video_url = source.get_video_url(url) except XVisiExternalError as e: return [ { 'label': 'Sorry.', }, { 'label': str(e), } ] # FIXME: maybe its possible to do this a little smarter and play directly? return [{ 'label': 'Play video', 'path': video_url, 'is_playable': True, }, { 'label': 'Download and play', 'path': plugin.url_for('download_and_play', url=video_url), }]