• Stars
    star
    220
  • Rank 180,422 (Top 4 %)
  • Language
    Rust
  • License
    MIT License
  • Created about 10 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A rust library for reading and writing ID3 metadata

rust-id3

Build Status Crate Documentation

A library for reading and writing ID3 metadata.

Implemented Features

  • ID3v1 reading
  • ID3v2.2, ID3v2.3, ID3v2.4 reading/writing
  • MP3, WAV and AIFF files
  • Latin1, UTF16 and UTF8 encodings
  • Text frames
  • Extended Text frames
  • Link frames
  • Extended Link frames
  • Comment frames
  • Lyrics frames
  • Synchronised Lyrics frames
  • Picture frames
  • Encapsulated Object frames
  • Chapter frames
  • Unsynchronisation
  • Compression
  • MPEG Location Lookup Table frames
  • Tag and File Alter Preservation bits

Examples

Reading tag frames

use id3::{Tag, TagLike};

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 any existing tag.

use id3::{Error, ErrorKind, Tag, TagLike, Version};
use std::fs::copy;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    copy("testdata/quiet.mp3", "/tmp/music.mp3")?;

    let mut tag = match Tag::read_from_path("/tmp/music.mp3") {
        Ok(tag) => tag,
        Err(Error{kind: ErrorKind::NoTag, ..}) => Tag::new(),
        Err(err) => return Err(Box::new(err)),
    };

    tag.set_album("Fancy Album Title");

    tag.write_to_path("/tmp/music.mp3", Version::Id3v24)?;
    Ok(())
}

Creating a new tag, overwriting any old tag.

use id3::{Tag, TagLike, Frame, Version};
use id3::frame::Content;
use std::fs::copy;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    copy("testdata/quiet.mp3", "/tmp/music.mp3")?;

    let mut tag = Tag::new();
    tag.set_album("Fancy Album Title");

    // Set the album the hard way.
    tag.add_frame(Frame::text("TALB", "album"));

    tag.write_to_path("/tmp/music.mp3", Version::Id3v24)?;
    Ok(())
}

Contributing

Do you think you have found a bug? Then please report it via the Github issue tracker. Make sure to attach any problematic files that can be used to reproduce the issue. Such files are also used to create regression tests that ensure that your bug will never return.

When submitting pull requests, please prefix your commit messages with fix: or feat: for bug fixes and new features respectively. This is the Conventional Commits scheme that is used to automate some maintenance chores such as generating the changelog and inferring the next version number.

More Repositories

1

go-errorlint

A source code linter that can be used to find code that will cause problems with Go's error wrapping scheme
Go
193
star
2

shady

CLI tool to render GLSL shaders
Go
108
star
3

ledcat

Control lots of LED's over lots of protocols
Rust
95
star
4

soundcloud-fs

A SoundCloud FUSE driver optimized for music libraries
Rust
64
star
5

trollibox

The hackerspace friendly music player web client
Go
40
star
6

edge-detection-rs

The Canny edge detection algorithm implemented in Rust
Rust
36
star
7

esp32-sensornode

Modular sensor platform
C++
14
star
8

cube-shaders

Animations for my 3D LED-Cube written in GLSL
GLSL
11
star
9

go-opentelemetry-lint

Golang linter to find and automatically fix issues with OpenTelemetry spans
Go
10
star
10

go-iterator

Go 1.18 generics iterator experiment
Go
5
star
11

go-ilda-renderer

A Go program that transcodes ILDA laser shows to animated GIFs
Go
5
star
12

glsl-workshop

GLSL
5
star
13

procsweeper

Minesweeper for your /proc
C
4
star
14

sha2017-badge-co2-sensor

Python
4
star
15

sha2017-lenny-face-generator

The Lenny Face Generator ported to the SHA2017 badge
Python
3
star
16

ledcubesim

A simulator for volumetric displays
Python
2
star
17

ledcat-nyancat

Nyan!
Python
2
star
18

librgbmatrix-sys

System crate for Hzeller's rpi-rgb-led-matrix C-library
Rust
2
star
19

video-mapper

An OpenGL application for projecting videos and images onto cubes
C++
2
star
20

audio-thing

WIP
Rust
2
star
21

gopolyjson

Go Code generator of JSON marshalers/unmarshalers for polymorphic datastructures
Go
2
star
22

buienradar-prometheus-exporter

Python
1
star
23

gyros

Arduino sketch to dump the BNO055 IMU rotation as a 4x4 matrix over serial
C
1
star
24

ektoplazm-flashfree

A free player for free music
JavaScript
1
star
25

webfs

A daemon that presents the contents of one or more directories through a web-interface
Go
1
star
26

hackerhotel2019-tvoc-grapher

An app for the HackerHotel2019 badge that displays readings from the SGP30 volatile organic compound sensor
Python
1
star