[-] Fixup PR 1309 (usermark)
This commit is contained in:
parent
45c5f0b347
commit
6692411040
|
@ -791,7 +791,7 @@ curl -X PUT "http://localhost:3689/api/queue/items/2"
|
||||||
| GET | [/api/library/albums/{id}/tracks](#list-album-tracks) | Get list of tracks for an album |
|
| GET | [/api/library/albums/{id}/tracks](#list-album-tracks) | Get list of tracks for an album |
|
||||||
| GET | [/api/library/tracks/{id}](#get-a-track) | Get a track |
|
| GET | [/api/library/tracks/{id}](#get-a-track) | Get a track |
|
||||||
| GET | [/api/library/tracks/{id}/playlists](#list-playlists-for-a-track) | Get list of playlists for a track |
|
| GET | [/api/library/tracks/{id}/playlists](#list-playlists-for-a-track) | Get list of playlists for a track |
|
||||||
| PUT | [/api/library/tracks/{id}](#update-track-properties) | Update a tracks properties (rating, play_count,usermark) |
|
| PUT | [/api/library/tracks/{id}](#update-track-properties) | Update track properties |
|
||||||
| GET | [/api/library/genres](#list-genres) | Get list of genres |
|
| 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/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 |
|
| GET | [/api/library/files](#list-local-directories) | Get list of directories in the local library |
|
||||||
|
|
10
src/db.h
10
src/db.h
|
@ -143,11 +143,11 @@ db_data_kind_label(enum data_kind data_kind);
|
||||||
|
|
||||||
|
|
||||||
/* Indicates user marked status on a track - values can be bitwise enumerated */
|
/* Indicates user marked status on a track - values can be bitwise enumerated */
|
||||||
enum user_mark {
|
enum usermark {
|
||||||
USER_MARK_NA = 0,
|
USERMARK_NA = 0,
|
||||||
USER_MARK_DELETE = 1,
|
USERMARK_DELETE = 1,
|
||||||
USER_MARK_REXCODE = 2,
|
USERMARK_REXCODE = 2,
|
||||||
USER_MARK_REVIEW = 4
|
USERMARK_REVIEW = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3305,7 +3305,6 @@ jsonapi_reply_library_tracks_put_byid(struct httpd_request *hreq)
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return HTTP_INTERNAL;
|
return HTTP_INTERNAL;
|
||||||
|
|
||||||
// Update play_count/skip_count
|
|
||||||
param = evhttp_find_header(hreq->query, "play_count");
|
param = evhttp_find_header(hreq->query, "play_count");
|
||||||
if (param)
|
if (param)
|
||||||
{
|
{
|
||||||
|
@ -3320,37 +3319,37 @@ jsonapi_reply_library_tracks_put_byid(struct httpd_request *hreq)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DPRINTF(E_WARN, L_WEB, "Ignoring invalid play_count value '%s' for track '%d'.\n", param, track_id);
|
DPRINTF(E_WARN, L_WEB, "Ignoring invalid play_count value '%s' for track '%d'.\n", param, track_id);
|
||||||
|
return HTTP_BADREQUEST;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update rating
|
|
||||||
param = evhttp_find_header(hreq->query, "rating");
|
param = evhttp_find_header(hreq->query, "rating");
|
||||||
if (param)
|
if (param)
|
||||||
{
|
{
|
||||||
ret = safe_atou32(param, &val);
|
ret = safe_atou32(param, &val);
|
||||||
if (ret < 0)
|
if (ret < 0 || val > DB_FILES_RATING_MAX)
|
||||||
|
{
|
||||||
|
DPRINTF(E_WARN, L_WEB, "Invalid rating value '%s' for track '%d'.\n", param, track_id);
|
||||||
return HTTP_BADREQUEST;
|
return HTTP_BADREQUEST;
|
||||||
|
}
|
||||||
|
|
||||||
if (val >= 0 && val <= DB_FILES_RATING_MAX)
|
|
||||||
ret = db_file_rating_update_byid(track_id, val);
|
ret = db_file_rating_update_byid(track_id, val);
|
||||||
else
|
|
||||||
DPRINTF(E_WARN, L_WEB, "Ignoring invalid rating value '%d' for track '%d'.\n", val, track_id);
|
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return HTTP_INTERNAL;
|
return HTTP_INTERNAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update usermark
|
// Retreive marked tracks via "/api/search?type=tracks&expression=usermark+=+1"
|
||||||
// retreive via "/api/search?type=tracks&expression=usermark+=+1"
|
|
||||||
param = evhttp_find_header(hreq->query, "usermark");
|
param = evhttp_find_header(hreq->query, "usermark");
|
||||||
if (param)
|
if (param)
|
||||||
{
|
{
|
||||||
ret = safe_atou32(param, &val);
|
ret = safe_atou32(param, &val);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
DPRINTF(E_WARN, L_WEB, "Invalid usermark value '%s' for track '%d'.\n", param, track_id);
|
||||||
return HTTP_BADREQUEST;
|
return HTTP_BADREQUEST;
|
||||||
|
}
|
||||||
|
|
||||||
ret = db_file_usermark_update_byid(track_id, val);
|
ret = db_file_usermark_update_byid(track_id, val);
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return HTTP_INTERNAL;
|
return HTTP_INTERNAL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue