Skip to main content

MetadataManager

Struct MetadataManager 

Source
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

Source

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 to
  • video - 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?;
Source

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 to
  • video - Video metadata to apply
  • video_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

Source

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 to
  • thumbnail_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

Source

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 file
  • video - The video metadata
  • video_format - Optional video format for technical metadata
  • audio_format - Optional audio format for technical metadata
ยงErrors

Returns an error if metadata or chapters cannot be added

Source

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 file
  • chapters - 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

Sourceยง

impl MetadataManager

Source

pub fn new() -> Self

Create a new MetadataManager with default ffmpeg path.

The default ffmpeg path is โ€œffmpegโ€ unless overridden by the FFMPEG_PATH environment variable.

ยงReturns

A new MetadataManager instance

Source

pub fn with_ffmpeg_path(ffmpeg_path: impl Into<PathBuf>) -> Self

Create a new MetadataManager with custom ffmpeg path.

ยงArguments
  • ffmpeg_path - Path to the ffmpeg executable
ยงReturns

A new MetadataManager instance with custom ffmpeg path

Trait Implementationsยง

Sourceยง

impl BaseMetadata for MetadataManager

Sourceยง

fn extract_basic_metadata(video: &Video) -> Vec<(String, String)>

Extract basic metadata from a video. Read more
Sourceยง

fn extract_video_format_metadata(format: &Format) -> Vec<(String, String)>

Extract video format metadata. Read more
Sourceยง

fn extract_audio_format_metadata(format: &Format) -> Vec<(String, String)>

Extract audio format metadata. Read more
Sourceยง

fn format_timestamp(timestamp: i64, format_str: &str) -> Option<String>

Format a timestamp into a string according to a specified format. Read more
Sourceยง

fn add_metadata_if_some<T: ToString>( metadata: &mut Vec<(String, String)>, key: &str, value: Option<T>, )

Add metadata to a vector if the value exists. Read more
Sourceยง

impl Clone for MetadataManager

Sourceยง

fn clone(&self) -> MetadataManager

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) ยท Sourceยง

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Sourceยง

impl Debug for MetadataManager

Sourceยง

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Sourceยง

impl Default for MetadataManager

Sourceยง

fn default() -> Self

Returns the โ€œdefault valueโ€ for a type. Read more
Sourceยง

impl Eq for MetadataManager

Sourceยง

impl PartialEq for MetadataManager

Sourceยง

fn eq(&self, other: &MetadataManager) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) ยท Sourceยง

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Sourceยง

impl StructuralPartialEq for MetadataManager

Auto Trait Implementationsยง

Blanket Implementationsยง

Sourceยง

impl<T> Any for T
where T: 'static + ?Sized,

Sourceยง

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Sourceยง

impl<T> Borrow<T> for T
where T: ?Sized,

Sourceยง

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Sourceยง

impl<T> BorrowMut<T> for T
where T: ?Sized,

Sourceยง

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Sourceยง

impl<T> CloneToUninit for T
where T: Clone,

Sourceยง

unsafe fn clone_to_uninit(&self, dest: *mut u8)

๐Ÿ”ฌThis is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Sourceยง

impl<T> Downcast for T
where T: Any,

Sourceยง

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts 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>

Converts 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)

Converts &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)

Converts &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
where T: Any + Send,

Sourceยง

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Sourceยง

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Sourceยง

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Sourceยง

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> โ“˜

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Sourceยง

impl<T> DynClone for T
where T: Clone,

Sourceยง

fn __clone_box(&self, _: Private) -> *mut ()

Sourceยง

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Sourceยง

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Sourceยง

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Sourceยง

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Sourceยง

impl<T> From<T> for T

Sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

Sourceยง

impl<T> Instrument for T

Sourceยง

fn instrument(self, span: Span) -> Instrumented<Self> โ“˜

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Sourceยง

fn in_current_span(self) -> Instrumented<Self> โ“˜

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Sourceยง

impl<T, U> Into<U> for T
where U: From<T>,

Sourceยง

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Sourceยง

impl<T> Pointable for T

Sourceยง

const ALIGN: usize

The alignment of pointer.
Sourceยง

type Init = T

The type for initializers.
Sourceยง

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Sourceยง

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Sourceยง

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Sourceยง

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Sourceยง

impl<T> PolicyExt for T
where T: ?Sized,

Sourceยง

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Sourceยง

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Sourceยง

impl<T> Same for T

Sourceยง

type Output = T

Should always be Self
Sourceยง

impl<T> ToOwned for T
where T: Clone,

Sourceยง

type Owned = T

The resulting type after obtaining ownership.
Sourceยง

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Sourceยง

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Sourceยง

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Sourceยง

type Error = Infallible

The type returned in the event of a conversion error.
Sourceยง

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Sourceยง

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Sourceยง

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Sourceยง

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Sourceยง

impl<T> WithSubscriber for T

Sourceยง

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> โ“˜
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Sourceยง

fn with_current_subscriber(self) -> WithDispatch<Self> โ“˜

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more