use std::path::PathBuf;
use crate::error::Result;
pub mod api;
pub mod base;
pub mod chapters;
pub mod postprocess;
pub mod writers;
pub use base::BaseMetadata;
#[derive(Debug, Clone)]
pub struct PlaylistMetadata {
pub title: String,
pub id: String,
pub index: usize,
pub total: Option<usize>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct MetadataManager {
ffmpeg_path: PathBuf,
}
impl MetadataManager {
pub fn new() -> Self {
let ffmpeg_path = Self::default_ffmpeg_path();
tracing::debug!(
ffmpeg_path = ?ffmpeg_path,
"⚙️ Creating new MetadataManager"
);
Self { ffmpeg_path }
}
pub fn with_ffmpeg_path(ffmpeg_path: impl Into<PathBuf>) -> Self {
let ffmpeg_path = ffmpeg_path.into();
tracing::debug!(
ffmpeg_path = ?ffmpeg_path,
"⚙️ Creating MetadataManager with custom ffmpeg path"
);
Self { ffmpeg_path }
}
pub(crate) fn default_ffmpeg_path() -> PathBuf {
std::env::var("FFMPEG_PATH")
.map(|path| {
tracing::debug!(
ffmpeg_path = %path,
"⚙️ Using ffmpeg path from FFMPEG_PATH environment variable"
);
PathBuf::from(path)
})
.unwrap_or_else(|_| {
tracing::debug!("⚙️ Using default ffmpeg path");
PathBuf::from("ffmpeg")
})
}
pub(crate) fn get_file_extension(file_path: impl Into<PathBuf>) -> Result<String> {
crate::utils::fs::try_extension(&file_path.into())
}
pub(crate) fn create_temp_output_path(
file_path: impl Into<PathBuf>,
file_format: &str,
) -> crate::error::Result<PathBuf> {
Ok(crate::utils::fs::create_temp_path(&file_path.into(), file_format))
}
}
impl Default for MetadataManager {
fn default() -> Self {
Self::new()
}
}
impl BaseMetadata for MetadataManager {}