[grilo-plugins] grl-acoustid: Use release and release group id



commit aa517b6f7422dc0cf05b839d6b5c87cd85806046
Author: Sumaid Syed <sumaidsyed gmail com>
Date:   Fri Aug 2 21:20:31 2019 +0530

    grl-acoustid: Use release and release group id
    
    Update AcoustID plugin to use newly added MB Release ID & MB Release Group ID  core keys.
    Keep MB Release Group ID tests different from MB Album ID.

 src/lua-factory/sources/grl-acoustid.lua      |  2 +-
 tests/lua-factory/sources/test_lua_acoustid.c | 27 ++++++++++++---------------
 2 files changed, 13 insertions(+), 16 deletions(-)
---
diff --git a/src/lua-factory/sources/grl-acoustid.lua b/src/lua-factory/sources/grl-acoustid.lua
index 71f4b530..4b402bcd 100644
--- a/src/lua-factory/sources/grl-acoustid.lua
+++ b/src/lua-factory/sources/grl-acoustid.lua
@@ -166,7 +166,7 @@ function build_media(record, releasegroup)
     end
 
     release = album.releases[1]
-    media.mb_release_id = keys.mb_album_id and release.id or nil
+    media.mb_release_id = (keys.mb_release_id or keys.mb_album_id) and release.id or nil
 
     if release.date then
       local date = release.date
