static void handle_tracknr_field (xmms_xform_t *xform, xmms_id3v2_header_t *head, const gchar *key, gchar *buf, gsize len) { const gchar *enc; gchar *nval; gsize clen; enc = binary_to_enc (buf[0]); nval = convert_id3_text (enc, &buf[1], len - 1, &clen); if (nval) { gint tracknr, tracktotal; parse_number_slash_number (nval, &tracknr, &tracktotal); if (tracknr > 0) { const gchar *metakey = XMMS_MEDIALIB_ENTRY_PROPERTY_TRACKNR; xmms_xform_metadata_set_int (xform, metakey, tracknr); } if (tracktotal > 0) { const gchar *metakey = XMMS_MEDIALIB_ENTRY_PROPERTY_TOTALTRACKS; xmms_xform_metadata_set_int (xform, metakey, tracktotal); } g_free (nval); } }
static void handle_partofset_field (xmms_xform_t *xform, xmms_id3v2_header_t *head, const gchar *key, gchar *buf, gsize len) { const gchar *enc; gchar *nval; gsize clen; enc = binary_to_enc (buf[0]); nval = convert_id3_text (enc, &buf[1], len - 1, &clen); if (nval) { gint partofset, totalset; parse_number_slash_number (nval, &partofset, &totalset); if (partofset > 0) { const gchar *metakey = XMMS_MEDIALIB_ENTRY_PROPERTY_PARTOFSET; xmms_xform_metadata_set_int (xform, metakey, partofset); } if (totalset > 0) { const gchar *metakey = XMMS_MEDIALIB_ENTRY_PROPERTY_TOTALSET; xmms_xform_metadata_set_int (xform, metakey, totalset); } g_free (nval); } }
static void handle_id3v2_tcon (xmms_xform_t *xform, xmms_id3v2_header_t *head, const gchar *key, gchar *buf, gsize len) { gint res; guint genre_id; gchar *val; const gchar *tmp; const gchar *metakey; /* XXX - we should handle it differently v4 separates them with NUL instead of using () */ /* if (head->ver == 4) { buf++; len -= 1; } */ tmp = binary_to_enc (buf[0]); val = convert_id3_text (tmp, &buf[1], len - 1, NULL); if (!val) return; res = sscanf (val, "(%u)", &genre_id); if (res > 0 && genre_id < G_N_ELEMENTS (id3_genres)) { metakey = XMMS_MEDIALIB_ENTRY_PROPERTY_GENRE; xmms_xform_metadata_set_str (xform, metakey, (gchar *) id3_genres[genre_id]); } else { metakey = XMMS_MEDIALIB_ENTRY_PROPERTY_GENRE; xmms_xform_metadata_set_str (xform, metakey, val); } g_free (val); }
static void handle_id3v2_txxx (xmms_xform_t *xform, xmms_id3v2_header_t *head, const gchar *_key, gchar *buf, gsize len) { const gchar *enc; gchar *cbuf; const gchar *key, *val; const gchar *metakey; gsize clen; enc = binary_to_enc (buf[0]); cbuf = convert_id3_text (enc, &buf[1], len - 1, &clen); if (!cbuf) return; key = cbuf; val = find_nul (cbuf, &clen); if (!val) { g_free (cbuf); return; } if (g_ascii_strcasecmp (key, "MusicBrainz Album Id") == 0) { metakey = XMMS_MEDIALIB_ENTRY_PROPERTY_ALBUM_ID; xmms_xform_metadata_set_str (xform, metakey, val); } else if (g_ascii_strcasecmp (key, "MusicBrainz Artist Id") == 0) { metakey = XMMS_MEDIALIB_ENTRY_PROPERTY_ARTIST_ID; xmms_xform_metadata_set_str (xform, metakey, val); } else if ((g_ascii_strcasecmp (key, "MusicBrainz Album Artist Id") == 0) && (g_ascii_strcasecmp (val, MUSICBRAINZ_VA_ID) == 0)) { metakey = XMMS_MEDIALIB_ENTRY_PROPERTY_COMPILATION; xmms_xform_metadata_set_int (xform, metakey, 1); } else if (g_ascii_strcasecmp (key, "ASIN") == 0) { metakey = XMMS_MEDIALIB_ENTRY_PROPERTY_ASIN; xmms_xform_metadata_set_str (xform, metakey, val); } else if (g_ascii_strcasecmp (key, "QuodLibet::albumartist") == 0) { metakey = XMMS_MEDIALIB_ENTRY_PROPERTY_ALBUM_ARTIST; xmms_xform_metadata_set_str (xform, metakey, val); } else if (g_ascii_strcasecmp (key, "ALBUMARTISTSORT") == 0) { metakey = XMMS_MEDIALIB_ENTRY_PROPERTY_ALBUM_ARTIST_SORT; xmms_xform_metadata_set_str (xform, metakey, val); } else if (g_ascii_strcasecmp (key, "BARCODE") == 0) { metakey = XMMS_MEDIALIB_ENTRY_PROPERTY_BARCODE; xmms_xform_metadata_set_str (xform, metakey, val); } else if (g_ascii_strcasecmp (key, "CATALOGNUMBER") == 0) { metakey = XMMS_MEDIALIB_ENTRY_PROPERTY_CATALOGNUMBER; xmms_xform_metadata_set_str (xform, metakey, val); } else { XMMS_DBG ("Unhandled tag 'TXXX:%s' = '%s'", key, val); } g_free (cbuf); }
static void handle_id3v2_txxx (xmms_xform_t *xform, xmms_id3v2_header_t *head, const gchar *_key, gchar *buf, gsize len) { const gchar *enc; gchar *cbuf; const gchar *key, *val; const gchar *metakey; gsize clen; enc = binary_to_enc (buf[0]); cbuf = convert_id3_text (enc, &buf[1], len - 1, &clen); if (!cbuf) return; key = cbuf; val = find_nul (cbuf, &clen); if (!val) { g_free (cbuf); return; } if (g_ascii_strcasecmp (key, "MusicBrainz Album Id") == 0) { metakey = XMMS_MEDIALIB_ENTRY_PROPERTY_ALBUM_ID; xmms_xform_metadata_set_str (xform, metakey, val); } else if (g_ascii_strcasecmp (key, "MusicBrainz Artist Id") == 0) { metakey = XMMS_MEDIALIB_ENTRY_PROPERTY_ARTIST_ID; xmms_xform_metadata_set_str (xform, metakey, val); } else if ((g_ascii_strcasecmp (key, "MusicBrainz Album Artist Id") == 0) && (g_ascii_strcasecmp (val, MUSICBRAINZ_VA_ID) == 0)) { metakey = XMMS_MEDIALIB_ENTRY_PROPERTY_COMPILATION; xmms_xform_metadata_set_int (xform, metakey, 1); } else if (g_ascii_strcasecmp (key, "ASIN") == 0) { metakey = XMMS_MEDIALIB_ENTRY_PROPERTY_ASIN; xmms_xform_metadata_set_str (xform, metakey, val); } else if (g_ascii_strcasecmp (key, "QuodLibet::albumartist") == 0) { metakey = XMMS_MEDIALIB_ENTRY_PROPERTY_ALBUM_ARTIST; xmms_xform_metadata_set_str (xform, metakey, val); // ArtistAlbumSort as last resort } else if ((g_ascii_strcasecmp (key, "ALBUMARTISTSORT") == 0)) { const gchar *tmp; metakey = XMMS_MEDIALIB_ENTRY_PROPERTY_ALBUM_ARTIST; if (xmms_xform_metadata_get_str (xform, metakey, &tmp) && !strlen (tmp)) { xmms_xform_metadata_set_str (xform, metakey, val); } } g_free (cbuf); }
static void handle_id3v2_comm (xmms_xform_t *xform, xmms_id3v2_header_t *head, const gchar *key, gchar *buf, gsize len) { /* COMM is weird but it's like this: * $xx enc * $xx xx xx lang * $text $0 desc according to enc * $text $0 comment according to enc */ const gchar *enc, *desc, *comm; gchar *cbuf; gsize clen; enc = binary_to_enc (buf[0]); buf++; len--; /* Language is always three _bytes_ - we currently don't care */ buf += 3; len -= 3; cbuf = convert_id3_text (enc, buf, len, &clen); if (!cbuf) return; desc = cbuf; comm = find_nul (cbuf, &clen); if (comm && comm[0]) { const gchar *metakey; gchar *tmp; if (desc && desc[0]) { metakey = XMMS_MEDIALIB_ENTRY_PROPERTY_COMMENT; tmp = g_strdup_printf ("%s_%s", metakey, desc); xmms_xform_metadata_set_str (xform, tmp, comm); g_free (tmp); } else { metakey = XMMS_MEDIALIB_ENTRY_PROPERTY_COMMENT; xmms_xform_metadata_set_str (xform, metakey, comm); } } g_free (cbuf); }
static void handle_int_field (xmms_xform_t *xform, xmms_id3v2_header_t *head, const gchar *key, gchar *buf, gsize len) { gchar *nval; const gchar *tmp; gint i; tmp = binary_to_enc (buf[0]); nval = convert_id3_text (tmp, &buf[1], len - 1, NULL); if (nval) { i = strtol (nval, NULL, 10); xmms_xform_metadata_set_int (xform, key, i); g_free (nval); } }
static void add_to_entry (xmms_xform_t *xform, xmms_id3v2_header_t *head, const gchar *key, gchar *val, gint len) { gchar *nval; const gchar *tmp; if (len < 1) return; tmp = binary_to_enc (val[0]); nval = convert_id3_text (tmp, &val[1], len - 1, NULL); if (nval) { xmms_xform_metadata_set_str (xform, key, nval); g_free (nval); } }