mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-27 06:33:21 -05:00
[jsonapi] Fix wrong artwork url for non library queue items and streams
Add check against the special file_id DB_MEDIA_FILE_NON_PERSISTENT_ID to identify if a queue item is not in the library. And always prefer the artwork url in the queue item before the artwork for the library file.
This commit is contained in:
parent
a8d3a045f2
commit
89ca5e8ba9
@ -1525,7 +1525,8 @@ queue_item_to_json(struct db_queue_item *queue_item, char shuffle)
|
|||||||
else
|
else
|
||||||
json_object_object_add(item, "position", json_object_new_int(queue_item->pos));
|
json_object_object_add(item, "position", json_object_new_int(queue_item->pos));
|
||||||
|
|
||||||
json_object_object_add(item, "track_id", json_object_new_int(queue_item->file_id));
|
if (queue_item->file_id > 0 && queue_item->file_id != DB_MEDIA_FILE_NON_PERSISTENT_ID)
|
||||||
|
json_object_object_add(item, "track_id", json_object_new_int(queue_item->file_id));
|
||||||
|
|
||||||
safe_json_add_string(item, "title", queue_item->title);
|
safe_json_add_string(item, "title", queue_item->title);
|
||||||
safe_json_add_string(item, "artist", queue_item->artist);
|
safe_json_add_string(item, "artist", queue_item->artist);
|
||||||
@ -1546,21 +1547,27 @@ queue_item_to_json(struct db_queue_item *queue_item, char shuffle)
|
|||||||
|
|
||||||
safe_json_add_string(item, "path", queue_item->path);
|
safe_json_add_string(item, "path", queue_item->path);
|
||||||
|
|
||||||
if (queue_item->file_id > 0)
|
if (queue_item->file_id > 0 && queue_item->file_id != DB_MEDIA_FILE_NON_PERSISTENT_ID)
|
||||||
{
|
{
|
||||||
ret = snprintf(uri, sizeof(uri), "%s:%s:%d", "library", "track", queue_item->file_id);
|
ret = snprintf(uri, sizeof(uri), "%s:%s:%d", "library", "track", queue_item->file_id);
|
||||||
if (ret < sizeof(uri))
|
if (ret < sizeof(uri))
|
||||||
json_object_object_add(item, "uri", json_object_new_string(uri));
|
json_object_object_add(item, "uri", json_object_new_string(uri));
|
||||||
|
|
||||||
ret = snprintf(artwork_url, sizeof(artwork_url), "/artwork/item/%d", queue_item->file_id);
|
|
||||||
if (ret < sizeof(artwork_url))
|
|
||||||
json_object_object_add(item, "artwork_url", json_object_new_string(artwork_url));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
safe_json_add_string(item, "uri", queue_item->path);
|
safe_json_add_string(item, "uri", queue_item->path);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (queue_item->artwork_url)
|
||||||
|
{
|
||||||
safe_json_add_string(item, "artwork_url", queue_item->artwork_url);
|
safe_json_add_string(item, "artwork_url", queue_item->artwork_url);
|
||||||
}
|
}
|
||||||
|
else if (queue_item->file_id > 0 && queue_item->file_id != DB_MEDIA_FILE_NON_PERSISTENT_ID)
|
||||||
|
{
|
||||||
|
ret = snprintf(artwork_url, sizeof(artwork_url), "/artwork/item/%d", queue_item->file_id);
|
||||||
|
if (ret < sizeof(artwork_url))
|
||||||
|
json_object_object_add(item, "artwork_url", json_object_new_string(artwork_url));
|
||||||
|
}
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user