MCPcopy Index your code
hub / github.com/TianyiShi2001/audiotags

github.com/TianyiShi2001/audiotags @0.5.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.5.0 ↗ · + Follow
214 symbols 404 edges 13 files 9 documented · 4% updated 1y ago0.5.0 · 2024-02-01★ 5810 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

audiotags

Crate Crate Crate Documentation

This crate makes it easier to parse, convert and write metadata (a.k.a. tag) in audio files of different file types.

This crate aims to provide a unified trait for parsers and writers of different audio file formats. This means that you can parse tags in mp3, flac, and m4a files with a single function: Tag::default(). read_from_path() and get fields by directly calling .album(), .artist() on its result. Without this crate, you would otherwise need to learn different APIs in id3, mp4ameta etc. in order to parse metadata in different file formats.

Performance

Using audiotags incurs a little overhead due to vtables if you want to guess the metadata format (from file extension). Apart from this the performance is almost the same as directly calling function provided by those 'specialized' crates.

No copies will be made if you only need to read and write metadata of one format. If you want to convert between tags, copying is unavoidable no matter if you use audiotags or use getters and setters provided by specialized libraries. audiotags is not making additional unnecessary copies.

Supported Formats

File Format Metadata Format backend
mp3 id3v2.4 id3
m4a/mp4/... MPEG-4 audio metadata mp4ameta
flac Vorbis comment metaflac

Examples

Read the manual for some examples, but here's a quick-one:

fn main() {
    // using `default()` or `new()` alone so that the metadata format is
    // guessed (from the file extension) (in this case, Id3v2 tag is read)
    let mut tag = Tag::new().read_from_path(MP3_FILE).unwrap();

    tag.set_title("foo title");
    assert_eq!(tag.title(), Some("foo title"));
    tag.remove_title();
    assert!(tag.title().is_none());
    tag.remove_title();
    // trying to remove a field that's already empty won't hurt

    let cover = Picture {
        mime_type: MimeType::Jpeg,
        data: &vec![0u8; 10],
    };

    tag.set_album_cover(cover.clone());
    assert_eq!(tag.album_cover(), Some(cover));
    tag.remove_album_cover();
    assert!(tag.album_cover().is_none());
    tag.remove_album_cover();

    tag.write_to_path(MP3_FILE).expect("Fail to save");
}

License: MIT

Extension points exported contracts — how you extend this code

AudioTagEdit (Interface)
Implementors of this trait are able to read and write audio metadata. Constructor methods e.g. `from_file` should be im [3 …
src/traits.rs
AudioTagWrite (Interface)
(no doc) [3 implementers]
src/traits.rs
AudioTagConfig (Interface)
(no doc) [1 implementers]
src/traits.rs
AudioTag (Interface)
(no doc)
src/traits.rs
ToAnyTag (Interface)
(no doc)
src/traits.rs

Core symbols most depended-on inside this repo

remove
called by 16
src/components/flac_tag.rs
get_first
called by 14
src/components/flac_tag.rs
set_first
called by 13
src/components/flac_tag.rs
set_album
called by 4
src/traits.rs
config
called by 4
src/anytag.rs
artists
called by 4
src/components/mp4_tag.rs
album_artists
called by 4
src/components/mp4_tag.rs
set_config
called by 3
src/anytag.rs

Shape

Method 199
Interface 6
Class 5
Enum 3
Function 1

Languages

Rust100%

Modules by API surface

src/components/mp4_tag.rs53 symbols
src/components/flac_tag.rs49 symbols
src/components/id3_tag.rs47 symbols
src/anytag.rs22 symbols
src/traits.rs20 symbols
src/types.rs10 symbols
src/lib.rs7 symbols
src/config.rs4 symbols
tests/inner.rs1 symbols
src/error.rs1 symbols

For agents

$ claude mcp add audiotags \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page