2016-03-02 05:07:24 -09:00
|
|
|
package domain
|
2016-02-24 11:30:28 -09:00
|
|
|
|
2016-02-26 23:35:01 -09:00
|
|
|
import (
|
2016-03-03 10:14:15 -09:00
|
|
|
"mime"
|
2016-03-04 13:01:14 -09:00
|
|
|
"time"
|
2016-02-26 23:35:01 -09:00
|
|
|
)
|
2016-02-24 11:30:28 -09:00
|
|
|
|
|
|
|
|
type MediaFile struct {
|
2020-01-09 19:33:01 -09:00
|
|
|
ID string
|
2016-02-26 23:35:01 -09:00
|
|
|
Path string
|
|
|
|
|
Title string
|
|
|
|
|
Album string
|
|
|
|
|
Artist string
|
2020-01-09 19:33:01 -09:00
|
|
|
ArtistID string
|
2016-02-26 23:35:01 -09:00
|
|
|
AlbumArtist string
|
2020-01-09 19:33:01 -09:00
|
|
|
AlbumID string `parent:"album"`
|
2016-03-03 06:34:17 -09:00
|
|
|
HasCoverArt bool
|
2016-03-02 20:42:42 -09:00
|
|
|
TrackNumber int
|
|
|
|
|
DiscNumber int
|
2016-03-02 19:15:17 -09:00
|
|
|
Year int
|
2016-03-02 19:51:26 -09:00
|
|
|
Size string
|
|
|
|
|
Suffix string
|
|
|
|
|
Duration int
|
|
|
|
|
BitRate int
|
2016-03-02 18:43:31 -09:00
|
|
|
Genre string
|
2016-02-26 23:35:01 -09:00
|
|
|
Compilation bool
|
2016-03-04 13:01:14 -09:00
|
|
|
PlayCount int
|
|
|
|
|
PlayDate time.Time
|
|
|
|
|
Rating int
|
2016-03-02 21:07:13 -09:00
|
|
|
Starred bool
|
2016-03-23 15:02:58 -08:00
|
|
|
StarredAt time.Time `idx:"Starred"`
|
2016-02-26 23:35:01 -09:00
|
|
|
CreatedAt time.Time
|
|
|
|
|
UpdatedAt time.Time
|
2016-03-02 05:33:49 -09:00
|
|
|
}
|
|
|
|
|
|
2016-03-03 10:14:15 -09:00
|
|
|
func (mf *MediaFile) ContentType() string {
|
|
|
|
|
return mime.TypeByExtension("." + mf.Suffix)
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-03 17:01:55 -09:00
|
|
|
type MediaFiles []MediaFile
|
2016-03-04 13:01:14 -09:00
|
|
|
|
|
|
|
|
func (a MediaFiles) Len() int { return len(a) }
|
2016-03-03 17:42:12 -09:00
|
|
|
func (a MediaFiles) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
|
|
|
|
func (a MediaFiles) Less(i, j int) bool {
|
2016-03-04 13:01:14 -09:00
|
|
|
return (a[i].DiscNumber*1000 + a[i].TrackNumber) < (a[j].DiscNumber*1000 + a[j].TrackNumber)
|
2016-03-03 17:42:12 -09:00
|
|
|
}
|
2016-03-03 17:01:55 -09:00
|
|
|
|
2016-03-02 05:33:49 -09:00
|
|
|
type MediaFileRepository interface {
|
|
|
|
|
BaseRepository
|
|
|
|
|
Put(m *MediaFile) error
|
2016-03-03 08:08:44 -09:00
|
|
|
Get(id string) (*MediaFile, error)
|
2016-03-20 09:14:04 -08:00
|
|
|
FindByAlbum(albumId string) (MediaFiles, error)
|
2020-01-11 17:33:41 -09:00
|
|
|
GetStarred(options ...QueryOptions) (MediaFiles, error)
|
2020-01-14 14:23:29 -09:00
|
|
|
PurgeInactive(active MediaFiles) error
|
2016-03-28 20:01:27 -08:00
|
|
|
GetAllIds() ([]string, error)
|
2020-01-13 06:44:35 -09:00
|
|
|
Search(q string, offset int, size int) (MediaFiles, error)
|
2016-03-02 09:18:39 -09:00
|
|
|
}
|