mirror of
https://github.com/ihmily/DouyinLiveRecorder.git
synced 2025-12-26 05:48:32 +08:00
fix: update
This commit is contained in:
parent
d37d9f25ad
commit
51f79d70f8
148
main.py
148
main.py
@ -655,7 +655,6 @@ def start_record(url_data: tuple, count_variable: int = -1) -> None:
|
||||
with semaphore:
|
||||
port_info = asyncio.run(spider.get_maoerfm_stream_url(
|
||||
url=record_url, proxy_addr=proxy_address, cookies=maoerfm_cookie))
|
||||
video_save_type = 'mp3音频'
|
||||
|
||||
elif record_url.find("www.winktv.co.kr/") > -1:
|
||||
platform = 'WinkTV'
|
||||
@ -1131,11 +1130,86 @@ def start_record(url_data: tuple, count_variable: int = -1) -> None:
|
||||
f"{platform} | {anchor_name} | 直播源地址: {real_url}")
|
||||
|
||||
only_flv_record = False
|
||||
only_flv_platform_list = ['shopee'] if os.name == 'nt' else ['shopee', '花椒直播']
|
||||
only_flv_platform_list = ['shopee', '花椒直播']
|
||||
if platform in only_flv_platform_list:
|
||||
logger.debug(f"提示: {platform} 将强制使用FLV格式录制")
|
||||
only_flv_record = True
|
||||
|
||||
only_audio_record = False
|
||||
only_audio_platform_list = ['猫耳FM直播', 'Look直播']
|
||||
if platform in only_audio_platform_list:
|
||||
only_audio_record = True
|
||||
|
||||
if only_audio_record:
|
||||
try:
|
||||
now = time.strftime("%Y-%m-%d_%H-%M-%S", time.localtime())
|
||||
extension = "mp3" if "m4a" not in video_save_type.lower () else "m4a"
|
||||
name_format = "_%03d" if split_video_by_time else ""
|
||||
save_file_path = (f"{full_path}/{anchor_name}_{title_in_name}{now}"
|
||||
f"{name_format}.{extension}")
|
||||
|
||||
if split_video_by_time:
|
||||
print(f'\r{anchor_name} 准备开始录制音频: {save_file_path}')
|
||||
|
||||
if "MP3" in video_save_type:
|
||||
command = [
|
||||
"-map", "0:a",
|
||||
"-c:a", "libmp3lame",
|
||||
"-ab", "320k",
|
||||
"-f", "segment",
|
||||
"-segment_time", split_time,
|
||||
"-reset_timestamps", "1",
|
||||
save_file_path,
|
||||
]
|
||||
else:
|
||||
command = [
|
||||
"-map", "0:a",
|
||||
"-c:a", "aac",
|
||||
"-bsf:a", "aac_adtstoasc",
|
||||
"-ab", "320k",
|
||||
"-f", "segment",
|
||||
"-segment_time", split_time,
|
||||
"-segment_format", 'mpegts',
|
||||
"-reset_timestamps", "1",
|
||||
save_file_path,
|
||||
]
|
||||
|
||||
else:
|
||||
if "MP3" in video_save_type:
|
||||
command = [
|
||||
"-map", "0:a",
|
||||
"-c:a", "libmp3lame",
|
||||
"-ab", "320k",
|
||||
save_file_path,
|
||||
]
|
||||
|
||||
else:
|
||||
command = [
|
||||
"-map", "0:a",
|
||||
"-c:a", "aac",
|
||||
"-bsf:a", "aac_adtstoasc",
|
||||
"-ab", "320k",
|
||||
"-movflags", "+faststart",
|
||||
save_file_path,
|
||||
]
|
||||
|
||||
ffmpeg_command.extend(command)
|
||||
comment_end = check_subprocess(
|
||||
record_name,
|
||||
record_url,
|
||||
ffmpeg_command,
|
||||
video_save_type,
|
||||
custom_script
|
||||
)
|
||||
if comment_end:
|
||||
return
|
||||
|
||||
except subprocess.CalledProcessError as e:
|
||||
logger.error(f"错误信息: {e} 发生错误的行数: {e.__traceback__.tb_lineno}")
|
||||
with max_request_lock:
|
||||
error_count += 1
|
||||
error_window.append(1)
|
||||
|
||||
if video_save_type == "FLV" or only_flv_record:
|
||||
filename = anchor_name + f'_{title_in_name}' + now + '.flv'
|
||||
save_file_path = f'{full_path}/{filename}'
|
||||
@ -1291,76 +1365,6 @@ def start_record(url_data: tuple, count_variable: int = -1) -> None:
|
||||
error_count += 1
|
||||
error_window.append(1)
|
||||
|
||||
elif "音频" in video_save_type:
|
||||
try:
|
||||
now = time.strftime("%Y-%m-%d_%H-%M-%S", time.localtime())
|
||||
extension = "mp3" if "MP3" in video_save_type.upper() else "m4a"
|
||||
name_format = "_%03d" if split_video_by_time else ""
|
||||
save_file_path = (f"{full_path}/{anchor_name}_{title_in_name}{now}"
|
||||
f"{name_format}.{extension}")
|
||||
|
||||
if split_video_by_time:
|
||||
print(f'\r{anchor_name} 准备开始录制音频: {save_file_path}')
|
||||
|
||||
if "MP3" in video_save_type:
|
||||
command = [
|
||||
"-map", "0:a",
|
||||
"-c:a", "libmp3lame",
|
||||
"-ab", "320k",
|
||||
"-f", "segment",
|
||||
"-segment_time", split_time,
|
||||
"-reset_timestamps", "1",
|
||||
save_file_path,
|
||||
]
|
||||
else:
|
||||
command = [
|
||||
"-map", "0:a",
|
||||
"-c:a", "aac",
|
||||
"-bsf:a", "aac_adtstoasc",
|
||||
"-ab", "320k",
|
||||
"-f", "segment",
|
||||
"-segment_time", split_time,
|
||||
"-segment_format", 'mpegts',
|
||||
"-reset_timestamps", "1",
|
||||
save_file_path,
|
||||
]
|
||||
|
||||
else:
|
||||
if "MP3" in video_save_type:
|
||||
command = [
|
||||
"-map", "0:a",
|
||||
"-c:a", "libmp3lame",
|
||||
"-ab", "320k",
|
||||
save_file_path,
|
||||
]
|
||||
|
||||
else:
|
||||
command = [
|
||||
"-map", "0:a",
|
||||
"-c:a", "aac",
|
||||
"-bsf:a", "aac_adtstoasc",
|
||||
"-ab", "320k",
|
||||
"-movflags", "+faststart",
|
||||
save_file_path,
|
||||
]
|
||||
|
||||
ffmpeg_command.extend(command)
|
||||
comment_end = check_subprocess(
|
||||
record_name,
|
||||
record_url,
|
||||
ffmpeg_command,
|
||||
video_save_type,
|
||||
custom_script
|
||||
)
|
||||
if comment_end:
|
||||
return
|
||||
|
||||
except subprocess.CalledProcessError as e:
|
||||
logger.error(f"错误信息: {e} 发生错误的行数: {e.__traceback__.tb_lineno}")
|
||||
with max_request_lock:
|
||||
error_count += 1
|
||||
error_window.append(1)
|
||||
|
||||
else:
|
||||
if split_video_by_time:
|
||||
now = time.strftime("%Y-%m-%d_%H-%M-%S", time.localtime())
|
||||
|
||||
@ -26,7 +26,7 @@ from . import JS_SCRIPT_PATH, utils
|
||||
from .utils import trace_error_decorator
|
||||
from .logger import script_path
|
||||
from .room import get_sec_user_id, get_unique_id, UnsupportedUrlError
|
||||
from .http_clients.async_http import async_req
|
||||
from .http_clients.async_http import async_req, get_response_status
|
||||
|
||||
|
||||
ssl_context = ssl.create_default_context()
|
||||
@ -2746,7 +2746,6 @@ async def get_6room_stream_url(url: str, proxy_addr: OptionalStr = None, cookies
|
||||
'rid': '',
|
||||
'ruid': room_id,
|
||||
}
|
||||
|
||||
api = 'https://v.6.cn/coop/mobile/index.php?padapi=coop-mobile-inroom.php'
|
||||
json_str = await async_req(api, data=data, proxy_addr=proxy_addr, headers=headers)
|
||||
json_data = json.loads(json_str)
|
||||
@ -2755,8 +2754,7 @@ async def get_6room_stream_url(url: str, proxy_addr: OptionalStr = None, cookies
|
||||
result = {"anchor_name": anchor_name, "is_live": False}
|
||||
if flv_title:
|
||||
flv_url = f'https://wlive.6rooms.com/httpflv/{flv_title}.flv'
|
||||
record_url = await async_req(flv_url, proxy_addr=proxy_addr, headers=headers, redirect_url=True)
|
||||
result |= {'is_live': True, 'flv_url': flv_url, 'record_url': record_url}
|
||||
result |= {'is_live': True, 'flv_url': flv_url, 'record_url': flv_url}
|
||||
return result
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user