From c5fe0d217b11b7604d3c63097c18660cc37bf39a Mon Sep 17 00:00:00 2001 From: whatdoineed2do/Ray Date: Sat, 9 May 2020 17:09:03 +0100 Subject: [PATCH] [jsonapi] support 'limit' on 'api/queue/items/add?expression=' Extend to support SMART query allows 'limit' curl -X POST "http://localhost:3689/api/queue/items/add?expression=genre+is+%22Pop%22+order+by+time_added+desc+limit+3" --- src/httpd_jsonapi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/httpd_jsonapi.c b/src/httpd_jsonapi.c index 3df3e597..d162f2e7 100644 --- a/src/httpd_jsonapi.c +++ b/src/httpd_jsonapi.c @@ -2299,7 +2299,6 @@ queue_tracks_add_byexpression(const char *param, int pos, int *total_count) query_params.type = Q_ITEMS; query_params.sort = S_NAME; - query_params.idx_type = I_NONE; memset(&smartpl_expression, 0, sizeof(struct smartpl)); expression = safe_asprintf("\"query\" { %s }", param); @@ -2311,10 +2310,13 @@ queue_tracks_add_byexpression(const char *param, int pos, int *total_count) query_params.filter = strdup(smartpl_expression.query_where); query_params.order = safe_strdup(smartpl_expression.order); + query_params.limit = smartpl_expression.limit; free_smartpl(&smartpl_expression, 1); player_get_status(&status); + query_params.idx_type = query_params.limit > 0 ? I_FIRST : I_NONE; + ret = db_queue_add_by_query(&query_params, status.shuffle, status.item_id, pos, total_count, NULL); free_query_params(&query_params, 1);