mirror of
https://github.com/ihmily/DouyinLiveRecorder.git
synced 2025-12-26 05:48:32 +08:00
feat: add picarto live (#1149)
This commit is contained in:
parent
8e4e9b098f
commit
bcfc268c1c
4
demo.py
4
demo.py
@ -202,6 +202,10 @@ LIVE_STREAM_CONFIG = {
|
||||
"laixiu": {
|
||||
"url": "https://www.imkktv.com/h5/share/video.html?uid=1845195&roomId=1710496",
|
||||
"func": spider.get_laixiu_stream_url,
|
||||
},
|
||||
"picarto": {
|
||||
"url": "https://www.picarto.tv/cuteavalanche",
|
||||
"func": spider.get_picarto_stream_url,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
12
main.py
12
main.py
@ -42,7 +42,7 @@ version = "v4.0.6"
|
||||
platforms = ("\n国内站点:抖音|快手|虎牙|斗鱼|YY|B站|小红书|bigo|blued|网易CC|千度热播|猫耳FM|Look|TwitCasting|百度|微博|"
|
||||
"酷狗|花椒|流星|Acfun|畅聊|映客|音播|知乎|嗨秀|VV星球|17Live|浪Live|漂漂|六间房|乐嗨|花猫|淘宝|京东|咪咕|连接|来秀"
|
||||
"\n海外站点:TikTok|SOOP|PandaTV|WinkTV|FlexTV|PopkonTV|TwitchTV|LiveMe|ShowRoom|CHZZK|Shopee|"
|
||||
"Youtube|Faceit")
|
||||
"Youtube|Faceit|Picarto")
|
||||
|
||||
recording = set()
|
||||
error_count = 0
|
||||
@ -945,6 +945,12 @@ def start_record(url_data: tuple, count_variable: int = -1) -> None:
|
||||
port_info = asyncio.run(spider.get_laixiu_stream_url(
|
||||
url=record_url, proxy_addr=proxy_address, cookies=laixiu_cookie))
|
||||
|
||||
elif record_url.find("www.picarto.tv") > -1:
|
||||
platform = 'Picarto'
|
||||
with semaphore:
|
||||
port_info = asyncio.run(spider.get_picarto_stream_url(
|
||||
url=record_url, proxy_addr=proxy_address, cookies=picarto_cookie))
|
||||
|
||||
elif record_url.find(".m3u8") > -1 or record_url.find(".flv") > -1:
|
||||
platform = '自定义录制直播'
|
||||
port_info = {
|
||||
@ -1788,6 +1794,7 @@ while True:
|
||||
migu_cookie = read_config_value(config, 'Cookie', 'migu_cookie', '')
|
||||
lianjie_cookie = read_config_value(config, 'Cookie', 'lianjie_cookie', '')
|
||||
laixiu_cookie = read_config_value(config, 'Cookie', 'laixiu_cookie', '')
|
||||
picarto_cookie = read_config_value(config, 'Cookie', 'picarto_cookie', '')
|
||||
|
||||
video_save_type_list = ("FLV", "MKV", "TS", "MP4", "MP3音频", "M4A音频")
|
||||
if video_save_type and video_save_type.upper() in video_save_type_list:
|
||||
@ -1909,7 +1916,8 @@ while True:
|
||||
'www.miguvideo.com',
|
||||
'm.miguvideo.com',
|
||||
'show.lailianjie.com',
|
||||
'www.imkktv.com'
|
||||
'www.imkktv.com',
|
||||
'www.picarto.tv'
|
||||
]
|
||||
overseas_platform_host = [
|
||||
'www.tiktok.com',
|
||||
|
||||
@ -3186,3 +3186,31 @@ async def get_laixiu_stream_url(url: str, proxy_addr: OptionalStr = None, cookie
|
||||
flv_url = room_data['playUrl']
|
||||
result |= {'is_live': True, 'flv_url': flv_url, 'record_url': flv_url}
|
||||
return result
|
||||
|
||||
|
||||
@trace_error_decorator
|
||||
async def get_picarto_stream_url(url: str, proxy_addr: OptionalStr = None, cookies: OptionalStr = None) -> dict:
|
||||
headers = {
|
||||
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
|
||||
'Chrome/121.0.0.0 Safari/537.36 Edg/121.0.0.0',
|
||||
'accept-language': 'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
|
||||
}
|
||||
|
||||
if cookies:
|
||||
headers['cookie'] = cookies
|
||||
|
||||
anchor_id = url.split('?')[0].rsplit('/', maxsplit=1)[-1]
|
||||
api = f'https://ptvintern.picarto.tv/api/channel/detail/{anchor_id}'
|
||||
|
||||
json_str = await async_req(api, proxy_addr=proxy_addr, headers=headers)
|
||||
json_data = json.loads(json_str)
|
||||
|
||||
anchor_name = json_data['channel']['name']
|
||||
live_status = json_data['channel']['online']
|
||||
|
||||
result = {"anchor_name": anchor_name, "is_live": live_status}
|
||||
if live_status:
|
||||
title = json_data['channel']['title']
|
||||
m3u8_url = f"https://1-edge1-us-newyork.picarto.tv/stream/hls/golive+{anchor_name}/index.m3u8"
|
||||
result |= {'is_live': True, 'title': title, 'm3u8_url': m3u8_url, 'record_url': m3u8_url}
|
||||
return result
|
||||
Loading…
x
Reference in New Issue
Block a user