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)