Crate id3[−][src]
A library to read and write ID3v2 tags. ID3 versions v2.2, v2.3, and v2.4 are supported.
Reading tag frames
use id3::{Tag, Version}; fn main() -> Result<(), Box<dyn std::error::Error>> { let tag = Tag::read_from_path("testdata/id3v24.id3")?; // Get a bunch of frames... if let Some(artist) = tag.artist() { println!("artist: {}", artist); } if let Some(title) = tag.title() { println!("title: {}", title); } if let Some(album) = tag.album() { println!("album: {}", album); } // Get frames before getting their content for more complex tags. if let Some(artist) = tag.get("TPE1").and_then(|frame| frame.content().text()) { println!("artist: {}", artist); } Ok(()) }
Modifying an existing tag.
use id3::{Tag, Version}; fn main() -> Result<(), Box<dyn std::error::Error>> { let mut tag = Tag::read_from_path("music.mp3")?; tag.set_album("Fancy Album Title"); tag.write_to_path("music.mp3", Version::Id3v24)?; Ok(()) }
Creating a new tag, overwriting any old tag.
use id3::{Tag, Frame, Version}; use id3::frame::Content; fn main() -> Result<(), Box<dyn std::error::Error>> { let mut tag = Tag::new(); tag.set_album("Fancy Album Title"); // Set the album the hard way. tag.add_frame(Frame::with_content("TALB", Content::Text("album".to_string()))); tag.write_to_path("music.mp3", Version::Id3v24)?; Ok(()) }
Resources
- ID3v2.2 http://id3.org/id3v2-00
- ID3v2.3 http://id3.org/id3v2.3.0
- ID3v2.4 http://id3.org/id3v2.4.0-structure
Re-exports
pub use crate::frame::Frame; |
Modules
frame | Contains types and methods for operating on ID3 frames. |
v1 | Utilities for working with ID3v1 tags. |
Structs
Encoder | The |
Error | A structure able to represent any error that may occur while performing metadata operations. |
Tag | An ID3 tag containing metadata frames. |
Timestamp | Represents a date and time according to the ID3v2.4 spec: |
Enums
Content | The decoded contents of a frame. |
ErrorKind | Kinds of errors that may occur while performing metadata operations. |
Version | Denotes the version of a tag. |
Type Definitions
Result | Type alias for the result of tag operations. |