From 64ab922154524120da383413ab83d4379a3b088f Mon Sep 17 00:00:00 2001 From: auqhjjqdo Date: Sat, 7 Oct 2023 10:18:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dpandalive=E7=9B=B4=E6=92=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- live_recorder.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/live_recorder.py b/live_recorder.py index f737ade..15b2ec5 100644 --- a/live_recorder.py +++ b/live_recorder.py @@ -17,7 +17,7 @@ from jsonpath_ng.ext import parse from loguru import logger from streamlink.options import Options -from streamlink.stream import StreamIO, HTTPStream +from streamlink.stream import StreamIO, HTTPStream, HLSStream from streamlink_cli.main import open_stream from streamlink_cli.output import FileOutput from streamlink_cli.streamrunner import StreamRunner @@ -403,6 +403,9 @@ async def run(self): response = (await self.request( method='POST', url='https://api.pandalive.co.kr/v1/live/play', + headers={ + 'x-device-info': '{"t":"webPc","v":"1.0","ui":0}' + }, data={ 'action': 'watch', 'userId': self.id @@ -410,7 +413,11 @@ async def run(self): )).json() if response['result']: title = response['media']['title'] - stream = self.get_streamlink().streams(url).get('best') # HLSStream[mpegts] + streams = HLSStream.parse_variant_playlist( + self.get_streamlink(), + response['PlayList']['hls'][0]['url'] + ) + stream = list(streams.values())[0] # HLSStream[mpegts] await asyncio.to_thread(self.run_record, stream, url, title, 'ts')