mirror of
https://github.com/Bluemangoo/sekai-unpacker.git
synced 2026-09-20 00:06:52 +08:00
fix export path
This commit is contained in:
@@ -179,7 +179,6 @@ pub async fn post_process_exported_files(
|
||||
handle_usm_files(
|
||||
export_path,
|
||||
sync_context,
|
||||
region,
|
||||
&app_config.tools.ffmpeg_path,
|
||||
&app_config.execution.retry,
|
||||
)
|
||||
@@ -202,7 +201,6 @@ pub async fn post_process_exported_files(
|
||||
async fn handle_usm_files(
|
||||
export_path: &Path,
|
||||
sync_context: &SyncContext,
|
||||
region: &RegionConfig,
|
||||
ffmpeg_path: &str,
|
||||
retry: &crate::core::config::RetryConfig,
|
||||
) -> Result<Vec<PathBuf>, ExportPipelineError> {
|
||||
@@ -211,28 +209,17 @@ async fn handle_usm_files(
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
|
||||
let usm_input = if usm_files.len() == 1 {
|
||||
usm_files[0].clone()
|
||||
} else {
|
||||
merge_usm_files(export_path, &usm_files)?
|
||||
};
|
||||
let mut out: Vec<PathBuf> = vec![];
|
||||
|
||||
process_usm_file(
|
||||
&usm_input,
|
||||
export_path,
|
||||
sync_context,
|
||||
region,
|
||||
ffmpeg_path,
|
||||
retry,
|
||||
)
|
||||
.await
|
||||
for f in usm_files {
|
||||
out.append(&mut process_usm_file(&f, sync_context, ffmpeg_path, retry).await?);
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
async fn process_usm_file(
|
||||
usm_file: &Path,
|
||||
export_path: &Path,
|
||||
sync_context: &SyncContext,
|
||||
_: &RegionConfig,
|
||||
ffmpeg_path: &str,
|
||||
retry: &crate::core::config::RetryConfig,
|
||||
) -> Result<Vec<PathBuf>, ExportPipelineError> {
|
||||
@@ -248,7 +235,10 @@ async fn process_usm_file(
|
||||
if sync_context.export.video.convert_to_mp4
|
||||
&& sync_context.export.video.direct_usm_to_mp4_with_ffmpeg
|
||||
{
|
||||
let mp4 = export_path.join(format!("{output_name}.mp4"));
|
||||
let mp4 = usm_file
|
||||
.parent()
|
||||
.unwrap()
|
||||
.join(format!("{output_name}.mp4"));
|
||||
convert_usm_to_mp4(usm_file, &mp4, ffmpeg_path, retry).await?;
|
||||
remove_file_if_exists(usm_file)?;
|
||||
return Ok(vec![mp4]);
|
||||
@@ -260,7 +250,7 @@ async fn process_usm_file(
|
||||
.and_then(|metadata| metadata.video_frame_rate())
|
||||
.filter(|(_, denominator)| *denominator > 0)
|
||||
.map(FrameRate::from_tuple);
|
||||
let extracted = codec::export_usm(usm_file, export_path)?;
|
||||
let extracted = codec::export_usm(usm_file, usm_file.parent().unwrap())?;
|
||||
let mut generated = extracted.clone();
|
||||
|
||||
if sync_context.export.video.convert_to_mp4 {
|
||||
@@ -271,7 +261,10 @@ async fn process_usm_file(
|
||||
.map(|ext| ext.eq_ignore_ascii_case("m2v"))
|
||||
.unwrap_or(false)
|
||||
{
|
||||
let mp4 = export_path.join(format!("{output_name}.mp4"));
|
||||
let mp4 = usm_file
|
||||
.parent()
|
||||
.unwrap()
|
||||
.join(format!("{output_name}.mp4"));
|
||||
convert_m2v_to_mp4(
|
||||
&extracted_file,
|
||||
&mp4,
|
||||
@@ -327,7 +320,7 @@ async fn handle_acb_files(
|
||||
|
||||
fn process_acb_file(
|
||||
acb_file: &Path,
|
||||
output_dir: &Path,
|
||||
_output_dir: &Path,
|
||||
sync_context: &SyncContext,
|
||||
region: &RegionConfig,
|
||||
ffmpeg_path: &str,
|
||||
@@ -381,7 +374,7 @@ fn process_acb_file(
|
||||
&retry,
|
||||
)
|
||||
})?;
|
||||
let final_outputs = move_result_files(output_dir, &generated)?;
|
||||
let final_outputs = move_result_files(acb_file.parent().unwrap(), &generated)?;
|
||||
|
||||
remove_file_if_exists(acb_file)?;
|
||||
Ok(final_outputs)
|
||||
@@ -429,7 +422,7 @@ fn process_hca_file(
|
||||
generated.clear();
|
||||
}
|
||||
|
||||
let final_outputs = move_result_files(output_dir, &generated)?;
|
||||
let final_outputs = move_result_files(hca_file.parent().unwrap(), &generated)?;
|
||||
Ok(final_outputs)
|
||||
}
|
||||
|
||||
@@ -710,38 +703,6 @@ fn panic_message(panic: Box<dyn std::any::Any + Send>) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
fn merge_usm_files(dir: &Path, usm_files: &[PathBuf]) -> Result<PathBuf, ExportPipelineError> {
|
||||
let dir_name = dir
|
||||
.file_name()
|
||||
.and_then(|name| name.to_str())
|
||||
.unwrap_or("merged");
|
||||
let merged_file = dir.join(format!("{dir_name}.usm"));
|
||||
let mut target =
|
||||
std::fs::File::create(&merged_file).map_err(|source| ExportPipelineError::Io {
|
||||
path: merged_file.clone(),
|
||||
source,
|
||||
})?;
|
||||
|
||||
for source_path in usm_files {
|
||||
if *source_path == merged_file {
|
||||
continue;
|
||||
}
|
||||
let mut source =
|
||||
std::fs::File::open(source_path).map_err(|source| ExportPipelineError::Io {
|
||||
path: source_path.clone(),
|
||||
source,
|
||||
})?;
|
||||
std::io::copy(&mut source, &mut target).map_err(|source| ExportPipelineError::Io {
|
||||
path: source_path.clone(),
|
||||
source,
|
||||
})?;
|
||||
drop(source);
|
||||
remove_file_if_exists(source_path)?;
|
||||
}
|
||||
|
||||
Ok(merged_file)
|
||||
}
|
||||
|
||||
pub fn find_files(dir: &Path) -> Result<Vec<PathBuf>, ExportPipelineError> {
|
||||
let mut files = Vec::new();
|
||||
walk(dir, &mut |path| {
|
||||
|
||||
Reference in New Issue
Block a user