From a744e23c2b7307f5347d827ca1dd19081666a4fc Mon Sep 17 00:00:00 2001 From: auqhjjqdo Date: Thu, 21 Dec 2023 11:33:36 +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 --- README.md | 1 + config.sample.json | 6 ++++++ live_recorder.py | 16 ++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/README.md b/README.md index 0e95625..a026ee8 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ - [x] Afreeca - [x] Pandalive - [x] Bigolive +- [x] Pixiv Sketch - [ ] 更多平台欢迎PR ## 已知bug diff --git a/config.sample.json b/config.sample.json index eb51d42..8673f41 100644 --- a/config.sample.json +++ b/config.sample.json @@ -65,6 +65,12 @@ "platform": "Bigolive", "id": "660801666", "name": "660801666" + }, + { + "platform": "Pixivsketch", + "id": "@blue_gk", + "name": "@blue_gk", + "cookies": "_sketch_session=xxxxx" } ] } 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)