mirror of
https://github.com/Bluemangoo/sekai-unpacker.git
synced 2026-05-06 20:44:47 +08:00
fix export path
This commit is contained in:
parent
cc4e6f0615
commit
8d4b6e79f3
@ -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| {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
use crate::config::{ClientConfig, Profile};
|
||||
use crate::queue::SharedQueue;
|
||||
use crate::signal::Signal;
|
||||
use crate::task::{AtomicCounters, AutoSaveManifest, post_run, run_main, run_side};
|
||||
use crate::task::{AtomicCounters, AutoSaveManifest, pre_run, run_main, run_side};
|
||||
use common::strings::REGION_NOT_FOUND;
|
||||
use common::updater::DownloadTask;
|
||||
use communicator::{ClientManager, Identity, TunnelEndpoint, TunnelListener, connect_tunnel};
|
||||
@ -233,7 +233,7 @@ async fn main() -> anyhow::Result<()> {
|
||||
if cancel_token.is_cancelled() {
|
||||
return;
|
||||
}
|
||||
let sync_id = post_run(client.clone(), profile.clone(), tasks.clone(), cnt.clone()).await;
|
||||
let sync_id = pre_run(client.clone(), profile.clone(), tasks.clone(), cnt.clone()).await;
|
||||
let sig = signal.pick().await;
|
||||
let result = match sync_id {
|
||||
Ok(Some(id)) => {
|
||||
@ -328,7 +328,7 @@ async fn main() -> anyhow::Result<()> {
|
||||
if cancel_token.is_cancelled() {
|
||||
return;
|
||||
}
|
||||
let sync_id = post_run(client.clone(), profile.clone(), tasks.clone(), cnt.clone()).await;
|
||||
let sync_id = pre_run(client.clone(), profile.clone(), tasks.clone(), cnt.clone()).await;
|
||||
let sig = signal.pick().await;
|
||||
let result = match sync_id {
|
||||
Ok(Some(id)) => {
|
||||
|
||||
@ -15,7 +15,7 @@ use tokio::sync::{RwLock, Semaphore};
|
||||
use tokio::task::JoinSet;
|
||||
use tokio_util::sync::CancellationToken;
|
||||
|
||||
pub async fn post_run(
|
||||
pub async fn pre_run(
|
||||
client: Arc<ClientManager>,
|
||||
profile: Arc<(String, Arc<RwLock<Profile>>)>,
|
||||
queue: SharedQueue<DownloadTask>,
|
||||
|
||||
@ -82,7 +82,7 @@ profiles:
|
||||
# 并发下载数(单个资源包的同时下载线程数)
|
||||
concurrent: 50
|
||||
|
||||
# 精确匹配单文件包
|
||||
# 展开单文件包
|
||||
exact_single_file_bundle: true
|
||||
|
||||
# 导出基础路径
|
||||
@ -93,7 +93,7 @@ profiles:
|
||||
# 启动应用时必须下载的资源类型
|
||||
start_app:
|
||||
- "thumbnail" # 缩略图
|
||||
- "stamp" # 邮票/表情
|
||||
- "stamp" # 表情
|
||||
# - "area" # 地图
|
||||
# - "home" # 主页背景
|
||||
|
||||
@ -158,7 +158,7 @@ profiles:
|
||||
# 并发下载数
|
||||
concurrent: 50
|
||||
|
||||
# 精确匹配单文件包
|
||||
# 展开单文件包
|
||||
exact_single_file_bundle: true
|
||||
|
||||
# 导出路径
|
||||
|
||||
@ -108,7 +108,7 @@ concurrency:
|
||||
# ACB 音频包解析的并发数
|
||||
acb: 8
|
||||
|
||||
# USM 视频解析的并发数
|
||||
# USM 视频解析的并发数(好像没用到)
|
||||
usm: 4
|
||||
|
||||
# HCA 音频解码的并发数(通常可设置较大值)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user