mirror of
https://github.com/OMGeeky/twba.splitter.git
synced 2026-02-23 15:49:57 +01:00
fix wrong path bugs
This commit is contained in:
@@ -95,9 +95,7 @@ impl SplitterClient {
|
|||||||
let duration = Instant::now().duration_since(start_time);
|
let duration = Instant::now().duration_since(start_time);
|
||||||
info!("FFMPEG-Splitting took: {:?}", duration);
|
info!("FFMPEG-Splitting took: {:?}", duration);
|
||||||
let split_info = utils::get_playlist_info(&split_playlist_path).await?;
|
let split_info = utils::get_playlist_info(&split_playlist_path).await?;
|
||||||
tokio::fs::remove_file(&split_playlist_path)
|
Self::remove_file(&split_playlist_path).await?;
|
||||||
.await
|
|
||||||
.map_err(|e| SplitterError::Write(split_playlist_path.clone(), e))?;
|
|
||||||
trace!(
|
trace!(
|
||||||
"total duration: {} in {} parts",
|
"total duration: {} in {} parts",
|
||||||
split_info.total_duration.to_string(),
|
split_info.total_duration.to_string(),
|
||||||
@@ -108,9 +106,7 @@ impl SplitterClient {
|
|||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
debug!("removing original file: {:?}", input_path);
|
debug!("removing original file: {:?}", input_path);
|
||||||
tokio::fs::remove_file(&input_path)
|
Self::remove_file(&input_path).await?;
|
||||||
.await
|
|
||||||
.map_err(|e| SplitterError::Write(input_path.clone(), e))?;
|
|
||||||
|
|
||||||
let duration = Instant::now().duration_since(start_time);
|
let duration = Instant::now().duration_since(start_time);
|
||||||
info!("Done Splitting. Whole operation took: {:?}", duration);
|
info!("Done Splitting. Whole operation took: {:?}", duration);
|
||||||
@@ -118,6 +114,13 @@ impl SplitterClient {
|
|||||||
Ok(paths.len())
|
Ok(paths.len())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn remove_file(input_path: &PathBuf) -> Result<()> {
|
||||||
|
tokio::fs::remove_file(&input_path).await.map_err(|e| {
|
||||||
|
SplitterError::Write(input_path.to_str().unwrap_or("invalid path").to_string(), e)
|
||||||
|
})?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
pub async fn split_videos(&self) -> Result<()> {
|
pub async fn split_videos(&self) -> Result<()> {
|
||||||
info!("Splitting videos");
|
info!("Splitting videos");
|
||||||
|
|||||||
@@ -75,6 +75,10 @@ async fn join_last_two_parts(input_parts: &mut PlaylistInfo, base_folder: &Path)
|
|||||||
let second_last_part_path = combine_path_as_string(base_folder, &second_last_part.path)?;
|
let second_last_part_path = combine_path_as_string(base_folder, &second_last_part.path)?;
|
||||||
let last_part_path = combine_path_as_string(base_folder, &last_part.path)?;
|
let last_part_path = combine_path_as_string(base_folder, &last_part.path)?;
|
||||||
let join_txt_path = base_folder.join("join.txt");
|
let join_txt_path = base_folder.join("join.txt");
|
||||||
|
let join_txt_path_string = join_txt_path
|
||||||
|
.to_str()
|
||||||
|
.unwrap_or("could not parse to string")
|
||||||
|
.to_string();
|
||||||
let join_out_tmp_path = base_folder.join("join_out_tmp.mp4");
|
let join_out_tmp_path = base_folder.join("join_out_tmp.mp4");
|
||||||
tokio::fs::write(
|
tokio::fs::write(
|
||||||
&join_txt_path,
|
&join_txt_path,
|
||||||
@@ -84,7 +88,7 @@ async fn join_last_two_parts(input_parts: &mut PlaylistInfo, base_folder: &Path)
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| SplitterError::Write(join_txt_path.clone(), e))?;
|
.map_err(|e| SplitterError::Write(join_txt_path_string.clone(), e))?;
|
||||||
|
|
||||||
run_ffmpeg_concat(
|
run_ffmpeg_concat(
|
||||||
join_txt_path
|
join_txt_path
|
||||||
@@ -99,27 +103,27 @@ async fn join_last_two_parts(input_parts: &mut PlaylistInfo, base_folder: &Path)
|
|||||||
.await?;
|
.await?;
|
||||||
debug!(
|
debug!(
|
||||||
"removing files: {:?}, {:?}, {:?}",
|
"removing files: {:?}, {:?}, {:?}",
|
||||||
second_last_part.path, last_part.path, join_txt_path
|
second_last_part_path, last_part_path, join_txt_path
|
||||||
);
|
);
|
||||||
trace!("removing file: {:?}", last_part.path);
|
trace!("removing file: {:?}", last_part_path);
|
||||||
tokio::fs::remove_file(&last_part.path)
|
tokio::fs::remove_file(&last_part_path)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| SplitterError::Write(last_part.path, e))?;
|
.map_err(|e| SplitterError::Write(last_part_path, e))?;
|
||||||
trace!("removing file: {:?}", second_last_part.path);
|
trace!("removing file: {:?}", second_last_part_path);
|
||||||
tokio::fs::remove_file(&second_last_part.path)
|
tokio::fs::remove_file(&second_last_part_path)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| SplitterError::Write(second_last_part.path.clone(), e))?;
|
.map_err(|e| SplitterError::Write(second_last_part_path.clone(), e))?;
|
||||||
trace!("removing file: {:?}", join_txt_path);
|
trace!("removing file: {:?}", join_txt_path);
|
||||||
tokio::fs::remove_file(&join_txt_path)
|
tokio::fs::remove_file(&join_txt_path)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| SplitterError::Write(join_txt_path.clone(), e))?;
|
.map_err(|e| SplitterError::Write(join_txt_path_string, e))?;
|
||||||
debug!(
|
debug!(
|
||||||
"renaming file: {:?} to {:?}",
|
"renaming file: {:?} to {:?}",
|
||||||
join_out_tmp_path, second_last_part.path
|
join_out_tmp_path, second_last_part_path
|
||||||
);
|
);
|
||||||
tokio::fs::rename(join_out_tmp_path, &second_last_part.path)
|
tokio::fs::rename(join_out_tmp_path, &second_last_part_path)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| SplitterError::Write(second_last_part.path.clone(), e))?;
|
.map_err(|e| SplitterError::Write(second_last_part_path, e))?;
|
||||||
debug!("joined last two parts together");
|
debug!("joined last two parts together");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ pub enum SplitterError {
|
|||||||
#[error("Could not read from filesystem: {0:?}")]
|
#[error("Could not read from filesystem: {0:?}")]
|
||||||
Read(#[source] io::Error),
|
Read(#[source] io::Error),
|
||||||
#[error("Could not write to filesystem: {0:?}")]
|
#[error("Could not write to filesystem: {0:?}")]
|
||||||
Write(PathBuf, #[source] io::Error),
|
Write(String, #[source] io::Error),
|
||||||
|
|
||||||
#[error("Path could not be canonicalized: {0:?}")]
|
#[error("Path could not be canonicalized: {0:?}")]
|
||||||
Canonicalize(#[source] io::Error),
|
Canonicalize(#[source] io::Error),
|
||||||
|
|||||||
Reference in New Issue
Block a user