Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Lyrics #1655

Merged
merged 4 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ OWNTONE_MODULES_CHECK([OWNTONE], [LIBAV],
[libavutil/avutil.h])
OWNTONE_CHECK_DECLS([avformat_network_init],
[libavformat/avformat.h])
OWNTONE_CHECK_DECLS([av_dict_iterate],
[libavutil/dict.h])
])

AC_CHECK_SIZEOF([void *])
Expand Down
4 changes: 3 additions & 1 deletion docs/json-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 [...]"
}
```

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion htdocs/assets/index.css

Large diffs are not rendered by default.

33 changes: 17 additions & 16 deletions htdocs/assets/index.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -371,6 +372,7 @@ static const ssize_t dbmfi_cols_map[] =
dbmfi_offsetof(channels),
dbmfi_offsetof(usermark),
dbmfi_offsetof(scan_kind),
dbmfi_offsetof(lyrics),
X-Ryl669 marked this conversation as resolved.
Show resolved Hide resolved
};

/* This list must be kept in sync with
Expand Down Expand Up @@ -777,6 +779,7 @@ free_mfi(struct media_file_info *mfi, int content_only)
free(mfi->composer_sort);
free(mfi->album_artist_sort);
free(mfi->virtual_path);
free(mfi->lyrics);

if (!content_only)
free(mfi);
Expand Down
2 changes: 2 additions & 0 deletions src/db.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ struct media_file_info {
char *composer_sort;

uint32_t scan_kind; /* Identifies the library_source that created/updates this item */
char *lyrics;
};

#define mfi_offsetof(field) offsetof(struct media_file_info, field)
Expand Down Expand Up @@ -422,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)
Expand Down
3 changes: 2 additions & 1 deletion src/db_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@
" composer_sort VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \
" channels INTEGER DEFAULT 0," \
" usermark INTEGER DEFAULT 0," \
" scan_kind INTEGER DEFAULT 0" \
" scan_kind INTEGER DEFAULT 0," \
" lyrics TEXT DEFAULT NULL COLLATE DAAP" \
");"

#define T_PL \
Expand Down
2 changes: 1 addition & 1 deletion src/db_init.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* is a major upgrade. In other words minor version upgrades permit downgrading
* the server after the database was upgraded. */
#define SCHEMA_VERSION_MAJOR 22
#define SCHEMA_VERSION_MINOR 0
#define SCHEMA_VERSION_MINOR 1

int
db_init_indices(sqlite3 *hdl);
Expand Down
26 changes: 26 additions & 0 deletions src/db_upgrade.c
Original file line number Diff line number Diff line change
Expand Up @@ -1227,6 +1227,26 @@ static const struct db_upgrade_query db_upgrade_v2200_queries[] =
{ U_v2200_SCVER_MINOR, "set schema_version_minor to 00" },
};

/* ---------------------------- 22.00 -> 22.01 ------------------------------ */

#define U_v2201_ALTER_FILES_ADD_LYRICS \
"ALTER TABLE files ADD COLUMN lyrics TEXT DEFAULT NULL COLLATE DAAP;"

#define U_v2201_SCVER_MAJOR \
"UPDATE admin SET value = '22' WHERE key = 'schema_version_major';"
#define U_v2201_SCVER_MINOR \
"UPDATE admin SET value = '01' WHERE key = 'schema_version_minor';"

static const struct db_upgrade_query db_upgrade_v2201_queries[] =
{
{ U_v2201_ALTER_FILES_ADD_LYRICS, "alter table files add column lyrics" },

{ U_v2201_SCVER_MAJOR, "set schema_version_major to 22" },
{ U_v2201_SCVER_MINOR, "set schema_version_minor to 01" },
};



/* -------------------------- Main upgrade handler -------------------------- */

int
Expand Down Expand Up @@ -1437,6 +1457,12 @@ db_upgrade(sqlite3 *hdl, int db_ver)
if (ret < 0)
return -1;

/* FALLTHROUGH */

case 2200:
ret = db_generic_upgrade(hdl, db_upgrade_v2201_queries, ARRAY_SIZE(db_upgrade_v2201_queries));
if (ret < 0)
return -1;

/* Last case statement is the only one that ends with a break statement! */
break;
Expand Down
7 changes: 4 additions & 3 deletions src/httpd_jsonapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,14 +322,15 @@ 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));

ret = snprintf(artwork_url, sizeof(artwork_url), "/artwork/item/%s", dbmfi->id);
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;
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
{
Expand Down
Loading
Loading