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-01-10 05:33:01 +01:00
|
|
|
ID string
|
2016-02-27 09:35:01 +01:00
|
|
|
Path string
|
|
|
|
Title string
|
|
|
|
Album string
|
|
|
|
Artist string
|
2020-01-10 05:33:01 +01:00
|
|
|
ArtistID string
|
2016-02-27 09:35:01 +01:00
|
|
|
AlbumArtist string
|
2020-01-18 01:36:50 +01:00
|
|
|
AlbumID string
|
2016-03-03 16:34:17 +01:00
|
|
|
HasCoverArt bool
|
2016-03-03 06:42:42 +01:00
|
|
|
TrackNumber int
|
|
|
|
DiscNumber int
|
2016-03-03 05:15:17 +01:00
|
|
|
Year int
|
2020-01-22 16:19:13 +01:00
|
|
|
Size int
|
2016-03-03 05:51:26 +01:00
|
|
|
Suffix string
|
|
|
|
Duration int
|
|
|
|
BitRate int
|
2016-03-03 04:43:31 +01:00
|
|
|
Genre string
|
2016-02-27 09:35:01 +01:00
|
|
|
Compilation bool
|
|
|
|
CreatedAt time.Time
|
|
|
|
UpdatedAt time.Time
|
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-15 14:21:32 +01:00
|
|
|
CountAll() (int64, error)
|
|
|
|
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)
|
2016-03-20 18:14:04 +01:00
|
|
|
FindByAlbum(albumId string) (MediaFiles, error)
|
2020-01-16 21:56:24 +01:00
|
|
|
FindByPath(path string) (MediaFiles, error)
|
2020-01-22 05:01:43 +01:00
|
|
|
GetStarred(userId string, 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-01-16 22:53:48 +01:00
|
|
|
DeleteByPath(path string) error
|
2016-03-02 19:18:39 +01:00
|
|
|
}
|