def list_qualities(video_url=_common.args.url): bitrates = [] video_data = _connection.getURL(video_url) smil_tree = BeautifulSoup(video_data, 'html.parser') video_url2 = smil_tree.video['src'] clip_id = smil_tree.video.find('param', attrs={'name': 'clipId'}) if clip_id is not None: clip_id = clip_id['value'] video_url = VIDEOPAGE % clip_id video_data = _connection.getURL(video_url) video_tree = BeautifulSoup(video_data, 'html.parser') clip_url = SMIL_BASE + video_tree.clipurl.string smil_data = _connection.getURL(clip_url) smil_tree = BeautifulSoup(smil_data, 'html.parser') video_url2 = smil_tree.find_all('video') for video_index in video_url2: bitrate = int(video_index['system-bitrate']) display = int(bitrate) / 1024 bitrates.append((display, bitrate)) else: m3u_master_data = _connection.getURL(video_url2) m3u_master = _m3u8.parse(m3u_master_data) for video_index in m3u_master.get('playlists'): try: codecs = video_index.get('stream_info')['codecs'] except: codecs = '' if codecs != 'mp4a.40.2': bitrate = int(video_index.get('stream_info')['bandwidth']) display = int(bitrate) / 1024 bitrates.append((display, bitrate)) return bitrates
def list_qualities(video_url = _common.args.url): bitrates = [] video_data = _connection.getURL(video_url) smil_tree = BeautifulSoup(video_data, 'html.parser') video_url2 = smil_tree.video['src'] clip_id = smil_tree.video.find('param', attrs = {'name' : 'clipId'}) if clip_id is not None: clip_id = clip_id['value'] video_url = VIDEOPAGE % clip_id video_data = _connection.getURL(video_url) video_tree = BeautifulSoup(video_data, 'html.parser') clip_url = SMIL_BASE + video_tree.clipurl.string smil_data = _connection.getURL(clip_url) smil_tree = BeautifulSoup(smil_data, 'html.parser') video_url2 = smil_tree.find_all('video') for video_index in video_url2: bitrate = int(video_index['system-bitrate']) display = int(bitrate)/1024 bitrates.append((display, bitrate)) else: m3u_master_data = _connection.getURL(video_url2) m3u_master = _m3u8.parse(m3u_master_data) for video_index in m3u_master.get('playlists'): try: codecs = video_index.get('stream_info')['codecs'] except: codecs = '' if codecs != 'mp4a.40.2': bitrate = int(video_index.get('stream_info')['bandwidth']) display = int(bitrate)/1024 bitrates.append((display, bitrate)) return bitrates
def list_qualities(): exception = False video_url = _common.args.url bitrates = [] video_data = _connection.getURL(video_url) video_tree = BeautifulSoup(video_data, 'html.parser') video_rtmp = video_tree.meta if video_rtmp is not None: for video_index in video_rtmp: bitrate = int(video_index['system-bitrate']) display = int(bitrate) bitrates.append((display, bitrate)) else: video_data = _connection.getURL(video_url + '&manifest=m3u') video_tree = BeautifulSoup(video_data, 'html.parser') if video_tree.find('param', attrs = {'name' : 'isException', 'value' : 'true'}) is None: video_url2 = video_tree.seq.find_all('video')[0] video_url3 = video_url2['src'] video_data2 = _connection.getURL(video_url3) video_url4 = _m3u8.parse(video_data2) for video_index in video_url4.get('playlists'): bitrate = int(video_index.get('stream_info')['bandwidth']) try: codecs = video_index.get('stream_info')['codecs'] except: codecs = '' display = int(bitrate) / 1024 bitrates.append((display, bitrate)) else: exception = True if not exception: return bitrates else: _common.show_exception(video_tree.ref['title'], video_tree.ref['abstract'])
def play_video(guid = _common.args.url): video_url = VIDEO % guid hbitrate = -1 lbitrate = -1 sbitrate = int(_addoncompat.get_setting('quality')) * 1024 closedcaption = None video_url2 = None finalurl = '' video_data = _connection.getURL(video_url) video_menu = simplejson.loads(video_data)['items'] video_item = video_menu[0] try: closedcaption = video_item['captions']['sami']['url'] except: pass if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None) and (closedcaption != ''): convert_subtitles(closedcaption.replace(' ', '+')) try: ipad_url = video_item['videos']['ipad']['url'] video_data2 = _connection.getURL(ipad_url + '?format=json') video_url3 = simplejson.loads(video_data2)['url'] video_data3 = _connection.getURL(video_url3) video_url4 = _m3u8.parse(video_data3) uri = None for video_index in video_url4.get('playlists'): try: codecs = video_index.get('stream_info')['codecs'] except: codecs = '' if codecs != 'mp4a.40.5': bitrate = int(video_index.get('stream_info')['bandwidth']) if bitrate < lbitrate or lbitrate == -1: lbitrate = bitrate luri = video_index.get('uri') if bitrate > hbitrate and bitrate <= sbitrate: hbitrate = bitrate uri = video_index.get('uri') if uri is None: uri = luri finalurl = video_url3.rsplit('/', 1)[0] + '/' + uri except: flash_url = video_item['videos']['flash']['url'] video_data2 = _connection.getURL(flash_url + '?format=json') video_url3 = simplejson.loads(video_data2)['url'] if '.mp4' in video_url3: base_url, playpath_url = video_url3.split('mp4:') playpath_url = ' playpath=mp4:' + playpath_url elif 'flv' in video_url3: base_url, playpath_url = video_url3.split('flv:') playpath_url = ' playpath=' + playpath_url.replace('.flv','') finalurl = base_url + playpath_url + '?player= swfurl=' + SWFURL % guid + ' swfvfy=true' xbmcplugin.setResolvedUrl(pluginHandle, True, xbmcgui.ListItem(path = finalurl)) if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None) and (closedcaption != ''): while not xbmc.Player().isPlaying(): xbmc.sleep(100) xbmc.Player().setSubtitles(_common.SUBTITLESMI)
def play_video(video_url = _common.args.url): hbitrate = -1 sbitrate = int(_addoncompat.get_setting('quality')) * 1000 finalurl = '' video_data = _connection.getURL(video_url + '&manifest=m3u') video_tree = BeautifulSoup(video_data) if (_addoncompat.get_setting('enablesubtitles') == 'true'): try: closedcaption = video_tree.find('textstream', src = True)['src'] convert_subtitles(closedcaption) video_closedcaption = 'true' except: video_closedcaption = 'false' video_url2 = video_tree.find('video', src = True)['src'] video_data2 = _connection.getURL(video_url2, savecookie = True) video_url3 = _m3u8.parse(video_data2) for video_index in video_url3.get('playlists'): bitrate = int(video_index.get('stream_info')['bandwidth']) if bitrate > hbitrate and bitrate <= sbitrate: hbitrate = bitrate video_url4 = video_index.get('uri') video_data4 = _connection.getURL(video_url4, loadcookie = True) key_url = re.compile('URI="(.*?)"').findall(video_data4)[0] key_data = _connection.getURL(key_url, loadcookie = True) key_file = open(_common.KEYFILE, 'wb') key_file.write(key_data) key_file.close() video_url5 = re.compile('(http:.*?)\n').findall(video_data4) for i, video_item in enumerate(video_url5): newurl = base64.b64encode(video_item) newurl = urllib.quote_plus(newurl) video_data4 = video_data4.replace(video_item, 'http://127.0.0.1:12345/foxstation/' + newurl) video_data4 = video_data4.replace(key_url, 'http://127.0.0.1:12345/play.key') localhttpserver = True filestring = 'XBMC.RunScript(' + os.path.join(_common.LIBPATH,'_proxy.py') + ', 12345)' xbmc.executebuiltin(filestring) time.sleep(2) playfile = open(_common.PLAYFILE, 'w') playfile.write(video_data4) playfile.close() finalurl = _common.PLAYFILE xbmcplugin.setResolvedUrl(pluginHandle, True, xbmcgui.ListItem(path = finalurl)) if ((_addoncompat.get_setting('enablesubtitles') == 'true') and (video_closedcaption != 'false')) or localhttpserver is True: while not xbmc.Player().isPlaying(): xbmc.sleep(100) if (_addoncompat.get_setting('enablesubtitles') == 'true') and (video_closedcaption != 'false'): xbmc.Player().setSubtitles(_common.SUBTITLE) if localhttpserver is True: while xbmc.Player().isPlaying(): xbmc.sleep(1000) _connection.getURL('http://localhost:12345/stop', connectiontype = 0)
def play_video(SITE): video_url = _common.args.url try: qbitrate = _common.args.quality except: qbitrate = None hbitrate = -1 lbitrate = -1 sbitrate = int(_addoncompat.get_setting('quality')) video_data = _connection.getURL(video_url) smil_url = re.compile("window.video_auth_playlist_url = '(.*)'").findall( video_data)[0] smil_data = _connection.getURL(smil_url + '&manifest=m3u') video_tree2 = BeautifulSoup(smil_data) video_url3 = video_tree2.video['src'] video_data3 = _connection.getURL(video_url3) video_url4 = _m3u8.parse(video_data3) video_url5 = None for video_index in video_url4.get('playlists'): bitrate = int(video_index.get('stream_info')['bandwidth']) if qbitrate is None: try: codecs = video_index.get('stream_info')['codecs'] except: codecs = '' if (bitrate < lbitrate or lbitrate == -1) and 'mp4a.40.2' != codecs: lbitrate = bitrate lvideo_url5 = video_index.get('uri') if bitrate > hbitrate and bitrate <= ( sbitrate * 1000) and codecs != 'mp4a.40.2': hbitrate = bitrate video_url5 = video_index.get('uri') elif bitrate == qbitrate: video_url5 = video_index.get('uri') if video_url5 is None: video_url5 = lvideo_url5 finalurl = video_url3.rsplit('/', 1)[0] + '/' + video_url5 item = xbmcgui.ListItem(path=finalurl) if qbitrate is not None: item.setThumbnailImage(_common.args.thumb) item.setInfo( 'Video', { 'title': _common.args.name, 'season': _common.args.season_number, 'episode': _common.args.episode_number, 'TVShowTitle': _common.args.show_title }) xbmcplugin.setResolvedUrl(pluginHandle, True, item)
def play_video(SITE): video_url = _common.args.url try: qbitrate = _common.args.quality except: qbitrate = None hbitrate = -1 lbitrate = -1 sbitrate = int(_addoncompat.get_setting("quality")) video_data = _connection.getURL(video_url) smil_url = re.compile("window.video_auth_playlist_url = '(.*)'").findall(video_data)[0] smil_data = _connection.getURL(smil_url + "&manifest=m3u") video_tree2 = BeautifulSoup(smil_data) video_url3 = video_tree2.video["src"] video_data3 = _connection.getURL(video_url3) video_url4 = _m3u8.parse(video_data3) video_url5 = None for video_index in video_url4.get("playlists"): bitrate = int(video_index.get("stream_info")["bandwidth"]) if qbitrate is None: try: codecs = video_index.get("stream_info")["codecs"] except: codecs = "" if (bitrate < lbitrate or lbitrate == -1) and "mp4a.40.2" != codecs: lbitrate = bitrate lvideo_url5 = video_index.get("uri") if bitrate > hbitrate and bitrate <= (sbitrate * 1000) and codecs != "mp4a.40.2": hbitrate = bitrate video_url5 = video_index.get("uri") elif bitrate == qbitrate: video_url5 = video_index.get("uri") if video_url5 is None: video_url5 = lvideo_url5 finalurl = video_url3.rsplit("/", 1)[0] + "/" + video_url5 item = xbmcgui.ListItem(path=finalurl) if qbitrate is not None: item.setThumbnailImage(_common.args.thumb) item.setInfo( "Video", { "title": _common.args.name, "season": _common.args.season_number, "episode": _common.args.episode_number, "TVShowTitle": _common.args.show_title, }, ) xbmcplugin.setResolvedUrl(pluginHandle, True, item)
def play_video(video_url=_common.args.url): hbitrate = -1 sbitrate = int(_addoncompat.get_setting('quality')) * 1024 closedcaption = None video_data = _connection.getURL(video_url) video_tree = BeautifulSoup(video_data, 'html.parser') video_rtmp = video_tree.meta if video_rtmp is not None: base_url = video_rtmp['base'] video_url2 = video_tree.switch.find_all('video') for video_index in video_url2: bitrate = int(video_index['system-bitrate']) if bitrate > hbitrate and bitrate <= sbitrate: hbitrate = bitrate playpath_url = video_index['src'] if '.mp4' in playpath_url: playpath_url = 'mp4:' + playpath_url else: playpath_url = playpath_url.replace('.flv', '') finalurl = base_url + ' playpath=' + playpath_url + ' swfurl=' + SWFURL + ' swfvfy=true' else: video_data = _connection.getURL(video_url + '&manifest=m3u') video_tree = BeautifulSoup(video_data) try: closedcaption = video_tree.textstream['src'] except: pass if (_addoncompat.get_setting('enablesubtitles') == 'true') and ( closedcaption is not None): convert_subtitles(closedcaption) video_url2 = video_tree.seq.find_all('video')[0] video_url3 = video_url2['src'] video_url4 = video_url3.split('/')[-1] video_data2 = _connection.getURL(video_url3) video_url5 = _m3u8.parse(video_data2) for video_index in video_url5.get('playlists'): bitrate = int(video_index.get('stream_info')['bandwidth']) if bitrate > hbitrate and bitrate <= sbitrate: hbitrate = bitrate finalurl = video_url3.replace(video_url4, video_index.get('uri')) xbmcplugin.setResolvedUrl(pluginHandle, True, xbmcgui.ListItem(path=finalurl)) if (_addoncompat.get_setting('enablesubtitles') == 'true') and ( closedcaption is not None): while not xbmc.Player().isPlaying(): xbmc.sleep(100) xbmc.Player().setSubtitles(_common.SUBTITLE)
def play_video(video_url=_common.args.url): hbitrate = -1 sbitrate = int(_addoncompat.get_setting('quality')) * 1024 closedcaption = None video_data = _connection.getURL(video_url) video_tree = BeautifulSoup(video_data, 'html.parser') video_rtmp = video_tree.meta if video_rtmp is not None: base_url = video_rtmp['base'] video_url2 = video_tree.switch.find_all('video') for video_index in video_url2: bitrate = int(video_index['system-bitrate']) if bitrate > hbitrate and bitrate <= sbitrate: hbitrate = bitrate playpath_url = video_index['src'] if '.mp4' in playpath_url: playpath_url = 'mp4:' + playpath_url else: playpath_url = playpath_url.replace('.flv', '') finalurl = base_url + ' playpath=' + playpath_url + ' swfurl=' + SWFURL + ' swfvfy=true' else: video_data = _connection.getURL(video_url + '&manifest=m3u') video_tree = BeautifulSoup(video_data) try: closedcaption = video_tree.textstream['src'] except: pass if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None): convert_subtitles(closedcaption) # video_url2 = video_tree.seq.find_all('video')[0] video_url3 = video_url2['src'] video_url4 = video_url3.split('/')[-1] video_data2 = _connection.getURL(video_url3) video_url5 = _m3u8.parse(video_data2) for video_index in video_url5.get('playlists'): bitrate = int(video_index.get('stream_info')['bandwidth']) if bitrate > hbitrate and bitrate <= sbitrate: hbitrate = bitrate finalurl = video_url3.replace(video_url4, video_index.get('uri')) xbmcplugin.setResolvedUrl(pluginHandle, True, xbmcgui.ListItem(path=finalurl)) if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None): while not xbmc.Player().isPlaying(): xbmc.sleep(100) xbmc.Player().setSubtitles(_common.SUBTITLE)
def list_qualities2(API, video_url = _common.args.url): video_bitrates = [] video_data = _connection.getURL(API + 'playlists/%s/videos.json' % video_url) video_tree = simplejson.loads(video_data) video_mgid = video_tree['playlist']['videos'][0]['video']['mgid'] video_data2 = _connection.getURL(VIDEOURLAPI % video_mgid) video_tree2 = BeautifulSoup(video_data2, 'html.parser') video_menu = video_tree2.find('src').string m3u8_url = None m3u8_master_data = _connection.getURL(video_menu, savecookie = True) m3u8_master = _m3u8.parse(m3u8_master_data) for video_index in m3u8_master.get('playlists'): video_bitrate = int(video_index.get('stream_info')['bandwidth']) bitrate_display = int(video_bitrate) / 1024 video_bitrates.append((bitrate_display, video_bitrate)) return video_bitrates
def play_video(video_url = _common.args.url): hbitrate = -1 sbitrate = int(_addoncompat.get_setting('quality')) video_data = _connection.getURL(video_url) video_tree = BeautifulSoup(video_data) video_url2 = video_tree.find('video', id = 'ngs_player')('source')[0]['src'] video_data2 = _connection.getURL(video_url2.replace('&format=redirect', '')) video_tree2 = BeautifulSoup(video_data2) video_url3 = video_tree2.video['src'] video_data3 = _connection.getURL(video_url3) video_url4 = _m3u8.parse(video_data3) for video_index in video_url4.get('playlists'): bitrate = int(video_index.get('stream_info')['bandwidth']) if bitrate > hbitrate and bitrate <= (sbitrate * 1000): hbitrate = bitrate finalurl = video_url3.rsplit('/',1)[0] + '/' + video_index.get('uri') xbmcplugin.setResolvedUrl(pluginHandle, True, xbmcgui.ListItem(path = finalurl))
def play_video(video_url=_common.args.url): hbitrate = -1 sbitrate = int(_addoncompat.get_setting('quality')) * 1000 finalurl = '' video_data = _connection.getURL(video_url + '&manifest=m3u') video_tree = BeautifulSoup(video_data) video_url2 = video_tree.find('video', src=True)['src'] signature = FOXsig(_common.args.url) print signature video_data2 = _connection.getFox( video_url2, header={'Cookie': signature}, referer='http://player.foxfdm.com/shared/1.4.522/pdk/swf/akamaiHD.swf') print video_data2 video_menu = _m3u8.parse(video_data2) for video_index in video_menu.get('playlists'): bitrate = int(video_index.get('stream_info')['bandwidth']) if bitrate > hbitrate and bitrate <= sbitrate: hbitrate = bitrate video_url3 = video_index.get('uri').replace('%2f', '') video_data3 = re.sub(r"\#EXT-X-DISCONTINUITY\n", "", _connection.getURL(video_url3)) keyurl = re.compile('URI="(.*?)"').findall(video_data3)[0] key_data = _connection.getURL(keyurl) keyfile = open(KEYPATH, 'w') keyfile.write(key_data) keyfile.close() localhttpserver = True filestring = 'XBMC.RunScript(' + os.path.join( _common.LIBPATH, '_proxy.py') + ',' + KEYPATH + ', 12345)' xbmc.executebuiltin(filestring) time.sleep(2) newkeyurl = 'http://127.0.0.1:12345' video_data4 = video_data4.replace(keyurl, newkeyurl) playfile = open(PLAYPATH, 'w') playfile.write(video_data4) playfile.close() finalurl = PLAYPATH xbmcplugin.setResolvedUrl(pluginHandle, True, xbmcgui.ListItem(path=finalurl)) if localhttpserver is True: _connection.getURL('http://localhost:12345/stop', connectiontype=0)
def play_video(SITE): video_url = _common.args.url try: qbitrate = _common.args.quality except: qbitrate = None hbitrate = -1 lbitrate = -1 sbitrate = int(_addoncompat.get_setting('quality')) video_data = _connection.getURL(video_url) smil_url = re.compile("window.video_auth_playlist_url = '(.*)'").findall(video_data)[0] smil_data = _connection.getURL(smil_url + '&manifest=m3u') video_tree2 = BeautifulSoup(smil_data, 'html.parser') video_url3 = video_tree2.video['src'] video_data3 = _connection.getURL(video_url3) video_url4 = _m3u8.parse(video_data3) video_url5 = None for video_index in video_url4.get('playlists'): bitrate = int(video_index.get('stream_info')['bandwidth']) if qbitrate is None: try: codecs = video_index.get('stream_info')['codecs'] except: codecs = '' if (bitrate < lbitrate or lbitrate == -1) and 'mp4a.40.2' != codecs: lbitrate = bitrate lvideo_url5 = video_index.get('uri') if bitrate > hbitrate and bitrate <= (sbitrate * 1000) and codecs != 'mp4a.40.2': hbitrate = bitrate video_url5 = video_index.get('uri') elif bitrate == qbitrate: video_url5 = video_index.get('uri') if video_url5 is None: video_url5 = lvideo_url5 finalurl = video_url3.rsplit('/',1)[0] + '/' + video_url5 item = xbmcgui.ListItem(path = finalurl) if qbitrate is not None: item.setThumbnailImage(_common.args.thumb) item.setInfo('Video', { 'title' : _common.args.name, 'season' : _common.args.season_number, 'episode' : _common.args.episode_number, 'TVShowTitle' : _common.args.show_title }) xbmcplugin.setResolvedUrl(pluginHandle, True, item)
def list_qualities(SITE): video_url = _common.args.url bitrates = [] video_data = _connection.getURL(video_url) smil_url = re.compile("window.video_auth_playlist_url = '(.*)'").findall(video_data)[0] smil_data = _connection.getURL(smil_url + "&manifest=m3u") video_tree2 = BeautifulSoup(smil_data) video_url3 = video_tree2.video["src"] video_data3 = _connection.getURL(video_url3) video_url4 = _m3u8.parse(video_data3) for video_index in video_url4.get("playlists"): try: codecs = video_index.get("stream_info")["codecs"] except: codecs = "" if codecs != "mp4a.40.2": bitrate = int(video_index.get("stream_info")["bandwidth"]) display = int(bitrate) / 1000 bitrates.append((display, bitrate)) return bitrates
def list_qualities(SITE): video_url = _common.args.url bitrates = [] video_data = _connection.getURL(video_url) smil_url = re.compile("window.video_auth_playlist_url = '(.*)'").findall(video_data)[0] smil_data = _connection.getURL(smil_url + '&manifest=m3u') video_tree2 = BeautifulSoup(smil_data, 'html.parser') video_url3 = video_tree2.video['src'] video_data3 = _connection.getURL(video_url3) video_url4 = _m3u8.parse(video_data3) for video_index in video_url4.get('playlists'): try: codecs = video_index.get('stream_info')['codecs'] except: codecs = '' if codecs != 'mp4a.40.2': bitrate = int(video_index.get('stream_info')['bandwidth']) display = int(bitrate) / 1000 bitrates.append((display, bitrate)) return bitrates
def play_video(video_url = _common.args.url): hbitrate = -1 sbitrate = int(_addoncompat.get_setting('quality')) * 1024 closedcaption = None video_url2 = None finalurl = '' try: closedcaption = simplejson.loads(_connection.getURL(CLOSEDCAPTION % video_url).replace('video_info(', '').replace(')', ''))['closed_captions_url'] except: pass if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None) and (closedcaption != ''): convert_subtitles(closedcaption.replace(' ', '+')) video_data = cove.videos.filter(fields = 'mediafiles', filter_tp_media_object_id = video_url) video_menu = video_data['results'][0]['mediafiles'] for video_item in video_menu: if video_item['video_encoding']['eeid'] == 'ipad-16x9': video_url2 = video_item['video_data_url'] elif video_item['video_encoding']['eeid'] == 'hls-2500k-16x9': video_url2 = video_item['video_data_url'] else: pass if video_url2 is None: video_url2 = video_item['video_data_url'] video_data2 = _connection.getURL(video_url2 + '?format=jsonp&callback=jQuery18303874830141490152_1377946043740') video_url3 = simplejson.loads(video_data2.replace('jQuery18303874830141490152_1377946043740(', '').replace(')', ''))['url'] if '.mp4' in video_url3: base_url, playpath_url = video_url3.split('mp4:') finalurl = base_url +' playpath=mp4:' + playpath_url + '?player= swfurl=' + SWFURL % video_data['results'][0]['guid'] + ' swfvfy=true' else: video_data3 = _connection.getURL(video_url3) video_url4 = _m3u8.parse(video_data3) for video_index in video_url4.get('playlists'): bitrate = int(video_index.get('stream_info')['bandwidth']) if bitrate > hbitrate and bitrate <= sbitrate: hbitrate = bitrate finalurl = video_url3.rsplit('/', 1)[0] + '/' + video_index.get('uri') xbmcplugin.setResolvedUrl(pluginHandle, True, xbmcgui.ListItem(path = finalurl)) if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None) and (closedcaption != ''): while not xbmc.Player().isPlaying(): xbmc.sleep(100) xbmc.Player().setSubtitles(_common.SUBTITLE)
def list_qualities(SITE): video_url = _common.args.url bitrates = [] video_data = _connection.getURL(video_url) smil_url = re.compile("window.video_auth_playlist_url = '(.*)'").findall( video_data)[0] smil_data = _connection.getURL(smil_url + '&manifest=m3u') video_tree2 = BeautifulSoup(smil_data) video_url3 = video_tree2.video['src'] video_data3 = _connection.getURL(video_url3) video_url4 = _m3u8.parse(video_data3) for video_index in video_url4.get('playlists'): try: codecs = video_index.get('stream_info')['codecs'] except: codecs = '' if codecs != 'mp4a.40.2': bitrate = int(video_index.get('stream_info')['bandwidth']) display = int(bitrate) / 1000 bitrates.append((display, bitrate)) return bitrates
def list_qualities(): exception = False video_url = _common.args.url bitrates = [] sbitrate = int(_addoncompat.get_setting('quality')) * 1024 closedcaption = None video_data = _connection.getURL(video_url) video_tree = BeautifulSoup(video_data, 'html.parser') video_rtmp = video_tree.meta if video_rtmp is not None: for video_index in video_url2: bitrate = int(video_index['system-bitrate']) display = int(bitrate) bitrates.append((display, bitrate)) else: video_data = _connection.getURL(video_url + '&manifest=m3u') video_tree = BeautifulSoup(video_data) if video_tree.find('param', attrs = {'name' : 'isException', 'value' : 'true'}) is None: video_url2 = video_tree.seq.find_all('video')[0] video_url3 = video_url2['src'] video_data2 = _connection.getURL(video_url3) video_url5 = _m3u8.parse(video_data2) for video_index in video_url5.get('playlists'): bitrate = int(video_index.get('stream_info')['bandwidth']) try: codecs = video_index.get('stream_info')['codecs'] except: codecs = '' display = int(bitrate) / 1024 if 'mp4a.40.2' not in codecs: bitrates.append((display, bitrate)) else: exception = True if not exception: return bitrates else: dialog = xbmcgui.Dialog() dialog.ok("Exception", video_tree.ref['title'], video_tree.ref['abstract']) return []
def list_qualities(): exception = False video_url = _common.args.url bitrates = [] sbitrate = int(_addoncompat.get_setting('quality')) * 1024 closedcaption = None video_data = _connection.getURL(video_url) video_tree = BeautifulSoup(video_data, 'html.parser') video_rtmp = video_tree.meta if video_rtmp is not None: for video_index in video_url2: bitrate = int(video_index['system-bitrate']) display = int(bitrate) bitrates.append((display, bitrate)) else: video_data = _connection.getURL(video_url + '&manifest=m3u') video_tree = BeautifulSoup(video_data,'html5lib') if video_tree.find('param', attrs = {'name' : 'isException', 'value' : 'true'}) is None: video_url2 = video_tree.seq.find_all('video')[0] video_url3 = video_url2['src'] video_data2 = _connection.getURL(video_url3) video_url5 = _m3u8.parse(video_data2) for video_index in video_url5.get('playlists'): bitrate = int(video_index.get('stream_info')['bandwidth']) try: codecs = video_index.get('stream_info')['codecs'] except: codecs = '' display = int(bitrate) / 1024 if 'mp4a.40.2' not in codecs: bitrates.append((display, bitrate)) else: exception = True if not exception: return bitrates else: dialog = xbmcgui.Dialog() dialog.ok("Exception", video_tree.ref['title'], video_tree.ref['abstract']) return []
def list_qualities(BASE, video_url = _common.args.url, media_base = VIDEOURL): bitrates = [] if media_base not in video_url: video_url = media_base + video_url exception = False if 'feed' not in video_url: swf_url = _connection.getRedirect(video_url, header = {'Referer' : BASE}) params = dict(item.split("=") for item in swf_url.split('?')[1].split("&")) uri = urllib.unquote_plus(params['uri']) config_url = urllib.unquote_plus(params['CONFIG_URL'].replace('Other', DEVICE)) config_data = _connection.getURL(config_url, header = {'Referer' : video_url, 'X-Forwarded-For' : '12.13.14.15'}) config_tree = BeautifulSoup(config_data, 'html.parser') if not config_tree.error: feed_url = config_tree.feed.string feed_url = feed_url.replace('{uri}', uri).replace('&', '&').replace('{device}', DEVICE).replace('{ref}', 'None').strip() else: exception = True error_text = config_tree.error.string.split('/')[-1].split('_') _common.show_exception(error_text[1], error_text[2]) else: feed_url = video_url if not exception: feed_data = _connection.getURL(feed_url) video_tree = BeautifulSoup(feed_data, 'html.parser', parse_only = SoupStrainer('media:group')) video_segments = video_tree.find_all('media:content') video_segment = video_segments[0] video_url3 = video_segment['url'].replace('{device}', DEVICE) video_data3 = _connection.getURL(video_url3, header = {'X-Forwarded-For' : '12.13.14.15'}) video_tree3 = BeautifulSoup(video_data3, 'html.parser') video_menu = video_tree3.find('src').string m3u8_url = None m3u_master_data = _connection.getURL(video_menu, savecookie = True) m3u_master = _m3u8.parse(m3u_master_data) for video_index in m3u_master.get('playlists'): bitrate = int(video_index.get('stream_info')['bandwidth']) display = int(bitrate) / 1024 bitrates.append((display, bitrate)) return bitrates
def play_video(video_url = _common.args.url): hbitrate = -1 sbitrate = int(_addoncompat.get_setting('quality')) * 1000 finalurl = '' video_data = _connection.getURL(video_url + '&manifest=m3u') video_tree = BeautifulSoup(video_data) video_url2 = video_tree.find('video', src = True)['src'] signature = FOXsig(_common.args.url) print signature video_data2 = _connection.getFox(video_url2, header = {'Cookie' : signature}, referer = 'http://player.foxfdm.com/shared/1.4.522/pdk/swf/akamaiHD.swf') print video_data2 video_menu = _m3u8.parse(video_data2) for video_index in video_menu.get('playlists'): bitrate = int(video_index.get('stream_info')['bandwidth']) if bitrate > hbitrate and bitrate <= sbitrate: hbitrate = bitrate video_url3 = video_index.get('uri').replace('%2f', '') video_data3 = re.sub(r"\#EXT-X-DISCONTINUITY\n","", _connection.getURL(video_url3)) keyurl = re.compile('URI="(.*?)"').findall(video_data3)[0] key_data = _connection.getURL(keyurl) keyfile = open(KEYPATH, 'w') keyfile.write(key_data) keyfile.close() localhttpserver = True filestring = 'XBMC.RunScript(' + os.path.join(_common.LIBPATH,'_proxy.py') + ',' + KEYPATH + ', 12345)' xbmc.executebuiltin(filestring) time.sleep(2) newkeyurl = 'http://127.0.0.1:12345' video_data4 = video_data4.replace(keyurl, newkeyurl) playfile = open(PLAYPATH, 'w') playfile.write(video_data4) playfile.close() finalurl = PLAYPATH xbmcplugin.setResolvedUrl(pluginHandle, True, xbmcgui.ListItem(path = finalurl)) if localhttpserver is True: _connection.getURL('http://localhost:12345/stop', connectiontype = 0)
def play_video(): try: qbitrate = _common.args.quality except: qbitrate = None exception = False video_url = _common.args.url hbitrate = -1 lbitrate = -1 sbitrate = int(_addoncompat.get_setting('quality')) * 1024 closedcaption = None video_data = _connection.getURL(video_url) video_tree = BeautifulSoup(video_data, 'html.parser') video_rtmp = video_tree.meta playpath_url = None lplaypath_url = None if video_rtmp is not None: base_url = video_rtmp['base'] if qbitrate is None: video_url2 = video_tree.switch.find_all('video') for video_index in video_url2: bitrate = int(video_index['system-bitrate']) if bitrate < lbitrate or lbitrate == -1: lbitrate = bitrate lplaypath_url = video_index['src'] if bitrate > hbitrate and bitrate <= sbitrate: hbitrate = bitrate playpath_url = video_index['src'] if playpath_url is None: playpath_url = lplaypath_url else: playpath_url = video_tree.switch.find('video', attrs = {'system-bitrate' : qbitrate})['src'] if '.mp4' in playpath_url: playpath_url = 'mp4:'+ playpath_url else: playpath_url = playpath_url.replace('.flv','') finalurl = base_url +' playpath=' + playpath_url + ' swfurl=' + SWFURL + ' swfvfy=true' else: video_data = _connection.getURL(video_url + '&manifest=m3u') video_tree = BeautifulSoup(video_data) try: closedcaption = video_tree.textstream['src'] except: pass if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None): convert_subtitles(closedcaption) if video_tree.find('param', attrs = {'name' : 'isException', 'value' : 'true'}) is None: video_url2 = video_tree.seq.find_all('video')[0] video_url3 = video_url2['src'] video_url4 = video_url3.split('/')[-1] video_data2 = _connection.getURL(video_url3) video_url5 = _m3u8.parse(video_data2) for video_index in video_url5.get('playlists'): bitrate = int(video_index.get('stream_info')['bandwidth']) try: codecs = video_index.get('stream_info')['codecs'] except: codecs = '' if qbitrate is None: if (bitrate < lbitrate or lbitrate == -1) and 'mp4a.40.2' not in codecs: lbitrate = bitrate lplaypath_url = video_index.get('uri') if (bitrate > hbitrate and bitrate <= sbitrate) and 'mp4a.40.2' not in codecs: hbitrate = bitrate playpath_url = video_index.get('uri') elif bitrate == qbitrate: playpath_url = video_index.get('uri') if playpath_url is None: playpath_url = lplaypath_url finalurl = video_url3.replace(video_url4, playpath_url) else: exception = True if not exception: item = xbmcgui.ListItem(path = finalurl) if qbitrate is not None: item.setThumbnailImage(_common.args.thumb) item.setInfo('Video', { 'title' : _common.args.name, 'season' : _common.args.season_number, 'episode' : _common.args.episode_number, 'TVShowTitle' : _common.args.show_title}) xbmcplugin.setResolvedUrl(pluginHandle, True, item) if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None): while not xbmc.Player().isPlaying(): xbmc.sleep(100) xbmc.Player().setSubtitles(_common.SUBTITLE) else: dialog = xbmcgui.Dialog() dialog.ok("Exception", video_tree.ref['title'], video_tree.ref['abstract'])
def play_video(BASE, video_url=_common.args.url, media_base=VIDEOURL): if media_base not in video_url: video_url = media_base + video_url try: qbitrate = _common.args.quality except: qbitrate = None video_url6 = 'stack://' sbitrate = int(_addoncompat.get_setting('quality')) closedcaption = [] if 'feed' not in video_url: swf_url = _connection.getRedirect(video_url, header={'Referer': BASE}) params = dict( item.split("=") for item in swf_url.split('?')[1].split("&")) uri = urllib.unquote_plus(params['uri']) config_url = urllib.unquote_plus(params['CONFIG_URL'].replace( 'Other', DEVICE)) config_data = _connection.getURL(config_url, header={ 'Referer': video_url, 'X-Forwarded-For': '12.13.14.15' }) feed_url = BeautifulSoup(config_data, 'html.parser', parse_only=SoupStrainer('feed')).feed.string feed_url = feed_url.replace('{uri}', uri).replace( '&', '&').replace('{device}', DEVICE).replace('{ref}', 'None').strip() else: feed_url = video_url feed_data = _connection.getURL(feed_url) video_tree = BeautifulSoup(feed_data, 'html.parser', parse_only=SoupStrainer('media:group')) video_segments = video_tree.find_all('media:content') for act, video_segment in enumerate(video_segments): video_url3 = video_segment['url'].replace('{device}', DEVICE) video_data3 = _connection.getURL( video_url3, header={'X-Forwarded-For': '12.13.14.15'}) video_tree3 = BeautifulSoup(video_data3, 'html5lib') try: closedcaption.append(video_tree3.find('typographic', format='ttml')) except: pass video_menu = video_tree3.find('src').string hbitrate = -1 lbitrate = -1 m3u_master_data = _connection.getURL(video_menu, savecookie=True) m3u_master = _m3u8.parse(m3u_master_data) hbitrate = -1 sbitrate = int(_addoncompat.get_setting('quality')) * 1024 for video_index in m3u_master.get('playlists'): bitrate = int(video_index.get('stream_info')['bandwidth']) if qbitrate is None: if bitrate > hbitrate and bitrate <= sbitrate: hbitrate = bitrate m3u8_url = video_index.get('uri') elif bitrate == qbitrate: m3u8_url = video_index.get('uri') m3u_data = _connection.getURL(m3u8_url, loadcookie=True) key_url = re.compile('URI="(.*?)"').findall(m3u_data)[0] key_data = _connection.getURL(key_url, loadcookie=True) key_file = open(_common.KEYFILE + str(act), 'wb') key_file.write(key_data) key_file.close() video_url5 = re.compile('(http:.*?)\n').findall(m3u_data) for i, video_item in enumerate(video_url5): newurl = base64.b64encode(video_item) newurl = urllib.quote_plus(newurl) m3u_data = m3u_data.replace( video_item, 'http://127.0.0.1:12345/foxstation/' + newurl) m3u_data = m3u_data.replace( key_url, 'http://127.0.0.1:12345/play.key' + str(act)) playfile = open( _common.PLAYFILE.replace('.m3u8', '_' + str(act) + '.m3u8'), 'w') playfile.write(m3u_data) playfile.close() video_url6 += _common.PLAYFILE.replace( '.m3u8', '_' + str(act) + '.m3u8') + ' , ' filestring = 'XBMC.RunScript(' + os.path.join(_common.LIBPATH, '_proxy.py') + ', 12345)' xbmc.executebuiltin(filestring) finalurl = video_url6[:-3] localhttpserver = True time.sleep(20) if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None): convert_subtitles(closedcaption) item = xbmcgui.ListItem(path=finalurl) if qbitrate is not None: item.setThumbnailImage(_common.args.thumb) item.setInfo( 'Video', { 'title': _common.args.name, 'season': _common.args.season_number, 'episode': _common.args.episode_number, 'TVShowTitle': _common.args.show_title }) xbmcplugin.setResolvedUrl(pluginHandle, True, item) if ((_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None)) or localhttpserver is True: while not xbmc.Player().isPlaying(): xbmc.sleep(200) if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None) and closedcaption != []: for count in range(1, len(closedcaption)): xbmc.Player().setSubtitles( os.path.join(_common.CACHEPATH, 'subtitle-%s.srt' % str(count))) while xbmc.Player().isPlaying(): xbmc.sleep(10) if localhttpserver is True: while xbmc.Player().isPlaying(): xbmc.sleep(10) _connection.getURL('http://localhost:12345/stop', connectiontype=0)
def play_video(video_url=_common.args.url, tonightshow=False): try: qbitrate = _common.args.quality except: qbitrate = None closedcaption = None video_data = _connection.getURL(video_url) smil_tree = BeautifulSoup(video_data, 'html.parser') video_url2 = smil_tree.video['src'] try: closedcaption = smil_tree.textstream['src'] except: pass clip_id = smil_tree.video.find('param', attrs={'name': 'clipId'}) if clip_id is not None: clip_id = clip_id['value'] video_url = VIDEOPAGE % clip_id video_data = _connection.getURL(video_url) video_tree = BeautifulSoup(video_data, 'html.parser') clip_url = SMIL_BASE + video_tree.clipurl.string smil_data = _connection.getURL(clip_url) smil_tree = BeautifulSoup(smil_data, 'html.parser') base_url = get_rtmp() hbitrate = -1 sbitrate = int(_addoncompat.get_setting('quality')) * 1024 if qbitrate is None: video_url2 = smil_tree.find_all('video') for video_index in video_url2: bitrate = int(video_index['system-bitrate']) if bitrate > hbitrate and bitrate <= sbitrate: hbitrate = bitrate playpath_url = video_index['src'] else: playpath_url = smil_tree.switch.find( 'video', attrs={'system-bitrate': qbitrate})['src'] if '.mp4' in playpath_url: playpath_url = 'mp4:' + playpath_url else: playpath_url = playpath_url.replace('.flv', '') finalurl = base_url + ' playpath=' + playpath_url + ' swfurl=' + SWFURL + ' swfvfy=true' else: m3u_master_data = _connection.getURL(video_url2, savecookie=True) m3u_master = _m3u8.parse(m3u_master_data) hbitrate = -1 sbitrate = int(_addoncompat.get_setting('quality')) * 1024 for video_index in m3u_master.get('playlists'): bitrate = int(video_index.get('stream_info')['bandwidth']) if qbitrate is None: if bitrate > hbitrate and bitrate <= sbitrate: hbitrate = bitrate m3u8_url = video_index.get('uri') elif bitrate == qbitrate: m3u8_url = video_index.get('uri') m3u_data = _connection.getURL(m3u8_url, loadcookie=True) key_url = re.compile('URI="(.*?)"').findall(m3u_data)[0] key_data = _connection.getURL(key_url, loadcookie=True) key_file = open(_common.KEYFILE, 'wb') key_file.write(key_data) key_file.close() video_url5 = re.compile('(http:.*?)\n').findall(m3u_data) for i, video_item in enumerate(video_url5): newurl = base64.b64encode(video_item) newurl = urllib.quote_plus(newurl) m3u_data = m3u_data.replace( video_item, 'http://127.0.0.1:12345/foxstation/' + newurl) localhttpserver = True filestring = 'XBMC.RunScript(' + os.path.join(_common.LIBPATH, '_proxy.py') + ', 12345)' xbmc.executebuiltin(filestring) time.sleep(20) m3u_data = m3u_data.replace(key_url, 'http://127.0.0.1:12345/play.key') playfile = open(_common.PLAYFILE, 'w') playfile.write(m3u_data) playfile.close() finalurl = _common.PLAYFILE if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None): convert_subtitles(closedcaption) item = xbmcgui.ListItem(path=finalurl) if qbitrate is not None: item.setThumbnailImage(_common.args.thumb) item.setInfo( 'Video', { 'title': _common.args.name, 'season': _common.args.season_number, 'episode': _common.args.episode_number, 'TVShowTitle': _common.args.show_title }) xbmcplugin.setResolvedUrl(pluginHandle, True, item) if ((_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None)): while not xbmc.Player().isPlaying(): xbmc.sleep(100) if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None): xbmc.Player().setSubtitles(_common.SUBTITLE)
def play_video(SITE, BRANDID, PARTNERID): video_id, video_type = _common.args.url.split('#') hbitrate = -1 lbitrate = -1 sbitrate = int(_addoncompat.get_setting('quality')) localhttpserver = False video_auth = get_authorization(BRANDID, video_id, video_type) if video_auth is False: video_url = VIDEOLIST % BRANDID + '001/-1/-1/-1/' + video_id + '/-1/-1' video_data = _connection.getURL(video_url) try: video_data2 = simplejson.loads(video_data)['videos']['video'] video_format = video_data2['assets']['asset'][0]['@format'] video_closedcaption = video_data2['closedcaption']['@enabled'] except: try: video_data2 = simplejson.loads(video_data)['videos']['video'] video_format = video_data2['assets']['asset']['@format'] video_closedcaption = video_data2['closedcaption']['@enabled'] except: video_format = 'MOV' video_closedcaption = 'false' video_id = video_id.replace('VDKA','') if video_format == 'MP4': video_url = PLAYLISTMP4 % (PARTNERID, PARTNERID) + video_id video_data = _connection.getURL(video_url) video_url2 = _m3u8.parse(video_data) for video_index in video_url2.get('playlists'): bitrate = int(video_index.get('stream_info')['bandwidth']) if bitrate > hbitrate and bitrate <= (sbitrate * 1000): hbitrate = bitrate playpath_url = video_index.get('uri') finalurl = playpath_url elif video_format == 'MOV': playpath_url = None video_url = PLAYLISTMOV % (PARTNERID, PARTNERID) + video_id video_data = _connection.getURL(video_url) video_tree = BeautifulSoup(video_data) base_url = video_tree('baseurl')[0].string video_url2 = video_tree.findAll('media') for video_index in video_url2: bitrate = int(video_index['bitrate']) if bitrate < lbitrate or lbitrate == -1: lbitrate = bitrate lplaypath_url = video_index['url'] if bitrate > hbitrate and bitrate <= sbitrate: hbitrate = bitrate playpath_url = video_index['url'] if playpath_url is None: playpath_url = lplaypath_url finalurl = base_url + ' playpath=' + playpath_url + ' swfUrl=' + SWFURL + ' swfVfy=true' else: video_url = VIDEOLIST % BRANDID + '002/-1/-1/-1/' + video_id + '/-1/-1' video_data = _connection.getURL(video_url) video_data2 = simplejson.loads(video_data)['videos']['video'] video_closedcaption = video_data2['closedcaption']['@enabled'] try: video_url2 = video_data2['assets']['asset']['$'] + video_auth except: video_url2 = video_data2['assets']['asset'][1]['$'] + video_auth video_data3 = _connection.getURL(video_url2.replace('m3u8','json')) video_url3 = simplejson.loads(video_data3) for video_keys in BITRATETABLE.iterkeys(): bitrate = int(video_keys) if bitrate > hbitrate and bitrate <= sbitrate: hbitrate = bitrate video_url4 = video_url3['url'].replace('__ray__', BITRATETABLE[video_keys]) video_url4 = video_url4.replace('https','http').replace('json','m3u8') video_data4 = re.sub(r"\#EXT-X-DISCONTINUITY\n","", _connection.getURL(video_url4)) key_url = re.compile('URI="(.*?)"').findall(video_data4)[0] key_data = _connection.getURL(key_url) key_file = open(_common.KEYFILE, 'wb') key_file.write(key_data) key_file.close() localhttpserver = True filestring = 'XBMC.RunScript(' + os.path.join(_common.LIBPATH,'_proxy.py') + ', 12345)' xbmc.executebuiltin(filestring) time.sleep(20) video_data4 = video_data4.replace(key_url, 'http://127.0.0.1:12345/play.key') playfile = open(_common.PLAYFILE, 'w') playfile.write(video_data4) playfile.close() finalurl = _common.PLAYFILE if (video_closedcaption == 'true') and (_addoncompat.get_setting('enablesubtitles') == 'true'): try: closedcaption = CLOSEDCAPTIONHOST + video_data2['closedcaption']['src']['$'].split('.com')[1] convert_subtitles(closedcaption) player._subtitles_Enabled = True except: video_closedcaption = 'false' xbmcplugin.setResolvedUrl(pluginHandle, True, xbmcgui.ListItem(path = finalurl)) while player.is_active: player.sleep(250)
def play_video(BASE, video_url=_common.args.url, media_base=VIDEOURL): if media_base not in video_url: video_url = media_base + video_url try: qbitrate = _common.args.quality except: qbitrate = None video_url6 = "stack://" sbitrate = int(_addoncompat.get_setting("quality")) closedcaption = [] if "feed" not in video_url: swf_url = _connection.getRedirect(video_url, header={"Referer": BASE}) params = dict(item.split("=") for item in swf_url.split("?")[1].split("&")) uri = urllib.unquote_plus(params["uri"]) config_url = urllib.unquote_plus(params["CONFIG_URL"].replace("Other", DEVICE)) config_data = _connection.getURL(config_url, header={"Referer": video_url, "X-Forwarded-For": "12.13.14.15"}) feed_url = BeautifulSoup(config_data, "html.parser", parse_only=SoupStrainer("feed")).feed.string feed_url = ( feed_url.replace("{uri}", uri) .replace("&", "&") .replace("{device}", DEVICE) .replace("{ref}", "None") .strip() ) else: feed_url = video_url feed_data = _connection.getURL(feed_url) video_tree = BeautifulSoup(feed_data, "html.parser", parse_only=SoupStrainer("media:group")) video_segments = video_tree.find_all("media:content") for act, video_segment in enumerate(video_segments): video_url3 = video_segment["url"].replace("{device}", DEVICE) video_data3 = _connection.getURL(video_url3, header={"X-Forwarded-For": "12.13.14.15"}) video_tree3 = BeautifulSoup(video_data3, "html5lib") try: closedcaption.append(video_tree3.find("typographic", format="ttml")) except: pass video_menu = video_tree3.find("src").string hbitrate = -1 lbitrate = -1 m3u_master_data = _connection.getURL(video_menu, savecookie=True) m3u_master = _m3u8.parse(m3u_master_data) hbitrate = -1 sbitrate = int(_addoncompat.get_setting("quality")) * 1024 for video_index in m3u_master.get("playlists"): bitrate = int(video_index.get("stream_info")["bandwidth"]) if qbitrate is None: if bitrate > hbitrate and bitrate <= sbitrate: hbitrate = bitrate m3u8_url = video_index.get("uri") elif bitrate == qbitrate: m3u8_url = video_index.get("uri") m3u_data = _connection.getURL(m3u8_url, loadcookie=True) key_url = re.compile('URI="(.*?)"').findall(m3u_data)[0] key_data = _connection.getURL(key_url, loadcookie=True) key_file = open(_common.KEYFILE + str(act), "wb") key_file.write(key_data) key_file.close() video_url5 = re.compile("(http:.*?)\n").findall(m3u_data) for i, video_item in enumerate(video_url5): newurl = base64.b64encode(video_item) newurl = urllib.quote_plus(newurl) m3u_data = m3u_data.replace(video_item, "http://127.0.0.1:12345/foxstation/" + newurl) m3u_data = m3u_data.replace(key_url, "http://127.0.0.1:12345/play.key" + str(act)) playfile = open(_common.PLAYFILE.replace(".m3u8", "_" + str(act) + ".m3u8"), "w") playfile.write(m3u_data) playfile.close() video_url6 += _common.PLAYFILE.replace(".m3u8", "_" + str(act) + ".m3u8") + " , " filestring = "XBMC.RunScript(" + os.path.join(_common.LIBPATH, "_proxy.py") + ", 12345)" xbmc.executebuiltin(filestring) finalurl = video_url6[:-3] localhttpserver = True time.sleep(20) if (_addoncompat.get_setting("enablesubtitles") == "true") and (closedcaption is not None): convert_subtitles(closedcaption) item = xbmcgui.ListItem(path=finalurl) if qbitrate is not None: item.setThumbnailImage(_common.args.thumb) item.setInfo( "Video", { "title": _common.args.name, "season": _common.args.season_number, "episode": _common.args.episode_number, "TVShowTitle": _common.args.show_title, }, ) xbmcplugin.setResolvedUrl(pluginHandle, True, item) if ( (_addoncompat.get_setting("enablesubtitles") == "true") and (closedcaption is not None) ) or localhttpserver is True: while not xbmc.Player().isPlaying(): xbmc.sleep(200) if (_addoncompat.get_setting("enablesubtitles") == "true") and (closedcaption is not None) and closedcaption != []: for count in range(1, len(closedcaption)): xbmc.Player().setSubtitles(os.path.join(_common.CACHEPATH, "subtitle-%s.srt" % str(count))) while xbmc.Player().isPlaying(): xbmc.sleep(10) if localhttpserver is True: while xbmc.Player().isPlaying(): xbmc.sleep(10) _connection.getURL("http://localhost:12345/stop", connectiontype=0)
def play_video(): try: qbitrate = _common.args.quality except: qbitrate = None exception = False video_url = _common.args.url hbitrate = -1 lbitrate = -1 sbitrate = int(_addoncompat.get_setting('quality')) * 1024 closedcaption = None video_data = _connection.getURL(video_url) video_tree = BeautifulSoup(video_data, 'html.parser') video_rtmp = video_tree.meta playpath_url = None lplaypath_url = None if video_rtmp is not None: base_url = video_rtmp['base'] if qbitrate is None: video_url2 = video_tree.switch.find_all('video') for video_index in video_url2: bitrate = int(video_index['system-bitrate']) if bitrate < lbitrate or lbitrate == -1: lbitrate = bitrate lplaypath_url = video_index['src'] if bitrate > hbitrate and bitrate <= sbitrate: hbitrate = bitrate playpath_url = video_index['src'] if playpath_url is None: playpath_url = lplaypath_url else: playpath_url = video_tree.switch.find('video', attrs = {'system-bitrate' : qbitrate})['src'] if '.mp4' in playpath_url: playpath_url = 'mp4:'+ playpath_url else: playpath_url = playpath_url.replace('.flv','') finalurl = base_url +' playpath=' + playpath_url + ' swfurl=' + SWFURL + ' swfvfy=true' else: video_data = _connection.getURL(video_url + '&manifest=m3u') video_tree = BeautifulSoup(video_data, 'html5lib') try: closedcaption = video_tree.textstream['src'] except: pass if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None): convert_subtitles(closedcaption) if video_tree.find('param', attrs = {'name' : 'isException', 'value' : 'true'}) is None: video_url2 = video_tree.seq.find_all('video')[0] video_url3 = video_url2['src'] video_url4 = video_url3.split('/')[-1] video_data2 = _connection.getURL(video_url3) video_url5 = _m3u8.parse(video_data2) for video_index in video_url5.get('playlists'): bitrate = int(video_index.get('stream_info')['bandwidth']) try: codecs = video_index.get('stream_info')['codecs'] except: codecs = '' if qbitrate is None: if (bitrate < lbitrate or lbitrate == -1) and 'mp4a.40.2' not in codecs: lbitrate = bitrate lplaypath_url = video_index.get('uri') if (bitrate > hbitrate and bitrate <= sbitrate) and 'mp4a.40.2' not in codecs: hbitrate = bitrate playpath_url = video_index.get('uri') elif bitrate == qbitrate: playpath_url = video_index.get('uri') if playpath_url is None: playpath_url = lplaypath_url finalurl = video_url3.replace(video_url4, playpath_url) else: exception = True if not exception: item = xbmcgui.ListItem(path = finalurl) if qbitrate is not None: item.setThumbnailImage(_common.args.thumb) item.setInfo('Video', { 'title' : _common.args.name, 'season' : _common.args.season_number, 'episode' : _common.args.episode_number, 'TVShowTitle' : _common.args.show_title}) xbmcplugin.setResolvedUrl(pluginHandle, True, item) if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None): while not xbmc.Player().isPlaying(): xbmc.sleep(100) xbmc.Player().setSubtitles(_common.SUBTITLE) else: dialog = xbmcgui.Dialog() dialog.ok("Exception", video_tree.ref['title'], video_tree.ref['abstract'])
def play_video(BASE, video_url = _common.args.url, media_base = VIDEOURL): if media_base not in video_url: video_url = media_base + video_url try: qbitrate = _common.args.quality except: qbitrate = None video_url6 = 'stack://' sbitrate = int(_addoncompat.get_setting('quality')) closedcaption = [] if 'feed' not in video_url: swf_url = _connection.getRedirect(video_url, header = {'Referer' : BASE}) params = dict(item.split("=") for item in swf_url.split('?')[1].split("&")) uri = urllib.unquote_plus(params['uri']) config_url = urllib.unquote_plus(params['CONFIG_URL'].replace('Other',DEVICE)) config_data = _connection.getURL(config_url, header = {'Referer' : video_url, 'X-Forwarded-For' : '12.13.14.15'}) feed_url = BeautifulSoup(config_data, 'html.parser', parse_only = SoupStrainer('feed')).feed.string feed_url = feed_url.replace('{uri}', uri).replace('&', '&').replace('{device}', DEVICE).replace('{ref}', 'None').strip() else: feed_url = video_url feed_data = _connection.getURL(feed_url) video_tree = BeautifulSoup(feed_data, 'html.parser', parse_only = SoupStrainer('media:group')) video_segments = video_tree.find_all('media:content') for act, video_segment in enumerate(video_segments): video_url3 = video_segment['url'].replace('{device}', DEVICE) video_data3 = _connection.getURL(video_url3, header = {'X-Forwarded-For' : '12.13.14.15'}) video_tree3 = BeautifulSoup(video_data3) try: closedcaption.append(video_tree3.find('typographic', format = 'ttml')) except: pass video_menu = video_tree3.find('src').string hbitrate = -1 lbitrate = -1 m3u_master_data = _connection.getURL(video_menu, savecookie = True) m3u_master = _m3u8.parse(m3u_master_data) hbitrate = -1 sbitrate = int(_addoncompat.get_setting('quality')) * 1024 for video_index in m3u_master.get('playlists'): bitrate = int(video_index.get('stream_info')['bandwidth']) if qbitrate is None: if bitrate > hbitrate and bitrate <= sbitrate: hbitrate = bitrate m3u8_url = video_index.get('uri') elif bitrate == qbitrate: m3u8_url = video_index.get('uri') m3u_data = _connection.getURL(m3u8_url, loadcookie = True) key_url = re.compile('URI="(.*?)"').findall(m3u_data)[0] key_data = _connection.getURL(key_url, loadcookie = True) key_file = open(_common.KEYFILE + str(act), 'wb') key_file.write(key_data) key_file.close() video_url5 = re.compile('(http:.*?)\n').findall(m3u_data) for i, video_item in enumerate(video_url5): newurl = base64.b64encode(video_item) newurl = urllib.quote_plus(newurl) m3u_data = m3u_data.replace(video_item, 'http://127.0.0.1:12345/foxstation/' + newurl) m3u_data = m3u_data.replace(key_url, 'http://127.0.0.1:12345/play.key' + str(act)) playfile = open(_common.PLAYFILE.replace('.m3u8', '_' + str(act) + '.m3u8'), 'w') playfile.write(m3u_data) playfile.close() video_url6 += _common.PLAYFILE.replace('.m3u8', '_' + str(act) + '.m3u8') + ' , ' filestring = 'XBMC.RunScript(' + os.path.join(_common.LIBPATH,'_proxy.py') + ', 12345)' xbmc.executebuiltin(filestring) finalurl = video_url6[:-3] localhttpserver = True time.sleep(20) if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None): convert_subtitles(closedcaption) item = xbmcgui.ListItem(path = finalurl) if qbitrate is not None: item.setThumbnailImage(_common.args.thumb) item.setInfo('Video', { 'title' : _common.args.name, 'season' : _common.args.season_number, 'episode' : _common.args.episode_number, 'TVShowTitle' : _common.args.show_title}) xbmcplugin.setResolvedUrl(pluginHandle, True, item) if ((_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None)) or localhttpserver is True: while not xbmc.Player().isPlaying(): xbmc.sleep(200) if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None) and closedcaption !=[]: for count in range(1, len(closedcaption)): xbmc.Player().setSubtitles(os.path.join(_common.CACHEPATH, 'subtitle-%s.srt' % str(count))) while xbmc.Player().isPlaying(): xbmc.sleep(10) if localhttpserver is True: while xbmc.Player().isPlaying(): xbmc.sleep(10) _connection.getURL('http://localhost:12345/stop', connectiontype = 0)
def play_video(video_id_type = _common.args.url): video_id, video_type = video_id_type.split('#') hbitrate = -1 sbitrate = int(_addoncompat.get_setting('quality')) localhttpserver = False video_auth = get_authorization(video_id, video_type) if video_auth is False: video_url = VIDEOURL + '/001/-1/-1/-1/' + video_id + '/-1/-1' video_data = _connection.getURL(video_url) try: video_data2 = simplejson.loads(video_data)['videos']['video'] video_format = video_data2['assets']['asset'][0]['@format'] video_closedcaption = video_data2['closedcaption']['@enabled'] except: try: video_data2 = simplejson.loads(video_data)['videos']['video'] video_format = video_data2['assets']['asset']['@format'] video_closedcaption = video_data2['closedcaption']['@enabled'] except: video_format = 'MOV' video_closedcaption = 'false' video_id = video_id.replace('VDKA','') if video_format == 'MP4': video_url = PLAYLISTMP4 + video_id video_data = _connection.getURL(video_url) video_url2 = _m3u8.parse(video_data) for video_index in video_url2.get('playlists'): bitrate = int(video_index.get('stream_info')['bandwidth']) if bitrate > hbitrate and bitrate <= (sbitrate * 1000): hbitrate = bitrate playpath_url = video_index.get('uri') finalurl = playpath_url elif video_format == 'MOV': video_url = PLAYLISTMOV + video_id video_data = _connection.getURL(video_url) video_tree = BeautifulSoup(video_data) base_url = video_tree('baseurl')[0].string video_url2 = video_tree.findAll('media') for video_index in video_url2: bitrate = int(video_index['bitrate']) if bitrate > hbitrate and bitrate <= sbitrate: hbitrate = bitrate playpath_url = video_index['url'] finalurl = base_url + ' playpath=' + playpath_url + ' swfUrl=' + SWFURL + ' swfVfy=true' else: video_url = VIDEOURL + '/002/-1/-1/-1/' + video_id + '/-1/-1' video_data = _connection.getURL(video_url) video_data2 = simplejson.loads(video_data)['videos']['video'] video_closedcaption = video_data2['closedcaption']['@enabled'] video_url2 = video_data2['assets']['asset']['$'] + video_auth video_data3 = _connection.getURL(video_url2.replace('m3u8','json')) video_url3 = simplejson.loads(video_data3) for video_keys in BITRATETABLE.iterkeys(): bitrate = int(video_keys) if bitrate > hbitrate and bitrate <= sbitrate: hbitrate = bitrate video_url4 = video_url3['url'].replace('__ray__', BITRATETABLE[video_keys]) video_url4 = video_url4.replace('https','http').replace('json','m3u8').replace('&rates=0-2500','') video_data4 = re.sub(r"\#EXT-X-DISCONTINUITY\n","", _connection.getURL(video_url4)) keyurl = re.compile('URI="(.*?)"').findall(video_data4)[0] key_data = _connection.getURL(keyurl) keyfile = open(KEYPATH, 'wb') keyfile.write(key_data) keyfile.close() localhttpserver = True filestring = 'XBMC.RunScript(' + os.path.join(_common.LIBPATH,'_proxy.py') + ',' + KEYPATH + ', 12345)' xbmc.executebuiltin(filestring) time.sleep(2) newkeyurl = 'http://127.0.0.1:12345' video_data4 = video_data4.replace(keyurl, newkeyurl) playfile = open(PLAYPATH, 'w') playfile.write(video_data4) playfile.close() finalurl = PLAYPATH if (video_closedcaption == 'true') and (_addoncompat.get_setting('enablesubtitles') == 'true'): try: closedcaption = CLOSEDCAPTIONHOST + video_data2['closedcaption']['src']['$'].split('.com')[1] convert_subtitles(closedcaption) except: video_closedcaption = 'false' xbmcplugin.setResolvedUrl(pluginHandle, True, xbmcgui.ListItem(path = finalurl)) if (_addoncompat.get_setting('enablesubtitles') == 'true') and (video_closedcaption != 'false'): while not xbmc.Player().isPlaying(): xbmc.sleep(100) xbmc.Player().setSubtitles(SUBTITLE) if localhttpserver is True: _connection.getURL('http://localhost:12345/stop', connectiontype = 0)
def get_videos(queue, i, video_item, qbitrate): try: video_mgid = video_item['video']['mgid'] except: try: video_mgid = video_item['url'].split('uri=')[1].split('&')[0] except: video_mgid = video_item['url'].split('/')[-1].split('?')[0] video_data = _connection.getURL(VIDEOURLAPI % video_mgid) video_tree = BeautifulSoup(video_data, 'html.parser') try: duration = video_tree.find('rendition')['duration'] closedcaption = video_tree.find('typographic', format = 'ttml') except: duration = 0 closedcaption = None try: video_menu = video_tree.src.string hbitrate = -1 lbitrate = -1 m3u8_url = None semaphore = BoundedSemaphore(1) semaphore.acquire() m3u8_master_data = _connection.getURL(video_menu, savecookie = True) semaphore.release() m3u8_master = _m3u8.parse(m3u8_master_data) sbitrate = int(_addoncompat.get_setting('quality')) * 1024 for video_index in m3u8_master.get('playlists'): bitrate = int(video_index.get('stream_info')['bandwidth']) if qbitrate is None: if bitrate < lbitrate or lbitrate == -1: lbitrate = bitrate lm3u8_url = video_index.get('uri') if bitrate > hbitrate and bitrate <= sbitrate: hbitrate = bitrate m3u8_url = video_index.get('uri') elif (qbitrate * (100 - BITRATERANGE)) / 100 < bitrate and (qbitrate * (100 + BITRATERANGE)) / 100 > bitrate: m3u8_url = video_index.get('uri') if ((m3u8_url is None) and (qbitrate is None)): m3u8_url = lm3u8_url semaphore2 = BoundedSemaphore(1) semaphore2.acquire() m3u8_data = _connection.getURL(m3u8_url, loadcookie = True) key_url = re.compile('URI="(.*?)"').findall(m3u8_data)[0] key_data = _connection.getURL(key_url, loadcookie = True) key_file = open(_common.KEYFILE + str(i), 'wb') key_file.write(key_data) key_file.close() semaphore2.release() video_url = re.compile('(http:.*?)\n').findall(m3u8_data) for video_item in video_url: newurl = base64.b64encode(video_item) newurl = urllib.quote_plus(newurl) m3u8_data = m3u8_data.replace(video_item, 'http://127.0.0.1:12345/foxstation/' + newurl) m3u8_data = m3u8_data.replace(key_url, 'http://127.0.0.1:12345/play.key' + str(i)) file_name = _common.PLAYFILE.replace('.m3u8', '_' + str(i) + '.m3u8') playfile = open(file_name, 'w') playfile.write(m3u8_data) playfile.close() queue.put([i, file_name, duration, closedcaption]) except: pass
def play_video(video_url = _common.args.url, tonightshow = False): try: qbitrate = _common.args.quality except: qbitrate = None closedcaption = None video_data = _connection.getURL(video_url) smil_tree = BeautifulSoup(video_data, 'html.parser') video_url2 = smil_tree.video['src'] try: closedcaption = smil_tree.textstream['src'] except: pass clip_id = smil_tree.video.find('param', attrs = {'name' : 'clipId'}) if clip_id is not None: clip_id = clip_id['value'] video_url = VIDEOPAGE % clip_id video_data = _connection.getURL(video_url) video_tree = BeautifulSoup(video_data, 'html.parser') clip_url = SMIL_BASE + video_tree.clipurl.string smil_data = _connection.getURL(clip_url) smil_tree = BeautifulSoup(smil_data, 'html.parser') base_url = get_rtmp() hbitrate = -1 sbitrate = int(_addoncompat.get_setting('quality')) * 1024 if qbitrate is None: video_url2 = smil_tree.find_all('video') for video_index in video_url2: bitrate = int(video_index['system-bitrate']) if bitrate > hbitrate and bitrate <= sbitrate: hbitrate = bitrate playpath_url = video_index['src'] else: playpath_url = smil_tree.switch.find('video', attrs = {'system-bitrate' : qbitrate})['src'] if '.mp4' in playpath_url: playpath_url = 'mp4:' + playpath_url else: playpath_url = playpath_url.replace('.flv', '') finalurl = base_url + ' playpath=' + playpath_url + ' swfurl=' + SWFURL + ' swfvfy=true' else: m3u_master_data = _connection.getURL(video_url2, savecookie = True) m3u_master = _m3u8.parse(m3u_master_data) hbitrate = -1 sbitrate = int(_addoncompat.get_setting('quality')) * 1024 for video_index in m3u_master.get('playlists'): bitrate = int(video_index.get('stream_info')['bandwidth']) if qbitrate is None: if bitrate > hbitrate and bitrate <= sbitrate: hbitrate = bitrate m3u8_url = video_index.get('uri') elif bitrate == qbitrate: m3u8_url = video_index.get('uri') m3u_data = _connection.getURL(m3u8_url, loadcookie = True) key_url = re.compile('URI="(.*?)"').findall(m3u_data)[0] key_data = _connection.getURL(key_url, loadcookie = True) key_file = open(_common.KEYFILE, 'wb') key_file.write(key_data) key_file.close() video_url5 = re.compile('(http:.*?)\n').findall(m3u_data) for i, video_item in enumerate(video_url5): newurl = base64.b64encode(video_item) newurl = urllib.quote_plus(newurl) m3u_data = m3u_data.replace(video_item, 'http://127.0.0.1:12345/foxstation/' + newurl) localhttpserver = True filestring = 'XBMC.RunScript(' + os.path.join(_common.LIBPATH,'_proxy.py') + ', 12345)' xbmc.executebuiltin(filestring) time.sleep(20) m3u_data = m3u_data.replace(key_url, 'http://127.0.0.1:12345/play.key') playfile = open(_common.PLAYFILE, 'w') playfile.write(m3u_data) playfile.close() finalurl = _common.PLAYFILE if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None): convert_subtitles(closedcaption) item = xbmcgui.ListItem(path = finalurl) if qbitrate is not None: item.setThumbnailImage(_common.args.thumb) item.setInfo('Video', { 'title' : _common.args.name, 'season' : _common.args.season_number, 'episode' : _common.args.episode_number, 'TVShowTitle' : _common.args.show_title}) xbmcplugin.setResolvedUrl(pluginHandle, True, item) if ((_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None)) : while not xbmc.Player().isPlaying(): xbmc.sleep(100) if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None): xbmc.Player().setSubtitles(_common.SUBTITLE)