2020-01-14 18:22:34 -09:00
|
|
|
package model
|
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-17 15:36:50 -09:00
|
|
|
AlbumID string
|
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
|
2020-01-17 15:36:50 -09:00
|
|
|
StarredAt time.Time
|
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
|
|
|
|
2016-03-02 05:33:49 -09:00
|
|
|
type MediaFileRepository interface {
|
2020-01-15 04:21:32 -09:00
|
|
|
CountAll() (int64, error)
|
|
|
|
|
Exists(id string) (bool, error)
|
2020-01-18 17:45:44 -09:00
|
|
|
Put(m *MediaFile, overrideAnnotation bool) 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-16 11:56:24 -09:00
|
|
|
FindByPath(path string) (MediaFiles, error)
|
2020-01-11 17:33:41 -09:00
|
|
|
GetStarred(options ...QueryOptions) (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)
|
2020-01-16 11:56:24 -09:00
|
|
|
Delete(id string) error
|
2020-01-16 12:53:48 -09:00
|
|
|
DeleteByPath(path string) error
|
2020-01-18 16:03:52 -09:00
|
|
|
SetStar(star bool, ids ...string) error
|
|
|
|
|
SetRating(rating int, ids ...string) error
|
2020-01-18 16:59:20 -09:00
|
|
|
MarkAsPlayed(id string, playTime time.Time) error
|
2016-03-02 09:18:39 -09:00
|
|
|
}
|