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 {
|
2021-07-31 21:21:20 -08:00
|
|
|
Annotations `structs:"-"`
|
|
|
|
|
Bookmarkable `structs:"-"`
|
2020-05-22 11:23:42 -08:00
|
|
|
|
2021-07-31 21:21:20 -08:00
|
|
|
ID string `structs:"id" json:"id" orm:"pk;column(id)"`
|
|
|
|
|
Path string `structs:"path" json:"path"`
|
|
|
|
|
Title string `structs:"title" json:"title"`
|
|
|
|
|
Album string `structs:"album" json:"album"`
|
|
|
|
|
ArtistID string `structs:"artist_id" json:"artistId" orm:"pk;column(artist_id)"`
|
|
|
|
|
Artist string `structs:"artist" json:"artist"`
|
|
|
|
|
AlbumArtistID string `structs:"album_artist_id" json:"albumArtistId" orm:"pk;column(album_artist_id)"`
|
|
|
|
|
AlbumArtist string `structs:"album_artist" json:"albumArtist"`
|
|
|
|
|
AlbumID string `structs:"album_id" json:"albumId" orm:"pk;column(album_id)"`
|
|
|
|
|
HasCoverArt bool `structs:"has_cover_art" json:"hasCoverArt"`
|
|
|
|
|
TrackNumber int `structs:"track_number" json:"trackNumber"`
|
|
|
|
|
DiscNumber int `structs:"disc_number" json:"discNumber"`
|
|
|
|
|
DiscSubtitle string `structs:"disc_subtitle" json:"discSubtitle,omitempty"`
|
|
|
|
|
Year int `structs:"year" json:"year"`
|
|
|
|
|
Size int64 `structs:"size" json:"size"`
|
|
|
|
|
Suffix string `structs:"suffix" json:"suffix"`
|
|
|
|
|
Duration float32 `structs:"duration" json:"duration"`
|
|
|
|
|
BitRate int `structs:"bit_rate" json:"bitRate"`
|
|
|
|
|
Genre string `structs:"genre" json:"genre"`
|
|
|
|
|
Genres Genres `structs:"-" json:"genres"`
|
|
|
|
|
FullText string `structs:"full_text" json:"fullText"`
|
|
|
|
|
SortTitle string `structs:"sort_title" json:"sortTitle,omitempty"`
|
|
|
|
|
SortAlbumName string `structs:"sort_album_name" json:"sortAlbumName,omitempty"`
|
|
|
|
|
SortArtistName string `structs:"sort_artist_name" json:"sortArtistName,omitempty"`
|
|
|
|
|
SortAlbumArtistName string `structs:"sort_album_artist_name" json:"sortAlbumArtistName,omitempty"`
|
|
|
|
|
OrderAlbumName string `structs:"order_album_name" json:"orderAlbumName"`
|
|
|
|
|
OrderArtistName string `structs:"order_artist_name" json:"orderArtistName"`
|
|
|
|
|
OrderAlbumArtistName string `structs:"order_album_artist_name" json:"orderAlbumArtistName"`
|
|
|
|
|
Compilation bool `structs:"compilation" json:"compilation"`
|
|
|
|
|
Comment string `structs:"comment" json:"comment,omitempty"`
|
|
|
|
|
Lyrics string `structs:"lyrics" json:"lyrics,omitempty"`
|
|
|
|
|
Bpm int `structs:"bpm" json:"bpm,omitempty"`
|
|
|
|
|
CatalogNum string `structs:"catalog_num" json:"catalogNum,omitempty"`
|
|
|
|
|
MbzTrackID string `structs:"mbz_track_id" json:"mbzTrackId,omitempty" orm:"column(mbz_track_id)"`
|
|
|
|
|
MbzAlbumID string `structs:"mbz_album_id" json:"mbzAlbumId,omitempty" orm:"column(mbz_album_id)"`
|
|
|
|
|
MbzArtistID string `structs:"mbz_artist_id" json:"mbzArtistId,omitempty" orm:"column(mbz_artist_id)"`
|
|
|
|
|
MbzAlbumArtistID string `structs:"mbz_album_artist_id" json:"mbzAlbumArtistId,omitempty" orm:"column(mbz_album_artist_id)"`
|
|
|
|
|
MbzAlbumType string `structs:"mbz_album_type" json:"mbzAlbumType,omitempty"`
|
|
|
|
|
MbzAlbumComment string `structs:"mbz_album_comment" json:"mbzAlbumComment,omitempty"`
|
|
|
|
|
CreatedAt time.Time `structs:"created_at" json:"createdAt"` // Time this entry was created in the DB
|
|
|
|
|
UpdatedAt time.Time `structs:"updated_at" json:"updatedAt"` // Time of file last update (mtime)
|
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)
|
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-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
|
|
|
}
|