mirror of
https://github.com/ihmily/DouyinLiveRecorder.git
synced 2025-12-26 05:48:32 +08:00
fix: update xhs live record
This commit is contained in:
parent
463fa44756
commit
ad0b6c72dd
@ -813,6 +813,7 @@ def get_xhs_stream_url(url: str, proxy_addr: OptionalStr = None, cookies: Option
|
||||
"anchor_name": '',
|
||||
"is_live": False,
|
||||
}
|
||||
flv_url = ''
|
||||
room_id = re.search('/livestream/(.*?)(?=/|\\?|$)', url)
|
||||
if room_id:
|
||||
room_id = room_id.group(1)
|
||||
@ -822,18 +823,11 @@ def get_xhs_stream_url(url: str, proxy_addr: OptionalStr = None, cookies: Option
|
||||
json_data = json.loads(json_str)
|
||||
anchor_name = json_data['data']['host_info']['nickname']
|
||||
live_title = json_data['data']['room']['name']
|
||||
live_status = json_data['data']['room']['status']
|
||||
result["anchor_name"] = anchor_name
|
||||
|
||||
# 这个判断不准确,无论是否在直播status都为0
|
||||
if live_status == 0:
|
||||
result['is_live'] = True
|
||||
result['title'] = live_title
|
||||
flv_url = f'http://live-play.xhscdn.com/live/{room_id}.flv'
|
||||
result['flv_url'] = flv_url
|
||||
result['record_url'] = flv_url
|
||||
if get_response_status(flv_url, proxy_addr=proxy_addr, headers=headers):
|
||||
return result
|
||||
result['title'] = live_title
|
||||
flv_url = f'http://live-play.xhscdn.com/live/{room_id}.flv'
|
||||
result['flv_url'] = flv_url
|
||||
result['record_url'] = flv_url
|
||||
|
||||
user_id = re.search('/user/profile/(.*?)(?=/|\\?|$)', url)
|
||||
user_id = user_id.group(1) if user_id else get_params(url, 'host_id')
|
||||
@ -850,6 +844,8 @@ def get_xhs_stream_url(url: str, proxy_addr: OptionalStr = None, cookies: Option
|
||||
result['is_live'] = True
|
||||
live_link = json_data['data'][0]['live_link']
|
||||
result['anchor_name'] = get_params(live_link, "host_nickname")
|
||||
if get_response_status(flv_url, proxy_addr=proxy_addr, headers=headers):
|
||||
return result
|
||||
flv_url = get_params(live_link, "flvUrl")
|
||||
result['flv_url'] = flv_url
|
||||
result['record_url'] = flv_url
|
||||
|
||||
8
main.py
8
main.py
@ -4,7 +4,7 @@
|
||||
Author: Hmily
|
||||
GitHub: https://github.com/ihmily
|
||||
Date: 2023-07-17 23:52:05
|
||||
Update: 2024-11-14 00:45:00
|
||||
Update: 2024-11-16 04:28:00
|
||||
Copyright (c) 2023-2024 by Hmily, All Rights Reserved.
|
||||
Function: Record live stream video.
|
||||
"""
|
||||
@ -1005,7 +1005,7 @@ def start_record(url_data: tuple, count_variable: int = -1) -> None:
|
||||
logger.info(
|
||||
f"{platform} | {anchor_name} | 直播源地址: {port_info['record_url']}")
|
||||
|
||||
if video_save_type == "FLV":
|
||||
if video_save_type == "FLV" or 'live.xhscdn.com' in real_url:
|
||||
filename = anchor_name + f'_{title_in_name}' + now + '.flv'
|
||||
save_file_path = f'{full_path}/{filename}'
|
||||
print(f'{rec_info}/{filename}')
|
||||
@ -1496,7 +1496,7 @@ while True:
|
||||
enable_https_recording = options.get(read_config_value(config, '录制设置', '强制启用HTTPS录制', "否"), False)
|
||||
disk_space_limit = float(read_config_value(config, '录制设置', '录制空间剩余阈值(gb)', 1.0))
|
||||
split_time = str(read_config_value(config, '录制设置', '视频分段时间(秒)', 1800))
|
||||
ts_to_mp4 = options.get(read_config_value(config, '录制设置', 'ts录制完成后自动转为mp4格式', "否"),False)
|
||||
ts_to_mp4 = options.get(read_config_value(config, '录制设置', 'ts录制完成后自动转为mp4格式', "否"), False)
|
||||
delete_origin_file = options.get(read_config_value(config, '录制设置', '追加格式后删除原文件', "否"), False)
|
||||
create_time_file = options.get(read_config_value(config, '录制设置', '生成时间字幕文件', "否"), False)
|
||||
is_run_script = options.get(read_config_value(config, '录制设置', '是否录制完成后执行自定义脚本', "否"), False)
|
||||
@ -1802,4 +1802,4 @@ while True:
|
||||
t2.start()
|
||||
first_run = False
|
||||
|
||||
time.sleep(3)
|
||||
time.sleep(3)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user