From 0d8d701958abb7596ebf6ba9b243cf90d08fa1dd Mon Sep 17 00:00:00 2001 From: auqhjjqdo Date: Sun, 26 Nov 2023 14:03:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DYoutube=E7=9B=B4=E6=92=AD?= =?UTF-8?q?=E4=B8=8D=E5=BD=95=E5=88=B6=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- live_recorder.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/live_recorder.py b/live_recorder.py index 3803310..21b7912 100644 --- a/live_recorder.py +++ b/live_recorder.py @@ -294,26 +294,25 @@ async def run(self): 'context': { 'client': { 'hl': 'zh-CN', - 'clientName': 'WEB', + 'clientName': 'MWEB', 'clientVersion': '2.20230101.00.00', 'timeZone': 'Asia/Shanghai' } }, 'browseId': self.id, - 'params': 'EghmZWF0dXJlZPIGBAoCMgA%3D' + 'params': 'EgdzdHJlYW1z8gYECgJ6AA%3D%3D' } )).json() - jsonpath = parse('$..channelFeaturedContentRenderer').find(response) + jsonpath = parse('$..videoWithContextRenderer').find(response) for match in jsonpath: - for item in match.value['items']: - video = item['videoRenderer'] - if '"style": "LIVE"' in json.dumps(video): - url = f"https://www.youtube.com/watch?v={video['videoId']}" - title = video['title']['runs'][0]['text'] - if url not in recording: - stream = self.get_streamlink().streams(url).get('best') # HLSStream[mpegts] - # FIXME:多开直播间中断 - asyncio.create_task(asyncio.to_thread(self.run_record, stream, url, title, 'ts')) + video = match.value + if '"style": "LIVE"' in json.dumps(video): + url = f"https://www.youtube.com/watch?v={video['videoId']}" + title = video['headline']['runs'][0]['text'] + if url not in recording: + stream = self.get_streamlink().streams(url).get('best') # HLSStream[mpegts] + # FIXME:多开直播间中断 + asyncio.create_task(asyncio.to_thread(self.run_record, stream, url, title, 'ts')) class Twitch(LiveRecoder):