-
Notifications
You must be signed in to change notification settings - Fork 243
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
feat: Support for additional metadata and multi-value metadata (genre, composer) #1852
base: master
Are you sure you want to change the base?
Conversation
…ata for local files
…s endpoint; add new tracks-metadata endpoint
Great that you have looked into this! It's come up a few times, and I have never been able to get around to it. I think this looks very promising. Some questions I would like to hear your thoughts about:
|
At the moment, I don't see a benefit in adding an additional table for genre/composer for proper m:m. Joining three tables makes it a bit more complex. Maybe there could be some slight performance improvement when fetching the list of genre/composer, but I doubt it is significant, especially when additional info like number of tracks should be returned (requires then joining the three tables). What I am thinking about is, to add a column to the
I would keep it simple. Modelling the application model close to the DB model, keeps it simple and performant. Adding an array of genre, would increase the complexity by a great deal, without a real benefit.
Some other not so great names :-)
The new table would be for tags with multiple values. And I would also store data in there, that is only relevant when looking at one specific item/track/file. And is not relevant when fetching a list of items. Data that would be nice to see in a details dialog of an item, but is of no importance in a list of items (like lyrics :-)). I have not measured the performance impact of having a library with lyrics for the majority of items. On my development laptop with my medium sized library it does not matter, I'll look into setting up my RPI again to get some numbers of a resource restrained system. |
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.