[sound-juicer] Support arrangers & multiple composers.



commit 1121403c9c30a5603e8acca8be4f675822394200
Author: Phillip Wood <phillip wood dunelm org uk>
Date:   Sun Feb 9 14:15:42 2014 +0000

    Support arrangers & multiple composers.
    
    Musicbrainz works can have more than one composer as well as
    arrangers, orchestrators and transcribers. Fetch the relevant work
    relations to get this information and format it in the composer text.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=730001

 libjuicer/sj-metadata-musicbrainz5.c |   52 ++++++++++++++++++++++------------
 1 files changed, 34 insertions(+), 18 deletions(-)
---
diff --git a/libjuicer/sj-metadata-musicbrainz5.c b/libjuicer/sj-metadata-musicbrainz5.c
index 13e4032..c886fff 100644
--- a/libjuicer/sj-metadata-musicbrainz5.c
+++ b/libjuicer/sj-metadata-musicbrainz5.c
@@ -578,7 +578,7 @@ static void composer_cb (SjMetadataMusicbrainz5 *self,
                          gpointer                user_data)
 {
   Mb5Artist composer;
-  TrackDetails *track = (TrackDetails *)user_data;
+  GSList **composers = user_data;
   char buffer[512]; /* For the GET macro */
   ArtistDetails *details;
 
@@ -590,29 +590,45 @@ static void composer_cb (SjMetadataMusicbrainz5 *self,
      therefore use query_artist rather than make_artist_details. */
   mb5_artist_get_id (composer, buffer, sizeof (buffer));
   details = query_artist (self, buffer);
-  if (details != NULL) {
-    track->composer = g_strdup (details->name);
-    track->composer_sortname = g_strdup (details->sortname);
-  } else {
-    GET (track->composer, mb5_artist_get_name, composer);
-    GET (track->composer_sortname, mb5_artist_get_sortname, composer);
-  }
+  if (details != NULL)
+    *composers = g_slist_append (*composers, details);
 }
 
 static void work_cb (SjMetadataMusicbrainz5 *self,
                      Mb5Relation             relation,
                      gpointer                user_data)
 {
-    Mb5RelationListList relation_lists;
-    Mb5Work work;
-
-    work = mb5_relation_get_work (relation);
-    if (work == NULL)
-        return;
-    relation_lists = mb5_work_get_relationlistlist (work);
-    relationlist_list_foreach_relation (self, relation_lists,
-                                        "artist", "composer",
-                                        composer_cb, user_data);
+  TrackDetails *track = user_data;
+  GSList *composers = NULL, *arrangers = NULL;
+  GSList *orchestrators = NULL, *transcribers = NULL;
+  Mb5RelationListList relation_lists;
+  Mb5Work work;
+
+  work = mb5_relation_get_work (relation);
+  if (work == NULL)
+    return;
+
+  relation_lists = mb5_work_get_relationlistlist (work);
+  relationlist_list_foreach_relation (self, relation_lists,
+                                      "artist", "composer",
+                                      composer_cb, &composers);
+  relationlist_list_foreach_relation (self, relation_lists,
+                                      "artist", "arranger",
+                                      composer_cb, &arrangers);
+  relationlist_list_foreach_relation (self, relation_lists,
+                                      "artist", "orchestrator",
+                                      composer_cb, &orchestrators);
+  relationlist_list_foreach_relation (self, relation_lists,
+                                      "artist", "instrument arranger",
+                                      composer_cb, &transcribers);
+
+  build_composer_text (composers, arrangers, orchestrators, transcribers,
+                       &track->composer, &track->composer_sortname);
+
+  g_slist_free (arrangers);
+  g_slist_free (composers);
+  g_slist_free (orchestrators);
+  g_slist_free (transcribers);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]