Try to match a list of genres in rescan #282
Merged
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 improves the way the rescan runner handles the genre tag and allows creating multiple genres from one tag.
Since ID3 tag and vorbis tags only allow one genre field, there are a lot of files that have a list of genres inside that one tag. Up until now we created a genre with the literal string inside the tag, often resulting in genres like
Folk/Rock
orRock, Folk, Folk-Rock
- which then need a manual conversion to multiple genres.With this PR, this logic is changed so that we pick up a list of genres and create a genre for each item in the list.
The logic is now as follows:
If the genre is already in the database (even if it is a list), we match this genre. (So that a user can use the separator inside a genre name if they want).
Otherwise, we split the string by
,
or/
and try to match each part (normalized and stripped of whitespace to allowGenre 1, Genre 2
) or create new genre for each partThere might be some other separators used or relevant, but these two seemed to be the two most common in our library. A combination of both is also possible (however unlikely/messy that sounds)
The new file in the test contains the genre tag
genre 1, genre 2 / genre 3