diff options
author | Phillip Wood <phillip.wood@dunelm.org.uk> | 2012-03-29 15:05:58 +0100 |
---|---|---|
committer | Christophe Fergeau <cfergeau@redhat.com> | 2012-06-16 11:41:55 +0200 |
commit | 3b23b8acfcbc109a64b6b8896440777b854a163c (patch) | |
tree | 0aed967df103c1ae8a4887e8596d1a84666009b8 /libjuicer | |
parent | d674cddb00e8c086574730d75a3e4208b8713dc0 (diff) |
Fill album composer using track composers
Musicbrainz relations do not provide an album composer. If all the
tracks have the same or have no composer use the composer and
composer_sortname from the first track, if they have
differing composers set the album composer and composer_sortname to
"Various Composers".
https://bugzilla.gnome.org/show_bug.cgi?id=661646
Diffstat (limited to 'libjuicer')
-rw-r--r-- | libjuicer/sj-metadata-musicbrainz4.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/libjuicer/sj-metadata-musicbrainz4.c b/libjuicer/sj-metadata-musicbrainz4.c index 087f79a..29e5bf7 100644 --- a/libjuicer/sj-metadata-musicbrainz4.c +++ b/libjuicer/sj-metadata-musicbrainz4.c @@ -228,6 +228,43 @@ fill_relations (Mb4RelationList relations, AlbumDetails *album) } } +static void +fill_album_composer (AlbumDetails *album) +{ + char *old_composer; + GList *l; + TrackDetails *track_one; /* The first track on the album */ + gboolean one_composer = TRUE; /* TRUE if all tracks have the same composer */ + + if (album->composer != NULL) + return; + + if (album->tracks == NULL) + return; + + l = album->tracks; + track_one = (TrackDetails*)l->data; + old_composer = track_one->composer; + + for (l = l->next; l != NULL; l = l->next) { + char *new_composer; + TrackDetails *track = (TrackDetails*)l->data; + new_composer = track->composer; + if (g_strcmp0 (old_composer, new_composer) != 0) { + one_composer = FALSE; + break; + } + } + + if (one_composer) { + album->composer = g_strdup (track_one->composer); + album->composer_sortname = g_strdup (track_one->composer_sortname); + } else { + album->composer = g_strdup ("Various Composers"); + album->composer_sortname = g_strdup ("Various Composers"); + } +} + typedef void (*RelationForeachFunc)(Mb4Relation relation, gpointer user_data); static void relationlist_list_foreach_relation(Mb4RelationListList relation_lists, @@ -426,6 +463,7 @@ make_album_from_release (Mb4ReleaseGroup group, album->disc_number = mb4_medium_get_position (medium); fill_tracks_from_medium (medium, album); + fill_album_composer (album); fill_relations (mb4_release_get_relationlist (release), album); sj_mb4_album_details_dump (album); |