aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-05-06 14:42:07 +0200
committerMax Kellermann <max@duempel.org>2009-05-06 14:42:07 +0200
commit0935d85c69eaa11d5f8daa8056fdf0f845871cc1 (patch)
tree3aa382fd73d73192919f182eb8a1620b9543e1e7 /src
parentfeae8b8f6840edbefe28aa81f472230c1f0ed599 (diff)
downloadmpd-0935d85c69eaa11d5f8daa8056fdf0f845871cc1.tar.gz
mpd-0935d85c69eaa11d5f8daa8056fdf0f845871cc1.tar.xz
mpd-0935d85c69eaa11d5f8daa8056fdf0f845871cc1.zip
tag_id3: added support for the UFID frame
If the UFID frame's owner is "http://musicbrainz.org", assume its value is the MusicBrainz track id.
Diffstat (limited to 'src')
-rw-r--r--src/tag_id3.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/tag_id3.c b/src/tag_id3.c
index 26bbb7061..ce0386a51 100644
--- a/src/tag_id3.c
+++ b/src/tag_id3.c
@@ -285,6 +285,45 @@ tag_id3_import_musicbrainz(struct tag *mpd_tag, struct id3_tag *id3_tag)
}
}
+/**
+ * Imports the MusicBrainz TrackId from the UFID tag.
+ */
+static void
+tag_id3_import_ufid(struct tag *mpd_tag, struct id3_tag *id3_tag)
+{
+ for (unsigned i = 0;; ++i) {
+ const struct id3_frame *frame;
+ union id3_field *field;
+ const id3_latin1_t *name;
+ const id3_byte_t *value;
+ id3_length_t length;
+
+ frame = id3_tag_findframe(id3_tag, "UFID", i);
+ if (frame == NULL)
+ break;
+
+ field = id3_frame_field(frame, 0);
+ if (field == NULL)
+ continue;
+
+ name = id3_field_getlatin1(field);
+ if (name == NULL ||
+ strcmp((const char *)name, "http://musicbrainz.org") != 0)
+ continue;
+
+ field = id3_frame_field(frame, 1);
+ if (field == NULL)
+ continue;
+
+ value = id3_field_getbinarydata(field, &length);
+ if (value == NULL || length == 0)
+ continue;
+
+ tag_add_item_n(mpd_tag, TAG_MUSICBRAINZ_TRACKID,
+ (const char*)value, length);
+ }
+}
+
struct tag *tag_id3_import(struct id3_tag * tag)
{
struct tag *ret = tag_new();
@@ -305,6 +344,7 @@ struct tag *tag_id3_import(struct id3_tag * tag)
getID3Info(tag, ID3_FRAME_DISC, TAG_ITEM_DISC, ret);
tag_id3_import_musicbrainz(ret, tag);
+ tag_id3_import_ufid(ret, tag);
if (tag_is_empty(ret)) {
tag_free(ret);