tag_id3: support multiple values
Loop over all frames with a specific id, and import all of them - not just the first one (index 0).
This commit is contained in:
parent
cb9965bab5
commit
748a8a6f42
1
NEWS
1
NEWS
|
@ -20,6 +20,7 @@ ver 0.16 (20??/??/??)
|
||||||
* tags:
|
* tags:
|
||||||
- added tags "ArtistSort", "AlbumArtistSort"
|
- added tags "ArtistSort", "AlbumArtistSort"
|
||||||
- id3: revised "performer" tag support
|
- id3: revised "performer" tag support
|
||||||
|
- id3: support multiple values
|
||||||
- ape: MusicBrainz tags
|
- ape: MusicBrainz tags
|
||||||
- ape: support multiple values
|
- ape: support multiple values
|
||||||
* decoders:
|
* decoders:
|
||||||
|
|
|
@ -126,17 +126,16 @@ import_id3_string(bool is_id3v1, const id3_ucs4_t *ucs4)
|
||||||
* - string list
|
* - string list
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
tag_id3_import_text(struct tag *dest, struct id3_tag *tag, const char *id,
|
tag_id3_import_text_frame(struct tag *dest, struct id3_tag *tag,
|
||||||
enum tag_type type)
|
const struct id3_frame *frame,
|
||||||
|
enum tag_type type)
|
||||||
{
|
{
|
||||||
struct id3_frame const *frame;
|
|
||||||
id3_ucs4_t const *ucs4;
|
id3_ucs4_t const *ucs4;
|
||||||
id3_utf8_t *utf8;
|
id3_utf8_t *utf8;
|
||||||
union id3_field const *field;
|
union id3_field const *field;
|
||||||
unsigned int nstrings, i;
|
unsigned int nstrings, i;
|
||||||
|
|
||||||
frame = id3_tag_findframe(tag, id, 0);
|
if (frame->nfields != 2)
|
||||||
if (frame == NULL || frame->nfields != 2)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* check the encoding field */
|
/* check the encoding field */
|
||||||
|
@ -170,6 +169,20 @@ tag_id3_import_text(struct tag *dest, struct id3_tag *tag, const char *id,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Import all text frames with the specified id (ID3v2.4.0 section
|
||||||
|
* 4.2). This is a wrapper for tag_id3_import_text_frame().
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
tag_id3_import_text(struct tag *dest, struct id3_tag *tag, const char *id,
|
||||||
|
enum tag_type type)
|
||||||
|
{
|
||||||
|
const struct id3_frame *frame;
|
||||||
|
for (unsigned i = 0;
|
||||||
|
(frame = id3_tag_findframe(tag, id, i)) != NULL; ++i)
|
||||||
|
tag_id3_import_text_frame(dest, tag, frame, type);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Import a "Comment frame" (ID3v2.4.0 section 4.10). It
|
* Import a "Comment frame" (ID3v2.4.0 section 4.10). It
|
||||||
* contains 4 fields:
|
* contains 4 fields:
|
||||||
|
@ -180,16 +193,15 @@ tag_id3_import_text(struct tag *dest, struct id3_tag *tag, const char *id,
|
||||||
* - full string (we use this one)
|
* - full string (we use this one)
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
tag_id3_import_comment(struct tag *dest, struct id3_tag *tag, const char *id,
|
tag_id3_import_comment_frame(struct tag *dest, struct id3_tag *tag,
|
||||||
enum tag_type type)
|
const struct id3_frame *frame,
|
||||||
|
enum tag_type type)
|
||||||
{
|
{
|
||||||
struct id3_frame const *frame;
|
|
||||||
id3_ucs4_t const *ucs4;
|
id3_ucs4_t const *ucs4;
|
||||||
id3_utf8_t *utf8;
|
id3_utf8_t *utf8;
|
||||||
union id3_field const *field;
|
union id3_field const *field;
|
||||||
|
|
||||||
frame = id3_tag_findframe(tag, id, 0);
|
if (frame->nfields != 4)
|
||||||
if (frame == NULL || frame->nfields != 4)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* for now I only read the 4th field, with the fullstring */
|
/* for now I only read the 4th field, with the fullstring */
|
||||||
|
@ -209,6 +221,20 @@ tag_id3_import_comment(struct tag *dest, struct id3_tag *tag, const char *id,
|
||||||
g_free(utf8);
|
g_free(utf8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Import all comment frames (ID3v2.4.0 section 4.10). This is a
|
||||||
|
* wrapper for tag_id3_import_comment_frame().
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
tag_id3_import_comment(struct tag *dest, struct id3_tag *tag, const char *id,
|
||||||
|
enum tag_type type)
|
||||||
|
{
|
||||||
|
const struct id3_frame *frame;
|
||||||
|
for (unsigned i = 0;
|
||||||
|
(frame = id3_tag_findframe(tag, id, i)) != NULL; ++i)
|
||||||
|
tag_id3_import_comment_frame(dest, tag, frame, type);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse a TXXX name, and convert it to a tag_type enum value.
|
* Parse a TXXX name, and convert it to a tag_type enum value.
|
||||||
* Returns TAG_NUM_OF_ITEM_TYPES if the TXXX name is not understood.
|
* Returns TAG_NUM_OF_ITEM_TYPES if the TXXX name is not understood.
|
||||||
|
|
Loading…
Reference in New Issue