mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-25 21:53:17 -05:00
[httpd] Add fetching lyrics in the JSON api
This commit is contained in:
parent
cf8b3ecd3a
commit
9670f6b079
@ -1544,7 +1544,8 @@ curl -X GET "http://localhost:3689/api/library/tracks/1"
|
||||
"data_kind": "file",
|
||||
"path": "/music/srv/Incubus/Make Yourself/12 Pardon Me.mp3",
|
||||
"uri": "library:track:1",
|
||||
"artwork_url": "/artwork/item/1"
|
||||
"artwork_url": "/artwork/item/1",
|
||||
"lyrics": "[00:00:10] Let's start the music [...]"
|
||||
}
|
||||
```
|
||||
|
||||
@ -2622,6 +2623,7 @@ curl --include \
|
||||
| uri | string | Resource identifier |
|
||||
| artwork_url | string | *(optional)* [Artwork url](#artwork-urls) |
|
||||
| usermark | integer | User review marking of track (ranges from 0) |
|
||||
| lyrics | string | The lyrics if found either as LRC or plain text |
|
||||
|
||||
|
||||
### `paging` object
|
||||
|
2
src/db.c
2
src/db.c
@ -230,6 +230,7 @@ static const struct col_type_map mfi_cols_map[] =
|
||||
{ "channels", mfi_offsetof(channels), DB_TYPE_INT },
|
||||
{ "usermark", mfi_offsetof(usermark), DB_TYPE_INT },
|
||||
{ "scan_kind", mfi_offsetof(scan_kind), DB_TYPE_INT },
|
||||
{ "lyrics", mfi_offsetof(lyrics), DB_TYPE_STRING },
|
||||
};
|
||||
|
||||
/* This list must be kept in sync with
|
||||
@ -371,6 +372,7 @@ static const ssize_t dbmfi_cols_map[] =
|
||||
dbmfi_offsetof(channels),
|
||||
dbmfi_offsetof(usermark),
|
||||
dbmfi_offsetof(scan_kind),
|
||||
dbmfi_offsetof(lyrics),
|
||||
};
|
||||
|
||||
/* This list must be kept in sync with
|
||||
|
1
src/db.h
1
src/db.h
@ -423,6 +423,7 @@ struct db_media_file_info {
|
||||
char *channels;
|
||||
char *usermark;
|
||||
char *scan_kind;
|
||||
char *lyrics;
|
||||
};
|
||||
|
||||
#define dbmfi_offsetof(field) offsetof(struct db_media_file_info, field)
|
||||
|
@ -322,7 +322,7 @@ track_to_json(struct db_media_file_info *dbmfi)
|
||||
|
||||
safe_json_add_string(item, "path", dbmfi->path);
|
||||
|
||||
ret = snprintf(uri, sizeof(uri), "%s:%s:%s", "library", "track", dbmfi->id);
|
||||
ret = snprintf(uri, sizeof(uri), "library:track:%s", dbmfi->id);
|
||||
if (ret < sizeof(uri))
|
||||
json_object_object_add(item, "uri", json_object_new_string(uri));
|
||||
|
||||
@ -330,6 +330,7 @@ track_to_json(struct db_media_file_info *dbmfi)
|
||||
if (ret < sizeof(artwork_url))
|
||||
json_object_object_add(item, "artwork_url", json_object_new_string(artwork_url));
|
||||
|
||||
safe_json_add_string(item, "lyrics", dbmfi->lyrics);
|
||||
return item;
|
||||
}
|
||||
|
||||
@ -3851,7 +3852,7 @@ jsonapi_reply_queue_save(struct httpd_request *hreq)
|
||||
if (!allow_modifying_stored_playlists)
|
||||
{
|
||||
DPRINTF(E_LOG, L_WEB, "Modifying stored playlists is not enabled in the config file\n");
|
||||
return 403;
|
||||
return 403;
|
||||
}
|
||||
|
||||
if (access(default_playlist_directory, W_OK) < 0)
|
||||
@ -4762,7 +4763,7 @@ jsonapi_init(void)
|
||||
default_playlist_directory = NULL;
|
||||
allow_modifying_stored_playlists = cfg_getbool(cfg_getsec(cfg, "library"), "allow_modifying_stored_playlists");
|
||||
if (allow_modifying_stored_playlists)
|
||||
{
|
||||
{
|
||||
temp_path = cfg_getstr(cfg_getsec(cfg, "library"), "default_playlist_directory");
|
||||
if (temp_path)
|
||||
{
|
||||
|
@ -330,7 +330,7 @@ iterate_metadata(struct media_file_info *mfi, const AVDictionaryEntry *mdt, cons
|
||||
if (*intval == 0)
|
||||
{
|
||||
if (safe_atou32(mdt->value, intval) < 0)
|
||||
return 1; /* Should probably be 0 */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
@ -361,11 +361,11 @@ extract_metadata_core(struct media_file_info *mfi, AVDictionary *md, const struc
|
||||
Instead, we are reversing the metadata searching algorithm to query all metadata key that FFMPEG fetched
|
||||
and matching them against our own map. This is the most efficient method to search it without having 2 pass
|
||||
on the KV store */
|
||||
mdt = av_dict_iterate(md, NULL);
|
||||
mdt = av_dict_get(md, "", NULL, AV_DICT_IGNORE_SUFFIX);
|
||||
while (mdt != NULL)
|
||||
{
|
||||
mdcount += iterate_metadata(mfi, mdt, md_map);
|
||||
mdt = av_dict_iterate(md, mdt);
|
||||
mdt = av_dict_get(md, "", mdt, AV_DICT_IGNORE_SUFFIX);
|
||||
}
|
||||
|
||||
return mdcount;
|
||||
|
Loading…
x
Reference in New Issue
Block a user