Commit b36f14b5 authored by Jean Felder's avatar Jean Felder Committed by Victor Toso

acoustid: Retrieve additional keys

Add support for album_disc_number, publication_date and track_number
tags.
Update acoustid test accordingly.
parent 9cf01fbf
Pipeline #72329 passed with stage
in 4 minutes and 14 seconds
......@@ -28,7 +28,7 @@ source = {
id = "grl-acoustid",
name = "Acoustid",
description = "a source that provides audio identification",
supported_keys = { "title", "album", "artist", "mb-recording-id", "mb-album-id", "mb-artist-id", "mb-release-group-id", "mb-release-id" },
supported_keys = { "title", "album", "artist", "mb-recording-id", "mb-album-id", "mb-artist-id", "mb-release-group-id", "mb-release-id", "album-disc-number", "publication-date", "track-number" },
supported_media = { 'audio' },
config_keys = {
required = { "api-key" },
......@@ -50,7 +50,7 @@ netopts = {
acoustid = {}
-- https://acoustid.org/webservice#lookup
ACOUSTID_LOOKUP = "https://api.acoustid.org/v2/lookup?client=%s&meta=compress+recordings+releasegroups+releases+sources&duration=%d&fingerprint=%s"
ACOUSTID_LOOKUP = "https://api.acoustid.org/v2/lookup?client=%s&meta=compress+recordings+releasegroups+releases+sources+tracks&duration=%d&fingerprint=%s"
---------------------------------
-- Handlers of Grilo functions --
......@@ -141,6 +141,22 @@ function build_media(results)
if album and album.releases and #album.releases > 0 then
release = album.releases[1]
media.mb_release_id = keys.mb_album_id and release.id or nil
if release.date then
local date = release.date
local month = date.month or 1
local day = date.day or 1
date = string.format('%04d-%02d-%02d', date.year, month, day)
media.publication_date = keys.publication_date and date or nil
end
if release.mediums and #release.mediums > 0 then
medium = release.mediums[1]
media.album_disc_number = keys.album_disc_number and medium.position or nil
if medium.tracks and #medium.tracks > 0 then
media.track_number = keys.track_number and medium.tracks[1].position or nil
end
end
end
return media
......
{"status": "ok", "results": [{"recordings": [{"sources": 1, "artists": [{"id": "e7d8aea3-9c1d-4fe0-b93a-481d545296fc", "name": "Craig Ogden"}], "duration": 414, "releasegroups": [{"releases": [{"track_count": 30, "releaseevents": [{"date": {"year": 2009}, "country": "GB"}], "country": "GB", "date": {"year": 2009}, "medium_count": 2, "id": "5fd10cc8-30e0-48aa-9ba1-19d05b871a75"}], "title": "Classic FM Summer Guitar", "secondarytypes": ["Compilation"], "artists": [{"id": "89ad4ac3-39f7-470e-963a-56509c546377", "name": "Various Artists"}], "type": "Album", "id": "2cde60bc-829c-49af-a62c-e20283167c30"}], "title": "Primavera", "id": "5d72b7d4-d0c4-4d0d-ab7f-3a737075e1c9"}, {"sources": 29, "artists": [{"id": "fa34b363-79df-434f-a5b8-be4e6898543f", "name": "Ludovico Einaudi"}], "duration": 443, "releasegroups": [{"type": "Album", "id": "39f2c673-1387-4272-9db9-5f19d48e47cb", "releases": [{"track_count": 13, "releaseevents": [{"date": {"month": 2, "day": 19, "year": 2007}, "country": "IT"}], "country": "IT", "date": {"month": 2, "day": 19, "year": 2007}, "medium_count": 1, "id": "931d4cfa-53c6-41cd-8ab0-a2917a7c1f3e"}], "title": "Divenire"}], "title": "Primavera", "id": "70088e7c-1c01-48cb-9103-ba8b500c68a4"}, {"sources": 2, "artists": [{"id": "fa34b363-79df-434f-a5b8-be4e6898543f", "name": "Ludovico Einaudi"}], "duration": 444, "releasegroups": [{"releases": [{"track_count": 15, "releaseevents": [{"date": {"year": 2012}, "country": "FR"}], "country": "FR", "date": {"year": 2012}, "medium_count": 1, "id": "7a06eb11-6013-4eb8-8aef-a2302ef4ed79"}], "title": "Einaudi essentiel", "secondarytypes": ["Compilation"], "type": "Album", "id": "6c42f326-7c15-41d5-851d-e887b544e217"}], "title": "Primavera", "id": "75e72e13-cf02-47f8-a4a7-98b916b3b18c"}, {"sources": 1, "artists": [{"id": "509249cd-a9ce-4e9e-b499-45be01bf1be1", "name": "Jeroen van Veen"}], "duration": 444, "releasegroups": [{"artists": [{"joinphrase": "; ", "id": "fa34b363-79df-434f-a5b8-be4e6898543f", "name": "Ludovico Einaudi"}, {"id": "509249cd-a9ce-4e9e-b499-45be01bf1be1", "name": "Jeroen van Veen"}], "type": "Album", "id": "ef007d8d-93ce-4e90-ab87-220037c0704c", "releases": [{"track_count": 91, "releaseevents": [{"date": {"year": 2013}, "country": "XE"}], "country": "XE", "date": {"year": 2013}, "medium_count": 7, "id": "045ad634-44c7-4a81-973c-fc02c896ecd5"}], "title": "Waves: The Piano Collection"}], "title": "Primavera", "id": "7f0873dd-2934-4af3-9616-1a02aec9d4f6"}, {"sources": 290, "artists": [{"id": "fa34b363-79df-434f-a5b8-be4e6898543f", "name": "Ludovico Einaudi"}], "duration": 443, "releasegroups": [{"releases": [{"track_count": 40, "releaseevents": [{"date": {"month": 11, "day": 26, "year": 2007}, "country": "GB"}], "country": "GB", "date": {"month": 11, "day": 26, "year": 2007}, "medium_count": 2, "id": "d73e4041-375c-4b9f-8366-46089bca304c"}], "title": "The Number One Classical Album 2008", "secondarytypes": ["Compilation"], "artists": [{"id": "89ad4ac3-39f7-470e-963a-56509c546377", "name": "Various Artists"}], "type": "Album", "id": "ac615d26-df00-3053-9462-7636375603b4"}, {"releases": [{"track_count": 42, "releaseevents": [{"date": {"year": 2007}, "country": "GB"}], "country": "GB", "date": {"year": 2007}, "medium_count": 2, "id": "c0cb63d4-9a2b-4e11-b44f-b5ed1dda4e36"}], "title": "Classic FM: As Heard on TV", "secondarytypes": ["Compilation"], "artists": [{"id": "89ad4ac3-39f7-470e-963a-56509c546377", "name": "Various Artists"}], "type": "Album", "id": "7e7b5f9c-4959-360b-8ce1-895dacab472a"}, {"type": "Album", "id": "39f2c673-1387-4272-9db9-5f19d48e47cb", "releases": [{"track_count": 12, "releaseevents": [{"date": {"month": 11, "day": 7, "year": 2006}, "country": "XE"}], "country": "XE", "date": {"month": 11, "day": 7, "year": 2006}, "medium_count": 1, "id": "4a796be9-612c-4fec-bac6-70fc1bef8175"}, {"track_count": 12, "releaseevents": [{"date": {"year": 2007}, "country": "US"}], "country": "US", "date": {"year": 2007}, "medium_count": 1, "id": "4694854e-5960-4fa2-b25e-46ad32707a31"}, {"track_count": 15, "releaseevents": [{"date": {"month": 11, "day": 5, "year": 2007}, "country": "IT"}], "country": "IT", "date": {"month": 11, "day": 5, "year": 2007}, "medium_count": 2, "id": "cbea7b36-3edb-392a-b703-f4d0b648deed"}], "title": "Divenire"}], "title": "Primavera", "id": "8f6ac978-95cf-41e8-82fb-043624652e04"}, {"sources": 79, "artists": [{"id": "fa34b363-79df-434f-a5b8-be4e6898543f", "name": "Ludovico Einaudi"}], "duration": 444, "releasegroups": [{"releases": [{"track_count": 14, "releaseevents": [{"date": {"month": 6, "day": 27, "year": 2011}, "country": "GB"}], "country": "GB", "date": {"month": 6, "day": 27, "year": 2011}, "medium_count": 1, "id": "4cec104f-25ac-4f10-9330-1fa67d851213"}, {"track_count": 27, "releaseevents": [{"date": {"month": 6, "day": 27, "year": 2011}, "country": "GB"}], "country": "GB", "date": {"month": 6, "day": 27, "year": 2011}, "medium_count": 2, "id": "45a7c1c6-26c0-4b07-8424-c88878de7611"}], "title": "Islands: Essential Einaudi", "secondarytypes": ["Compilation"], "type": "Album", "id": "e0901be3-7942-4677-ba24-013c37894344"}], "title": "Primavera", "id": "9efb88b2-618e-4de2-a672-9b3faec0b0c4"}], "score": 0.946137, "id": "843671ef-8722-4700-bd9e-0605f53180f2"}, {"recordings": [{"sources": 112, "artists": [{"id": "fa34b363-79df-434f-a5b8-be4e6898543f", "name": "Ludovico Einaudi"}], "duration": 444, "releasegroups": [{"releases": [{"track_count": 15, "releaseevents": [{"date": {"year": 2012}, "country": "FR"}], "country": "FR", "date": {"year": 2012}, "medium_count": 1, "id": "7a06eb11-6013-4eb8-8aef-a2302ef4ed79"}], "title": "Einaudi essentiel", "secondarytypes": ["Compilation"], "type": "Album", "id": "6c42f326-7c15-41d5-851d-e887b544e217"}], "title": "Primavera", "id": "75e72e13-cf02-47f8-a4a7-98b916b3b18c"}, {"sources": 1, "artists": [{"id": "fa34b363-79df-434f-a5b8-be4e6898543f", "name": "Ludovico Einaudi"}], "duration": 443, "releasegroups": [{"releases": [{"track_count": 40, "releaseevents": [{"date": {"month": 11, "day": 26, "year": 2007}, "country": "GB"}], "country": "GB", "date": {"month": 11, "day": 26, "year": 2007}, "medium_count": 2, "id": "d73e4041-375c-4b9f-8366-46089bca304c"}], "title": "The Number One Classical Album 2008", "secondarytypes": ["Compilation"], "artists": [{"id": "89ad4ac3-39f7-470e-963a-56509c546377", "name": "Various Artists"}], "type": "Album", "id": "ac615d26-df00-3053-9462-7636375603b4"}, {"releases": [{"track_count": 42, "releaseevents": [{"date": {"year": 2007}, "country": "GB"}], "country": "GB", "date": {"year": 2007}, "medium_count": 2, "id": "c0cb63d4-9a2b-4e11-b44f-b5ed1dda4e36"}], "title": "Classic FM: As Heard on TV", "secondarytypes": ["Compilation"], "artists": [{"id": "89ad4ac3-39f7-470e-963a-56509c546377", "name": "Various Artists"}], "type": "Album", "id": "7e7b5f9c-4959-360b-8ce1-895dacab472a"}, {"type": "Album", "id": "39f2c673-1387-4272-9db9-5f19d48e47cb", "releases": [{"track_count": 12, "releaseevents": [{"date": {"month": 11, "day": 7, "year": 2006}, "country": "XE"}], "country": "XE", "date": {"month": 11, "day": 7, "year": 2006}, "medium_count": 1, "id": "4a796be9-612c-4fec-bac6-70fc1bef8175"}, {"track_count": 12, "releaseevents": [{"date": {"year": 2007}, "country": "US"}], "country": "US", "date": {"year": 2007}, "medium_count": 1, "id": "4694854e-5960-4fa2-b25e-46ad32707a31"}, {"track_count": 15, "releaseevents": [{"date": {"month": 11, "day": 5, "year": 2007}, "country": "IT"}], "country": "IT", "date": {"month": 11, "day": 5, "year": 2007}, "medium_count": 2, "id": "cbea7b36-3edb-392a-b703-f4d0b648deed"}], "title": "Divenire"}], "title": "Primavera", "id": "8f6ac978-95cf-41e8-82fb-043624652e04"}], "score": 0.94462, "id": "2fd40d3c-6e6b-44eb-8d11-446ce5b0ea24"}]}
{"status": "ok", "results": [{"recordings": [{"sources": 1, "artists": [{"id": "e7d8aea3-9c1d-4fe0-b93a-481d545296fc", "name": "Craig Ogden"}], "duration": 414, "releasegroups": [{"releases": [{"track_count": 30, "releaseevents": [{"date": {"year": 2009}, "country": "GB"}], "country": "GB", "date": {"year": 2009}, "medium_count": 2, "mediums": [{"position": 1, "tracks": [{"position": 8, "artists": [{"id": "fa34b363-79df-434f-a5b8-be4e6898543f", "name": "Ludovico Einaudi"}], "id": "325b74b0-c6c0-3388-9cc2-41b3a2af7113"}], "track_count": 15, "format": "CD"}], "id": "5fd10cc8-30e0-48aa-9ba1-19d05b871a75"}], "title": "Classic FM Summer Guitar", "secondarytypes": ["Compilation"], "artists": [{"id": "89ad4ac3-39f7-470e-963a-56509c546377", "name": "Various Artists"}], "type": "Album", "id": "2cde60bc-829c-49af-a62c-e20283167c30"}], "title": "Primavera", "id": "5d72b7d4-d0c4-4d0d-ab7f-3a737075e1c9"}, {"sources": 29, "artists": [{"id": "fa34b363-79df-434f-a5b8-be4e6898543f", "name": "Ludovico Einaudi"}], "duration": 443, "releasegroups": [{"type": "Album", "id": "39f2c673-1387-4272-9db9-5f19d48e47cb", "releases": [{"track_count": 13, "releaseevents": [{"date": {"month": 2, "day": 19, "year": 2007}, "country": "IT"}], "country": "IT", "date": {"month": 2, "day": 19, "year": 2007}, "medium_count": 1, "mediums": [{"position": 1, "tracks": [{"position": 6, "id": "5bfbd570-aafa-3c78-b690-eac90bc72751"}], "track_count": 13, "format": "Digital Media"}], "id": "931d4cfa-53c6-41cd-8ab0-a2917a7c1f3e"}], "title": "Divenire"}], "title": "Primavera", "id": "70088e7c-1c01-48cb-9103-ba8b500c68a4"}, {"sources": 2, "artists": [{"id": "fa34b363-79df-434f-a5b8-be4e6898543f", "name": "Ludovico Einaudi"}], "duration": 444, "releasegroups": [{"releases": [{"track_count": 15, "releaseevents": [{"date": {"year": 2012}, "country": "FR"}], "country": "FR", "date": {"year": 2012}, "medium_count": 1, "mediums": [{"position": 1, "tracks": [{"position": 11, "id": "8250a5b3-4a06-338c-b00b-a67d31c28ffe"}], "track_count": 15, "format": "CD"}], "id": "7a06eb11-6013-4eb8-8aef-a2302ef4ed79"}], "title": "Einaudi essentiel", "secondarytypes": ["Compilation"], "type": "Album", "id": "6c42f326-7c15-41d5-851d-e887b544e217"}], "title": "Primavera", "id": "75e72e13-cf02-47f8-a4a7-98b916b3b18c"}, {"sources": 1, "artists": [{"id": "509249cd-a9ce-4e9e-b499-45be01bf1be1", "name": "Jeroen van Veen"}], "duration": 444, "releasegroups": [{"artists": [{"joinphrase": "; ", "id": "fa34b363-79df-434f-a5b8-be4e6898543f", "name": "Ludovico Einaudi"}, {"id": "509249cd-a9ce-4e9e-b499-45be01bf1be1", "name": "Jeroen van Veen"}], "type": "Album", "id": "ef007d8d-93ce-4e90-ab87-220037c0704c", "releases": [{"track_count": 91, "releaseevents": [{"date": {"year": 2013}, "country": "XE"}], "country": "XE", "date": {"year": 2013}, "medium_count": 7, "mediums": [{"position": 5, "tracks": [{"position": 6, "artists": [{"id": "fa34b363-79df-434f-a5b8-be4e6898543f", "name": "Ludovico Einaudi"}], "id": "0f3d3838-0fb1-4bf4-8a1f-cadb2f206235"}], "title": "Divenire", "track_count": 11, "format": "CD"}], "id": "045ad634-44c7-4a81-973c-fc02c896ecd5"}], "title": "Waves: The Piano Collection"}], "title": "Primavera", "id": "7f0873dd-2934-4af3-9616-1a02aec9d4f6"}, {"sources": 290, "artists": [{"id": "fa34b363-79df-434f-a5b8-be4e6898543f", "name": "Ludovico Einaudi"}], "duration": 443, "releasegroups": [{"releases": [{"track_count": 40, "releaseevents": [{"date": {"month": 11, "day": 26, "year": 2007}, "country": "GB"}], "country": "GB", "date": {"month": 11, "day": 26, "year": 2007}, "medium_count": 2, "mediums": [{"position": 1, "tracks": [{"position": 19, "artists": [{"id": "fa34b363-79df-434f-a5b8-be4e6898543f", "name": "Ludovico Einaudi"}], "id": "19ba2457-7885-374b-83d9-e969a88cb489"}], "track_count": 20, "format": "CD"}], "id": "d73e4041-375c-4b9f-8366-46089bca304c"}], "title": "The Number One Classical Album 2008", "secondarytypes": ["Compilation"], "artists": [{"id": "89ad4ac3-39f7-470e-963a-56509c546377", "name": "Various Artists"}], "type": "Album", "id": "ac615d26-df00-3053-9462-7636375603b4"}, {"releases": [{"track_count": 42, "releaseevents": [{"date": {"year": 2007}, "country": "GB"}], "country": "GB", "date": {"year": 2007}, "medium_count": 2, "mediums": [{"position": 1, "tracks": [{"position": 15, "artists": [{"id": "fa34b363-79df-434f-a5b8-be4e6898543f", "name": "Ludovico Einaudi"}], "id": "95398287-e62a-300b-b06b-f52e0222ce63", "title": "Primavera (Sony Blu-Ray)"}], "title": "Music from Adverts", "track_count": 20, "format": "CD"}], "id": "c0cb63d4-9a2b-4e11-b44f-b5ed1dda4e36"}], "title": "Classic FM: As Heard on TV", "secondarytypes": ["Compilation"], "artists": [{"id": "89ad4ac3-39f7-470e-963a-56509c546377", "name": "Various Artists"}], "type": "Album", "id": "7e7b5f9c-4959-360b-8ce1-895dacab472a"}, {"type": "Album", "id": "39f2c673-1387-4272-9db9-5f19d48e47cb", "releases": [{"track_count": 12, "releaseevents": [{"date": {"month": 11, "day": 7, "year": 2006}, "country": "XE"}], "country": "XE", "date": {"month": 11, "day": 7, "year": 2006}, "medium_count": 1, "mediums": [{"position": 1, "tracks": [{"position": 6, "id": "70b26c5a-3fc3-31a2-8644-67ff2a9dc48b"}], "track_count": 12, "format": "CD"}], "id": "4a796be9-612c-4fec-bac6-70fc1bef8175"}, {"track_count": 12, "releaseevents": [{"date": {"year": 2007}, "country": "US"}], "country": "US", "date": {"year": 2007}, "medium_count": 1, "mediums": [{"position": 1, "tracks": [{"position": 6, "id": "51b86462-628c-436e-92fa-58e868fc3451"}], "track_count": 12, "format": "CD"}], "id": "4694854e-5960-4fa2-b25e-46ad32707a31"}, {"track_count": 15, "releaseevents": [{"date": {"month": 11, "day": 5, "year": 2007}, "country": "IT"}], "country": "IT", "date": {"month": 11, "day": 5, "year": 2007}, "medium_count": 2, "mediums": [{"position": 1, "tracks": [{"position": 6, "id": "4aff1a3c-db3e-3ec7-b389-9ad877434cfe"}], "track_count": 12, "format": "CD"}], "id": "cbea7b36-3edb-392a-b703-f4d0b648deed"}], "title": "Divenire"}], "title": "Primavera", "id": "8f6ac978-95cf-41e8-82fb-043624652e04"}, {"sources": 79, "artists": [{"id": "fa34b363-79df-434f-a5b8-be4e6898543f", "name": "Ludovico Einaudi"}], "duration": 444, "releasegroups": [{"releases": [{"track_count": 14, "releaseevents": [{"date": {"month": 6, "day": 27, "year": 2011}, "country": "GB"}], "country": "GB", "date": {"month": 6, "day": 27, "year": 2011}, "medium_count": 1, "mediums": [{"position": 1, "tracks": [{"position": 10, "id": "dd9ad2a5-52b8-37a9-9e34-75fddf4d0ff4"}], "track_count": 14, "format": "CD"}], "id": "4cec104f-25ac-4f10-9330-1fa67d851213"}, {"track_count": 27, "releaseevents": [{"date": {"month": 6, "day": 27, "year": 2011}, "country": "GB"}], "country": "GB", "date": {"month": 6, "day": 27, "year": 2011}, "medium_count": 2, "mediums": [{"position": 1, "tracks": [{"position": 10, "id": "0e6de59f-cf6b-3244-9845-37162676bff1"}], "track_count": 14, "format": "CD"}], "id": "45a7c1c6-26c0-4b07-8424-c88878de7611"}], "title": "Islands: Essential Einaudi", "secondarytypes": ["Compilation"], "type": "Album", "id": "e0901be3-7942-4677-ba24-013c37894344"}], "title": "Primavera", "id": "9efb88b2-618e-4de2-a672-9b3faec0b0c4"}], "score": 0.946137, "id": "843671ef-8722-4700-bd9e-0605f53180f2"}, {"recordings": [{"sources": 112, "artists": [{"id": "fa34b363-79df-434f-a5b8-be4e6898543f", "name": "Ludovico Einaudi"}], "duration": 444, "releasegroups": [{"releases": [{"track_count": 15, "releaseevents": [{"date": {"year": 2012}, "country": "FR"}], "country": "FR", "date": {"year": 2012}, "medium_count": 1, "mediums": [{"position": 1, "tracks": [{"position": 11, "id": "8250a5b3-4a06-338c-b00b-a67d31c28ffe"}], "track_count": 15, "format": "CD"}], "id": "7a06eb11-6013-4eb8-8aef-a2302ef4ed79"}], "title": "Einaudi essentiel", "secondarytypes": ["Compilation"], "type": "Album", "id": "6c42f326-7c15-41d5-851d-e887b544e217"}], "title": "Primavera", "id": "75e72e13-cf02-47f8-a4a7-98b916b3b18c"}, {"sources": 1, "artists": [{"id": "fa34b363-79df-434f-a5b8-be4e6898543f", "name": "Ludovico Einaudi"}], "duration": 443, "releasegroups": [{"releases": [{"track_count": 40, "releaseevents": [{"date": {"month": 11, "day": 26, "year": 2007}, "country": "GB"}], "country": "GB", "date": {"month": 11, "day": 26, "year": 2007}, "medium_count": 2, "mediums": [{"position": 1, "tracks": [{"position": 19, "artists": [{"id": "fa34b363-79df-434f-a5b8-be4e6898543f", "name": "Ludovico Einaudi"}], "id": "19ba2457-7885-374b-83d9-e969a88cb489"}], "track_count": 20, "format": "CD"}], "id": "d73e4041-375c-4b9f-8366-46089bca304c"}], "title": "The Number One Classical Album 2008", "secondarytypes": ["Compilation"], "artists": [{"id": "89ad4ac3-39f7-470e-963a-56509c546377", "name": "Various Artists"}], "type": "Album", "id": "ac615d26-df00-3053-9462-7636375603b4"}, {"releases": [{"track_count": 42, "releaseevents": [{"date": {"year": 2007}, "country": "GB"}], "country": "GB", "date": {"year": 2007}, "medium_count": 2, "mediums": [{"position": 1, "tracks": [{"position": 15, "artists": [{"id": "fa34b363-79df-434f-a5b8-be4e6898543f", "name": "Ludovico Einaudi"}], "id": "95398287-e62a-300b-b06b-f52e0222ce63", "title": "Primavera (Sony Blu-Ray)"}], "title": "Music from Adverts", "track_count": 20, "format": "CD"}], "id": "c0cb63d4-9a2b-4e11-b44f-b5ed1dda4e36"}], "title": "Classic FM: As Heard on TV", "secondarytypes": ["Compilation"], "artists": [{"id": "89ad4ac3-39f7-470e-963a-56509c546377", "name": "Various Artists"}], "type": "Album", "id": "7e7b5f9c-4959-360b-8ce1-895dacab472a"}, {"type": "Album", "id": "39f2c673-1387-4272-9db9-5f19d48e47cb", "releases": [{"track_count": 12, "releaseevents": [{"date": {"month": 11, "day": 7, "year": 2006}, "country": "XE"}], "country": "XE", "date": {"month": 11, "day": 7, "year": 2006}, "medium_count": 1, "mediums": [{"position": 1, "tracks": [{"position": 6, "id": "70b26c5a-3fc3-31a2-8644-67ff2a9dc48b"}], "track_count": 12, "format": "CD"}], "id": "4a796be9-612c-4fec-bac6-70fc1bef8175"}, {"track_count": 12, "releaseevents": [{"date": {"year": 2007}, "country": "US"}], "country": "US", "date": {"year": 2007}, "medium_count": 1, "mediums": [{"position": 1, "tracks": [{"position": 6, "id": "51b86462-628c-436e-92fa-58e868fc3451"}], "track_count": 12, "format": "CD"}], "id": "4694854e-5960-4fa2-b25e-46ad32707a31"}, {"track_count": 15, "releaseevents": [{"date": {"month": 11, "day": 5, "year": 2007}, "country": "IT"}], "country": "IT", "date": {"month": 11, "day": 5, "year": 2007}, "medium_count": 2, "mediums": [{"position": 1, "tracks": [{"position": 6, "id": "4aff1a3c-db3e-3ec7-b389-9ad877434cfe"}], "track_count": 12, "format": "CD"}], "id": "cbea7b36-3edb-392a-b703-f4d0b648deed"}], "title": "Divenire"}], "title": "Primavera", "id": "8f6ac978-95cf-41e8-82fb-043624652e04"}], "score": 0.94462, "id": "2fd40d3c-6e6b-44eb-8d11-446ce5b0ea24"}]}
{"status": "ok", "results": [{"recordings": [{"sources": 11, "artists": [{"id": "5ae54dee-4dba-49c0-802a-a3b3b3adfe9b", "name": "Philip Glass"}], "duration": 602, "releasegroups": [{"type": "Album", "id": "52f1f9d5-5166-4ceb-9289-6fb1a87f367c", "releases": [{"track_count": 6, "releaseevents": [{"date": {"year": 2012}, "country": "US"}], "country": "US", "date": {"year": 2012}, "medium_count": 1, "id": "2807def3-7873-4277-b079-c9a963d99993"}], "title": "The Passion of Ramakrishna"}], "title": "Part 2", "id": "298e15a1-b29b-4947-9dca-ec3634f9ebde"}], "score": 0.999604, "id": "b3179c26-c4cb-45da-b750-a5f9211a54da"}]}
{"status": "ok", "results": [{"recordings": [{"sources": 11, "artists": [{"id": "5ae54dee-4dba-49c0-802a-a3b3b3adfe9b", "name": "Philip Glass"}], "duration": 602, "releasegroups": [{"type": "Album", "id": "52f1f9d5-5166-4ceb-9289-6fb1a87f367c", "releases": [{"track_count": 6, "releaseevents": [{"date": {"year": 2012}, "country": "US"}], "country": "US", "date": {"year": 2012}, "medium_count": 1, "mediums": [{"position": 1, "tracks": [{"position": 3, "id": "06d8de09-52b5-4f05-96c2-1cc11ff814bc", "title": "The Passion of Ramakrishna: Part 2"}], "track_count": 6, "format": "CD"}], "id": "2807def3-7873-4277-b079-c9a963d99993"}], "title": "The Passion of Ramakrishna"}], "title": "Part 2", "id": "298e15a1-b29b-4947-9dca-ec3634f9ebde"}], "score": 0.999604, "id": "b3179c26-c4cb-45da-b750-a5f9211a54da"}]}
This source diff could not be displayed because it is too large. You can view the blob instead.
{"status": "ok", "results": [{"recordings": [{"sources": 60, "artists": [{"id": "cae4fd51-4d58-4d48-92c1-6198cc2e45ed", "name": "Trombone Shorty"}], "duration": 245, "releasegroups": [{"type": "Album", "id": "c3418122-387b-4477-90cf-e5e6d110e054", "releases": [{"track_count": 14, "releaseevents": [{"date": {"year": 2011}, "country": "US"}], "country": "US", "date": {"year": 2011}, "medium_count": 1, "id": "567621e3-b80f-4c30-af5f-2ecf0882e94a"}, {"track_count": 14, "releaseevents": [{"date": {"month": 9, "day": 19, "year": 2011}, "country": "GB"}], "country": "GB", "date": {"month": 9, "day": 19, "year": 2011}, "medium_count": 1, "id": "2af487be-ef25-4076-a729-911a8ee0c590"}, {"track_count": 14, "releaseevents": [{"date": {"month": 9, "day": 16, "year": 2011}, "country": "XE"}], "country": "XE", "date": {"month": 9, "day": 16, "year": 2011}, "medium_count": 1, "id": "f32ccfd7-bb10-489a-979b-85929fcccf42"}], "title": "For True"}], "title": "Buckjump", "id": "96483bdd-f219-4ae3-a94e-04feeeef22a4"}], "score": 1.0, "id": "b13c6dd3-9e27-4740-8da7-ee766917a8d9"}]}
{"status": "ok", "results": [{"recordings": [{"sources": 60, "artists": [{"id": "cae4fd51-4d58-4d48-92c1-6198cc2e45ed", "name": "Trombone Shorty"}], "duration": 245, "releasegroups": [{"type": "Album", "id": "c3418122-387b-4477-90cf-e5e6d110e054", "releases": [{"track_count": 14, "releaseevents": [{"date": {"year": 2011}, "country": "US"}], "country": "US", "date": {"year": 2011}, "medium_count": 1, "mediums": [{"position": 1, "tracks": [{"position": 1, "id": "19e865c0-be5a-4b4d-bafd-e894fc934545"}], "track_count": 14, "format": "12\" Vinyl"}], "id": "567621e3-b80f-4c30-af5f-2ecf0882e94a"}, {"track_count": 14, "releaseevents": [{"date": {"month": 9, "day": 19, "year": 2011}, "country": "GB"}], "country": "GB", "date": {"month": 9, "day": 19, "year": 2011}, "medium_count": 1, "mediums": [{"position": 1, "tracks": [{"position": 1, "id": "e423904b-3720-312c-8021-d04f29231778"}], "track_count": 14, "format": "CD"}], "id": "2af487be-ef25-4076-a729-911a8ee0c590"}, {"track_count": 14, "releaseevents": [{"date": {"month": 9, "day": 16, "year": 2011}, "country": "XE"}], "country": "XE", "date": {"month": 9, "day": 16, "year": 2011}, "medium_count": 1, "mediums": [{"position": 1, "tracks": [{"position": 1, "id": "7cb643b6-9b6a-4960-8601-3a42dfed82fd"}], "track_count": 14, "format": "CD"}], "id": "f32ccfd7-bb10-489a-979b-85929fcccf42"}], "title": "For True"}], "title": "Buckjump", "id": "96483bdd-f219-4ae3-a94e-04feeeef22a4"}], "score": 1.0, "id": "b13c6dd3-9e27-4740-8da7-ee766917a8d9"}]}
......@@ -3,13 +3,13 @@ version=1
ignored-parameters=fingerprint
# test_lua_acoustid
[https://api.acoustid.org/v2/lookup?client=ACOUSTID_TEST_MOCK_API_KEY&meta=compress+recordings+releasegroups+releases+sources&duration=445]
[https://api.acoustid.org/v2/lookup?client=ACOUSTID_TEST_MOCK_API_KEY&meta=compress+recordings+releasegroups+releases+sources+tracks&duration=445]
data = acoustid_ludovico_einaudi_primavera.txt
[https://api.acoustid.org/v2/lookup?client=ACOUSTID_TEST_MOCK_API_KEY&meta=compress+recordings+releasegroups+releases+sources&duration=160]
[https://api.acoustid.org/v2/lookup?client=ACOUSTID_TEST_MOCK_API_KEY&meta=compress+recordings+releasegroups+releases+sources+tracks&duration=160]
data = acoustid_norah_jones_chasing_pirates.txt
[https://api.acoustid.org/v2/lookup?client=ACOUSTID_TEST_MOCK_API_KEY&meta=compress+recordings+releasegroups+releases+sources&duration=243]
[https://api.acoustid.org/v2/lookup?client=ACOUSTID_TEST_MOCK_API_KEY&meta=compress+recordings+releasegroups+releases+sources+tracks&duration=243]
data = acoustid_trombone_shorty_buckjump.txt
[https://api.acoustid.org/v2/lookup?client=ACOUSTID_TEST_MOCK_API_KEY&meta=compress+recordings+releasegroups+releases+sources&duration=601]
[https://api.acoustid.org/v2/lookup?client=ACOUSTID_TEST_MOCK_API_KEY&meta=compress+recordings+releasegroups+releases+sources+tracks&duration=601]
data = acoustid_philip_glass_the_passion_of.txt
[https://api.acoustid.org/v2/lookup?client=ACOUSTID_TEST_MOCK_API_KEY&meta=compress+recordings+releasegroups+releases+sources&duration=385]
[https://api.acoustid.org/v2/lookup?client=ACOUSTID_TEST_MOCK_API_KEY&meta=compress+recordings+releasegroups+releases+sources+tracks&duration=385]
data = acoustid_radiohead_paranoid_android.txt
......@@ -49,13 +49,17 @@ resolve (GrlSource *source,
gchar **out_mb_recording_id,
gchar **out_title,
gchar **out_mb_release_id,
gchar **out_mb_release_group_id)
gchar **out_mb_release_group_id,
gint *out_album_disc_number,
gchar **out_publication_date,
gint *out_track_number)
{
GList *keys;
GrlMedia *audio;
GrlOperationOptions *options;
GrlRegistry *registry;
GrlKeyID chromaprint_key, mb_release_id_key, mb_release_group_id_key;
GDateTime *date;
GError *error = NULL;
registry = grl_registry_get_default ();
......@@ -72,6 +76,9 @@ resolve (GrlSource *source,
GRL_METADATA_KEY_ALBUM,
GRL_METADATA_KEY_MB_RECORDING_ID,
GRL_METADATA_KEY_TITLE,
GRL_METADATA_KEY_ALBUM_DISC_NUMBER,
GRL_METADATA_KEY_PUBLICATION_DATE,
GRL_METADATA_KEY_TRACK_NUMBER,
NULL);
options = grl_operation_options_new (NULL);
grl_operation_options_set_resolution_flags (options, GRL_RESOLVE_NORMAL);
......@@ -97,6 +104,10 @@ resolve (GrlSource *source,
*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_album_disc_number = grl_media_get_album_disc_number (audio);
date = grl_media_get_publication_date (audio);
*out_publication_date = g_date_time_format (date, "%Y-%m-%d");
*out_track_number = grl_media_get_track_number (audio);
g_list_free (keys);
g_object_unref (options);
......@@ -120,32 +131,40 @@ test_resolve_fingerprint (void)
gchar *mb_recording_id;
gchar *title;
gchar *mb_release_id;
gint album_disc_number;
gchar *publication_date;
gint track_number;
} audios[] = {
{ FINGERPRINT_LUDOVICO_EI, 445,
"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",
1, "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",
1, "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",
1, "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",
1, "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",
1, "1997-01-01", 4,
},
};
......@@ -156,7 +175,8 @@ test_resolve_fingerprint (void)
gsize size;
GError *error = NULL;
gchar *mb_artist_id, *artist, *mb_album_id, *album, *mb_recording_id, *title,
*mb_release_id, *mb_release_group_id;
*mb_release_id, *mb_release_group_id, *publication_date;
gint album_disc_number, track_number;
file = g_file_new_for_uri (audios[i].fingerprint_file);
g_file_load_contents (file, NULL, &data, &size, NULL, &error);
......@@ -165,7 +185,8 @@ test_resolve_fingerprint (void)
resolve (source, data, audios[i].duration,
&mb_artist_id, &artist, &mb_album_id, &album, &mb_recording_id, &title,
&mb_release_id, &mb_release_group_id);
&mb_release_id, &mb_release_group_id, &album_disc_number, &publication_date,
&track_number);
g_free (data);
g_assert_cmpstr (audios[i].title, ==, title);
......@@ -184,6 +205,10 @@ test_resolve_fingerprint (void)
g_free (mb_release_id);
g_assert_cmpstr (audios[i].mb_album_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);
g_free (publication_date);
g_assert_cmpint (audios[i].track_number, ==, track_number);
}
}
......
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