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

BPM metadata enhancement #1087

Merged
merged 3 commits into from May 6, 2021

Conversation

brianschrameck
Copy link
Contributor

@brianschrameck brianschrameck commented May 4, 2021

Closes #1086 and is related to #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.

Screen Shot 2021-05-04 at 10 37 48 AM

Screen Shot 2021-05-04 at 10 37 53 AM

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.
@brianschrameck
Copy link
Contributor Author

brianschrameck commented May 4, 2021

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. 😉

@brianschrameck brianschrameck changed the title BPM metadata enhancement WIP: BPM metadata enhancement May 4, 2021
@brianschrameck
Copy link
Contributor Author

Making this WIP; as discussed, BPM could be a float and TagLib isn't handling that scenario.

@ghost
Copy link

ghost commented May 4, 2021

Would there be a way to not show this field at all?

@brianschrameck
Copy link
Contributor Author

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
@brianschrameck brianschrameck changed the title WIP: BPM metadata enhancement BPM metadata enhancement May 4, 2021
Copy link
Member

@deluan deluan left a 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!

@@ -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: (
Copy link
Member

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?

<FunctionField
record={record}
source="bpm"
render={(r) => r.bpm || '?'}
Copy link
Member

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?

Copy link
Contributor Author

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.

@@ -39,6 +39,7 @@ type MediaFile struct {
Compilation bool `json:"compilation"`
Comment string `json:"comment"`
Lyrics string `json:"lyrics"`
Bpm int `json:"bpm"`
Copy link
Member

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

Copy link
Contributor Author

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;
Copy link
Member

@deluan deluan May 5, 2021

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.

Input #0, ogg, from 'tests/fixtures/test.ogg':
Metadata:
FBPM : 141.7`
md, _ := e.extractMetadata("tests/fixtures/test.mp3", output)
Copy link
Member

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)

Copy link
Contributor Author

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.

@brianschrameck
Copy link
Contributor Author

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.
@brianschrameck brianschrameck requested a review from deluan May 5, 2021 12:59
Copy link
Member

@deluan deluan left a 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.

@brianschrameck
Copy link
Contributor Author

We do need the new field added to the en.json file, this is the only language handled in the code.

Correct me if I'm wrong, but the en.json file is still in there with the changes.

@deluan
Copy link
Member

deluan commented May 5, 2021

Correct me if I'm wrong, but the en.json file is still in there with the changes.

Ops, my bad! I've previously marked it as "Viewed" and inadvertently skipped it this time.

@deluan
Copy link
Member

deluan commented May 6, 2021

Merging. This just makes it even more important to have #923 in place before next release.

@deluan deluan merged commit 30bb3f7 into navidrome:master May 6, 2021
@brianschrameck brianschrameck deleted the bpm-metadata-enhancements branch May 6, 2021 21:08
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BPM metadata enhancement
2 participants