mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-27 14:43:21 -05:00
[jsonapi] Add endpoint for playlist update of query_limit
Makes it possible to set number of podcasts retrieved for RSS feeds. Closes #951.
This commit is contained in:
parent
95bc6e3e70
commit
3994ef0f2e
@ -746,6 +746,7 @@ curl -X PUT "http://localhost:3689/api/queue/items/2"
|
|||||||
| GET | [/api/library](#library-information) | Get library information |
|
| GET | [/api/library](#library-information) | Get library information |
|
||||||
| GET | [/api/library/playlists](#list-playlists) | Get a list of playlists |
|
| GET | [/api/library/playlists](#list-playlists) | Get a list of playlists |
|
||||||
| GET | [/api/library/playlists/{id}](#get-a-playlist) | Get a playlist |
|
| GET | [/api/library/playlists/{id}](#get-a-playlist) | Get a playlist |
|
||||||
|
| PUT | [/api/library/playlists/{id}](#update-a-playlist) | Update a playlist attribute |
|
||||||
| DELETE | [/api/library/playlists/{id}](#delete-a-playlist) | Delete a playlist |
|
| DELETE | [/api/library/playlists/{id}](#delete-a-playlist) | Delete a playlist |
|
||||||
| GET | [/api/library/playlists/{id}/tracks](#list-playlist-tracks) | Get list of tracks for a playlist |
|
| GET | [/api/library/playlists/{id}/tracks](#list-playlist-tracks) | Get list of tracks for a playlist |
|
||||||
| PUT | [/api/library/playlists/{id}/tracks](#update-playlist-tracks) | Update play count of tracks for a playlist |
|
| PUT | [/api/library/playlists/{id}/tracks](#update-playlist-tracks) | Update play count of tracks for a playlist |
|
||||||
@ -899,6 +900,59 @@ curl -X GET "http://localhost:3689/api/library/playlists/1"
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Update a playlist
|
||||||
|
|
||||||
|
Update attributes of a specific playlists in your library
|
||||||
|
|
||||||
|
**Endpoint**
|
||||||
|
|
||||||
|
```http
|
||||||
|
PUT /api/library/playlists/{id}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Path parameters**
|
||||||
|
|
||||||
|
| Parameter | Value |
|
||||||
|
| --------------- | -------------------- |
|
||||||
|
| id | Playlist id |
|
||||||
|
|
||||||
|
**Query parameters**
|
||||||
|
|
||||||
|
| Parameter | Value |
|
||||||
|
| --------------- | ----------------------------------------------------------- |
|
||||||
|
| query_limit | For RSS feeds, this sets how many podcasts to retrieve |
|
||||||
|
|
||||||
|
|
||||||
|
**Example**
|
||||||
|
|
||||||
|
```shell
|
||||||
|
curl -X PUT "http://localhost:3689/api/library/playlists/25?query_limit=20"
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Delete a playlist
|
||||||
|
|
||||||
|
Delete a playlist, e.g. a RSS feed
|
||||||
|
|
||||||
|
**Endpoint**
|
||||||
|
|
||||||
|
```http
|
||||||
|
DELETE /api/library/playlists/{id}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Path parameters**
|
||||||
|
|
||||||
|
| Parameter | Value |
|
||||||
|
| --------------- | -------------------- |
|
||||||
|
| id | Playlist id |
|
||||||
|
|
||||||
|
**Example**
|
||||||
|
|
||||||
|
```shell
|
||||||
|
curl -X DELETE "http://localhost:3689/api/library/playlists/25"
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### List playlist tracks
|
### List playlist tracks
|
||||||
|
|
||||||
Lists the tracks in a playlists
|
Lists the tracks in a playlists
|
||||||
|
@ -3226,7 +3226,7 @@ jsonapi_reply_library_playlists(struct httpd_request *hreq)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
jsonapi_reply_library_playlist(struct httpd_request *hreq)
|
jsonapi_reply_library_playlist_get(struct httpd_request *hreq)
|
||||||
{
|
{
|
||||||
uint32_t playlist_id;
|
uint32_t playlist_id;
|
||||||
json_object *reply = NULL;
|
json_object *reply = NULL;
|
||||||
@ -3275,6 +3275,55 @@ jsonapi_reply_library_playlist(struct httpd_request *hreq)
|
|||||||
return HTTP_OK;
|
return HTTP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
playlist_attrib_query_limit_set(int playlist_id, const char *param)
|
||||||
|
{
|
||||||
|
struct playlist_info *pli;
|
||||||
|
int query_limit;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = safe_atoi32(param, &query_limit);
|
||||||
|
if (ret < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
pli = db_pl_fetch_byid(playlist_id);
|
||||||
|
if (!pli)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
pli->query_limit = query_limit;
|
||||||
|
|
||||||
|
ret = db_pl_update(pli);
|
||||||
|
|
||||||
|
free_pli(pli, 0);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
jsonapi_reply_library_playlist_put(struct httpd_request *hreq)
|
||||||
|
{
|
||||||
|
uint32_t playlist_id;
|
||||||
|
const char *param;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = safe_atou32(hreq->uri_parsed->path_parts[3], &playlist_id);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
DPRINTF(E_LOG, L_WEB, "Could not parse playlist id to integer\n");
|
||||||
|
return HTTP_BADREQUEST;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((param = evhttp_find_header(hreq->query, "query_limit")))
|
||||||
|
ret = playlist_attrib_query_limit_set(playlist_id, param);
|
||||||
|
else
|
||||||
|
ret = -1;
|
||||||
|
|
||||||
|
if (ret < 0)
|
||||||
|
return HTTP_BADREQUEST;
|
||||||
|
|
||||||
|
return HTTP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
jsonapi_reply_library_playlist_tracks(struct httpd_request *hreq)
|
jsonapi_reply_library_playlist_tracks(struct httpd_request *hreq)
|
||||||
{
|
{
|
||||||
@ -4094,7 +4143,8 @@ static struct httpd_uri_map adm_handlers[] =
|
|||||||
{ EVHTTP_REQ_POST, "^/api/queue/save$", jsonapi_reply_queue_save},
|
{ EVHTTP_REQ_POST, "^/api/queue/save$", jsonapi_reply_queue_save},
|
||||||
|
|
||||||
{ EVHTTP_REQ_GET, "^/api/library/playlists$", jsonapi_reply_library_playlists },
|
{ EVHTTP_REQ_GET, "^/api/library/playlists$", jsonapi_reply_library_playlists },
|
||||||
{ EVHTTP_REQ_GET, "^/api/library/playlists/[[:digit:]]+$", jsonapi_reply_library_playlist },
|
{ EVHTTP_REQ_GET, "^/api/library/playlists/[[:digit:]]+$", jsonapi_reply_library_playlist_get },
|
||||||
|
{ EVHTTP_REQ_PUT, "^/api/library/playlists/[[:digit:]]+$", jsonapi_reply_library_playlist_put },
|
||||||
{ EVHTTP_REQ_GET, "^/api/library/playlists/[[:digit:]]+/tracks$", jsonapi_reply_library_playlist_tracks },
|
{ EVHTTP_REQ_GET, "^/api/library/playlists/[[:digit:]]+/tracks$", jsonapi_reply_library_playlist_tracks },
|
||||||
{ EVHTTP_REQ_PUT, "^/api/library/playlists/[[:digit:]]+/tracks", jsonapi_reply_library_playlist_tracks_put_byid},
|
{ EVHTTP_REQ_PUT, "^/api/library/playlists/[[:digit:]]+/tracks", jsonapi_reply_library_playlist_tracks_put_byid},
|
||||||
// { EVHTTP_REQ_POST, "^/api/library/playlists/[[:digit:]]+/tracks$", jsonapi_reply_library_playlists_tracks },
|
// { EVHTTP_REQ_POST, "^/api/library/playlists/[[:digit:]]+/tracks$", jsonapi_reply_library_playlists_tracks },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user