fix: 修复导出路径中的Windows UNC前缀问题
- 添加normalize_windows_path函数清理路径格式 - 移除导出结果中的\\\\?\\ UNC前缀 - 确保导出的JSON文件中包含标准Windows路径格式 - 提升剪映导入兼容性
This commit is contained in:
parent
0495a32c74
commit
fb6b345188
|
|
@ -300,6 +300,15 @@ pub struct MatchingStatistics {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TemplateMatchingResultService {
|
impl TemplateMatchingResultService {
|
||||||
|
/// 清理Windows路径格式,移除UNC前缀
|
||||||
|
fn normalize_windows_path(path: &str) -> String {
|
||||||
|
// 移除 \\?\ 前缀(Windows长路径UNC格式)
|
||||||
|
if path.starts_with("\\\\?\\") {
|
||||||
|
path.strip_prefix("\\\\?\\").unwrap_or(path).to_string()
|
||||||
|
} else {
|
||||||
|
path.to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
/// 导出匹配结果到剪映格式
|
/// 导出匹配结果到剪映格式
|
||||||
/// 根据模板匹配结果生成剪映可导入的 draft_content.json 文件
|
/// 根据模板匹配结果生成剪映可导入的 draft_content.json 文件
|
||||||
pub async fn export_to_jianying(
|
pub async fn export_to_jianying(
|
||||||
|
|
@ -378,6 +387,9 @@ impl TemplateMatchingResultService {
|
||||||
let material_segment = material_repository.get_segment_by_id_sync(&segment_result.material_segment_id)?
|
let material_segment = material_repository.get_segment_by_id_sync(&segment_result.material_segment_id)?
|
||||||
.ok_or_else(|| anyhow!("找不到素材片段: {}", segment_result.material_segment_id))?;
|
.ok_or_else(|| anyhow!("找不到素材片段: {}", segment_result.material_segment_id))?;
|
||||||
|
|
||||||
|
// 清理文件路径格式
|
||||||
|
let normalized_path = Self::normalize_windows_path(&material_segment.file_path);
|
||||||
|
|
||||||
// 创建剪映视频素材
|
// 创建剪映视频素材
|
||||||
let video = JianYingVideo {
|
let video = JianYingVideo {
|
||||||
aigc_type: "none".to_string(),
|
aigc_type: "none".to_string(),
|
||||||
|
|
@ -414,7 +426,7 @@ impl TemplateMatchingResultService {
|
||||||
local_id: String::new(),
|
local_id: String::new(),
|
||||||
local_material_id: Uuid::new_v4().to_string(),
|
local_material_id: Uuid::new_v4().to_string(),
|
||||||
material_id: String::new(),
|
material_id: String::new(),
|
||||||
material_name: Path::new(&material_segment.file_path)
|
material_name: Path::new(&normalized_path)
|
||||||
.file_name()
|
.file_name()
|
||||||
.and_then(|n| n.to_str())
|
.and_then(|n| n.to_str())
|
||||||
.unwrap_or("unknown.mp4")
|
.unwrap_or("unknown.mp4")
|
||||||
|
|
@ -431,7 +443,7 @@ impl TemplateMatchingResultService {
|
||||||
media_path: String::new(),
|
media_path: String::new(),
|
||||||
object_locked: None,
|
object_locked: None,
|
||||||
origin_material_id: String::new(),
|
origin_material_id: String::new(),
|
||||||
path: material_segment.file_path.clone(), // 使用匹配的素材路径
|
path: normalized_path.clone(), // 使用清理后的素材路径
|
||||||
picture_from: "none".to_string(),
|
picture_from: "none".to_string(),
|
||||||
picture_set_category_id: String::new(),
|
picture_set_category_id: String::new(),
|
||||||
picture_set_category_name: String::new(),
|
picture_set_category_name: String::new(),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue