From 382467eb9cf397ad296f36f80e6d2faf41dbe469 Mon Sep 17 00:00:00 2001 From: chme Date: Sat, 22 Aug 2020 12:59:56 +0200 Subject: [PATCH] [jsonapi] Map additional metadata for artist and album --- src/httpd_jsonapi.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/httpd_jsonapi.c b/src/httpd_jsonapi.c index 6b17fdf8..3d27a2de 100644 --- a/src/httpd_jsonapi.c +++ b/src/httpd_jsonapi.c @@ -151,6 +151,7 @@ static json_object * artist_to_json(struct db_group_info *dbgri) { json_object *item; + int intval; char uri[100]; char artwork_url[100]; int ret; @@ -164,6 +165,14 @@ artist_to_json(struct db_group_info *dbgri) safe_json_add_int_from_string(item, "track_count", dbgri->itemcount); safe_json_add_int_from_string(item, "length_ms", dbgri->song_length); + ret = safe_atoi32(dbgri->media_kind, &intval); + if (ret == 0) + safe_json_add_string(item, "media_kind", db_media_kind_label(intval)); + + ret = safe_atoi32(dbgri->data_kind, &intval); + if (ret == 0) + safe_json_add_string(item, "data_kind", db_data_kind_label(intval)); + ret = snprintf(uri, sizeof(uri), "%s:%s:%s", "library", "artist", dbgri->persistentid); if (ret < sizeof(uri)) json_object_object_add(item, "uri", json_object_new_string(uri)); @@ -179,6 +188,7 @@ static json_object * album_to_json(struct db_group_info *dbgri) { json_object *item; + int intval; char uri[100]; char artwork_url[100]; int ret; @@ -193,6 +203,17 @@ album_to_json(struct db_group_info *dbgri) safe_json_add_int_from_string(item, "track_count", dbgri->itemcount); safe_json_add_int_from_string(item, "length_ms", dbgri->song_length); + ret = safe_atoi32(dbgri->media_kind, &intval); + if (ret == 0) + safe_json_add_string(item, "media_kind", db_media_kind_label(intval)); + + ret = safe_atoi32(dbgri->data_kind, &intval); + if (ret == 0) + safe_json_add_string(item, "data_kind", db_data_kind_label(intval)); + + safe_json_add_time_from_string(item, "date_released", dbgri->date_released, false); + safe_json_add_int_from_string(item, "year", dbgri->year); + ret = snprintf(uri, sizeof(uri), "%s:%s:%s", "library", "album", dbgri->persistentid); if (ret < sizeof(uri)) json_object_object_add(item, "uri", json_object_new_string(uri));