diff --git a/README.md b/README.md index 4ef16e1..042af87 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ - [x] 哔哩哔哩 - [x] 斗鱼 - [x] 虎牙 +- [x] 抖音 - [x] YouTube - [x] Twitch - [x] TwitCasting diff --git a/config.sample.json b/config.sample.json index facf841..3553eca 100644 --- a/config.sample.json +++ b/config.sample.json @@ -22,6 +22,11 @@ "id": "991111", "name": "TheShy" }, + { + "platform": "Douyin", + "id": "282773369501", + "name": "央视新闻" + }, { "platform": "Youtube", "id": "UCShXNLMXCfstmWKH_q86B8w", diff --git a/main.py b/main.py index a7e9b02..66635a2 100644 --- a/main.py +++ b/main.py @@ -3,6 +3,7 @@ import os import re import time +import urllib import uuid from http.cookies import SimpleCookie from pathlib import Path @@ -245,6 +246,27 @@ async def run(self): await asyncio.to_thread(self.run_record, stream, url, title, 'flv') +class Douyin(LiveRecoder): + async def run(self): + url = f'https://live.douyin.com/{self.id}' + if url not in recording: + response = (await self.request( + method='GET', + url=url, + cookies={'__ac_nonce': uuid.uuid4().hex[:21]} + )).text + result = re.search('', response).group(1) + data = json.loads(urllib.parse.unquote(result)) + room_info = data['app']['initialState']['roomStore']['roomInfo'] + if web_stream_url := room_info['web_stream_url']: + title = room_info['room']['title'] + stream = HTTPStream( + self.get_streamlink(), + web_stream_url['flv_pull_url']['FULL_HD1'] + ) # HTTPStream[flv] + await asyncio.to_thread(self.run_record, stream, url, title, 'flv') + + class Youtube(LiveRecoder): async def run(self): response = (await self.request(