feat: Support for additional metadata and multi-value metadata (genre, composer) #1852
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR are is a poc / rfc.
Its purpose is to revive the discussion about supporting more than one genre/compose for a song #886 and hopefully come to a solution.
It follows what @whatdoineed2do outlined as third option in #886 (comment):
As described in the comment a new table is introduced
files_metadata
that links to thefiles
table and contains key / value pairs. A file can have multiple entries for a key.When scanning a file with ffmpeg the
files_metadata
table is populated. Genre and composer tags are split by separators (currently hard-coded, should be configurable) and multiple rows are inserted for the file infiles_metadata
.files_metadata
entries are not updated, if a file changed, all rows for thisfile_id
are deleted and new ones are inserted.The scan logic for the
files
table is unchanged.To fetch via the
files_metadata
table, newquery_type
s are added for genre / composer browse queries.The existing queries and usages to fetch from the DB are unchanged.
The JSON API was updated to show how the queries can be used (note, that this currently breaks the web UI).
How the JSON API should be changed in the end, needs further thought (e. g. if it is OK to have breaking changes or not).
In my opinion, this solution has several advantages:
files_metadata
table allows to easily expose additional metadata fields without impacting existing queries. In this PR for example, I added several MusicBrainz IDs (the web UI could e. g. make use of them to fetch additional data from external service).files
table, which increases the result set size for files queries by a lot (assuming a user that has a lot of files with lyrics tags). Lyrics are only relevant when looking at a single file/song, e. g. in the now playing page or in the file/song details dialog. But most or all of the time a list of songs is fetched, they are not relevant. This might also apply for other tags, and could improve the query execution times for large libraries.There are of course some limitations or difficulties with this approach:
files_metadata
in smart playlist queries will be difficult and most probably - if possible at all - not performant.files
andfiles_metadata
. But I would argue here that this is OK. In thefiles
table is the raw value from the scan, while infiles_metadata
are the parsed/processed values. And also not normalizing a DB to improve performance is in my opinion also OK.@ejurgensen, it would be great if you could take a look and say whether this approach is OK and worth fleshing out and looking into in detail.