diff --git a/tests/lua-factory/sources/test_lua_acoustid.c b/tests/lua-factory/sources/test_lua_acoustid.c
index bc080675..7af9faad 100644
--- a/tests/lua-factory/sources/test_lua_acoustid.c
+++ b/tests/lua-factory/sources/test_lua_acoustid.c
@@ -59,7 +59,7 @@ resolve (GrlSource   *source,
   GrlMedia *audio;
   GrlOperationOptions *options;
   GrlRegistry *registry;
-  GrlKeyID chromaprint_key, mb_release_id_key, mb_release_group_id_key;
+  GrlKeyID chromaprint_key;
   GDateTime *publication_date, *creation_date;
   GError *error = NULL;
 
@@ -74,6 +74,8 @@ resolve (GrlSource   *source,
   keys = grl_metadata_key_list_new (GRL_METADATA_KEY_MB_ARTIST_ID,
                                     GRL_METADATA_KEY_ARTIST,
                                     GRL_METADATA_KEY_MB_ALBUM_ID,
+                                    GRL_METADATA_KEY_MB_RELEASE_ID,
+                                    GRL_METADATA_KEY_MB_RELEASE_GROUP_ID,
                                     GRL_METADATA_KEY_ALBUM,
                                     GRL_METADATA_KEY_MB_RECORDING_ID,
                                     GRL_METADATA_KEY_TITLE,
@@ -92,20 +94,14 @@ resolve (GrlSource   *source,
                            &error);
   g_assert_no_error (error);
 
-  mb_release_id_key = grl_registry_lookup_metadata_key (registry, "mb-release-id");
-  g_assert_cmpint (mb_release_id_key, !=, GRL_METADATA_KEY_INVALID);
-  mb_release_group_id_key = grl_registry_lookup_metadata_key (registry, "mb-release-group-id");
-  g_assert_cmpint (mb_release_group_id_key, !=, GRL_METADATA_KEY_INVALID);
-
   *out_mb_artist_id = g_strdup (grl_media_get_mb_artist_id (audio));
   *out_artist = g_strdup (grl_media_get_artist (audio));
   *out_mb_album_id = g_strdup (grl_media_get_mb_album_id (audio));
   *out_album = g_strdup (grl_media_get_album (audio));
   *out_mb_recording_id = g_strdup (grl_media_get_mb_recording_id (audio));
   *out_title = g_strdup (grl_media_get_title (audio));
-  *out_mb_release_id = g_strdup (grl_data_get_string (GRL_DATA (audio), mb_release_id_key));
-  *out_mb_release_group_id = g_strdup (grl_data_get_string (GRL_DATA (audio),
-                                                            mb_release_group_id_key));
+  *out_mb_release_id = g_strdup (grl_media_get_mb_release_id (audio));
+  *out_mb_release_group_id = g_strdup (grl_media_get_mb_release_group_id (audio));
   *out_album_disc_number = grl_media_get_album_disc_number (audio);
   publication_date = grl_media_get_publication_date (audio);
   *out_publication_date = g_date_time_format (publication_date, "%Y-%m-%d");
@@ -135,6 +131,7 @@ test_resolve_fingerprint (void)
     gchar *mb_recording_id;
     gchar *title;
     gchar *mb_release_id;
+    gchar *mb_release_group_id;
     gint album_disc_number;
     gchar *publication_date;
     gchar *creation_date;
@@ -144,31 +141,31 @@ test_resolve_fingerprint (void)
      "fa34b363-79df-434f-a5b8-be4e6898543f", "Ludovico Einaudi",
      "ac615d26-df00-3053-9462-7636375603b4", "The Number One Classical Album 2008",
      "8f6ac978-95cf-41e8-82fb-043624652e04", "Primavera",
-     "d73e4041-375c-4b9f-8366-46089bca304c",
+     "d73e4041-375c-4b9f-8366-46089bca304c", "ac615d26-df00-3053-9462-7636375603b4",
      1, "2007-11-26", "2007-11-26", 19 },
    { FINGERPRINT_NORAH_JONES, 160,
      "985c709c-7771-4de3-9024-7bda29ebe3f9", "Norah Jones",
      "f5cffa96-262c-49af-9747-3f04a1d42c78", "\u00d63 Greatest Hits 49",
      "6d8ba615-d8fe-4f99-b38f-0a17d657b1bb", "Chasing Pirates",
-     "1ee64f6c-560f-421f-83dc-7fd34e5b0674",
+     "1ee64f6c-560f-421f-83dc-7fd34e5b0674", "f5cffa96-262c-49af-9747-3f04a1d42c78",
      1, "2010-03-12", "2010-03-12", 18 },
    { FINGERPRINT_TROMBONE_SH, 243,
      "cae4fd51-4d58-4d48-92c1-6198cc2e45ed", "Trombone Shorty",
      "c3418122-387b-4477-90cf-e5e6d110e054", "For True",
      "96483bdd-f219-4ae3-a94e-04feeeef22a4", "Buckjump",
-     "567621e3-b80f-4c30-af5f-2ecf0882e94a",
+     "567621e3-b80f-4c30-af5f-2ecf0882e94a", "c3418122-387b-4477-90cf-e5e6d110e054",
      1, "2011-01-01", "2011-01-01", 1 },
    { FINGERPRINT_PHILIP_GLAS, 601,
      "5ae54dee-4dba-49c0-802a-a3b3b3adfe9b", "Philip Glass",
      "52f1f9d5-5166-4ceb-9289-6fb1a87f367c", "The Passion of Ramakrishna",
      "298e15a1-b29b-4947-9dca-ec3634f9ebde", "Part 2",
-     "2807def3-7873-4277-b079-c9a963d99993",
+     "2807def3-7873-4277-b079-c9a963d99993", "52f1f9d5-5166-4ceb-9289-6fb1a87f367c",
      1, "2012-01-01", "2012-01-01", 3 },
    { FINGERPRINT_RADIOHEAD_PA, 385,
      "a74b1b7f-71a5-4011-9441-d0b5e4122711", "Radiohead",
      "dd02a722-bb7f-4771-9a5b-681f5556ce71", "3X plus de bruit!",
      "9f9cf187-d6f9-437f-9d98-d59cdbd52757", "Paranoid Android",
-     "67016a2b-118d-483d-9e36-49080ae43df4",
+     "67016a2b-118d-483d-9e36-49080ae43df4", "dd02a722-bb7f-4771-9a5b-681f5556ce71",
      1, "1997-01-01", "1997-01-01", 4,
    },
   };
@@ -208,7 +205,7 @@ test_resolve_fingerprint (void)
     g_free (mb_recording_id);
     g_assert_cmpstr (audios[i].mb_release_id, ==, mb_release_id);
     g_free (mb_release_id);
-    g_assert_cmpstr (audios[i].mb_album_id, ==, mb_release_group_id);
+    g_assert_cmpstr (audios[i].mb_release_group_id, ==, mb_release_group_id);
     g_free (mb_release_group_id);
     g_assert_cmpint (audios[i].album_disc_number, ==, album_disc_number);
     g_assert_cmpstr (audios[i].publication_date, ==, publication_date);


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