mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-12 15:33:23 -05:00
[jsonapi] Change library_item_add, add delete pl and drop library_item_remove
This commit is contained in:
parent
59fa33311d
commit
16a3b8878f
@ -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/playlists](#list-playlists) | Get a list of playlists |
|
||||
| GET | [/api/library/playlists/{id}](#get-a-playlist) | Get 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 |
|
||||
| PUT | [/api/library/playlists/{id}/tracks](#update-playlist-tracks) | Update play count of tracks for a playlist |
|
||||
| GET | [/api/library/playlists/{id}/playlists](#list-playlists-in-a-playlist-folder) | Get list of playlists for a playlist folder |
|
||||
@ -760,6 +761,7 @@ curl -X PUT "http://localhost:3689/api/queue/items/2"
|
||||
| GET | [/api/library/genres](#list-genres) | Get list of genres |
|
||||
| GET | [/api/library/count](#get-count-of-tracks-artists-and-albums) | Get count of tracks, artists and albums |
|
||||
| GET | [/api/library/files](#list-local-directories) | Get list of directories in the local library |
|
||||
| POST | [/api/library/add](#add-an-item-to-the-library) | Add an item to the library |
|
||||
| PUT | [/api/update](#trigger-rescan) | Trigger a library rescan |
|
||||
| PUT | [/api/rescan](#trigger-meta-rescan) | Trigger a library metadata rescan |
|
||||
|
||||
|
@ -3331,6 +3331,25 @@ jsonapi_reply_library_playlist_tracks(struct httpd_request *hreq)
|
||||
return HTTP_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
jsonapi_reply_library_playlist_delete(struct httpd_request *hreq)
|
||||
{
|
||||
uint32_t pl_id;
|
||||
int ret;
|
||||
|
||||
ret = safe_atou32(hreq->uri_parsed->path_parts[3], &pl_id);
|
||||
if (ret < 0)
|
||||
{
|
||||
DPRINTF(E_LOG, L_WEB, "No valid playlist id given '%s'\n", hreq->uri_parsed->path);
|
||||
|
||||
return HTTP_BADREQUEST;
|
||||
}
|
||||
|
||||
db_pl_delete(pl_id);
|
||||
|
||||
return HTTP_NOCONTENT;
|
||||
}
|
||||
|
||||
static int
|
||||
jsonapi_reply_library_playlist_playlists(struct httpd_request *hreq)
|
||||
{
|
||||
@ -3691,46 +3710,19 @@ jsonapi_reply_library_files(struct httpd_request *hreq)
|
||||
}
|
||||
|
||||
static int
|
||||
jsonapi_reply_library_item_add(struct httpd_request *hreq)
|
||||
{
|
||||
const char *name;
|
||||
const char *url;
|
||||
const char *limit;
|
||||
int ret = -1;
|
||||
|
||||
name = evhttp_find_header(hreq->query, "name");
|
||||
url = evhttp_find_header(hreq->query, "url");
|
||||
if (!name || !url)
|
||||
{
|
||||
DPRINTF(E_LOG, L_WEB, "Missing parameters: name: '%s' url: '%s'\n", name, url);
|
||||
return HTTP_BADREQUEST;
|
||||
}
|
||||
|
||||
limit = evhttp_find_header(hreq->query, "limit");
|
||||
if (limit == NULL)
|
||||
limit = "-1";
|
||||
|
||||
ret = library_item_add(name, url, atol(limit));
|
||||
if (ret < 0)
|
||||
return HTTP_INTERNAL;
|
||||
|
||||
return HTTP_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
jsonapi_reply_library_item_remove(struct httpd_request *hreq)
|
||||
jsonapi_reply_library_add(struct httpd_request *hreq)
|
||||
{
|
||||
const char *url;
|
||||
int ret = -1;
|
||||
int ret;
|
||||
|
||||
url = evhttp_find_header(hreq->query, "url");
|
||||
if (!url)
|
||||
{
|
||||
DPRINTF(E_LOG, L_WEB, "Missing url parameter\n");
|
||||
DPRINTF(E_LOG, L_WEB, "Missing URL parameter for library add\n");
|
||||
return HTTP_BADREQUEST;
|
||||
}
|
||||
|
||||
ret = library_item_remove(url);
|
||||
ret = library_item_add(url);
|
||||
if (ret < 0)
|
||||
return HTTP_INTERNAL;
|
||||
|
||||
@ -4106,7 +4098,7 @@ static struct httpd_uri_map adm_handlers[] =
|
||||
{ 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_POST, "^/api/library/playlists/[[:digit:]]+/tracks$", jsonapi_reply_library_playlists_tracks },
|
||||
// { EVHTTP_REQ_DELETE, "^/api/library/playlists/[[:digit:]]+$", jsonapi_reply_library_playlist_tracks },
|
||||
{ EVHTTP_REQ_DELETE, "^/api/library/playlists/[[:digit:]]+$", jsonapi_reply_library_playlist_delete },
|
||||
{ EVHTTP_REQ_GET, "^/api/library/playlists/[[:digit:]]+/playlists", jsonapi_reply_library_playlist_playlists },
|
||||
{ EVHTTP_REQ_GET, "^/api/library/artists$", jsonapi_reply_library_artists },
|
||||
{ EVHTTP_REQ_GET, "^/api/library/artists/[[:digit:]]+$", jsonapi_reply_library_artist },
|
||||
@ -4120,8 +4112,7 @@ static struct httpd_uri_map adm_handlers[] =
|
||||
{ EVHTTP_REQ_GET, "^/api/library/genres$", jsonapi_reply_library_genres},
|
||||
{ EVHTTP_REQ_GET, "^/api/library/count$", jsonapi_reply_library_count },
|
||||
{ EVHTTP_REQ_GET, "^/api/library/files$", jsonapi_reply_library_files },
|
||||
{ EVHTTP_REQ_POST, "^/api/library/item_add$", jsonapi_reply_library_item_add },
|
||||
{ EVHTTP_REQ_DELETE, "^/api/library/item_remove$", jsonapi_reply_library_item_remove },
|
||||
{ EVHTTP_REQ_POST, "^/api/library/add$", jsonapi_reply_library_add },
|
||||
|
||||
{ EVHTTP_REQ_GET, "^/api/search$", jsonapi_reply_search },
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user