From 16745bdf0adcf7b8e87baf98d9da3c051191583c Mon Sep 17 00:00:00 2001 From: auqhjjqdo Date: Thu, 21 Dec 2023 11:23:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9EPixiv=20Sketch=E7=9B=B4?= =?UTF-8?q?=E6=92=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- live_recorder.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/live_recorder.py b/live_recorder.py index 5fe35b6..05c4d3d 100644 --- a/live_recorder.py +++ b/live_recorder.py @@ -438,6 +438,22 @@ async def run(self): await asyncio.to_thread(self.run_record, stream, url, title, 'ts') +class Pixivsketch(LiveRecoder): + async def run(self): + url = f'https://sketch.pixiv.net/{self.id}' + if url not in recording: + response = (await self.request( + method='GET', + url=f'https://sketch.pixiv.net/_next/data/9yFpS_JEo_sQWcZoqUqYd/{self.id}.json', + params={'id': self.id} + )).json() + initial_state = json.loads(response['pageProps']['initialState']) + if lives := initial_state['live']['lives']: + title = list(lives.values())[0]['name'] + stream = self.get_streamlink().streams(url).get('best') # HLSStream[mpegts] + await asyncio.to_thread(self.run_record, stream, url, title, 'ts') + + async def run(): with open('config.json', 'r', encoding='utf-8') as f: config = json.load(f)