mirror of
https://github.com/owntone/owntone-server.git
synced 2025-11-24 03:27:46 -05:00
[scan/library] Media rating sync (#1681)
Automatically read/write ratings to files in the library, if options read_rating/ write_rating are enabled. Also adds a max_rating so the user can set the rating scale. Doesn't sync automatic rating updates, because that could lead to whole-playlist file rewriting. Closes #1678 --------- Co-authored-by: whatdoineed2do/Ray <whatdoineed2do@nospam.gmail.com> Co-authored-by: ejurgensen <espenjurgensen@gmail.com>
This commit is contained in:
20
src/mpd.c
20
src/mpd.c
@@ -3269,7 +3269,8 @@ static int
|
||||
mpd_sticker_set(struct evbuffer *evbuf, int argc, char **argv, char **errmsg, const char *virtual_path)
|
||||
{
|
||||
uint32_t rating;
|
||||
int ret = 0;
|
||||
int id;
|
||||
int ret;
|
||||
|
||||
if (strcmp(argv[4], "rating") != 0)
|
||||
{
|
||||
@@ -3291,20 +3292,22 @@ mpd_sticker_set(struct evbuffer *evbuf, int argc, char **argv, char **errmsg, co
|
||||
return ACK_ERROR_ARG;
|
||||
}
|
||||
|
||||
ret = db_file_rating_update_byvirtualpath(virtual_path, rating);
|
||||
if (ret <= 0)
|
||||
id = db_file_id_byvirtualpath(virtual_path);
|
||||
if (id <= 0)
|
||||
{
|
||||
*errmsg = safe_asprintf("Invalid path '%s'", virtual_path);
|
||||
return ACK_ERROR_ARG;
|
||||
}
|
||||
|
||||
library_item_attrib_save(id, LIBRARY_ATTRIB_RATING, rating);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
mpd_sticker_delete(struct evbuffer *evbuf, int argc, char **argv, char **errmsg, const char *virtual_path)
|
||||
{
|
||||
int ret = 0;
|
||||
int id;
|
||||
|
||||
if (strcmp(argv[4], "rating") != 0)
|
||||
{
|
||||
@@ -3312,12 +3315,15 @@ mpd_sticker_delete(struct evbuffer *evbuf, int argc, char **argv, char **errmsg,
|
||||
return ACK_ERROR_NO_EXIST;
|
||||
}
|
||||
|
||||
ret = db_file_rating_update_byvirtualpath(virtual_path, 0);
|
||||
if (ret <= 0)
|
||||
id = db_file_id_byvirtualpath(virtual_path);
|
||||
if (id <= 0)
|
||||
{
|
||||
*errmsg = safe_asprintf("Invalid path '%s'", virtual_path);
|
||||
return ACK_ERROR_ARG;
|
||||
}
|
||||
|
||||
library_item_attrib_save(id, LIBRARY_ATTRIB_RATING, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -4714,7 +4720,7 @@ artwork_cb(struct evhttp_request *req, void *arg)
|
||||
|
||||
DPRINTF(E_DBG, L_MPD, "Artwork request for path: %s\n", decoded_path);
|
||||
|
||||
itemid = db_file_id_by_virtualpath_match(decoded_path);
|
||||
itemid = db_file_id_byvirtualpath_match(decoded_path);
|
||||
if (!itemid)
|
||||
{
|
||||
DPRINTF(E_WARN, L_MPD, "No item found for path '%s' from request uri '%s'\n", decoded_path, uri);
|
||||
|
||||
Reference in New Issue
Block a user