本帖最后由 huhus123 于 2020-3-10 15:52 编辑
用potplayer播放很方便,在办公电脑上看看想看的直播很舒服。[Python] 纯文本查看 复制代码 import requests
ret = requests.get("https://www.huya.com/cache.php?m=LiveList&do=getLiveListByPage&gameId=2135&tagAll=0&page=1")
got = ret.json()['data']['datas']
f = open("./test.m3u", "a+")
f.write("#EXTM3U\n")
for i in range(len(got)):
room = got[i]['roomName']
if got[i]['roomName'] == 'null':
room = got[i]['nick']
info = "http://tx.hls.huya.com/huyalive/" + got[i]['screenshot'].split('/')[4] + "_4000.m3u8"
f.write('#EXTINF:-1 group-title="一起看",{}\n'.format(room))
f.write(info)
f.write("\n")
f.close()
代码很简单,url里面“page=1”意思是第一页
2020年3月10日更新:
之前抓的直播源失效了,但是整体思路没有变,我重新抓了一下直播源,更改代码如下,申明一点我写的只是核心代码你们想获取什么节目,请自行发挥!
[Python] 纯文本查看 复制代码 import requests
ret = requests.get("https://www.huya.com/cache.php?m=LiveList&do=getLiveListByPage&gameId=2135&tagAll=0&page=1")
got = ret.json()['data']['datas']
f = open("./test.m3u", "w+")
f.write("#EXTM3U\n")
for i in range(len(got)):
room = got[i]['roomName']
if got[i]['roomName'] == 'null':
room = got[i]['nick']
info = "http://aldirect.rtmp.huya.com/backsrc/" + got[i]['screenshot'].split('/')[4] + ".m3u8"
f.write('#EXTINF:-1 group-title="一起看",{}\n'.format(room))
f.write(info)
f.write("\n")
f.close()
知道的人多了难免会失效,先这么着吧。。工作生活上的事情比较多,这个只是用来娱乐 |