Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

m4a files fail to be parsed #71

Closed
TurtleP opened this issue Jul 20, 2021 · 4 comments
Closed

m4a files fail to be parsed #71

TurtleP opened this issue Jul 20, 2021 · 4 comments

Comments

@TurtleP
Copy link

TurtleP commented Jul 20, 2021

Hi,

I've been learning rust and wanted to mess around with this library. However, all my media is in an m4a format from iTunes. The following seems to not work whatsoever:

use std::path::Path;

use id3::{Tag, Version};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // this is relative to the current directory
    let path = Path::new("./10 I Write Sins Not Tragedies.m4a");

    let tag = Tag::read_from_path(path)?;

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

When I run this, I get Error: NoTag: reader does not contain an id3 tag. Though a similar library written in python can find the id3 tag for this file and all the others. I'm not sure if this is specifically due to the m4a format or what, but If there's something I did wrong, please let me know.

@polyfloyd
Copy link
Owner

Could you please attach a problematic file to this issue?

@TurtleP
Copy link
Author

TurtleP commented Jul 20, 2021

Here is the file in the example. Hopefully it's okay to share, as it's directly from my iTunes library.
id3_issue_file.zip

@polyfloyd
Copy link
Owner

Thanks, I got it.

There is no ID3 tag in this file. I did some quick searching and concluded that M4A has a different format to store its metadata.

I had a glance at the list of crates that have ID3 as dependency, you could give this library a shot: https://crates.io/crates/audiotags

@TurtleP
Copy link
Author

TurtleP commented Jul 20, 2021

Interesting then, I'll take a look. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants