1
0
mirror of https://github.com/wbt5/real-url.git synced 2025-12-16 23:10:29 +08:00
zhibo-url/kuaishou.py
2020-01-03 00:16:40 +08:00

25 lines
831 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 获取快手直播的真实流媒体地址,默认输出最高画质
import requests
import json
import re
def get_real_url(rid):
try:
room_url = 'https://m.gifshow.com/fw/live/' + str(rid)
headers = {
'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1'}
response = requests.get(url=room_url, headers=headers).text
m3u8_url = re.findall(r'type="video/mp4" src="([\s\S]*?)_sd1000tp.m3u8', response)[0]
real_url = [m3u8_url + i for i in ['.flv', '.m3u8']]
except:
real_url = '该直播间不存在或未开播'
return real_url
rid = input('请输入快手直播间ID\n')
real_url = get_real_url(rid)
print('该直播源地址为:')
print(real_url)