|
|
|
@ -3,7 +3,7 @@ use std::{ |
|
|
|
set_current_dir},
|
|
|
|
ffi::OsString,
|
|
|
|
io::ErrorKind,
|
|
|
|
path::Path,
|
|
|
|
path::{Path, PathBuf},
|
|
|
|
process::{Command, ExitStatus}
|
|
|
|
};
|
|
|
|
|
|
|
|
@ -13,7 +13,7 @@ use shellwords::escape; |
|
|
|
use tokio::fs::{create_dir, remove_dir_all};
|
|
|
|
use which::which;
|
|
|
|
|
|
|
|
use log::{log, Level};
|
|
|
|
use log::debug;
|
|
|
|
|
|
|
|
|
|
|
|
pub(super) async fn enter_download_dir(name: &dyn AsRef<Path>) -> anyhow::Result<OsString> {
|
|
|
|
@ -29,15 +29,18 @@ pub(super) async fn enter_download_dir(name: &dyn AsRef<Path>) -> anyhow::Result |
|
|
|
return Err(anyhow!("Unable to create directory at {:?}", basename));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
set_current_dir(basename)?;
|
|
|
|
let basename = PathBuf::from(basename)
|
|
|
|
. canonicalize()?;
|
|
|
|
|
|
|
|
set_current_dir(basename.clone())?;
|
|
|
|
|
|
|
|
Ok(basename.into())
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(super) async fn remove_download_dir(name: &dyn AsRef<Path>) -> anyhow::Result<()> {
|
|
|
|
let name = name.as_ref().parent()
|
|
|
|
let parent = name.as_ref().parent()
|
|
|
|
. ok_or(anyhow!("Failed to get parent of download dir"))?;
|
|
|
|
set_current_dir(name)?;
|
|
|
|
set_current_dir(parent)?;
|
|
|
|
remove_dir_all(name).await?;
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
@ -59,15 +62,14 @@ pub(super) async fn ffmpeg(name: &dyn AsRef<Path>, uri: &Uri) -> anyhow::Result< |
|
|
|
let index = Path::new(index).canonicalize()?;
|
|
|
|
let index = index.as_os_str();
|
|
|
|
|
|
|
|
log!(Level::Debug, "ffmpeg: {:?}", ffmpeg);
|
|
|
|
log!(Level::Debug, "index: {:?}", index);
|
|
|
|
log!(Level::Debug, "outfile: {:?}", outfile);
|
|
|
|
debug!("ffmpeg: {:?}", ffmpeg);
|
|
|
|
debug!("index: {:?}", index);
|
|
|
|
debug!("outfile: {:?}", outfile);
|
|
|
|
|
|
|
|
log!( Level::Debug
|
|
|
|
, "execute: {} -allowed_extensions ALL -i {} -c copy {}"
|
|
|
|
, escape(ffmpeg.try_into()?)
|
|
|
|
, escape(index.try_into()?)
|
|
|
|
, escape(outfile.try_into()?) );
|
|
|
|
debug!("execute: {} -allowed_extensions ALL -i {} -c copy {}"
|
|
|
|
, escape(ffmpeg.try_into()?)
|
|
|
|
, escape(index.try_into()?)
|
|
|
|
, escape(outfile.try_into()?) );
|
|
|
|
let mut child = Command::new(ffmpeg)
|
|
|
|
. arg("-allowed_extensions")
|
|
|
|
. arg("ALL")
|
|
|
|
|