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-05-22 11:23:42 -08:00
|
|
|
Annotations
|
2020-08-01 08:17:06 -08:00
|
|
|
Bookmarkable
|
2020-05-22 11:23:42 -08:00
|
|
|
|
2020-04-24 06:13:59 -08:00
|
|
|
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"`
|
2020-06-12 13:02:04 -08:00
|
|
|
AlbumArtistID string `json:"albumArtistId" orm:"pk;column(album_artist_id)"`
|
2020-04-24 06:13:59 -08:00
|
|
|
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"`
|
2020-05-12 07:17:22 -08:00
|
|
|
DiscSubtitle string `json:"discSubtitle"`
|
2020-04-24 06:13:59 -08:00
|
|
|
Year int `json:"year"`
|
2020-05-19 19:50:27 -08:00
|
|
|
Size int64 `json:"size"`
|
2020-04-24 06:13:59 -08:00
|
|
|
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"`
|
2020-04-24 09:27:18 -08:00
|
|
|
OrderArtistName string `json:"orderArtistName"`
|
2020-04-24 06:13:59 -08:00
|
|
|
OrderAlbumArtistName string `json:"orderAlbumArtistName"`
|
|
|
|
|
Compilation bool `json:"compilation"`
|
|
|
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
|
|
|
UpdatedAt time.Time `json:"updatedAt"`
|
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-28 04:22:17 -09:00
|
|
|
CountAll(options ...QueryOptions) (int64, error)
|
2020-01-15 04:21:32 -09:00
|
|
|
Exists(id string) (bool, error)
|
2020-01-20 14:19:16 -09:00
|
|
|
Put(m *MediaFile) error
|
2016-03-03 08:08:44 -09:00
|
|
|
Get(id string) (*MediaFile, error)
|
2020-04-17 16:52:50 -08:00
|
|
|
GetAll(options ...QueryOptions) (MediaFiles, error)
|
2016-03-20 09:14:04 -08:00
|
|
|
FindByAlbum(albumId string) (MediaFiles, error)
|
2020-07-11 10:38:17 -08:00
|
|
|
FindAllByPath(path string) (MediaFiles, error)
|
|
|
|
|
FindByPath(path string) (*MediaFile, error)
|
2020-06-12 09:26:46 -08:00
|
|
|
FindPathsRecursively(basePath string) ([]string, error)
|
2020-01-30 18:07:02 -09:00
|
|
|
GetStarred(options ...QueryOptions) (MediaFiles, error)
|
2020-01-21 04:49:43 -09:00
|
|
|
GetRandom(options ...QueryOptions) (MediaFiles, 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-07-12 07:48:57 -08:00
|
|
|
DeleteByPath(path string) (int64, error)
|
2020-01-31 17:09:23 -09:00
|
|
|
|
|
|
|
|
AnnotatedRepository
|
2020-08-01 08:17:06 -08:00
|
|
|
BookmarkableRepository
|
2016-03-02 09:18:39 -09:00
|
|
|
}
|
2020-05-22 11:23:42 -08:00
|
|
|
|
|
|
|
|
func (mf MediaFile) GetAnnotations() Annotations {
|
|
|
|
|
return mf.Annotations
|
|
|
|
|
}
|