From 3343e9cfc81049be0eac9bda55362ec975ebadfb Mon Sep 17 00:00:00 2001 From: chme Date: Thu, 14 Feb 2019 08:22:50 +0100 Subject: [PATCH 1/3] [jsonapi] Rename queue item "albumartist_id" to "album_artist_id" Keeps it in sync with the naming in the track object. Also introduce a helper function to add an int64 as a json string. --- src/httpd_jsonapi.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/httpd_jsonapi.c b/src/httpd_jsonapi.c index 551ba011..d6785036 100644 --- a/src/httpd_jsonapi.c +++ b/src/httpd_jsonapi.c @@ -66,6 +66,20 @@ safe_json_add_string(json_object *obj, const char *key, const char *value) json_object_object_add(obj, key, json_object_new_string(value)); } +static inline void +safe_json_add_string_from_int64(json_object *obj, const char *key, int64_t value) +{ + char tmp[100]; + int ret; + + if (value > 0) + { + ret = snprintf(tmp, sizeof(tmp), "%" PRIi64, value); + if (ret < sizeof(tmp)) + json_object_object_add(obj, key, json_object_new_string(tmp)); + } +} + static inline void safe_json_add_int_from_string(json_object *obj, const char *key, const char *value) { @@ -1649,24 +1663,13 @@ queue_item_to_json(struct db_queue_item *queue_item, char shuffle) safe_json_add_string(item, "artist_sort", queue_item->artist_sort); safe_json_add_string(item, "album", queue_item->album); safe_json_add_string(item, "album_sort", queue_item->album_sort); + safe_json_add_string_from_int64(item, "album_id", queue_item->songalbumid); safe_json_add_string(item, "album_artist", queue_item->album_artist); safe_json_add_string(item, "album_artist_sort", queue_item->album_artist_sort); + safe_json_add_string_from_int64(item, "album_artist_id", queue_item->songartistid); safe_json_add_string(item, "composer", queue_item->composer); safe_json_add_string(item, "genre", queue_item->genre); - if (queue_item->songartistid > 0) - { - ret = snprintf(uri, sizeof(uri), "%" PRIi64, queue_item->songartistid); - if (ret < sizeof(uri)) - json_object_object_add(item, "albumartist_id", json_object_new_string(uri)); - } - if (queue_item->songalbumid > 0) - { - ret = snprintf(uri, sizeof(uri), "%" PRIi64, queue_item->songalbumid); - if (ret < sizeof(uri)) - json_object_object_add(item, "album_id", json_object_new_string(uri)); - } - json_object_object_add(item, "year", json_object_new_int(queue_item->year)); json_object_object_add(item, "track_number", json_object_new_int(queue_item->track)); json_object_object_add(item, "disc_number", json_object_new_int(queue_item->disc)); From 19c92df8256ac7e8eebfa93a0104a9396bda6c65 Mon Sep 17 00:00:00 2001 From: chme Date: Thu, 14 Feb 2019 08:24:03 +0100 Subject: [PATCH 2/3] [web-src] Improve modal for queue items, if item is not part of the library and adjust after renaming to "album_artist_id" --- web-src/src/components/ModalDialogQueueItem.vue | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/web-src/src/components/ModalDialogQueueItem.vue b/web-src/src/components/ModalDialogQueueItem.vue index 72543e40..7f708f5c 100644 --- a/web-src/src/components/ModalDialogQueueItem.vue +++ b/web-src/src/components/ModalDialogQueueItem.vue @@ -15,11 +15,13 @@

Album - {{ item.album }} + {{ item.album }} + {{ item.album }}

Album artist - {{ item.album_artist }} + {{ item.album_artist }} + {{ item.album_artist }}

Composer @@ -29,7 +31,7 @@ Year {{ item.year }}

-

+

Genre {{ item.genre }}

@@ -92,7 +94,7 @@ export default { }, open_album_artist: function () { - this.$router.push({ path: '/music/artists/' + this.item.albumartist_id }) + this.$router.push({ path: '/music/artists/' + this.item.album_artist_id }) }, open_genre: function () { From 0caa98d8ff26648f9d36173cc6814162ebcfc675 Mon Sep 17 00:00:00 2001 From: chme Date: Thu, 14 Feb 2019 08:24:36 +0100 Subject: [PATCH 3/3] [REAMDE] Update JSON API readme (add new queue item attributes) --- README_JSON_API.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README_JSON_API.md b/README_JSON_API.md index 2606f927..642976e1 100644 --- a/README_JSON_API.md +++ b/README_JSON_API.md @@ -1961,8 +1961,10 @@ curl --include \ | artist_sort | string | Track artist sort name | | album | string | Album name | | album_sort | string | Album sort name | +| album_id | string | Album id | | album_artist | string | Album artist name | | album_artist_sort | string | Album artist sort name | +| album_artist_id | string | Album artist id | | composer | string | Composer (optional) | | genre | string | Genre | | year | integer | Release year |