def play(params): try: import drmhelper if not drmhelper.check_inputstream(drm=False): return except ImportError: utils.log("Failed to import drmhelper") utils.dialog_message('DRM Helper is needed for inputstream.adaptive ' 'playback. For more information, please visit: ' 'http://aussieaddons.com/drm') return try: stream = comm.get_stream(params['video_id']) utils.log('Attempting to play: {0} {1}'.format(stream['name'], stream['url'])) item = xbmcgui.ListItem(label=stream['name'], path=stream['url']) item.setProperty('inputstreamaddon', 'inputstream.adaptive') item.setProperty('inputstream.adaptive.manifest_type', 'hls') item.setMimeType('application/vnd.apple.mpegurl') item.setContentLookup(False) xbmcplugin.setResolvedUrl(pluginhandle, True, listitem=item) except Exception: utils.handle_error('Unable to play video')
def router(paramstring): """ Router function that calls other functions depending on the provided paramstring :param paramstring: """ params = dict(parse_qsl(paramstring)) utils.log('Running with params: {0}'.format(params)) if params: if params['action'] == 'listcategories': if params['category'] == 'Live Matches': menu.list_matches(params, live=True) elif params['category'] == 'Settings': addon.openSettings() else: menu.list_videos(params) elif params['action'] in ['listvideos', 'listmatches']: play.play_video(params) elif params['action'] == 'clearticket': stream_auth.clear_ticket() elif params['action'] == 'open_ia_settings': try: import drmhelper if drmhelper.check_inputstream(drm=False): ia = drmhelper.get_addon() ia.openSettings() else: utils.dialog_message( "Can't open inputstream.adaptive settings") except Exception: utils.dialog_message( "Can't open inputstream.adaptive settings") else: menu.list_categories()
def router(paramstring): """ Router function that calls other functions depending on the provided paramstring :param paramstring: """ params = dict(parse_qsl(paramstring)) if params: if params['action'] == 'listcategories': if params['category'] == 'settings': addon.openSettings() else: matches.make_matches_list(params) elif params['action'] == 'listmatches': play.play_video(params) elif params['action'] == 'clearticket': stream_auth.clear_ticket() elif params['action'] == 'sendreport': utils.user_report() elif params['action'] == 'open_ia_settings': try: import drmhelper if drmhelper.check_inputstream(drm=False): ia = drmhelper.get_addon() ia.openSettings() else: utils.dialog_message( "Can't open inputstream.adaptive settings") except Exception: utils.dialog_message( "Can't open inputstream.adaptive settings") else: categories.list_categories()
def play_video(params): """ Play a video by the provided path. :param path: str """ if 'dummy' in params: if params['dummy'] == 'True': return try: import drmhelper if drmhelper.check_inputstream(): dash_stream = ooyalahelper.get_dash_playlist(params['video_id']) url = dash_stream['dash_url'] play_item = xbmcgui.ListItem(path=url) play_item.setProperty('inputstream.adaptive.manifest_type', 'mpd') play_item.setProperty('inputstream.adaptive.license_type', 'com.widevine.alpha') play_item.setProperty( 'inputstream.adaptive.license_key', dash_stream['wv_lic'] + ('|Content-Type=application%2F' 'x-www-form-urlencoded|A{SSM}|')) xbmcplugin.setResolvedUrl(_handle, True, listitem=play_item) else: xbmcplugin.setResolvedUrl(_handle, True, xbmcgui.ListItem(path=None)) return except Exception: utils.handle_error('Unable to play video')
def play_video(params): """ Determine content and pass url to Kodi for playback """ if params['action'] == 'listchannels': json_url = config.BRIGHTCOVE_DRM_URL.format(config.BRIGHTCOVE_ACCOUNT, params['id']) url = comm.get_stream(json_url, live=True) play_item = xbmcgui.ListItem(path=url) elif params['drm'] == 'True': if xbmcaddon.Addon().getSetting('ignore_drm') == 'false': if not drmhelper.check_inputstream(): return acc = config.BRIGHTCOVE_ACCOUNT drm_url = config.BRIGHTCOVE_DRM_URL.format(acc, params['id']) widevine = comm.get_widevine_auth(drm_url) url = widevine['url'] play_item = xbmcgui.ListItem(path=url) play_item.setProperty('inputstream.adaptive.manifest_type', 'mpd') play_item.setProperty('inputstream.adaptive.license_type', 'com.widevine.alpha') play_item.setProperty( 'inputstream.adaptive.license_key', widevine['key'] + ('|Content-Type=application%2F' 'x-www-form-urlencoded|A{SSM}|')) else: json_url = config.BRIGHTCOVE_DRM_URL.format(config.BRIGHTCOVE_ACCOUNT, params['id']) m3u8 = comm.get_stream(json_url) data = urllib2.urlopen(m3u8).read().splitlines() url = parse_m3u8(data, m3u8_path=m3u8) play_item = xbmcgui.ListItem(path=url) xbmcplugin.setResolvedUrl(_handle, True, play_item)
def play(url): try: params = utils.get_url(url) v = classes.Video() v.parse_xbmc_url(url) if params.get('isdummy'): xbmcgui.Dialog().ok( 'Dummy item', 'This item is not playable, it is used only to display ' 'the upcoming schedule. Please check back once the match ' 'has started. Playable matches will have "LIVE NOW" in ' 'green next to the title.') if 'ooyalaid' in params: login_token = None if params.get('subscription_required') == 'True': login_token = ooyalahelper.get_user_token() stream_data = ooyalahelper.get_m3u8_playlist(params['ooyalaid'], v.live, login_token) else: stream_data = {'stream_url': v.get_url()} listitem = xbmcgui.ListItem(label=v.get_title(), iconImage=v.get_thumbnail(), thumbnailImage=v.get_thumbnail(), path=stream_data.get('stream_url')) inputstream = drmhelper.check_inputstream(drm=v.live) if not inputstream: utils.dialog_message( 'Failed to play stream. Please visit our website at ' 'http://aussieaddons.com/addons/afl/ for more ' 'information.') return widevine_url = stream_data.get('widevine_url') if inputstream and (not v.live or not widevine_url): listitem.setProperty('inputstreamaddon', 'inputstream.adaptive') listitem.setProperty('inputstream.adaptive.manifest_type', 'hls') listitem.setProperty('inputstream.adaptive.license_key', stream_data.get('stream_url')) elif v.live: listitem.setProperty('inputstreamaddon', 'inputstream.adaptive') listitem.setProperty('inputstream.adaptive.manifest_type', 'mpd') listitem.setProperty('inputstream.adaptive.license_type', 'com.widevine.alpha') listitem.setProperty('inputstream.adaptive.license_key', widevine_url + '|Content-Type=application%2F' 'x-www-form-urlencoded|A{SSM}|') listitem.addStreamInfo('video', v.get_kodi_stream_info()) listitem.setInfo('video', v.get_kodi_list_item()) xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem=listitem) except Exception: utils.handle_error('Unable to play video')
def main(): params_str = sys.argv[2] params = utils.get_url(params_str) addon = xbmcaddon.Addon() if (len(params) == 0): categories.make_category_list() elif 'action' in params: action = params.get('action') if action in ['program_list', 'livestreams']: play.play(params_str) elif action in ['series_list']: if params.get('type') == 'Series': if params.get('dummy') == 'True': return else: programs.make_programs_list(params) else: play.play(params_str) elif action == 'collect_list': series.make_series_list(params, atoz=False) elif action == 'category_list': category = params.get('category') if category == 'settings': addon.openSettings() elif category == 'livestreams': live.make_livestreams_list() elif category == 'search': search.make_search_history_list() else: if addon.getSetting('SHOW_COLLECTIONS') == '1': collect.make_collect_list(params) else: series.make_series_list(params) elif action == 'searchhistory': if params.get('name') == 'New Search': search.get_search_input() else: search.make_search_list(params) elif action == 'removesearch': search.remove_from_search_history(params.get('name')) elif action == 'sendreport': utils.user_report() elif action == 'open_ia_settings': try: import drmhelper if drmhelper.check_inputstream(drm=False): ia = drmhelper.get_addon() ia.openSettings() else: utils.dialog_message( "Can't open inputstream.adaptive settings") except Exception: utils.dialog_message( "Can't open inputstream.adaptive settings")
def main(): params_str = sys.argv[2] params = utils.get_url(params_str) utils.log('Loading with params: {0}'.format(params)) if len(params) == 0: index.make_list() elif 'category' in params: if params['category'] == 'Settings': xbmcaddon.Addon().openSettings() elif params['category'] == 'Team Video': teams.make_list() elif params['category'] == 'All Match Replays': index.make_seasons_list() else: videos.make_list(params) elif 'season' in params: rounds.make_rounds(params) elif 'team' in params: videos.make_list(params) elif 'round_id' in params: videos.make_list(params) elif 'title' in params: play.play(params_str) elif 'action' in params: if params['action'] == 'cleartoken': stream_auth.clear_token() elif params['action'] == 'sendreport': utils.user_report() elif params['action'] == 'iap_help': stream_auth.iap_help() elif params['action'] == 'open_ia_settings': try: import drmhelper if drmhelper.check_inputstream(drm=False): ia = drmhelper.get_addon() ia.openSettings() else: utils.dialog_message( "Can't open inputstream.adaptive settings") except Exception: utils.dialog_message( "Can't open inputstream.adaptive settings")
def play(url): try: # Remove cookies.dat for Kodi < 17.0 - causes issues with playback addon = xbmcaddon.Addon() cookies_dat = xbmc.translatePath('special://home/cache/cookies.dat') if os.path.isfile(cookies_dat): os.remove(cookies_dat) p = classes.Program() p.parse_kodi_url(url) stream_data = comm.get_stream_url(p.get_house_number(), p.get_url()) stream_url = stream_data.get('stream_url') if not stream_url: utils.log('Not Playable: {0}'.format(repr(stream_data))) raise AussieAddonsException( 'Not available: {0}\n{1}'.format(stream_data.get('msg'), stream_data.get( 'availability'))) use_ia = addon.getSetting('USE_IA') == 'true' if use_ia: if addon.getSetting('IGNORE_DRM') == 'false': try: import drmhelper if not drmhelper.check_inputstream(drm=False): return except ImportError: utils.log("Failed to import drmhelper") utils.dialog_message( 'DRM Helper is needed for inputstream.adaptive ' 'playback. Disable "Use inputstream.adaptive for ' 'playback" in settings or install drmhelper. For ' 'more information, please visit: ' 'http://aussieaddons.com/drm') return hdrs = stream_url[stream_url.find('|') + 1:] listitem = xbmcgui.ListItem(label=p.get_list_title(), path=stream_url) thumb = p.get_thumb() listitem.setArt({'icon': thumb, 'thumb': thumb}) if use_ia: listitem.setProperty('inputstreamaddon', 'inputstream.adaptive') listitem.setProperty('inputstream.adaptive.manifest_type', 'hls') listitem.setProperty('inputstream.adaptive.stream_headers', hdrs) listitem.setProperty('inputstream.adaptive.license_key', stream_url) listitem.setInfo('video', p.get_kodi_list_item()) # Add subtitles if available if p.is_captions(): captions_url = stream_data.get('captions_url') profile = xbmcaddon.Addon().getAddonInfo('profile') path = xbmc.translatePath(profile) if not os.path.isdir(path): os.makedirs(path) caption_file = os.path.join(path, 'subtitles.eng.srt') if os.path.isfile(caption_file): os.remove(caption_file) try: sess = session.Session() webvtt_data = sess.get(captions_url).text if webvtt_data: with io.BytesIO() as buf: webvtt_captions = WebVTTReader().read(webvtt_data) srt_captions = SRTWriter().write(webvtt_captions) srt_unicode = srt_captions.encode('utf-8') buf.write(srt_unicode) with io.open(caption_file, "wb") as f: f.write(buf.getvalue()) if hasattr(listitem, 'setSubtitles'): listitem.setSubtitles([caption_file]) except Exception as e: utils.log( 'Subtitles not available for this program: {0}'.format(e)) if hasattr(listitem, 'addStreamInfo'): listitem.addStreamInfo('audio', p.get_kodi_audio_stream_info()) listitem.addStreamInfo('video', p.get_kodi_video_stream_info()) xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem=listitem) except Exception: utils.handle_error('Unable to play video')
def play_video(params): """ Determine content and pass url to Kodi for playback """ try: json_url = config.BRIGHTCOVE_DRM_URL.format(config.BRIGHTCOVE_ACCOUNT, params['id']) if params['drm'] == 'True': if xbmcaddon.Addon().getSetting('ignore_drm') == 'false': if not drmhelper.check_inputstream(): return widevine = comm.get_widevine_auth(json_url) url = widevine['url'] sub_url = widevine['sub_url'] play_item = xbmcgui.ListItem(path=url) play_item.setProperty('inputstream.adaptive.manifest_type', 'mpd') play_item.setProperty('inputstream.adaptive.license_type', 'com.widevine.alpha') play_item.setProperty( 'inputstream.adaptive.license_key', widevine['key'] + ('|Content-Type=application%2F' 'x-www-form-urlencoded|A{SSM}|')) else: if params['action'] == 'listchannels': qual = int(xbmcaddon.Addon().getSetting('LIVEQUALITY')) live = True else: qual = int(xbmcaddon.Addon().getSetting('HLSQUALITY')) live = False stream_data = comm.get_stream(json_url, live=live) m3u8 = stream_data.get('url') sub_url = stream_data.get('sub_url') url = parse_m3u8(m3u8, qual=qual, live=live) play_item = xbmcgui.ListItem(path=url) utils.log('Playing {0} - {1}'.format(params.get('title'), url)) if sub_url: try: utils.log("Enabling subtitles: {0}".format(sub_url)) profile = xbmcaddon.Addon().getAddonInfo('profile') subfilename = xbmc.translatePath( os.path.join(profile, 'subtitle.srt')) profiledir = xbmc.translatePath(os.path.join(profile)) if not os.path.isdir(profiledir): os.makedirs(profiledir) with custom_session.Session() as s: webvtt_data = s.get(sub_url).text if webvtt_data: with open(subfilename, 'w') as f: webvtt_subtitle = WebVTTReader().read(webvtt_data) srt_subtitle = SRTWriter().write(webvtt_subtitle) srt_unicode = srt_subtitle.encode('utf-8') f.write(srt_unicode) if hasattr(play_item, 'setSubtitles'): # This function only supported from Kodi v14+ play_item.setSubtitles([subfilename]) except Exception as e: utils.log('Unable to add subtitles: {0}'.format(e)) xbmcplugin.setResolvedUrl(_handle, True, play_item) except Exception: utils.handle_error('Unable to play video')
def play_video(params): """ Determine content and pass url to Kodi for playback """ try: _url = sys.argv[0] _handle = int(sys.argv[1]) json_url = config.BRIGHTCOVE_DRM_URL.format(config.BRIGHTCOVE_ACCOUNT, params['id']) play_item = xbmcgui.ListItem() play_item.setProperty('inputstreamaddon', 'inputstream.adaptive') play_item.setProperty('inputstream', 'inputstream.adaptive') if params.get('drm') == 'True': if xbmcaddon.Addon().getSetting('ignore_drm') == 'false': if not drmhelper.check_inputstream(): return widevine = comm.get_widevine_auth(json_url) url = widevine['url'] sub_url = widevine['sub_url'] play_item.setPath(url) play_item.setProperty('inputstream.adaptive.manifest_type', 'mpd') play_item.setProperty('inputstream.adaptive.license_type', 'com.widevine.alpha') play_item.setProperty( 'inputstream.adaptive.license_key', widevine['key'] + ('|Content-Type=application%2F' 'x-www-form-urlencoded|A{SSM}|')) else: live = params['action'] == 'listchannels' stream_data = comm.get_stream(json_url, live=live) url = str(stream_data.get('url')) sub_url = stream_data.get('sub_url') play_item.setPath(url) play_item.setProperty('inputstream.adaptive.manifest_type', 'hls') utils.log('Playing {0} - {1}'.format(params.get('title'), url)) if sub_url: try: utils.log("Enabling subtitles: {0}".format(sub_url)) profile = xbmcaddon.Addon().getAddonInfo('profile') subfilename = xbmc.translatePath( os.path.join(profile, 'subtitle.srt')) profiledir = xbmc.translatePath(os.path.join(profile)) if not os.path.isdir(profiledir): os.makedirs(profiledir) with custom_session.Session() as s: webvtt_data = s.get(sub_url).text if webvtt_data: with open(subfilename, 'w') as f: webvtt_subtitle = WebVTTReader().read(webvtt_data) srt_subtitle = SRTWriter().write(webvtt_subtitle) srt_unicode = srt_subtitle.encode('utf-8') f.write(srt_unicode) if hasattr(play_item, 'setSubtitles'): # This function only supported from Kodi v14+ play_item.setSubtitles([subfilename]) except Exception as e: utils.log('Unable to add subtitles: {0}'.format(e)) play_item.setProperty('isPlayable', 'true') if hasattr(play_item, 'setIsFolder'): play_item.setIsFolder(False) # TODO: add more info play_item.setInfo( 'video', { 'mediatype': 'episode', 'tvshowtitle': params.get('series_title', ''), 'title': params.get('episode_name', ''), 'plot': params.get('desc', ''), 'plotoutline': params.get('desc', ''), 'duration': params.get('duration', ''), 'aired': params.get('airdate', ''), 'season': params.get('season_no', ''), 'episode': params.get('episode_no', '') }) xbmcplugin.setResolvedUrl(_handle, True, play_item) if params['action'] != 'listepisodes': return next_item = comm.get_next_episode(params) if not next_item: return try: import upnext except Exception as e: utils.log('UpNext addon not installed: %s' % e) return upnext_info = dict(current_episode=dict( episodeid=params.get('id', ''), tvshowid=params.get('series_slug', ''), title=params.get('episode_name', ''), art={ 'thumb': params.get('thumb', ''), 'tvshow.fanart': params.get('fanart', ''), }, season=params.get('season_no', ''), episode=params.get('episode_no', ''), showtitle=params.get('series_title', ''), plot=params.get('desc', ''), playcount=0, rating=None, firstaired=params.get('airdate', ''), runtime=params.get('duration', ''), ), next_episode=dict( episodeid=next_item.id, tvshowid=next_item.series_slug, title=next_item.episode_name, art={ 'thumb': next_item.thumb, 'tvshow.fanart': next_item.fanart, }, season=next_item.season_no, episode=next_item.episode_no, showtitle=next_item.series_title, plot=next_item.desc, playcount=0, rating=None, firstaired=next_item.airdate, runtime=next_item.duration, ), play_url='{0}?action=listepisodes{1}'.format( _url, next_item.make_kodi_url())) upnext.send_signal(xbmcaddon.Addon().getAddonInfo('id'), upnext_info) except Exception: utils.handle_error('Unable to play video')
def play(url): try: # Remove cookies.dat for Kodi < 17.0 - causes issues with playback addon = xbmcaddon.Addon() cookies_dat = xbmc.translatePath('special://home/cache/cookies.dat') if os.path.isfile(cookies_dat): os.remove(cookies_dat) p = classes.Program() p.parse_xbmc_url(url) stream = comm.get_stream_url(p.get_house_number(), p.get_url()) use_ia = addon.getSetting('use_ia') == 'true' if use_ia: if addon.getSetting('ignore_drm') == 'false': try: import drmhelper if not drmhelper.check_inputstream(drm=False): return except ImportError: utils.log("Failed to import drmhelper") utils.dialog_message( 'DRM Helper is needed for inputstream.adaptive ' 'playback. Disable "Use inputstream.adaptive for ' 'playback" in settings or install drmhelper. For ' 'more information, please visit: ' 'http://aussieaddons.com/drm') return hdrs = stream[stream.find('|') + 1:] listitem = xbmcgui.ListItem(label=p.get_list_title(), iconImage=p.thumbnail, thumbnailImage=p.thumbnail, path=stream) if use_ia: listitem.setProperty('inputstreamaddon', 'inputstream.adaptive') listitem.setProperty('inputstream.adaptive.manifest_type', 'hls') listitem.setProperty('inputstream.adaptive.stream_headers', hdrs) listitem.setProperty('inputstream.adaptive.license_key', stream) listitem.setInfo('video', p.get_kodi_list_item()) # Add subtitles if available if p.subtitle_url: profile = xbmcaddon.Addon().getAddonInfo('profile') path = xbmc.translatePath(profile).decode('utf-8') if not os.path.isdir(path): os.makedirs(path) subfile = xbmc.translatePath( os.path.join(path, 'subtitles.eng.srt')) if os.path.isfile(subfile): os.remove(subfile) try: webvtt_data = urllib2.urlopen( p.subtitle_url).read().decode('utf-8') if webvtt_data: with open(subfile, 'w') as f: webvtt_subtitle = WebVTTReader().read(webvtt_data) srt_subtitle = SRTWriter().write(webvtt_subtitle) srt_unicode = srt_subtitle.encode('utf-8') f.write(srt_unicode) if hasattr(listitem, 'setSubtitles'): listitem.setSubtitles([subfile]) except Exception as e: utils.log( 'Subtitles not available for this program {0}'.format(e)) if hasattr(listitem, 'addStreamInfo'): listitem.addStreamInfo('audio', p.get_kodi_audio_stream_info()) listitem.addStreamInfo('video', p.get_kodi_video_stream_info()) xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem=listitem) except Exception: utils.handle_error('Unable to play video')
def play(url): try: addon = xbmcaddon.Addon() p = classes.Program() p.parse_kodi_url(url) stream_info = comm.get_stream(p) if not stream_info: return stream_url = stream_info.get('stream_url') if p.needs_ia: import drmhelper if not drmhelper.check_inputstream(drm=False): utils.dialog_message( "inputstream.adaptive needed for playback of" "DAI streams, please disable 'Use DAI Streams' in" "SBS add-on settings for playback.") return bandwidth = addon.getSetting('BANDWIDTH') if bandwidth == '0': stream_url = stream_url.replace('&b=0-2000', '&b=400-600') elif bandwidth == '1': stream_url = stream_url.replace('&b=0-2000', '&b=900-1100') elif bandwidth == '2': stream_url = stream_url.replace('&b=0-2000', '&b=1400-1600') listitem = comm.create_listitem(label=p.get_list_title(), path=str(stream_url)) listitem.setArt({'icon': p.thumb, 'thumb': p.thumb}) listitem.setInfo('video', p.get_kodi_list_item()) # Add subtitles if available if 'subtitles' in stream_info: sub_url = stream_info['subtitles'] profile = addon.getAddonInfo('profile') path = xbmc.translatePath(profile) if not os.path.isdir(path): os.makedirs(path) subfile = xbmc.translatePath( os.path.join(path, 'subtitles.eng.srt')) if os.path.isfile(subfile): os.remove(subfile) try: sess = session.Session() data = sess.get(sub_url).text f = open(subfile, 'w') f.write(data) f.close() if hasattr(listitem, 'setSubtitles'): # This function only supported from Kodi v14+ listitem.setSubtitles([subfile]) except Exception: utils.log('Subtitles not available for this program') listitem.setProperty('inputstreamaddon', 'inputstream.adaptive') listitem.setProperty('inputstream', 'inputstream.adaptive') listitem.setProperty('inputstream.adaptive.manifest_type', 'hls') listitem.setProperty('inputstream.adaptive.license_key', stream_url) if hasattr(listitem, 'addStreamInfo'): listitem.addStreamInfo('audio', p.get_kodi_audio_stream_info()) listitem.addStreamInfo('video', p.get_kodi_video_stream_info()) listitem.setProperty('isPlayable', 'true') if utils.get_kodi_major_version() >= 18: listitem.setIsFolder(False) xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem=listitem) np = comm.get_next_program(p) if not isinstance(np, classes.Program): return next_info = OrderedDict(current_episode=OrderedDict( episodeid=p.id, tvshowid=p.get_tvshowid(), title=p.get_title(), art={ 'thumb': p.get_thumb(), 'tvshow.fanart': p.get_fanart(), }, season=p.get_season_no(), episode=p.get_episode_no(), showtitle=p.get_series_title(), plot=p.get_description(), playcount=0, rating=None, firstaired=p.get_date(), runtime=p.get_duration(), ), next_episode=OrderedDict( episodeid=np.id, tvshowid=np.get_tvshowid(), title=np.get_title(), art={ 'thumb': np.get_thumb(), 'tvshow.fanart': np.get_fanart(), }, season=np.get_season_no(), episode=np.get_episode_no(), showtitle=np.get_series_title(), plot=np.get_description(), playcount=0, rating=None, firstaired=np.get_date(), runtime=np.get_duration(), ), play_url='{0}?{1}'.format( sys.argv[0], np.make_kodi_url()), notification_offset=p.get_credits_time()) upnext_signal('plugin.video.sbs', next_info) except Exception: utils.handle_error("Unable to play video")
def play(params): try: p = comm.get_program(params) # enable HD streams if ADDON.getSetting('hd_enabled') == 'true': if p.dash_url: if '&rule=sd-only' in p.dash_url: p.dash_url = p.dash_url.replace('&rule=sd-only', '') if p.hls_url: if '&rule=sd-only' in p.hls_url: p.hls_url = p.hls_url.replace('&rule=sd-only', '') listitem = xbmcgui.ListItem(label=p.get_title(), path=p.get_url()) listitem.setInfo('video', p.get_kodi_list_item()) if hasattr(listitem, 'addStreamInfo'): listitem.addStreamInfo('audio', p.get_kodi_audio_stream_info()) listitem.addStreamInfo('video', p.get_kodi_video_stream_info()) if (p.dash_preferred and p.dash_url) or not p.hls_url: import drmhelper drm = p.drm_key is not None if drmhelper.check_inputstream(drm=drm): listitem.setProperty('inputstreamaddon', 'inputstream.adaptive') listitem.setProperty('inputstream.adaptive.manifest_type', 'mpd') if drm: listitem.setProperty('inputstream.adaptive.license_type', 'com.widevine.alpha') listitem.setProperty( 'inputstream.adaptive.license_key', p.drm_key+'|Content-Type=application%2F' 'x-www-form-urlencoded|A{SSM}|') else: if drm: xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, xbmcgui.ListItem(path=None)) return else: pass # let's try to play hls if available # Pull subtitles if available if p.subtitle: utils.log('Enabling subtitles: {0}'.format(p.subtitle)) profile = ADDON.getAddonInfo('profile') subfilename = xbmc.translatePath(os.path.join(profile, 'subtitle.srt')) profiledir = xbmc.translatePath(os.path.join(profile)) if not os.path.isdir(profiledir): os.makedirs(profiledir) webvtt_data = session.Session().get( p.subtitle).text if webvtt_data: with open(subfilename, 'w') as f: webvtt_subtitle = WebVTTReader().read(webvtt_data) srt_subtitle = SRTWriter().write(webvtt_subtitle) srt_unicode = srt_subtitle.encode('utf-8') f.write(srt_unicode) if hasattr(listitem, 'setSubtitles'): # This function only supported from Kodi v14+ listitem.setSubtitles([subfilename]) # Play video utils.log('Attempting to play: {0} : {1}'.format(p.get_title(), p.get_url())) xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem=listitem) except Exception: utils.handle_error('Unable to play video')
index.make_seasons_list() else: videos.make_list(params) elif 'season' in params: rounds.make_rounds(params) elif 'team' in params: videos.make_list(params) elif 'round_id' in params: videos.make_list(params) elif 'title' in params: play.play(params_str) elif 'action' in params: if params['action'] == 'cleartoken': ooyalahelper.clear_token() elif params['action'] == 'sendreport': utils.user_report() elif params['action'] == 'iap_help': ooyalahelper.iap_help() elif params['action'] == 'open_ia_settings': try: import drmhelper if drmhelper.check_inputstream(drm=False): ia = drmhelper.get_addon() ia.openSettings() else: utils.dialog_message( "Can't open inputstream.adaptive settings") except Exception as e: utils.dialog_message( "Can't open inputstream.adaptive settings")
def test_check_inputstream(self): drmhelper.check_inputstream()
def main(): addon = xbmcaddon.Addon() if addon.getSetting('firstrun') == 'true': utils.dialog_message( 'Welcome to the new On Demand add-on. An SBS On Demand account ' 'is now required to use this service. Please sign up at ' 'sbs.com.au or in the mobile app, then enter your details in ' 'the add-on settings.') comm.get_login_token() addon.setSetting('firstrun', 'false') params_str = sys.argv[2] params = utils.get_url(params_str) utils.log(str(params)) if len(params) == 0: index.make_index_list() elif params.get('obj_type') == 'Program': play.play(params_str) elif 'feed_url' in params: index.make_entries_list(params) elif 'category' in params or params.get('item_type') in [ 'ProgramGenre', 'FilmGenre', 'Channel' ]: if params.get('category') == 'Search': index.make_search_history_list() else: index.make_category_list(params) elif 'action' in params: action = params.get('action') if action == 'favouritescategories': index.make_favourites_categories_list() elif action == 'addfavourites': comm.add_to_favourites(params) elif action == 'removefavourites': comm.remove_from_favourites(params) xbmc.executebuiltin('Container.Refresh') elif action == 'searchhistory': if params.get('name') == 'New Search': search.get_search_input() else: index.make_search_list(params) elif action == 'removesearch': search.remove_from_search_history(params.get('name')) elif action == 'sendreport': utils.user_report() elif action == 'settings': xbmcaddon.Addon().openSettings() elif action == 'logout': comm.clear_login_token() elif action == 'login': comm.get_login_token() xbmc.executebuiltin('Container.Refresh') elif action == 'open_ia_settings': try: import drmhelper if drmhelper.check_inputstream(drm=False): ia = drmhelper.get_addon() ia.openSettings() else: utils.dialog_message( "Can't open inputstream.adaptive settings") except Exception: utils.dialog_message( "Can't open inputstream.adaptive settings")