MCPcopy Create free account

hub / github.com/harry0703/MoneyPrinterTurbo / functions

Functions428 in github.com/harry0703/MoneyPrinterTurbo

↓ 166 callersFunctiontr
(key)
webui/Main.py:217
↓ 28 callersMethodupdate_task
(self, task_id: str, state: int, progress: int = 0, **kwargs)
app/services/state.py:11
↓ 11 callersMethodclose
(self)
test/services/test_video.py:425
↓ 9 callersFunction_normalize_text_response
(content, llm_provider: str)
app/services/llm.py:41
↓ 9 callersFunctionclose_clip
(clip)
app/services/video.py:395
↓ 8 callersFunctionscroll_to_bottom
()
webui/Main.py:163
↓ 6 callersMethodcreate
(self, **kwargs)
test/services/test_llm.py:304
↓ 6 callersFunctionensure_legacy_submaker_fields
为项目里仍然沿用旧字幕结构的调用方补齐兼容字段。 edge_tts 7.x 的 `SubMaker` 主要暴露 `cues/get_srt()`,但项目里 Azure v2、 Gemini、SiliconFlow 这些路径仍然会直接读写 `subs/offset`。这里统
app/services/voice.py:390
↓ 5 callersFunction_get_response_field
兼容 dict 和 SDK 响应对象的字段读取。
app/services/llm.py:82
↓ 4 callersMethod_assert_ollama_base_url
(self, expected_base_url: str)
test/services/test_llm.py:395
↓ 4 callersFunction_clamp_text
(text, max_length: int)
app/services/llm.py:845
↓ 4 callersFunction_get_tls_verify
()
app/services/material.py:20
↓ 4 callersFunction_limit_script_text
(text: str | None, max_length: int, field_name: str)
app/services/llm.py:555
↓ 4 callersFunction_limit_social_text
(text: str | None, max_length: int, field_name: str)
app/services/llm.py:821
↓ 4 callersFunction_load_translation
(locale)
test/services/test_webui_i18n.py:28
↓ 4 callersFunction_open_video_clip_quietly
安静地打开视频文件,避免 MoviePy 2.1.x 把 ffmpeg 探测信息直接打印到 stdout。 背景: 当前依赖版本的 `FFMPEG_VideoReader` 内部存在 `print(self.infos)` 和 `print(ffmpeg comm
app/services/video.py:365
↓ 4 callersMethod_patch_dashscope_generation
(self, response)
test/services/test_llm.py:216
↓ 4 callersFunction_resolve_social_platform
(platform: str | None)
app/services/llm.py:805
↓ 4 callersMethod_use_litellm_provider
(self, model_name="openai/gpt-4o-mini")
test/services/test_llm.py:125
↓ 4 callersMethod_use_ollama_provider
(self, base_url="")
test/services/test_llm.py:389
↓ 4 callersMethod_use_qwen_provider
(self)
test/services/test_llm.py:211
↓ 4 callersFunctionensure_file_path_exists
确保输出文件所在目录一定存在。 这里单独做一层兜底,是因为 edge_tts 7.x 在真正发起网络请求之前, 就会先打开目标音频文件;如果目录不存在,会直接因为本地文件路径报错, 从而掩盖真正的 TTS 行为结果。
app/services/voice.py:377
↓ 4 callersMethodget_task
(self, task_id: str)
app/services/state.py:15
↓ 4 callersFunctionget_text_size
(inner_text)
app/services/video.py:706
↓ 4 callersMethodto_resolution
(self)
app/models/schema.py:37
↓ 3 callersFunction_do
()
app/services/voice.py:1449
↓ 3 callersFunction_extract_chat_completion_text
(response, llm_provider: str)
app/services/llm.py:64
↓ 3 callersFunction_generate_response
(prompt: str)
app/services/llm.py:119
↓ 3 callersFunction_get_configured_video_codec
读取用户配置的视频编码器。 该配置面向高级用户,用于尝试启用 NVENC/AMF/QSV/VideoToolbox 等硬件 编码。这里刻意只允许固定白名单,避免开放任意 FFmpeg 参数后,用户填错 参数导致输出格式不可控,甚至让生成任务在后续阶段才失败。
app/services/video.py:137
↓ 3 callersMethodadd_task
(self, func: Callable, *args: Any, **kwargs: Any)
app/controllers/manager/base_manager.py:22
↓ 3 callersFunctioncreate_task
( request: Request, body: Union[TaskVideoRequest, SubtitleRequest, AudioRequest], stop_at: str, )
app/controllers/v1/video.py:136
↓ 3 callersFunctiondelete_files
(files: List[str] | str)
app/services/video.py:432
↓ 3 callersMethoddelete_task
(self, task_id: str)
app/services/state.py:132
↓ 3 callersMethodget_all_tasks
(self, page: int, page_size: int)
app/services/state.py:19
↓ 3 callersFunctionget_api_key
(cfg_key: str)
app/services/material.py:37
↓ 3 callersFunctionget_keys_from_config
(cfg_key)
webui/Main.py:632
↓ 3 callersFunctionis_azure_v2_voice
(voice_name: str)
app/services/voice.py:181
↓ 3 callersFunctionparse_voice_name
(name: str)
app/services/voice.py:173
↓ 3 callersFunctionpopulate_legacy_submaker_with_full_text
用整段文本填充项目历史沿用的 `subs/offset` 字幕结构。 背景: 1. edge_tts 7.x 的 `SubMaker` 不再提供旧版本里的 `create_sub()`; 2. 项目里 Gemini、SiliconFlow 等非 edge 路径依然
app/services/voice.py:405
↓ 3 callersFunctionresource_dir
(sub_dir: str = "")
app/utils/utils.py:82
↓ 3 callersFunctionsave_keys_to_config
(cfg_key, value)
webui/Main.py:639
↓ 3 callersFunctionsimilarity
(a, b)
app/services/subtitle.py:194
↓ 3 callersMethodwrite_videofile
(self, output_file, codec, **kwargs)
test/services/test_video.py:236
↓ 2 callersFunction_build_subtitle_formatter
返回统一的 SRT 行格式化函数。 这里单独拆成一个小工具,是为了让 edge_tts 7.x 的 cues 路径 和项目原有的 legacy `subs/offset` 路径共用同一套字幕落盘格式, 避免两套逻辑各自产生细微格式差异。
app/services/voice.py:1164
↓ 2 callersFunction_configure_pydub_ffmpeg
(audio_segment_cls)
app/services/voice.py:39
↓ 2 callersFunction_consume_async_stream
()
app/services/voice.py:616
↓ 2 callersMethod_convert_to_original_type
Convert the value from byte string to its original data type. You can extend this method to handle other data types as needed.
app/services/state.py:136
↓ 2 callersFunction_disable_runtime_video_codec
(codec: str, reason: str)
app/services/video.py:218
↓ 2 callersFunction_format_duration_to_offset
(duration)
app/services/voice.py:837
↓ 2 callersFunction_format_text
清理字幕对齐前的脚本文本。 这里不能只在 LLM 生成阶段处理,因为用户也可能手动粘贴脚本,或通过 API 直接传入包含 Markdown 标记的文本。TTS 通常不会朗读 `---`、 `___`、`***` 这类分隔符行,也不会朗读 `_` 这种强调标记;如果
app/services/voice.py:1145
↓ 2 callersFunction_get_effective_video_codec
返回本次实际使用的视频编码器。 用户选择硬件编码器时,先做 FFmpeg encoder 列表检测;如果本进程里已经 实际编码失败过,也直接回退,避免一个任务里每个片段都重复失败。
app/services/video.py:189
↓ 2 callersFunction_match_script_line
尝试把当前累计的字幕文本,与脚本中的某一条标准断句匹配起来。 这里复用了项目原有的“按标点拆脚本,再逐段比对”的思路: 1. 优先精确匹配; 2. 再做一次去标点和 Markdown `_` 格式符后的匹配; 3. 最后做一次阿拉伯语字符形态归一化匹配。
app/services/voice.py:1205
↓ 2 callersFunction_normalize_arabic
统一阿拉伯语常见字母变体,提升字幕 cue 与脚本行的匹配容错率。 edge-tts 对阿拉伯语可能返回与原脚本不同的字母形态,例如把 أ/إ/آ 归一成 ا,或者携带变音符号。这里仅在最后一层匹配兜底中使用, 不改变原始字幕文本,避免影响最终展示内容。
app/services/voice.py:1186
↓ 2 callersFunction_normalize_hashtags
将 LLM 返回的 hashtag 统一整理成 `#tag` 格式。 LLM 可能返回字符串、数组、带空格的词组、重复标签或包含标点的内容。 这里集中清洗,可以让接口响应结构稳定,也避免平台发布时出现空标签、 重复标签或不符合常见格式的 hashtag。
app/services/llm.py:852
↓ 2 callersFunction_normalize_script_paragraph_number
(paragraph_number: int | None)
app/services/llm.py:569
↓ 2 callersFunction_normalize_social_language
(language: str | None)
app/services/llm.py:810
↓ 2 callersFunction_open_image_clip_with_fallback
(image_path: str)
app/services/video.py:353
↓ 2 callersFunction_resolve_path_within_directory
(base_dir: str, unsafe_path: str, request_id: str)
app/controllers/v1/video.py:76
↓ 2 callersFunction_sanitize_upload_filename
(filename: str, request_id: str)
app/controllers/v1/video.py:63
↓ 2 callersFunction_task_file_to_uri
(file: str, endpoint: str, task_dir: str, request_id: str)
app/controllers/v1/video.py:90
↓ 2 callersFunction_write_videofile_with_codec_fallback
使用指定编码器写出视频,失败时自动用 libx264 重试一次。 硬件编码器是否可用不仅取决于 FFmpeg,还取决于显卡、驱动和当前运行环境。 生成任务不能因为高级编码器不可用而整体失败,所以这里把回退集中处理。
app/services/video.py:241
↓ 2 callersFunctionazure_tts_v2
(text: str, voice_name: str, voice_file: str)
app/services/voice.py:830
↓ 2 callersMethodexecute_task
(self, func: Callable, *args: Any, **kwargs: Any)
app/controllers/manager/base_manager.py:46
↓ 2 callersMethodexport
(self, output_file, format)
test/services/test_voice.py:432
↓ 2 callersFunctionfile_to_subtitles
(filename)
app/services/subtitle.py:145
↓ 2 callersFunctionformatter
(idx: int, start_time: float, end_time: float, sub_text: str)
app/services/voice.py:1173
↓ 2 callersMethodgenerate_content
(self, contents, generation_config)
test/services/test_voice.py:361
↓ 2 callersMethodhgetall
(self, key)
test/services/test_state.py:29
↓ 2 callersMethodis_configured
Check if Upload-Post is properly configured.
app/services/upload_post.py:28
↓ 2 callersFunctionmktimestamp
将 edge_tts 使用的 100 纳秒时间单位转换为字幕时间戳。 edge_tts 7.x 不再导出旧版本里的 `mktimestamp`,但项目里旧字幕链路 还需要这个格式化函数来兼容 Azure v2、Gemini、SiliconFlow 这些 手工构造的
app/services/voice.py:45
↓ 2 callersFunctionnew_router
(dependencies=None)
app/controllers/v1/base.py:4
↓ 2 callersFunctionrecognized
(seg_text, seg_start, seg_end)
app/services/subtitle.py:69
↓ 2 callersFunctionroot_dir
()
app/utils/utils.py:68
↓ 2 callersFunctionrun_concat
(codec: str)
app/services/video.py:308
↓ 2 callersMethodstream_sync
(self)
test/services/test_voice.py:276
↓ 2 callersFunctiontime_convert_seconds_to_hmsm
(seconds)
app/utils/utils.py:173
↓ 1 callersFunction__init_logger
()
app/config/__init__.py:10
↓ 1 callersMethod_build_state
(self, batch_sizes)
test/services/test_state.py:34
↓ 1 callersFunction_build_subtitle_items_from_edge_cues
将 edge_tts 7.x 的细粒度 `cues` 聚合为按脚本断句的 SRT 片段。 背景: edge_tts 7.x 的 `SubMaker.get_srt()` 更偏向逐词/逐短语的时间轴。 对英文做逐词高亮尚可,但中文短视频字幕如果直接照搬,会出现
app/services/voice.py:1266
↓ 1 callersFunction_build_subtitle_items_from_legacy_submaker
将项目原有 `subs/offset` 结构聚合为按脚本断句的 SRT 片段。 这部分保留了原来的核心思路,只是拆成独立函数,便于与 edge_tts 7.x 的 cues 聚合逻辑共享同一套断句匹配与落盘流程。
app/services/voice.py:1321
↓ 1 callersFunction_can_resolve_hostname
(hostname: str)
app/config/config.py:43
↓ 1 callersFunction_decode_linux_route_gateway
(hex_gateway: str)
app/config/config.py:51
↓ 1 callersFunction_escape_ffmpeg_concat_path
(file_path: str)
app/services/video.py:264
↓ 1 callersFunction_extract_qwen_generation_text
从 DashScope Generation 响应中提取文本。 Qwen 使用 `messages` 调用时返回的是 chat 结构: `output.choices[0].message.content`;旧 completion 形态才会返回 `output.
app/services/llm.py:93
↓ 1 callersFunction_fallback_social_metadata
( video_subject: str, video_script: str, platform: str )
app/services/llm.py:955
↓ 1 callersFunction_fallback_write_videofile
硬件编码失败后用 libx264 重试,只有重试成功才禁用该硬件编码器。 Windows 上 FFmpeg 失败原因比较复杂:可能是显卡/驱动不支持,也可能是输出 文件被占用、目录权限、杀软拦截等通用 IO 问题。只有 libx264 能成功写出时, 才能判断原始
app/services/video.py:228
↓ 1 callersFunction_ffmpeg_encoder_exists
检查当前 FFmpeg 是否声明支持指定编码器。 这只能证明 FFmpeg 编译时包含该 encoder,不能证明当前机器硬件和驱动 一定可用。因此实际编码失败时仍会再回退到 libx264。
app/services/video.py:158
↓ 1 callersFunction_format_ffmpeg_concat_path
生成 concat demuxer 文件列表中的路径。 FFmpeg 官方文档要求 concat list 中的特殊字符和空格需要转义;Windows 绝对路径里的反斜杠也容易被解析成转义字符。这里统一转成正斜杠形式, 让 `C:\\Users\\...` 变成
app/services/video.py:269
↓ 1 callersFunction_get_audio_duration_from_mp3
获取MP3音频时长
app/services/voice.py:1410
↓ 1 callersFunction_get_audio_duration_from_submaker
获取音频时长
app/services/voice.py:1396
↓ 1 callersFunction_hex_to_rgb
(color: str)
app/services/video.py:763
↓ 1 callersFunction_load_azure_voices
()
app/services/voice.py:148
↓ 1 callersFunction_parse_social_metadata
(response: str, platform: str)
app/services/llm.py:929
↓ 1 callersFunction_prioritize_unique_source_clips
优先让每个源素材只出现一次,降低成片里同一素材反复出现的概率。 线上素材经常会遇到“一个长视频被切成多个短片段”的情况。旧逻辑在 random 模式下直接打乱所有短片段,导致同一个源视频的多个切片可能 分布在开头和中间,用户会感知为素材重复。本函数只调整片段顺序:
app/services/video.py:83
↓ 1 callersFunction_resolve_bgm_file_path
(song_dir: str, bgm_file: str)
app/services/video.py:443
↓ 1 callersFunction_rounded_subtitle_background_clip
( width: int, height: int, color: str, alpha: int = 140, radius: int = 16, )
app/services/video.py:774
↓ 1 callersFunction_sanitize_image_file
(image_path: str)
app/services/video.py:337
↓ 1 callersFunction_social_language_instruction
(language: str | None)
app/services/llm.py:834
↓ 1 callersFunction_stream_edge_tts_sync_with_timeout
带总超时地消费 edge_tts 7.x 的同步流。 实现原因: `stream_sync()` 本身是阻塞迭代器,网络层卡住时主线程无法及时恢复。 这里把阻塞迭代放到 daemon 线程中,主线程通过 Queue 获取 chunk, 到达超时时间后直接抛
app/services/voice.py:534
↓ 1 callersFunction_write_subtitle_items
将已经聚合好的字幕段写入到 SRT 文件,并做一次基本可读性验证。 返回值: - `True`:字幕文件成功落盘且可被 moviepy 解析; - `False`:字幕文件写入或解析失败。
app/services/voice.py:1240
next →1–100 of 428, ranked by callers