mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-20 22:07:43 +03:00
* BPM metadata enhancement 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. * Enhances support for BPM metadata extraction - 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 * Addresses various issues with PR #1087. - 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.
83 lines
3.4 KiB
Go
83 lines
3.4 KiB
Go
package model
|
|
|
|
import (
|
|
"mime"
|
|
"time"
|
|
)
|
|
|
|
type MediaFile struct {
|
|
Annotations
|
|
Bookmarkable
|
|
|
|
ID string `json:"id" orm:"pk;column(id)"`
|
|
Path string `json:"path"`
|
|
Title string `json:"title"`
|
|
Album string `json:"album"`
|
|
ArtistID string `json:"artistId" orm:"pk;column(artist_id)"`
|
|
Artist string `json:"artist"`
|
|
AlbumArtistID string `json:"albumArtistId" orm:"pk;column(album_artist_id)"`
|
|
AlbumArtist string `json:"albumArtist"`
|
|
AlbumID string `json:"albumId" orm:"pk;column(album_id)"`
|
|
HasCoverArt bool `json:"hasCoverArt"`
|
|
TrackNumber int `json:"trackNumber"`
|
|
DiscNumber int `json:"discNumber"`
|
|
DiscSubtitle string `json:"discSubtitle"`
|
|
Year int `json:"year"`
|
|
Size int64 `json:"size"`
|
|
Suffix string `json:"suffix"`
|
|
Duration float32 `json:"duration"`
|
|
BitRate int `json:"bitRate"`
|
|
Genre string `json:"genre"`
|
|
FullText string `json:"fullText"`
|
|
SortTitle string `json:"sortTitle"`
|
|
SortAlbumName string `json:"sortAlbumName"`
|
|
SortArtistName string `json:"sortArtistName"`
|
|
SortAlbumArtistName string `json:"sortAlbumArtistName"`
|
|
OrderAlbumName string `json:"orderAlbumName"`
|
|
OrderArtistName string `json:"orderArtistName"`
|
|
OrderAlbumArtistName string `json:"orderAlbumArtistName"`
|
|
Compilation bool `json:"compilation"`
|
|
Comment string `json:"comment"`
|
|
Lyrics string `json:"lyrics"`
|
|
Bpm int `json:"bpm,omitempty"`
|
|
CatalogNum string `json:"catalogNum"`
|
|
MbzTrackID string `json:"mbzTrackId" orm:"column(mbz_track_id)"`
|
|
MbzAlbumID string `json:"mbzAlbumId" orm:"column(mbz_album_id)"`
|
|
MbzArtistID string `json:"mbzArtistId" orm:"column(mbz_artist_id)"`
|
|
MbzAlbumArtistID string `json:"mbzAlbumArtistId" orm:"column(mbz_album_artist_id)"`
|
|
MbzAlbumType string `json:"mbzAlbumType"`
|
|
MbzAlbumComment string `json:"mbzAlbumComment"`
|
|
CreatedAt time.Time `json:"createdAt"` // Time this entry was created in the DB
|
|
UpdatedAt time.Time `json:"updatedAt"` // Time of file last update (mtime)
|
|
}
|
|
|
|
func (mf *MediaFile) ContentType() string {
|
|
return mime.TypeByExtension("." + mf.Suffix)
|
|
}
|
|
|
|
type MediaFiles []MediaFile
|
|
|
|
type MediaFileRepository interface {
|
|
CountAll(options ...QueryOptions) (int64, error)
|
|
Exists(id string) (bool, error)
|
|
Put(m *MediaFile) error
|
|
Get(id string) (*MediaFile, error)
|
|
GetAll(options ...QueryOptions) (MediaFiles, error)
|
|
FindByAlbum(albumId string) (MediaFiles, error)
|
|
FindAllByPath(path string) (MediaFiles, error)
|
|
FindByPath(path string) (*MediaFile, error)
|
|
FindPathsRecursively(basePath string) ([]string, error)
|
|
GetStarred(options ...QueryOptions) (MediaFiles, error)
|
|
GetRandom(options ...QueryOptions) (MediaFiles, error)
|
|
Search(q string, offset int, size int) (MediaFiles, error)
|
|
Delete(id string) error
|
|
DeleteByPath(path string) (int64, error)
|
|
|
|
AnnotatedRepository
|
|
BookmarkableRepository
|
|
}
|
|
|
|
func (mf MediaFile) GetAnnotations() Annotations {
|
|
return mf.Annotations
|
|
}
|