def take_stream(params): params = eval(params) orig_title = params.get('title') import sport365 as mod busy() stream_url, url, header, title = mod.getChannelVideo(json.loads(ex_link)) if stream_url: liz = xbmcgui.ListItem(label=orig_title) liz.setArt({"fanart": FANART, "icon": ICON}) liz.setInfo(type="Video", infoLabels={"title": orig_title}) liz.setProperty("IsPlayable", "true") idle() if my_addon.getSetting('play') != 'F4M': stream_url = stream_url.replace('/i', '/index.m3u8') liz.setPath(stream_url) if float(xbmc.getInfoLabel('System.BuildVersion')[0:4]) >= 17.5: liz.setMimeType('application/vnd.apple.mpegurl') liz.setProperty('inputstream.adaptive.manifest_type', 'hls') liz.setProperty('inputstream.adaptive.stream_headers', str(header)) else: liz.setProperty('inputstreamaddon', None) liz.setContentLookup(True) try: import threading thread = threading.Thread(name='sport356Thread', target=sport356Thread2, args=[url, header]) thread.start() #xbmc.Player().play(stream_url, liz) #addLinkItem(orig_title, stream_url, '', '', ICON, liz, True, FANART) ok = xbmcplugin.setResolvedUrl(addon_handle, False, liz) #ok = xbmcplugin.addDirectoryItem(handle=addon_handle, url=stream_url, listitem=liz, isFolder=False) return ok except BaseException: pass else: stream_url = 'plugin://plugin.video.f4mTester/?streamtype=HLSRETRY&url={0}&name={1}'.format( urllib.quote_plus(stream_url), urllib.quote_plus(orig_title)) liz.setPath(stream_url) idle() try: xbmc.executebuiltin('RunPlugin(' + stream_url + ')') except BaseException: pass # xbmcplugin.setResolvedUrl(addon_handle, False, liz) else: xbmcgui.Dialog().ok("Sorry for that", 'plz contact Dev')
def take_stream(params): params = eval(params) orig_title = params.get('title') import sport365 as mod busy() stream_url, url, header, title = mod.getChannelVideo(json.loads(ex_link)) xbmc.log(stream_url, level=xbmc.LOGNOTICE) xbmc.log(url, level=xbmc.LOGNOTICE) xbmc.log(str(header), level=xbmc.LOGNOTICE) # xbmc.log(title, level=xbmc.LOGNOTICE) if stream_url: liz = xbmcgui.ListItem(label=orig_title) liz.setArt({"fanart": FANART, "icon": ICON}) liz.setInfo(type="Video", infoLabels={"title": orig_title}) liz.setProperty("IsPlayable", "true") idle() if my_addon.getSetting('play') == 'Inputstream': stream_url = stream_url.replace( '/i', '/index.m3u8') if stream_url.endswith('/i') else stream_url liz.setPath(stream_url) if float(xbmc.getInfoLabel('System.BuildVersion')[0:4]) >= 17.5: liz.setMimeType('application/vnd.apple.mpegurl') liz.setProperty('inputstream.adaptive.manifest_type', 'hls') liz.setProperty('inputstream.adaptive.stream_headers', str(header)) else: liz.setProperty('inputstreamaddon', None) liz.setContentLookup(True) try: # import threading # thread = threading.Thread(name='sport356Thread', target=sport356Thread2, args=[url, header]) # thread.start() # xbmc.Player().play(stream_url, liz) ok = xbmcplugin.setResolvedUrl(addon_handle, True, liz) #ok = xbmcplugin.addDirectoryItem(handle=addon_handle, url=stream_url, listitem=liz, isFolder=False) return ok except BaseException: pass elif my_addon.getSetting('play') == 'Streamlink': # stream_url = 'hls://' + stream_url.replace('/i', '/master.m3u8') import streamlink.session session = streamlink.session.Streamlink() stream_url, hdrs = stream_url.split('|') stream_url = 'hls://' + stream_url.replace('/i', '/index.m3u8') if stream_url.endswith('/i') else\ 'hls://' + stream_url hdrs += '&Origin=http://h5.adshell.net' session.set_option("http-headers", hdrs) streams = session.streams(stream_url) stream_url = streams['best'].to_url() + '|' + hdrs liz.setPath(stream_url) idle() # import threading # thread = threading.Thread(name='sport356Thread', target=sport356Thread2, args=[url, header]) # thread.start() ok = xbmcplugin.setResolvedUrl(addon_handle, False, liz) return ok else: stream_url = 'plugin://plugin.video.f4mTester/?streamtype=HLSRETRY&url={0}&name={1}'.format( urllib.quote_plus(stream_url), urllib.quote_plus(orig_title)) liz.setPath(stream_url) idle() try: xbmc.executebuiltin('RunPlugin(' + stream_url + ')') except BaseException: pass # xbmcplugin.setResolvedUrl(addon_handle, False, liz) else: xbmcgui.Dialog().ok("Sorry for that", 'plz contact Dev')
def take_stream(params): import sport365 as mod params = eval(params) orig_title = params.get('title') # busy() xbmc.log(str(ex_link), level=xbmc.LOGNOTICE) stream_url, url, header, title, ref = mod.getChannelVideo(str(ex_link)) # xbmc.log(stream_url, level=xbmc.LOGNOTICE) # xbmc.log(ref, level=xbmc.LOGNOTICE) # xbmc.log(title, level=xbmc.LOGNOTICE) if stream_url: UA = 'Mozilla/5.0 (Linux; Android 8.0; Nexus 6P Build/OPP3.170518.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.121 Mobile Safari/537.36' hdrs = 'User-Agent={}&Referer={}'.format( urllib.quote(UA), urllib.quote('http://h5.adshell.net/peer5')) liz = xbmcgui.ListItem(label=orig_title) liz.setArt({"fanart": FANART, "icon": ICON}) liz.setInfo(type="Video", infoLabels={ "title": orig_title, 'mediatype': 'video' }) liz.setProperty("IsPlayable", "true") idle() if my_addon.getSetting('play') == 'Inputstream': stream_url = stream_url.replace( '/i', '/index.m3u8') if stream_url.endswith('/i') else stream_url stream_url += '|' + hdrs liz.setPath(stream_url) if float(xbmc.getInfoLabel('System.BuildVersion')[0:4]) >= 17.5: liz.setMimeType('application/vnd.apple.mpegurl') liz.setProperty('inputstream.adaptive.manifest_type', 'hls') liz.setProperty('inputstream.adaptive.stream_headers', str(hdrs)) else: liz.setProperty('inputstreamaddon', None) liz.setContentLookup(True) try: # import threading # thread = threading.Thread(name='sport356Thread', target=sport356Thread2, args=[url, header]) # thread.start() # xbmc.Player().play(stream_url, liz) xbmcplugin.setResolvedUrl(addon_handle, True, liz) #ok = xbmcplugin.addDirectoryItem(handle=addon_handle, url=stream_url, listitem=liz, isFolder=False) except BaseException: pass elif my_addon.getSetting('play') == 'Streamlink': import streamlink.session session = streamlink.session.Streamlink() stream_url = 'hls://' + stream_url.replace('/i', '/index.m3u8') if stream_url.endswith('/i') else\ 'hls://' + stream_url hdrs += '&Origin=http://h5.adshell.net' session.set_option("http-headers", hdrs) streams = session.streams(stream_url) stream_url = streams['best'].to_url() + '|' + hdrs liz.setPath(stream_url) idle() # import threading # thread = threading.Thread(name='sport356Thread', target=sport356Thread2, args=[url, header]) # thread.start() xbmcplugin.setResolvedUrl(addon_handle, False, liz) else: try: stream_url = 'plugin://plugin.video.f4mTester/?streamtype=HLSRETRY&url={0}&name={1}'.format( urllib.quote_plus(stream_url), urllib.quote_plus(orig_title)) liz.setPath(stream_url) idle() xbmcplugin.endOfDirectory(addon_handle, succeeded=False) xbmc.executebuiltin('RunPlugin(' + stream_url + ')') return except BaseException: pass else: xbmcgui.Dialog().ok("Sorry for that", 'plz contact Dev')