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("#EXTM3Un")
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()