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
BPM metadata enhancement #1087
BPM metadata enhancement #1087
Conversation
Related to navidrome#1036. Adds BPM to the stored metadata about MediaFiles. Displays BPM in the following locations: - Listing songs in the song list (desktop, sortable) - Listing songs in playlists (desktop, sortable) - Listing songs in albums (desktop) - Expanding song details When listing, shows a blank field if no BPM is present. When showing song details, shows a question mark. Updates test MP3 file to have BPM tag. Updated test to ensure tag is read correctly. Updated localization files. Most languages just use "BPM" as discovered during research on Wikipedia. However, a couple use some different nomenclature. Spanish uses PPM and Japanese uses M.M.
Also, note that the localization files were reformatted in alignment with the style enforced by the included Prettier extensions in the dev environment. I suggest hiding whitespace changes during review. 😉 |
Making this WIP; as discussed, BPM could be a float and TagLib isn't handling that scenario. |
Would there be a way to not show this field at all? |
That's being addressed via PR #923. |
- Supports reading floating point BPM (still storing it as an integer) and FFmpeg as the extractor - Replaces existing .ogg test file with one that shouldn't fail randomly - Adds supporting tests for both FFmpeg and TagLib
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this! Looks good in general, just a few minor things.
Updated localization files. Most languages just use "BPM" as discovered during research on Wikipedia. However, a couple use some different nomenclature. Spanish uses PPM and Japanese uses M.M.
Thanks for the research! One thing that I'd like to point out is that you don't need to add the new string in all translations, usually you only add the English one. I prefer to handle the translations in our POEditor project, so it can be reviewed by the translators responsible for each language. Adding the translations in PRs make my life harder, as I have to manually update the POEditor project 😞
So, if you don't mind, can you please remove the translations? At least the ones that are not really translated (still BPM), as ND falls back automatically to English. Thanks!
ui/src/common/SongDetails.js
Outdated
@@ -33,6 +39,13 @@ export const SongDetails = (props) => { | |||
updatedAt: <DateField record={record} source="updatedAt" showTime />, | |||
playCount: <TextField record={record} source="playCount" />, | |||
comment: <MultiLineTextField record={record} source="comment" />, | |||
bpm: ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think comment
should always be the last field here, as it can have multiple lines. Maybe put bpm
after genre
?
ui/src/common/SongDetails.js
Outdated
<FunctionField | ||
record={record} | ||
source="bpm" | ||
render={(r) => r.bpm || '?'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason why show a "?" when the fiend is empty? Why not do the same as discSubtitle
and comment
, remove the field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely missed that it does remove those fields dynamically. Will remove it instead.
model/mediafile.go
Outdated
@@ -39,6 +39,7 @@ type MediaFile struct { | |||
Compilation bool `json:"compilation"` | |||
Comment string `json:"comment"` | |||
Lyrics string `json:"lyrics"` | |||
Bpm int `json:"bpm"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should tag the field as json:"bpm,omitempty"
. This way we don't need <FunctionField source="bpm" render={(r) => r.bpm || ''} />
as it will be empty, not zero, simplifying the Datagrids (just need a simple <TextField/>
field
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, much cleaner.
func upAddBpmMetadata(tx *sql.Tx) error { | ||
_, err := tx.Exec(` | ||
alter table media_file | ||
add bpm integer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this field will appear in the Datagrids, it will be sortable, so we should add an index for it.
scanner/metadata/ffmpeg_test.go
Outdated
Input #0, ogg, from 'tests/fixtures/test.ogg': | ||
Metadata: | ||
FBPM : 141.7` | ||
md, _ := e.extractMetadata("tests/fixtures/test.mp3", output) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nitpick: I know the path here is irrelevant, but I think for clarity sake it should match the file path passed to the function (.ogg
and not .mp3
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, copy/paste error. Agreed.
All good call outs. First time using Go (and this code!) so definitely still learning. Will make changes today, thanks. |
- Adds index for BPM. Removes drop column as it's not supported by SQLite (duh). - Removes localizations for BPM as those will be done in POEditor. - Moves BPM before Comment in Song Details and removes BPM altogether if it's empty. - Omits empty BPM in JSON responses, eliminating need for FunctionField. - Fixes copy/paste error in ffmpeg_test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we got everything in place. But I think I was not 100% clear about the translations: We do need the new field added to the en.json
file, this is the only language handled in the code. The other languages are the ones handled in the POEEditor. Please add the en.json
string back if you can.
I'll do some manual testing tonight before merging.
Correct me if I'm wrong, but the |
Ops, my bad! I've previously marked it as "Viewed" and inadvertently skipped it this time. |
Merging. This just makes it even more important to have #923 in place before next release. |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Closes #1086 and is related to #1036.
Adds BPM to the stored metadata about MediaFiles.
Displays BPM in the following locations:
When listing, shows a blank field if no BPM is present. When showing song details, shows a question mark.
Updates test MP3 file to have BPM tag. Updated test to ensure tag is read correctly.
Updated localization files. Most languages just use "BPM" as discovered during research on Wikipedia. However, a couple use some different nomenclature. Spanish uses PPM and Japanese uses M.M.