Skip to content

Commit

Permalink
BPM metadata enhancement
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
brianschrameck committed May 4, 2021
1 parent 66b3164 commit 13beb86
Show file tree
Hide file tree
Showing 29 changed files with 5,746 additions and 5,668 deletions.
31 changes: 31 additions & 0 deletions db/migration/20210430212322_add_bpm_metadata.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package migrations

import (
"database/sql"

"github.com/pressly/goose"
)

func init() {
goose.AddMigration(upAddBpmMetadata, downAddBpmMetadata)
}

func upAddBpmMetadata(tx *sql.Tx) error {
_, err := tx.Exec(`
alter table media_file
add bpm integer;
`)
if err != nil {
return err
}
notice(tx, "A full rescan needs to be performed to import more tags")
return forceFullRescan(tx)
}

func downAddBpmMetadata(tx *sql.Tx) error {
_, err := tx.Exec(`
alter table media_file
drop bpm;
`)
return err
}
1 change: 1 addition & 0 deletions model/mediafile.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type MediaFile struct {
Compilation bool `json:"compilation"`
Comment string `json:"comment"`
Lyrics string `json:"lyrics"`
Bpm int `json:"bpm"`
CatalogNum string `json:"catalogNum"`
MbzTrackID string `json:"mbzTrackId" orm:"column(mbz_track_id)"`
MbzAlbumID string `json:"mbzAlbumId" orm:"column(mbz_album_id)"`
Expand Down

0 comments on commit 13beb86

Please sign in to comment.