[jsonapi] Get currently playing queue item details (closes #1206)

Add now_playing shorthand, so that /api/queue?id=now_playing returns the
currently playing queue item info.
This commit is contained in:
ejurgensen 2021-04-01 23:23:18 +02:00
parent 1fafab12e3
commit f77161b5c2
2 changed files with 6 additions and 2 deletions

View File

@ -548,7 +548,7 @@ GET /api/queue
| Parameter | Value |
| --------------- | ----------------------------------------------------------- |
| id | *(Optional)* If a queue item id is given, only the item with the id will be returend. |
| id | *(Optional)* If a queue item id is given, only the item with the id will be returend. Use id=now_playing to get the currently playing item. |
| start | *(Optional)* If a `start`and an `end` position is given, only the items from `start` (included) to `end` (excluded) will be returned. If only a `start` position is given, only the item at this position will be returned. |
| end | *(Optional)* See `start` parameter |

View File

@ -2682,7 +2682,11 @@ jsonapi_reply_queue(struct httpd_request *hreq)
query_params.sort = S_SHUFFLE_POS;
param = evhttp_find_header(hreq->query, "id");
if (param && safe_atou32(param, &item_id) == 0)
if (param && strcmp(param, "now_playing") == 0)
{
query_params.filter = db_mprintf("id = %d", status.item_id);
}
else if (param && safe_atou32(param, &item_id) == 0)
{
query_params.filter = db_mprintf("id = %d", item_id);
}