pub struct MetadataManager { /* private fields */ }Expand description
Metadata manager for handling file metadata.
This manager provides methods to add metadata and thumbnails to downloaded files in various formats (MP3, M4A, MP4, WebM, MKV, etc.).
Implementationsยง
Sourceยงimpl MetadataManager
impl MetadataManager
Sourcepub async fn add_metadata(
&self,
file_path: impl Into<PathBuf>,
video: &Video,
) -> Result<()>
pub async fn add_metadata( &self, file_path: impl Into<PathBuf>, video: &Video, ) -> Result<()>
Add metadata to a file based on its format.
This method automatically detects the file format and applies appropriate metadata. Use this for standalone files when you donโt have format details.
ยงArguments
file_path- Path to the file to add metadata tovideo- Video metadata to apply
ยงErrors
Returns an error if the file format is unsupported or if metadata writing fails
ยงExamples
let manager = MetadataManager::new();
// video obtained from a fetch_video_infos call
manager.add_metadata("video.mp4", &video).await?;Sourcepub async fn add_metadata_with_format(
&self,
file_path: impl Into<PathBuf>,
video: &Video,
video_format: Option<&Format>,
audio_format: Option<&Format>,
) -> Result<()>
pub async fn add_metadata_with_format( &self, file_path: impl Into<PathBuf>, video: &Video, video_format: Option<&Format>, audio_format: Option<&Format>, ) -> Result<()>
Add metadata to a file with format details for audio and video.
This method should be used when you have detailed format information, typically for combined audio+video files. Technical metadata (resolution, codecs, bitrates) will be included for MP4 and WebM formats.
ยงArguments
file_path- Path to the file to add metadata tovideo- Video metadata to applyvideo_format- Optional video format details (for technical metadata)audio_format- Optional audio format details (for technical metadata)
ยงErrors
Returns an error if the file format is unsupported or if metadata writing fails
Sourcepub async fn add_thumbnail_to_file(
&self,
file_path: impl Into<PathBuf>,
thumbnail_path: impl Into<PathBuf>,
) -> Result<()>
pub async fn add_thumbnail_to_file( &self, file_path: impl Into<PathBuf>, thumbnail_path: impl Into<PathBuf>, ) -> Result<()>
Add a thumbnail to a file based on its format.
Thumbnails are embedded in the file metadata. Supported formats: MP3, M4A, MP4, WebM, MKV
ยงArguments
file_path- Path to the file to add thumbnail tothumbnail_path- Path to the thumbnail image file
ยงErrors
Returns an error if the file format doesnโt support thumbnails or if embedding fails
ยงExamples
let manager = MetadataManager::new();
manager
.add_thumbnail_to_file("video.mp3", "cover.jpg")
.await?;Sourceยงimpl MetadataManager
impl MetadataManager
Sourcepub async fn add_metadata_with_chapters(
&self,
file_path: impl Into<PathBuf>,
video: &Video,
video_format: Option<&Format>,
audio_format: Option<&Format>,
) -> Result<()>
pub async fn add_metadata_with_chapters( &self, file_path: impl Into<PathBuf>, video: &Video, video_format: Option<&Format>, audio_format: Option<&Format>, ) -> Result<()>
Add both regular metadata and chapters to a video file.
This is a convenience method that combines add_metadata_with_format and
add_chapters_metadata in a single operation.
ยงArguments
file_path- Path to the video filevideo- The video metadatavideo_format- Optional video format for technical metadataaudio_format- Optional audio format for technical metadata
ยงErrors
Returns an error if metadata or chapters cannot be added
Sourcepub async fn add_chapters_metadata(
&self,
file_path: impl Into<PathBuf>,
chapters: &[Chapter],
) -> Result<()>
pub async fn add_chapters_metadata( &self, file_path: impl Into<PathBuf>, chapters: &[Chapter], ) -> Result<()>
Add chapters metadata to a video file using FFmpeg.
This method embeds chapter markers into MP4/MKV/WebM files. Chapters allow media players to navigate to specific sections of the video.
ยงArguments
file_path- Path to the video filechapters- The chapters to embed
ยงErrors
Returns an error if FFmpeg fails or if the file cannot be processed
ยงReturns
Ok(()) if chapters were successfully embedded
Trait Implementationsยง
Sourceยงimpl BaseMetadata for MetadataManager
impl BaseMetadata for MetadataManager
Sourceยงfn extract_basic_metadata(video: &Video) -> Vec<(String, String)>
fn extract_basic_metadata(video: &Video) -> Vec<(String, String)>
Sourceยงfn extract_video_format_metadata(format: &Format) -> Vec<(String, String)>
fn extract_video_format_metadata(format: &Format) -> Vec<(String, String)>
Sourceยงfn extract_audio_format_metadata(format: &Format) -> Vec<(String, String)>
fn extract_audio_format_metadata(format: &Format) -> Vec<(String, String)>
Sourceยงimpl Clone for MetadataManager
impl Clone for MetadataManager
Sourceยงfn clone(&self) -> MetadataManager
fn clone(&self) -> MetadataManager
1.0.0 (const: unstable) ยท Sourceยงfn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSourceยงimpl Debug for MetadataManager
impl Debug for MetadataManager
Sourceยงimpl Default for MetadataManager
impl Default for MetadataManager
impl Eq for MetadataManager
Sourceยงimpl PartialEq for MetadataManager
impl PartialEq for MetadataManager
impl StructuralPartialEq for MetadataManager
Auto Trait Implementationsยง
impl Freeze for MetadataManager
impl RefUnwindSafe for MetadataManager
impl Send for MetadataManager
impl Sync for MetadataManager
impl Unpin for MetadataManager
impl UnsafeUnpin for MetadataManager
impl UnwindSafe for MetadataManager
Blanket Implementationsยง
Sourceยงimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Sourceยงfn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Sourceยงimpl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Sourceยงimpl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Sourceยงfn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Sourceยงfn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Sourceยงfn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Anyโs vtable from &Traitโs.Sourceยงfn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Anyโs vtable from &mut Traitโs.Sourceยงimpl<T> DowncastSend for T
impl<T> DowncastSend for T
Sourceยงimpl<T> DowncastSync for T
impl<T> DowncastSync for T
Sourceยงimpl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Sourceยงfn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.