[jsonapi] Add boolean field "random" to playlist

The new field "random" is true for smart playlists with an order by
clause "random", otherwise it is false. This allows clients to handle
randomly generated playlists differently from static playlists.
This commit is contained in:
chme 2020-08-29 13:57:44 +02:00
parent dd811e6c70
commit 20a2c96b2a

View File

@ -338,6 +338,7 @@ playlist_to_json(struct db_playlist_info *dbpli)
json_object *item;
char uri[100];
int intval;
bool boolval;
int ret;
item = json_object_new_object();
@ -351,6 +352,10 @@ playlist_to_json(struct db_playlist_info *dbpli)
{
safe_json_add_string(item, "type", db_pl_type_label(intval));
json_object_object_add(item, "smart_playlist", json_object_new_boolean(intval == PL_SMART));
boolval = dbpli->query_order && strcasestr(dbpli->query_order, "random");
json_object_object_add(item, "random", json_object_new_boolean(boolval));
json_object_object_add(item, "folder", json_object_new_boolean(intval == PL_FOLDER));
}