polyfloyd / rust-id3

A rust library for reading and writing ID3 metadata
MIT License
240 stars 46 forks source link

Support for UFID frames #136

Closed 0xNF closed 3 months ago

0xNF commented 3 months ago

IDv3 supports a frame called UFID which is used to store ids related to unique databases that a given track appears in. It seems mostly used by MusicBrainz, but other places also use it. It's defined here:

4.1.   Unique file identifier

   This frame's purpose is to be able to identify the audio file in a
   database, that may provide more information relevant to the content.
   Since standardisation of such a database is beyond this document, all
   UFID frames begin with an 'owner identifier' field. It is a null-
   terminated string with a URL [URL] containing an email address, or a
   link to a location where an email address can be found, that belongs
   to the organisation responsible for this specific database
   implementation. Questions regarding the database should be sent to
   the indicated email address. The URL should not be used for the
   actual database queries. The string
   "http://www.id3.org/dummy/ufid.html" should be used for tests. The
   'Owner identifier' must be non-empty (more than just a termination).
   The 'Owner identifier' is then followed by the actual identifier,
   which may be up to 64 bytes. There may be more than one "UFID" frame
   in a tag, but only one with the same 'Owner identifier'.

     <Header for 'Unique file identifier', ID: "UFID">
     Owner identifier        <text string> $00
     Identifier              <up to 64 bytes binary data>

Right now, I'm implementing it by using an ExtendedLink frame like so:

fn add_ufid(tag: &mut Tag, source: &str, id: &str) {
    let f = id3::Frame::with_content(
            "UFID",
            id3::Content::ExtendedLink(ExtendedLink {
                description: id,
                link: String::from(source),
            }),
        );
    self.tag.add_frame(f);
}

But I wonder if there's a better way. Official support would be even better, ideally.

polyfloyd commented 3 months ago

Yes, we can definitely add support for this :)

Not sure when I will have time for this myself. @0xNF, if you want, you could write up a patch yourself if you need this soon-ish

polyfloyd commented 3 months ago

Fixed in #137