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 a744e23
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- [x] Afreeca
- [x] Pandalive
- [x] Bigolive
- [x] Pixiv Sketch
- [ ] 更多平台欢迎PR

## 已知bug
Expand Down
6 changes: 6 additions & 0 deletions config.sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@
"platform": "Bigolive",
"id": "660801666",
"name": "660801666"
},
{
"platform": "Pixivsketch",
"id": "@blue_gk",
"name": "@blue_gk",
"cookies": "_sketch_session=xxxxx"
}
]
}
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 a744e23

Please sign in to comment.