Skip to content

Commit

Permalink
新增Pixiv Sketch直播
Browse files Browse the repository at this point in the history
  • Loading branch information
auqhjjqdo committed Dec 21, 2023
1 parent dd38dbc commit 16745bd
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions live_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 16745bd

Please sign in to comment.