本文整理汇总了Python中ykdl.videoinfo.VideoInfo.live方法的典型用法代码示例。如果您正苦于以下问题:Python VideoInfo.live方法的具体用法?Python VideoInfo.live怎么用?Python VideoInfo.live使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ykdl.videoinfo.VideoInfo
的用法示例。
在下文中一共展示了VideoInfo.live方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prepare
# 需要导入模块: from ykdl.videoinfo import VideoInfo [as 别名]
# 或者: from ykdl.videoinfo.VideoInfo import live [as 别名]
def prepare(self):
info = VideoInfo(self.name, True)
html = get_content(self.url)
t_a = match1(html, '"keywords" content="([^"]+)')
info.title = t_a.split(',')[0]
info.artist = t_a.split(',')[1]
replay_url = match1(html, '"m3u8":"([^"]+)')
if replay_url:
replay_url = replay_url.replace('\/','/')
info.live = False
info.stream_types.append('current')
info.streams['current'] = {'container': 'm3u8', 'video_profile': 'current', 'src' : [replay_url], 'size': float('inf')}
return info
self.vid = match1(html, '"sn":"([^"]+)')
channel = match1(html, '"channel":"([^"]+)')
api_url = 'http://g2.live.360.cn/liveplay?stype=flv&channel={}&bid=huajiao&sn={}&sid={}&_rate=xd&ts={}&r={}&_ostype=flash&_delay=0&_sign=null&_ver=13'.format(channel, self.vid, SID, time.time(),random.random())
encoded_json = get_content(api_url)
decoded_json = base64.decodestring(compact_bytes(encoded_json[0:3]+ encoded_json[6:], 'utf-8')).decode('utf-8')
video_data = json.loads(decoded_json)
live_url = video_data['main']
info.live = True
info.stream_types.append('current')
info.streams['current'] = {'container': 'flv', 'video_profile': 'current', 'src' : [live_url], 'size': float('inf')}
return info
示例2: prepare
# 需要导入模块: from ykdl.videoinfo import VideoInfo [as 别名]
# 或者: from ykdl.videoinfo.VideoInfo import live [as 别名]
def prepare(self):
info = VideoInfo(self.name)
info.live = True
self.vid = self.url[self.url.rfind('/')+1:].split(".")[0]
json_request_url = 'http://www.yizhibo.com/live/h5api/get_basic_live_info?scid={}'.format(self.vid)
content = json.loads(get_content(json_request_url))
assert content['result'] == 1, "Error : {}".format(content['result'])
info.title = content['data']['live_title']
info.artist = content['data']['nickname']
info.streams['current'] = {'container': 'm3u8', 'video_profile': 'current', 'src' : [content['data']['play_url']], 'size': float('inf')}
info.stream_types.append('current')
return info
示例3: prepare
# 需要导入模块: from ykdl.videoinfo import VideoInfo [as 别名]
# 或者: from ykdl.videoinfo.VideoInfo import live [as 别名]
def prepare(self):
info = VideoInfo(self.name)
html = get_content(self.url)
video_type = match1(html, 'VideoType":"([^"]+)"')
if video_type == 'LIVE':
info.live = True
elif not video_type == 'VOD':
raise NotImplementedError('Unknown_video_type')
info.title = match1(html, '<title>([^<]+)').split("_")[0]
if info.live:
rtmp_id = match1(html, 'videoId":"([^"]+)"').replace('\\/','/')
real_url = self.live_base+'/'+rtmp_id+'.m3u8'
info.stream_types, info.streams = load_m3u8_playlist(real_url)
else:
vod_m3u8 = self.vod_base + '/' + match1(html, 'VideoID":"([^"]+)').replace('\\/','/')
info.stream_types.append('current')
info.streams['current'] = {'container': 'm3u8', 'video_profile': 'current', 'src' : [vod_m3u8], 'size': 0}
return info