2020-01-15 04:22:34 +01:00
|
|
|
package model
|
2016-02-24 21:30:28 +01:00
|
|
|
|
2016-02-27 09:35:01 +01:00
|
|
|
import (
|
2016-03-03 20:14:15 +01:00
|
|
|
"mime"
|
2016-03-04 23:01:14 +01:00
|
|
|
"time"
|
2016-02-27 09:35:01 +01:00
|
|
|
)
|
2016-02-24 21:30:28 +01:00
|
|
|
|
|
|
|
type MediaFile struct {
|
2020-05-22 21:23:42 +02:00
|
|
|
Annotations
|
2020-08-01 18:17:06 +02:00
|
|
|
Bookmarkable
|
2020-05-22 21:23:42 +02:00
|
|
|
|
2020-04-24 16:13:59 +02: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 23:02:04 +02:00
|
|
|
AlbumArtistID string `json:"albumArtistId" orm:"pk;column(album_artist_id)"`
|
2020-04-24 16:13:59 +02: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 17:17:22 +02:00
|
|
|
DiscSubtitle string `json:"discSubtitle"`
|
2020-04-24 16:13:59 +02:00
|
|
|
Year int `json:"year"`
|
2020-05-20 05:50:27 +02:00
|
|
|
Size int64 `json:"size"`
|
2020-04-24 16:13:59 +02: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 19:27:18 +02:00
|
|
|
OrderArtistName string `json:"orderArtistName"`
|
2020-04-24 16:13:59 +02:00
|
|
|
OrderAlbumArtistName string `json:"orderAlbumArtistName"`
|
|
|
|
Compilation bool `json:"compilation"`
|
2020-11-11 16:43:17 +01:00
|
|
|
Comment string `json:"comment"`
|
|
|
|
Lyrics string `json:"lyrics"`
|
2020-08-27 22:51:55 +02:00
|
|
|
CatalogNum string `json:"catalogNum"`
|
|
|
|
MbzTrackID string `json:"mbzTrackId" orm:"column(mbz_track_id)"`
|
|
|
|
MbzAlbumID string `json:"mbzAlbumId" orm:"column(mbz_album_id)"`
|
|
|
|
MbzArtistID string `json:"mbzArtistId" orm:"column(mbz_artist_id)"`
|
|
|
|
MbzAlbumArtistID string `json:"mbzAlbumArtistId" orm:"column(mbz_album_artist_id)"`
|
|
|
|
MbzAlbumType string `json:"mbzAlbumType"`
|
|
|
|
MbzAlbumComment string `json:"mbzAlbumComment"`
|
2020-04-24 16:13:59 +02:00
|
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
|
|
UpdatedAt time.Time `json:"updatedAt"`
|
2016-03-02 15:33:49 +01:00
|
|
|
}
|
|
|
|
|
2016-03-03 20:14:15 +01:00
|
|
|
func (mf *MediaFile) ContentType() string {
|
|
|
|
return mime.TypeByExtension("." + mf.Suffix)
|
|
|
|
}
|
|
|
|
|
2016-03-04 03:01:55 +01:00
|
|
|
type MediaFiles []MediaFile
|
2016-03-04 23:01:14 +01:00
|
|
|
|
2016-03-02 15:33:49 +01:00
|
|
|
type MediaFileRepository interface {
|
2020-01-28 14:22:17 +01:00
|
|
|
CountAll(options ...QueryOptions) (int64, error)
|
2020-01-15 14:21:32 +01:00
|
|
|
Exists(id string) (bool, error)
|
2020-01-21 00:19:16 +01:00
|
|
|
Put(m *MediaFile) error
|
2016-03-03 18:08:44 +01:00
|
|
|
Get(id string) (*MediaFile, error)
|
2020-04-18 02:52:50 +02:00
|
|
|
GetAll(options ...QueryOptions) (MediaFiles, error)
|
2016-03-20 18:14:04 +01:00
|
|
|
FindByAlbum(albumId string) (MediaFiles, error)
|
2020-07-11 20:38:17 +02:00
|
|
|
FindAllByPath(path string) (MediaFiles, error)
|
|
|
|
FindByPath(path string) (*MediaFile, error)
|
2020-06-12 19:26:46 +02:00
|
|
|
FindPathsRecursively(basePath string) ([]string, error)
|
2020-01-31 04:07:02 +01:00
|
|
|
GetStarred(options ...QueryOptions) (MediaFiles, error)
|
2020-01-21 14:49:43 +01:00
|
|
|
GetRandom(options ...QueryOptions) (MediaFiles, error)
|
2020-01-13 16:44:35 +01:00
|
|
|
Search(q string, offset int, size int) (MediaFiles, error)
|
2020-01-16 21:56:24 +01:00
|
|
|
Delete(id string) error
|
2020-07-12 17:48:57 +02:00
|
|
|
DeleteByPath(path string) (int64, error)
|
2020-02-01 03:09:23 +01:00
|
|
|
|
|
|
|
AnnotatedRepository
|
2020-08-01 18:17:06 +02:00
|
|
|
BookmarkableRepository
|
2016-03-02 19:18:39 +01:00
|
|
|
}
|
2020-05-22 21:23:42 +02:00
|
|
|
|
|
|
|
func (mf MediaFile) GetAnnotations() Annotations {
|
|
|
|
return mf.Annotations
|
|
|
|
}
|