def get_video_url(params): """Get video URL and start video player""" if params.next == 'play_r' or params.next == 'download_video': return resolver.get_brightcove_video_json(params.data_account, params.data_player, params.data_video_id) elif params.next == 'play_l': live_html = utils.get_webcontent(URL_LIVE) data_account = re.compile(r'accountId":"(.*?)"').findall(live_html)[0] data_player = re.compile(r'playerId":"(.*?)"').findall(live_html)[0] data_video_id = re.compile(r'assetId":"(.*?)"').findall(live_html)[0] return resolver.get_brightcove_video_json(data_account, data_player, data_video_id)
def get_video_url(params): """Get video URL and start video player""" if params.next == 'download_video': return params.video_url elif params.next == 'play_r': video_html = utils.get_webcontent(params.video_url) video_data = video_html.split('addPlayer(')[1].split(');')[0].replace( "\n", "").replace("\r", "").split(',') data_account = video_data[0].strip().replace("'", "") data_player = video_data[1].strip().replace("'", "") if params.module_name == 'tx': data_video_id = video_data[4].strip().replace("'", "") else: data_video_id = 'ref:' + video_data[4].strip().replace("'", "") json_parser = resolver.get_brightcove_video_json( data_account, data_player, data_video_id) video_url = '' for url in json_parser["sources"]: if 'm3u8' in url["src"]: video_url = url["src"] return video_url
def get_video_url(params): """Get video URL and start video player""" if params.next == 'play_l': return params.url_live elif params.channel_name == 'rmcdecouverte' and params.next == 'play_r': url_video_datas = utils.get_webcontent(URL_VIDEO_HTML_RMCDECOUVERTE % (params.video_id)) video_datas_soup = bs(url_video_datas, 'html.parser') video_datas = video_datas_soup.find('div', class_='next-player') data_account = video_datas['data-account'] data_video_id = video_datas['data-video-id'] data_player = video_datas['data-player'] return resolver.get_brightcove_video_json(data_account, data_player, data_video_id) elif params.channel_name == 'rmcdecouverte' and \ params.next == 'download_video': return URL_VIDEO_HTML_RMCDECOUVERTE % (params.video_id) elif params.channel_name != 'rmcdecouverte' and \ (params.next == 'play_r' or params.next == 'download_video'): file_medias = utils.get_webcontent( URL_VIDEO % (params.channel_name, get_token( params.channel_name), params.video_id)) json_parser = json.loads(file_medias) if params.next == 'download_video': return json_parser['video']['long_url'].encode('utf-8') video_streams = json_parser['video']['medias'] desired_quality = common.PLUGIN.get_setting('quality') if desired_quality == "DIALOG": all_datas_videos_quality = [] all_datas_videos_path = [] for datas in video_streams: all_datas_videos_quality.append("Video Height : " + str(datas['frame_height']) + " (Encoding : " + str(datas['encoding_rate']) + ")") all_datas_videos_path.append(datas['video_url']) seleted_item = common.sp.xbmcgui.Dialog().select( common.GETTEXT('Choose video quality'), all_datas_videos_quality) return all_datas_videos_path[seleted_item].encode('utf-8') elif desired_quality == 'BEST': # GET LAST NODE (VIDEO BEST QUALITY) url_best_quality = '' for datas in video_streams: url_best_quality = datas['video_url'].encode('utf-8') return url_best_quality else: # DEFAULT VIDEO return json_parser['video']['video_url'].encode('utf-8')
def start_live_tv_stream(params): url_live_data = '' if params.channel_name == 'rmcdecouverte': url_live_data = URL_LIVE_RMCDECOUVERTE elif params.channel_name == 'bfmtv': url_live_data = URL_LIVE_BFMTV elif params.channel_name == 'bfmparis': url_live_data = URL_LIVE_BFM_PARIS elif params.channel_name == 'bfmbusiness': url_live_data = URL_LIVE_BFMBUSINESS elif params.channel_name == 'rmc': url_live_data = URL_LIVE_BFM_SPORT live_html = utils.get_webcontent(url_live_data) live_soup = bs(live_html, 'html.parser') if params.channel_name == 'rmcdecouverte': data_live_soup = live_soup.find('div', class_='next-player') data_account = data_live_soup['data-account'] data_video_id = data_live_soup['data-video-id'] data_player = data_live_soup['data-player'] else: data_live_soup = live_soup.find('div', class_='BCLvideoWrapper') data_account = data_live_soup.find('script')['data-account'] data_video_id = data_live_soup.find('script')['data-video-id'] data_player = data_live_soup.find('script')['data-player'] url_live = resolver.get_brightcove_video_json(data_account, data_player, data_video_id) params['next'] = 'play_l' params['url_live'] = url_live return get_video_url(params)
def get_video_url(params): """Get video URL and start video player""" if params.next == 'play_r' or params.next == 'download_video': return resolver.get_brightcove_video_json(params.data_account, params.data_player, params.data_vidid)
def get_video_url(params): """Get video URL and start video player""" if params.next == 'download_video': return params.video_url elif params.next == 'play_r': video_html = utils.get_webcontent(params.video_url) video_data = video_html.split( 'addPlayer(')[1].split( ');')[0].replace( "\n", "").replace("\r", "").split(',') data_account = video_data[0].strip().replace("'", "") data_player = video_data[1].strip().replace("'", "") if params.module_name == 'tx': data_video_id = video_data[4].strip().replace("'", "") else: data_video_id = 'ref:' + video_data[4].strip().replace("'", "") json_parser = resolver.get_brightcove_video_json( data_account, data_player, data_video_id) video_url = '' for url in json_parser["sources"]: if 'm3u8' in url["src"]: video_url = url["src"] return video_url
def get_video_url(params): """Get video URL and start video player""" if params.next == 'play_l': file_path = utils.get_webcontent(URL_LIVE) data_account = re.compile(r'data-account\'\,\'(.*?)\'').findall( file_path)[0] data_player = re.compile(r'data-player\'\,\'(.*?)\'').findall( file_path)[0] data_video_id = re.compile(r'data-video-id\'\,\'(.*?)\'').findall( file_path)[0] return resolver.get_brightcove_video_json(data_account, data_player, data_video_id)
def start_live_tv_stream(params): url_live_data = '' if params.channel_name == 'rmcdecouverte': url_live_data = URL_LIVE_RMCDECOUVERTE elif params.channel_name == 'bfmtv': url_live_data = URL_LIVE_BFMTV elif params.channel_name == 'bfmparis': url_live_data = URL_LIVE_BFM_PARIS elif params.channel_name == 'bfmbusiness': url_live_data = URL_LIVE_BFMBUSINESS elif params.channel_name == 'rmc': url_live_data = URL_LIVE_BFM_SPORT live_html = utils.get_webcontent( url_live_data) live_soup = bs(live_html, 'html.parser') if params.channel_name == 'rmcdecouverte': data_live_soup = live_soup.find( 'div', class_='next-player') data_account = data_live_soup['data-account'] data_video_id = data_live_soup['data-video-id'] data_player = data_live_soup['data-player'] else: data_live_soup = live_soup.find( 'div', class_='BCLvideoWrapper') data_account = data_live_soup.find( 'script')['data-account'] data_video_id = data_live_soup.find( 'script')['data-video-id'] data_player = data_live_soup.find( 'script')['data-player'] json_parser = resolver.get_brightcove_video_json( data_account, data_player, data_video_id) if json_parser["long_description"]: plot = json_parser["long_description"] plot = plot.encode('utf-8') for url in json_parser["sources"]: url_live = url["src"].encode('utf-8') params['next'] = 'play_l' params['url_live'] = url_live return get_video_url(params)
def get_video_url(params): """Get video URL and start video player""" if params.next == 'play_l': file_path = utils.get_webcontent(URL_LIVE) data_account = '' data_player = '' data_video_id = '' if re.compile(r'data-account="(.*?)"').findall(file_path) > 0: data_account = re.compile(r'data-account="(.*?)"').findall( file_path)[0] data_player = re.compile(r'data-player="(.*?)"').findall( file_path)[0] data_video_id = re.compile(r'data-video-id="(.*?)"').findall( file_path)[0] else: data_account = re.compile(r'accountId\: "(.*?)"').findall( file_path)[0] data_player = re.compile(r'player\: "(.*?)"').findall(file_path)[0] data_video_id = re.compile(r'videoId\: "(.*?)"').findall( file_path)[0] return resolver.get_brightcove_video_json(data_account, data_player, data_video_id)
def list_live(params): """Build live listing""" lives = [] title = '' plot = '' duration = 0 img = '' url_live = '' list_urls_live = [] if params.channel_name == 'rmcdecouverte': list_urls_live.append(URL_LIVE_RMCDECOUVERTE) elif params.channel_name == 'bfmtv': list_urls_live.append(URL_LIVE_BFMTV) list_urls_live.append(URL_LIVE_BFM_PARIS) elif params.channel_name == 'bfmbusiness': list_urls_live.append(URL_LIVE_BFMBUSINESS) elif params.channel_name == 'rmc': list_urls_live.append(URL_LIVE_BFM_SPORT) for url_live_data in list_urls_live: live_html = utils.get_webcontent( url_live_data) live_soup = bs(live_html, 'html.parser') if params.channel_name == 'rmcdecouverte': data_live_soup = live_soup.find( 'div', class_='next-player') data_account = data_live_soup['data-account'] data_video_id = data_live_soup['data-video-id'] data_player = data_live_soup['data-player'] else: data_live_soup = live_soup.find( 'div', class_='BCLvideoWrapper') data_account = data_live_soup.find( 'script')['data-account'] data_video_id = data_live_soup.find( 'script')['data-video-id'] data_player = data_live_soup.find( 'script')['data-player'] json_parser = resolver.get_brightcove_video_json( data_account, data_player, data_video_id) title = json_parser["name"] plot = '' if json_parser["long_description"]: plot = json_parser["long_description"] plot = plot.encode('utf-8') for url in json_parser["sources"]: url_live = url["src"].encode('utf-8') if 'poster' in json_parser: img = json_parser["poster"].encode('utf-8') info = { 'video': { 'title': title, 'plot': plot, 'duration': duration } } lives.append({ 'label': title, 'fanart': img, 'thumb': img, 'url': common.PLUGIN.get_url( action='channel_entry', next='play_l', url_live=url_live, ), 'is_playable': True, 'info': info }) return common.PLUGIN.create_listing( lives, sort_methods=( common.sp.xbmcplugin.SORT_METHOD_UNSORTED, common.sp.xbmcplugin.SORT_METHOD_LABEL ) )
def list_videos(params): """Build videos listing""" videos = [] if params.channel_name == 'rmcdecouverte': file_path = utils.download_catalog( URL_VIDEO_HTML_RMCDECOUVERTE % (params.video_id), '%s_%s_replay.html' % (params.channel_name, params.video_id)) video_html = open(file_path).read() video_soup = bs(video_html, 'html.parser') data_video_soup = video_soup.find('div', class_='next-player') data_account = data_video_soup['data-account'] data_video_id = data_video_soup['data-video-id'] data_player = data_video_soup['data-player'] json_parser = resolver.get_brightcove_video_json( data_account, data_player, data_video_id) video_title = '' program_title = '' for program in json_parser["tags"]: program_title = program.upper() + ' - ' video_title = program_title + \ json_parser["name"].encode('utf-8').lower() video_img = '' for poster in json_parser["poster_sources"]: video_img = poster["src"] video_plot = json_parser["long_description"].encode('utf-8') video_duration = 0 video_duration = json_parser["duration"] / 1000 video_url = '' for url in json_parser["sources"]: if 'type' in url: video_url = url["src"].encode('utf-8') date_value_list = json_parser["published_at"].split('T')[0].split('-') day = date_value_list[2] mounth = date_value_list[1] year = date_value_list[0] date = '.'.join((day, mounth, year)) aired = '-'.join((year, mounth, day)) info = { 'video': { 'title': video_title, 'aired': aired, 'date': date, 'duration': video_duration, 'plot': video_plot, 'year': year, 'mediatype': 'tvshow' } } download_video = ( _('Download'), 'XBMC.RunPlugin(' + common.PLUGIN.get_url( action='download_video', video_id=params.video_id) + ')' ) context_menu = [] context_menu.append(download_video) videos.append({ 'label': video_title, 'thumb': video_img, 'fanart': video_img, 'url': common.PLUGIN.get_url( action='channel_entry', next='play_r', video_url=video_url ), 'is_playable': True, 'info': info, 'context_menu': context_menu }) else: if 'previous_listing' in params: videos = ast.literal_eval(params['previous_listing']) if params.next == 'list_videos_1': file_path = utils.download_catalog( URL_SHOW % ( params.channel_name, get_token(params.channel_name), params.category, params.page), '%s_%s_%s.json' % ( params.channel_name, params.category, params.page)) file_show = open(file_path).read() json_show = json.loads(file_show) for video in json_show['videos']: video_id = video['video'].encode('utf-8') video_id_ext = video['id_ext'].encode('utf-8') category = video['category'].encode('utf-8') title = video['title'].encode('utf-8') description = video['description'].encode('utf-8') # begin_date = video['begin_date'] # 1486725600, image = video['image'].encode('utf-8') duration = video['video_duration_ms'] / 1000 value_date = time.strftime( '%d %m %Y', time.localtime(video["begin_date"])) date = str(value_date).split(' ') day = date[0] mounth = date[1] year = date[2] date = '.'.join((day, mounth, year)) aired = '-'.join((year, mounth, day)) info = { 'video': { 'title': title, 'plot': description, 'aired': aired, 'date': date, 'duration': duration, 'year': year, 'genre': category, 'mediatype': 'tvshow' } } download_video = ( _('Download'), 'XBMC.RunPlugin(' + common.PLUGIN.get_url( action='download_video', video_id=video_id) + ')' ) context_menu = [] context_menu.append(download_video) videos.append({ 'label': title, 'thumb': image, 'url': common.PLUGIN.get_url( action='channel_entry', next='play_r', video_id=video_id, video_id_ext=video_id_ext ), 'is_playable': True, 'info': info, 'context_menu': context_menu }) # More videos... videos.append({ 'label': common.ADDON.get_localized_string(30100), 'url': common.PLUGIN.get_url( action='channel_entry', category=params.category, next='list_videos_1', title=title, page=str(int(params.page) + 1), window_title=params.window_title, update_listing=True, previous_listing=str(videos) ) }) return common.PLUGIN.create_listing( videos, sort_methods=( common.sp.xbmcplugin.SORT_METHOD_UNSORTED, common.sp.xbmcplugin.SORT_METHOD_DURATION, common.sp.xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE, common.sp.xbmcplugin.SORT_METHOD_GENRE, common.sp.xbmcplugin.SORT_METHOD_UNSORTED ), content='tvshows', update_listing='update_listing' in params, category=common.get_window_title() )
def list_videos(params): """Build videos listing""" videos = [] if params.channel_name == 'rmcdecouverte': file_path = utils.download_catalog( URL_VIDEO_HTML_RMCDECOUVERTE % (params.video_id), '%s_%s_replay.html' % (params.channel_name, params.video_id)) video_html = open(file_path).read() video_soup = bs(video_html, 'html.parser') data_video_soup = video_soup.find('div', class_='next-player') data_account = data_video_soup['data-account'] data_video_id = data_video_soup['data-video-id'] data_player = data_video_soup['data-player'] json_parser = resolver.get_brightcove_video_json( data_account, data_player, data_video_id) video_title = '' program_title = '' for program in json_parser["tags"]: program_title = program.upper() + ' - ' video_title = program_title + \ json_parser["name"].encode('utf-8').lower() video_img = '' for poster in json_parser["poster_sources"]: video_img = poster["src"] video_plot = json_parser["long_description"].encode('utf-8') video_duration = 0 video_duration = json_parser["duration"] / 1000 video_url = '' for url in json_parser["sources"]: if 'type' in url: video_url = url["src"].encode('utf-8') date_value_list = json_parser["published_at"].split('T')[0].split('-') day = date_value_list[2] mounth = date_value_list[1] year = date_value_list[0] date = '.'.join((day, mounth, year)) aired = '-'.join((year, mounth, day)) info = { 'video': { 'title': video_title, 'aired': aired, 'date': date, 'duration': video_duration, 'plot': video_plot, 'year': year, 'mediatype': 'tvshow' } } download_video = ( common.GETTEXT('Download'), 'XBMC.RunPlugin(' + common.PLUGIN.get_url( action='download_video', module_path=params.module_path, module_name=params.module_name, video_id=params.video_id) + ')' ) context_menu = [] context_menu.append(download_video) videos.append({ 'label': video_title, 'thumb': video_img, 'fanart': video_img, 'url': common.PLUGIN.get_url( module_path=params.module_path, module_name=params.module_name, action='replay_entry', next='play_r', video_url=video_url ), 'is_playable': True, 'info': info, 'context_menu': context_menu }) else: if 'previous_listing' in params: videos = ast.literal_eval(params['previous_listing']) if params.next == 'list_videos_1': file_path = utils.download_catalog( URL_SHOW % ( params.channel_name, get_token(params.channel_name), params.category, params.page), '%s_%s_%s.json' % ( params.channel_name, params.category, params.page)) file_show = open(file_path).read() json_show = json.loads(file_show) for video in json_show['videos']: video_id = video['video'].encode('utf-8') video_id_ext = video['id_ext'].encode('utf-8') category = video['category'].encode('utf-8') title = video['title'].encode('utf-8') description = video['description'].encode('utf-8') # begin_date = video['begin_date'] # 1486725600, image = video['image'].encode('utf-8') duration = video['video_duration_ms'] / 1000 value_date = time.strftime( '%d %m %Y', time.localtime(video["begin_date"])) date = str(value_date).split(' ') day = date[0] mounth = date[1] year = date[2] date = '.'.join((day, mounth, year)) aired = '-'.join((year, mounth, day)) info = { 'video': { 'title': title, 'plot': description, 'aired': aired, 'date': date, 'duration': duration, 'year': year, 'genre': category, 'mediatype': 'tvshow' } } download_video = ( common.GETTEXT('Download'), 'XBMC.RunPlugin(' + common.PLUGIN.get_url( action='download_video', module_path=params.module_path, module_name=params.module_name, video_id=video_id) + ')' ) context_menu = [] context_menu.append(download_video) videos.append({ 'label': title, 'thumb': image, 'url': common.PLUGIN.get_url( module_path=params.module_path, module_name=params.module_name, action='replay_entry', next='play_r', video_id=video_id, video_id_ext=video_id_ext ), 'is_playable': True, 'info': info, 'context_menu': context_menu }) # More videos... videos.append({ 'label': common.ADDON.get_localized_string(30700), 'url': common.PLUGIN.get_url( module_path=params.module_path, module_name=params.module_name, action='replay_entry', category=params.category, next='list_videos_1', title=title, page=str(int(params.page) + 1), window_title=params.window_title, update_listing=True, previous_listing=str(videos) ) }) return common.PLUGIN.create_listing( videos, sort_methods=( common.sp.xbmcplugin.SORT_METHOD_UNSORTED, common.sp.xbmcplugin.SORT_METHOD_DURATION, common.sp.xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE, common.sp.xbmcplugin.SORT_METHOD_GENRE, common.sp.xbmcplugin.SORT_METHOD_UNSORTED ), content='tvshows', update_listing='update_listing' in params, category=common.get_window_title() )
def get_video_url(params): """Get video URL and start video player""" return resolver.get_brightcove_video_json( params.data_account, params.data_player, params.data_video_id)