本文整理汇总了Python中resources.lib.utils.get_webcontent函数的典型用法代码示例。如果您正苦于以下问题:Python get_webcontent函数的具体用法?Python get_webcontent怎么用?Python get_webcontent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_webcontent函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_video_url
def get_video_url(params):
"""Get video URL and start video player"""
if params.next == 'play_l':
return resolver.get_stream_youtube(params.video_id, False)
elif params.next == 'play_r_news':
return resolver.get_stream_youtube(params.video_id, False)
elif params.next == 'play_r_sports':
data_embed_token = utils.get_webcontent(
URL_PCODE_EMBED_TOKEN)
pcode = re.compile(
'sas/embed_token/(.*?)/all').findall(data_embed_token)[0]
data_embed_token = urllib.quote_plus(
data_embed_token.replace('"',''))
video_vod = utils.get_webcontent(
URL_OOYALA_VOD % (pcode, params.video_id, data_embed_token))
json_parser = json.loads(video_vod)
# Get Value url encodebase64
if 'streams' in json_parser["authorization_data"][params.video_id]:
for stream in json_parser["authorization_data"][params.video_id]["streams"]:
url_base64 = stream["url"]["data"]
return base64.standard_b64decode(url_base64)
else:
return None
elif params.next == 'download_video':
return resolver.get_stream_youtube(params.video_id, True)
示例2: get_video_url
def get_video_url(params):
"""Get video URL and start video player"""
if params.next == 'play_r' or params.next == 'download_video':
url = ''
html_video = utils.get_webcontent(params.url_video)
if 'dailymotion' in html_video:
video_id = re.compile(
r'www.dailymotion.com/embed/video/(.*?)[\?\"]').findall(
html_video)[0]
if params.next == 'download_video':
return resolver.get_stream_dailymotion(video_id, True)
else:
return resolver.get_stream_dailymotion(video_id, False)
else:
# get videoId and accountId
videoId, accountId = re.compile(
r'embed/(.*?)/(.*?)/').findall(html_video)[0]
html_json = utils.get_webcontent(
URL_VIDEO_REPLAY % (videoId, accountId))
html_json_2 = re.compile(r'\((.*?)\);').findall(html_json)[0]
json_parser = json.loads(html_json_2)
for playlist in json_parser['Playlist']:
datas_video = playlist['MediaFiles']['M3u8']
for data in datas_video:
url = data['Url']
return url
elif params.next == 'play_l':
return resolver.get_stream_dailymotion(params.video_id, False)
示例3: get_video_url
def get_video_url(params):
"""Get video URL and start video player"""
if params.next == 'play_r' or params.next == 'download_video':
if 'http' in params.video_url:
video_html = utils.get_webcontent(
params.video_url)
stream_id = re.compile(
'\'media_id\' : "(.*?)"').findall(video_html)[0]
streams_jsonparser = json.loads(
utils.get_webcontent(URL_STREAM % stream_id))
url = ''
if 'mediaList' in streams_jsonparser:
# Case Jarvis
if common.sp.xbmc.__version__ == '2.24.0':
for stream in streams_jsonparser["mediaList"][0]["mobileUrls"]:
if 'MobileH264' in stream["targetMediaPlatform"]:
url = stream["mobileUrl"]
# Case Krypton and ...
else:
for stream in streams_jsonparser["mediaList"][0]["mobileUrls"]:
if 'HttpLiveStreaming' in stream["targetMediaPlatform"]:
url = stream["mobileUrl"]
return url
else:
return ''
else:
return ''
示例4: get_video_url
def get_video_url(params):
"""Get video URL and start video player"""
video_json = utils.get_webcontent(
URL_JSON_VIDEO % (params.video_id),
random_ua=True)
json_parser = json.loads(video_json)
video_assets = json_parser['clips'][0]['assets']
if video_assets is None:
utils.send_notification(common.ADDON.get_localized_string(30712))
return ''
# "type":"primetime_phls_h264" => Video protected by DRM (m3u8)
# "type":"usp_hls_h264" => Video not protected by DRM (m3u8)
# "type":"usp_dashcenc_h264" => No supported by Kodi (MDP)
# "type":"usp_hlsfp_h264" => Video protected by DRM (m3u8)
# "type":"http_h264" => Video not proted by DRM (mp4) (Quality SD "video_quality":"sd", HD "video_quality":"hq", HD "video_quality":"hd", HD "video_quality":"lq", 3G)
# "type":"http_subtitle_vtt_sm" => Subtitle (in English TVShows)
desired_quality = common.PLUGIN.get_setting('quality')
all_datas_videos_quality = []
all_datas_videos_path = []
for asset in video_assets:
if 'http_h264' in asset["type"]:
all_datas_videos_quality.append(asset["video_quality"])
all_datas_videos_path.append(
asset['full_physical_path'].encode('utf-8'))
elif 'h264' in asset["type"]:
manifest = utils.get_webcontent(
asset['full_physical_path'].encode('utf-8'),
random_ua=True)
if 'drm' not in manifest:
all_datas_videos_quality.append(asset["video_quality"])
all_datas_videos_path.append(
asset['full_physical_path'].encode('utf-8'))
if len(all_datas_videos_quality) == 0:
utils.send_notification(common.ADDON.get_localized_string(30702))
return ''
elif len(all_datas_videos_quality) == 1:
return all_datas_videos_path[0]
else:
if desired_quality == "DIALOG":
seleted_item = common.sp.xbmcgui.Dialog().select(
common.GETTEXT('Choose video quality'),
all_datas_videos_quality)
if seleted_item == -1:
return ''
return all_datas_videos_path[seleted_item]
elif desired_quality == "BEST":
url_best = ''
i = 0
for data_video in all_datas_videos_quality:
if 'lq' not in data_video:
url_best = all_datas_videos_path[i]
i = i + 1
return url_best
else:
return all_datas_videos_path[0]
示例5: list_videos_categories
def list_videos_categories(params):
"""Build videos categories listing"""
videos_categories = []
url = ''.join((
params.program_url,
'/videos'))
program_html = utils.get_webcontent(url)
program_soup = bs(program_html, 'html.parser')
filters_1_soup = program_soup.find(
'ul',
class_='filters_1')
if filters_1_soup is not None:
for li in filters_1_soup.find_all('li'):
category_title = li.get_text().encode('utf-8')
category_id = li.find('a')['data-filter'].encode('utf-8')
# Get Last Page of each categorie
# Get First page :
url_first_page = ''.join((
params.program_url,
'/videos',
'?filter=',
category_id))
program_first_page_html = utils.get_webcontent(url_first_page)
program_first_page_soup = bs(
program_first_page_html, 'html.parser')
# Get Last page :
last_page = '0'
if program_first_page_soup.find(
'a', class_='icon i-chevron-right-double trackXiti'
) is not None:
last_page = program_first_page_soup.find(
'a',
class_='icon i-chevron-right-double trackXiti'
).get('href').rsplit('/')[-1].split('?')[0]
videos_categories.append({
'label': category_title,
'url': common.PLUGIN.get_url(
module_path=params.module_path,
module_name=params.module_name,
action='replay_entry',
program_url=params.program_url,
page='1',
last_page=last_page,
next='list_videos',
window_title=category_title,
category_id=category_id
)
})
return common.PLUGIN.create_listing(
videos_categories,
sort_methods=(
common.sp.xbmcplugin.SORT_METHOD_UNSORTED,
common.sp.xbmcplugin.SORT_METHOD_LABEL
),
category=common.get_window_title()
)
示例6: get_video_url
def get_video_url(params):
"""Get video URL and start video player"""
if params.next == 'play_r' or params.next == 'download_video':
video_html = utils.get_webcontent(
params.video_url)
video_id = re.compile(
r'itemId":"(.*?)"').findall(video_html)[0]
json_video_stream = utils.get_webcontent(
URL_STREAM % video_id)
json_video_stream_parser = json.loads(json_video_stream)
return json_video_stream_parser["package"]["video"]["item"][0]["rendition"][0]["src"]
示例7: get_video_url
def get_video_url(params):
"""Get video URL and start video player"""
if params.next == 'play_l':
return params.url
elif params.next == 'play_r' or params.next == 'download_video':
video_html = utils.get_webcontent(params.video_url)
videoId = re.compile('data-uvid="(.*?)"').findall(video_html)[0]
apikey_html = utils.get_webcontent(URL_API_KEY)
apikey = re.compile('"apiKey": "(.*?)"').findall(apikey_html)[0]
stream_html = utils.get_webcontent(URL_STREAM % (apikey, videoId))
return re.compile('"hls":"(.*?)"').findall(stream_html)[0]
示例8: get_video_url
def get_video_url(params):
"""Get video URL and start video player"""
if params.next == 'play_r' or params.next == 'download_video':
video_html = utils.get_webcontent(
params.video_url)
video_id = re.compile(
r'item_longId" \: "(.*?)"').findall(video_html)[0]
xml_video_stream = utils.get_webcontent(
URL_STREAM % video_id)
return re.compile(
r'src\>(.*?)\<').findall(xml_video_stream)[0]
示例9: get_video_url
def get_video_url(params):
"""Get video URL and start video player"""
if params.next == 'play_r' or params.next == 'download_video':
video_html = utils.get_webcontent(
params.video_url)
url_video = re.compile(
r'jQuery.get\("(.*?)"').findall(video_html)[0]
if params.next == 'download_video':
return url_video
else:
url = utils.get_webcontent(
url_video)
return re.compile(
r'src="(.*?)"').findall(url)[0]
示例10: get_live_item
def get_live_item(params):
lives = []
title = ''
plot = ''
duration = 0
img = ''
url_live = ''
for town_name, live_id in LIVES_TOWN.iteritems():
title = 'YES TV : ' + town_name + ' Live TV'
live_html = utils.get_webcontent(
URL_LIVE % live_id)
url_live_2 = re.compile(
'iframe src="(.*?) "').findall(live_html)[0]
url_live_2 = url_live_2 + live_id
live_html_2 = utils.get_webcontent(url_live_2)
live_json = re.compile(
'sources\:(.*?)\]\,').findall(live_html_2)[0]
live_jsonpaser = json.loads(live_json + ']')
url_live = 'http:' + live_jsonpaser[0]["file"]
info = {
'video': {
'title': title,
'plot': plot,
'duration': duration
}
}
lives.append({
'label': title,
'fanart': img,
'thumb': img,
'url': common.PLUGIN.get_url(
action='start_live_tv_stream',
next='play_l',
module_name=params.module_name,
module_path=params.module_path,
url=url_live,
),
'is_playable': True,
'info': info
})
return lives
示例11: getVideoURL
def getVideoURL(channel,id):
filPrgm = utils.get_webcontent(showInfo % (id))
jsonParser = json.loads(filPrgm)
for video in jsonParser['videos']:
if video['format']==globalvar.ADDON.getSetting('%sQuality' % (channel)):
url = video['url']
return url
示例12: get_video_url
def get_video_url(params):
"""Get video URL and start video player"""
url_selected = ''
all_datas_videos_quality = []
all_datas_videos_path = []
videos_html = utils.get_webcontent(params.video_url)
videos_soup = bs(videos_html, 'html.parser')
list_videos = videos_soup.find(
'ul', class_='nav nav-tabs').find_all('a')
for video in list_videos:
if '#video-' in video.get('href'):
# Find a better solution to strip
all_datas_videos_quality.append(video.get_text().strip())
# Get link
value_jwplayer_id = video.get('data-jwplayer-id')
# Case mp4
if value_jwplayer_id != '':
list_streams = videos_soup.find_all(
'div', class_='jwplayer')
for stream in list_streams:
if stream.get('id') == value_jwplayer_id:
url = stream.get('data-source')
# Cas Yt
else:
video_id = re.compile(
'youtube.com/embed/(.*?)\?').findall(videos_html)[0]
url = resolver.get_stream_youtube(video_id, False)
all_datas_videos_path.append(url)
# Get link from FranceTV
elif '#ftv-player-' in video.get('href'):
# Find a better solution to strip
all_datas_videos_quality.append(video.get_text().strip())
# Get link
value_ftvlayer_id = video.get('data-ftvplayer-id')
list_streams = videos_soup.find_all(
'iframe', class_='embed-responsive-item')
for stream in list_streams:
if stream.get('id') == value_ftvlayer_id:
url_id = stream.get('src')
ydl = YoutubeDL()
ydl.add_default_info_extractors()
with ydl:
result = ydl.extract_info(
url_id, download=False)
for format_video in result['formats']:
url = format_video['url']
all_datas_videos_path.append(url)
if len(all_datas_videos_quality) > 1:
seleted_item = common.sp.xbmcgui.Dialog().select(
common.GETTEXT('Choose video quality'),
all_datas_videos_quality)
if seleted_item == -1:
return ''
url_selected = all_datas_videos_path[seleted_item]
return url_selected
else:
return all_datas_videos_path[0]
示例13: getVideoURL
def getVideoURL(channel,id):
#xbmc.log("channel:"+str(channel))
#xbmc.log("id:"+str(id))
html=utils.get_webcontent(urlVideo % id)
url= re.findall("file:\"(.*\/"+id[3:len(id)]+"\/.*)\"",html) [0]
#xbmc.log("url:"+str(url))
return url
示例14: get_live_item
def get_live_item(params):
plot = ''
duration = 0
img = ''
live_html = utils.get_webcontent(URL_LIVE)
live_id = re.compile(
'iframe.dacast.com\/(.*?)"').findall(live_html)[0]
info = {
'video': {
'title': params.channel_label,
'plot': plot,
'duration': duration
}
}
return {
'label': params.channel_label,
'fanart': img,
'thumb': img,
'url': common.PLUGIN.get_url(
module_path=params.module_path,
module_name=params.module_name,
action='start_live_tv_stream',
next='play_l',
live_id=live_id,
),
'is_playable': True,
'info': info
}
示例15: get_video_url
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