Commit 88589ce5 authored by Jean Felder's avatar Jean Felder Committed by Sam Thursfield

extract-vorbis: Use ExtractReference to store musicbrainz tags

Store MusicBrainz IDs as ExternalResources instead of a list of
properties. This approach is more generic.

Extraction of MusicBrainz IDs is done based on tags used by Picard.
Tags Mapping: https://picard.musicbrainz.org/docs/mappings/
parent d6c9479f
......@@ -171,7 +171,11 @@ tracker_extract_get_metadata (TrackerExtractInfo *info)
md.creator = tracker_extract_new_artist (md.creator_name);
if (vd.mb_artist_id) {
tracker_resource_set_string (md.creator, "nmm:mbArtistID", vd.mb_artist_id);
TrackerResource *mb_artist_id = tracker_extract_new_external_reference("https://musicbrainz.org/doc/Artist",
vd.mb_artist_id);
tracker_resource_set_relation (md.creator, "tracker:hasExternalReference", mb_artist_id);
g_object_unref (mb_artist_id);
g_free (vd.mb_artist_id);
}
......@@ -180,6 +184,7 @@ tracker_extract_get_metadata (TrackerExtractInfo *info)
if (vd.album) {
TrackerResource *album, *album_disc, *album_artist;
TrackerResource *mb_release_id = NULL, *mb_release_group_id = NULL;
if (vd.album_artist) {
album_artist = tracker_extract_new_artist (vd.album_artist);
......@@ -210,12 +215,23 @@ tracker_extract_get_metadata (TrackerExtractInfo *info)
}
if (vd.mb_release_id) {
tracker_resource_set_string (album, "nmm:mbReleaseID", vd.mb_release_id);
mb_release_id = tracker_extract_new_external_reference("https://musicbrainz.org/doc/Release",
vd.mb_release_id);
tracker_resource_set_relation (album, "tracker:hasExternalReference", mb_release_id);
g_free (vd.mb_release_id);
}
if (vd.mb_release_group_id) {
tracker_resource_set_string (album, "nmm:mbReleaseGroupID", vd.mb_release_group_id);
mb_release_group_id = tracker_extract_new_external_reference("https://musicbrainz.org/doc/Release_Group",
vd.mb_release_group_id);
if (mb_release_id) {
tracker_resource_add_relation (album, "tracker:hasExternalReference", mb_release_group_id);
} else
tracker_resource_set_relation (album, "tracker:hasExternalReference", mb_release_group_id);
g_free (vd.mb_release_group_id);
}
......@@ -223,6 +239,8 @@ tracker_extract_get_metadata (TrackerExtractInfo *info)
tracker_resource_set_relation (metadata, "nmm:musicAlbumDisc", album_disc);
g_object_unref (album_disc);
g_object_unref (mb_release_id);
g_object_unref (mb_release_group_id);
}
g_free (vd.track_count);
......@@ -301,13 +319,28 @@ tracker_extract_get_metadata (TrackerExtractInfo *info)
g_free (vd.acoustid_fingerprint);
}
TrackerResource *mb_recording_id = NULL, *mb_track_id = NULL;
if (vd.mb_recording_id) {
tracker_resource_set_string (metadata, "nmm:mbRecordingID", vd.mb_recording_id);
mb_recording_id = tracker_extract_new_external_reference("https://musicbrainz.org/doc/Recording",
vd.mb_recording_id);
tracker_resource_set_relation (metadata, "tracker:hasExternalReference", mb_recording_id);
g_free (vd.mb_recording_id);
}
if (vd.mb_track_id) {
tracker_resource_set_string (metadata, "nmm:mbTrackID", vd.mb_track_id);
mb_track_id = tracker_extract_new_external_reference("https://musicbrainz.org/doc/Track",
vd.mb_track_id);
if (mb_recording_id) {
tracker_resource_add_relation (metadata, "tracker:hasExternalReference", mb_track_id);
g_object_unref (mb_recording_id);
} else {
tracker_resource_set_relation (metadata, "tracker:hasExternalReference", mb_track_id);
}
g_object_unref (mb_track_id);
g_free (vd.mb_track_id);
}
......
......@@ -15,14 +15,45 @@
"nmm:performer": {
"@type": "nmm:Artist",
"nmm:artistName": "AbBaby",
"nmm:mbArtistID": "234561"
"tracker:hasExternalReference": {
"@id": "tracker:ExternalReference:https:%2F%2Fmusicbrainz.org%2Fdoc%2FArtist",
"@type": "tracker:ExternalReference",
"tracker:referenceSource": "https://musicbrainz.org/doc/Artist",
"tracker:referenceIdentifier": "234561"
}
},
"nmm:musicAlbum": {
"@type": "nmm:MusicAlbum",
"nie:title": "SinCos",
"nmm:mbReleaseGroupID": "561234",
"nmm:mbReleaseID": "345612"
"tracker:hasExternalReference": [
{
"@id": "tracker:ExternalReference:https:%2F%2Fmusicbrainz.org%2Fdoc%2FRelease",
"@type": "tracker:ExternalReference",
"tracker:referenceSource": "https://musicbrainz.org/doc/Release",
"tracker:referenceIdentifier": "345612"
},
{
"@id": "tracker:ExternalReference:https:%2F%2Fmusicbrainz.org%2Fdoc%2FRelease_Group",
"@type": "tracker:ExternalReference",
"tracker:referenceSource": "https://musicbrainz.org/doc/Release_Group",
"tracker:referenceIdentifier": "561234"
}
]
},
"tracker:hasExternalReference": [
{
"@id": "tracker:ExternalReference:https:%2F%2Fmusicbrainz.org%2Fdoc%2FRecording",
"@type": "tracker:ExternalReference",
"tracker:referenceSource": "https://musicbrainz.org/doc/Recording",
"tracker:referenceIdentifier": "456123"
},
{
"@id": "tracker:ExternalReference:https:%2F%2Fmusicbrainz.org%2Fdoc%2FTrack",
"@type": "tracker:ExternalReference",
"tracker:referenceSource": "https://musicbrainz.org/doc/Track",
"tracker:referenceIdentifier": "123456"
}
],
"nfo:hasHash": {
"@type": "nfo:hasHash",
"nfo:hashAlgorithm": "chromaprint",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment