2020-01-14 22:22:34 -05:00
|
|
|
package model
|
2016-02-24 15:30:28 -05:00
|
|
|
|
2016-02-27 03:35:01 -05:00
|
|
|
import (
|
2016-03-03 14:14:15 -05:00
|
|
|
"mime"
|
2016-03-04 17:01:14 -05:00
|
|
|
"time"
|
2016-02-27 03:35:01 -05:00
|
|
|
)
|
2016-02-24 15:30:28 -05:00
|
|
|
|
|
|
|
|
type MediaFile struct {
|
2020-01-09 23:33:01 -05:00
|
|
|
ID string
|
2016-02-27 03:35:01 -05:00
|
|
|
Path string
|
|
|
|
|
Title string
|
|
|
|
|
Album string
|
|
|
|
|
Artist string
|
2020-01-09 23:33:01 -05:00
|
|
|
ArtistID string
|
2016-02-27 03:35:01 -05:00
|
|
|
AlbumArtist string
|
2020-01-17 19:36:50 -05:00
|
|
|
AlbumID string
|
2016-03-03 10:34:17 -05:00
|
|
|
HasCoverArt bool
|
2016-03-03 00:42:42 -05:00
|
|
|
TrackNumber int
|
|
|
|
|
DiscNumber int
|
2016-03-02 23:15:17 -05:00
|
|
|
Year int
|
2016-03-02 23:51:26 -05:00
|
|
|
Size string
|
|
|
|
|
Suffix string
|
|
|
|
|
Duration int
|
|
|
|
|
BitRate int
|
2016-03-02 22:43:31 -05:00
|
|
|
Genre string
|
2016-02-27 03:35:01 -05:00
|
|
|
Compilation bool
|
2016-03-04 17:01:14 -05:00
|
|
|
PlayCount int
|
|
|
|
|
PlayDate time.Time
|
|
|
|
|
Rating int
|
2016-03-03 01:07:13 -05:00
|
|
|
Starred bool
|
2020-01-17 19:36:50 -05:00
|
|
|
StarredAt time.Time
|
2016-02-27 03:35:01 -05:00
|
|
|
CreatedAt time.Time
|
|
|
|
|
UpdatedAt time.Time
|
2016-03-02 09:33:49 -05:00
|
|
|
}
|
|
|
|
|
|
2016-03-03 14:14:15 -05:00
|
|
|
func (mf *MediaFile) ContentType() string {
|
|
|
|
|
return mime.TypeByExtension("." + mf.Suffix)
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-03 21:01:55 -05:00
|
|
|
type MediaFiles []MediaFile
|
2016-03-04 17:01:14 -05:00
|
|
|
|
2016-03-02 09:33:49 -05:00
|
|
|
type MediaFileRepository interface {
|
2020-01-15 08:21:32 -05:00
|
|
|
CountAll() (int64, error)
|
|
|
|
|
Exists(id string) (bool, error)
|
2020-01-18 21:45:44 -05:00
|
|
|
Put(m *MediaFile, overrideAnnotation bool) error
|
2016-03-03 12:08:44 -05:00
|
|
|
Get(id string) (*MediaFile, error)
|
2016-03-20 13:14:04 -04:00
|
|
|
FindByAlbum(albumId string) (MediaFiles, error)
|
2020-01-16 15:56:24 -05:00
|
|
|
FindByPath(path string) (MediaFiles, error)
|
2020-01-11 21:33:41 -05:00
|
|
|
GetStarred(options ...QueryOptions) (MediaFiles, error)
|
2016-03-29 00:01:27 -04:00
|
|
|
GetAllIds() ([]string, error)
|
2020-01-13 10:44:35 -05:00
|
|
|
Search(q string, offset int, size int) (MediaFiles, error)
|
2020-01-16 15:56:24 -05:00
|
|
|
Delete(id string) error
|
2020-01-16 16:53:48 -05:00
|
|
|
DeleteByPath(path string) error
|
2020-01-18 20:03:52 -05:00
|
|
|
SetStar(star bool, ids ...string) error
|
|
|
|
|
SetRating(rating int, ids ...string) error
|
2020-01-18 20:59:20 -05:00
|
|
|
MarkAsPlayed(id string, playTime time.Time) error
|
2016-03-02 13:18:39 -05:00
|
|
|
}
|