mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-25 21:53:17 -05:00
[jsonapi] Include info about tracks added to queue (closes issue #1564)
This commit is contained in:
parent
5ea49c94de
commit
f430b71645
@ -655,7 +655,9 @@ On success returns the HTTP `200 OK` success status response code.
|
||||
|
||||
| Key | Type | Value |
|
||||
| --------------- | -------- | ----------------------------------------- |
|
||||
| count | integer | number of tracks added to the queue |
|
||||
| version | integer | Version number of the current queue |
|
||||
| count | integer | Number of tracks added to the queue |
|
||||
| items | array | Array of [`queue item`](#queue-item-object) objects added |
|
||||
|
||||
|
||||
**Example**
|
||||
@ -668,7 +670,32 @@ curl -X POST "http://localhost:3689/api/queue/items/add?uris=library:playlist:68
|
||||
|
||||
```json
|
||||
{
|
||||
"count": 42
|
||||
"version": 833,
|
||||
"count": 20,
|
||||
"items": [
|
||||
{
|
||||
"id": 12122,
|
||||
"position": 0,
|
||||
"track_id": 10749,
|
||||
"title": "Angels",
|
||||
"artist": "The xx",
|
||||
"artist_sort": "xx, The",
|
||||
"album": "Coexist",
|
||||
"album_sort": "Coexist",
|
||||
"albumartist": "The xx",
|
||||
"albumartist_sort": "xx, The",
|
||||
"genre": "Indie Rock",
|
||||
"year": 2012,
|
||||
"track_number": 1,
|
||||
"disc_number": 1,
|
||||
"length_ms": 171735,
|
||||
"media_kind": "music",
|
||||
"data_kind": "file",
|
||||
"path": "/music/srv/The xx/Coexist/01 Angels.mp3",
|
||||
"uri": "library:track:10749"
|
||||
},
|
||||
...
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
@ -680,7 +707,32 @@ curl -X POST "http://localhost:3689/api/queue/items/add?expression=media_kind+is
|
||||
|
||||
```json
|
||||
{
|
||||
"count": 42
|
||||
"version": 833,
|
||||
"count": 20,
|
||||
"items": [
|
||||
{
|
||||
"id": 12122,
|
||||
"position": 0,
|
||||
"track_id": 10749,
|
||||
"title": "Angels",
|
||||
"artist": "The xx",
|
||||
"artist_sort": "xx, The",
|
||||
"album": "Coexist",
|
||||
"album_sort": "Coexist",
|
||||
"albumartist": "The xx",
|
||||
"albumartist_sort": "xx, The",
|
||||
"genre": "Indie Rock",
|
||||
"year": 2012,
|
||||
"track_number": 1,
|
||||
"disc_number": 1,
|
||||
"length_ms": 171735,
|
||||
"media_kind": "music",
|
||||
"data_kind": "file",
|
||||
"path": "/music/srv/The xx/Coexist/01 Angels.mp3",
|
||||
"uri": "library:track:10749"
|
||||
},
|
||||
...
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -2304,18 +2304,45 @@ static int
|
||||
create_reply_queue_tracks_add(struct evbuffer *evbuf, int count, int new_item_id, char shuffle)
|
||||
{
|
||||
json_object *reply = json_object_new_object();
|
||||
json_object *items = json_object_new_array();
|
||||
json_object *item;
|
||||
struct query_params query_params = { 0 };
|
||||
struct db_queue_item queue_item;
|
||||
int version = 0;
|
||||
int ret;
|
||||
|
||||
db_admin_getint(&version, DB_ADMIN_QUEUE_VERSION);
|
||||
|
||||
json_object_object_add(reply, "version", json_object_new_int(version));
|
||||
json_object_object_add(reply, "count", json_object_new_int(count));
|
||||
json_object_object_add(reply, "items", items);
|
||||
|
||||
ret = db_queue_enum_start(&query_params);
|
||||
if (ret < 0)
|
||||
goto error;
|
||||
|
||||
while ((ret = db_queue_enum_fetch(&query_params, &queue_item)) == 0 && queue_item.id > 0)
|
||||
{
|
||||
if (queue_item.id < new_item_id)
|
||||
continue;
|
||||
|
||||
item = queue_item_to_json(&queue_item, shuffle);
|
||||
if (!item)
|
||||
goto error;
|
||||
|
||||
json_object_array_add(items, item);
|
||||
}
|
||||
|
||||
ret = evbuffer_add_printf(evbuf, "%s", json_object_to_json_string(reply));
|
||||
if (ret < 0)
|
||||
goto error;
|
||||
|
||||
db_queue_enum_end(&query_params);
|
||||
jparse_free(reply);
|
||||
return 0;
|
||||
|
||||
error:
|
||||
db_queue_enum_end(&query_params);
|
||||
jparse_free(reply);
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user