#id3 #audio #parser #metadata

id3

A library for reading and writing ID3 metadata

27 releases

0.6.2 Feb 13, 2021
0.5.3 Jan 31, 2021
0.5.1 May 1, 2020
0.5.0 Feb 2, 2020
0.1.6 Jun 6, 2015

#3 in Audio

Download history 292/week @ 2020-11-14 389/week @ 2020-11-21 549/week @ 2020-11-28 933/week @ 2020-12-05 1050/week @ 2020-12-12 679/week @ 2020-12-19 1059/week @ 2020-12-26 482/week @ 2021-01-02 1097/week @ 2021-01-09 711/week @ 2021-01-16 543/week @ 2021-01-23 678/week @ 2021-01-30 522/week @ 2021-02-06 535/week @ 2021-02-13 788/week @ 2021-02-20 327/week @ 2021-02-27

2,976 downloads per month
Used in 20 crates (16 directly)

MIT license

230KB
5K SLoC

rust-id3

Build Status Crate Documentation

A library for reading and writing ID3 metadata.

Examples

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(())
}

Supported ID3 Versions

  • ID3v1 reading
  • ID3v2.2 reading/writing
  • ID3v2.3 reading/writing
  • ID3v2.4 reading/writing

Unsupported Features

  • Grouping identity
  • Encryption

Dependencies

~340–465KB