Skip to content

Commit

Permalink
新增抖音直播
Browse files Browse the repository at this point in the history
  • Loading branch information
auqhjjqdo committed Jun 15, 2023
1 parent c6a68f2 commit add15c7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- [x] 哔哩哔哩
- [x] 斗鱼
- [x] 虎牙
- [x] 抖音
- [x] YouTube
- [x] Twitch
- [x] TwitCasting
Expand Down
5 changes: 5 additions & 0 deletions config.sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
"id": "991111",
"name": "TheShy"
},
{
"platform": "Douyin",
"id": "282773369501",
"name": "央视新闻"
},
{
"platform": "Youtube",
"id": "UCShXNLMXCfstmWKH_q86B8w",
Expand Down
22 changes: 22 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import re
import time
import urllib
import uuid
from http.cookies import SimpleCookie
from pathlib import Path
Expand Down Expand Up @@ -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('<script id="RENDER_DATA".*?>(.*?)</script>', 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(
Expand Down

0 comments on commit add15c7

Please sign in to comment.