Skip to content

Commit

Permalink
修复Youtube直播不录制的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
auqhjjqdo committed Nov 26, 2023
1 parent d657e92 commit 0d8d701
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions live_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 0d8d701

Please sign in to comment.