mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-15 11:40:36 +03:00
50 lines
1.1 KiB
Go
50 lines
1.1 KiB
Go
package model
|
|
|
|
import (
|
|
"mime"
|
|
"time"
|
|
)
|
|
|
|
type MediaFile struct {
|
|
ID string
|
|
Path string
|
|
Title string
|
|
Album string
|
|
Artist string
|
|
ArtistID string
|
|
AlbumArtist string
|
|
AlbumID string
|
|
HasCoverArt bool
|
|
TrackNumber int
|
|
DiscNumber int
|
|
Year int
|
|
Size int
|
|
Suffix string
|
|
Duration int
|
|
BitRate int
|
|
Genre string
|
|
Compilation bool
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
}
|
|
|
|
func (mf *MediaFile) ContentType() string {
|
|
return mime.TypeByExtension("." + mf.Suffix)
|
|
}
|
|
|
|
type MediaFiles []MediaFile
|
|
|
|
type MediaFileRepository interface {
|
|
CountAll() (int64, error)
|
|
Exists(id string) (bool, error)
|
|
Put(m *MediaFile) error
|
|
Get(id string) (*MediaFile, error)
|
|
FindByAlbum(albumId string) (MediaFiles, error)
|
|
FindByPath(path string) (MediaFiles, error)
|
|
GetStarred(userId string, 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) error
|
|
}
|