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 | 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)); 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 () {