construct subsonic models elsewhere

This commit is contained in:
sentriz
2019-05-28 14:22:44 +01:00
parent 6eb1041ad8
commit 74c55bd509
13 changed files with 243 additions and 192 deletions

No files matched your search

+54
View File
@@ -0,0 +1,54 @@
package handler
import (
"github.com/sentriz/gonic/model"
"github.com/sentriz/gonic/server/subsonic"
)
func makeChildFromFolder(f *model.Folder, parent *model.Folder) *subsonic.Child {
return &subsonic.Child{
ID: f.ID,
Title: f.Name,
CoverID: f.CoverID,
ParentID: parent.ID,
IsDir: true,
}
}
func makeChildFromTrack(t *model.Track, parent *model.Folder) *subsonic.Child {
return &subsonic.Child{
ID: t.ID,
Album: t.Album.Title,
Artist: t.TrackArtist,
ContentType: t.ContentType,
Path: t.Path,
Size: t.Size,
Suffix: t.Suffix,
Title: t.Title,
Track: t.TrackNumber,
ParentID: parent.ID,
CoverID: parent.CoverID,
Duration: 0,
IsDir: false,
Type: "music",
}
}
func makeAlbumFromFolder(f *model.Folder) *subsonic.Album {
return &subsonic.Album{
ID: f.ID,
Title: f.Name,
Album: f.Name,
CoverID: f.CoverID,
ParentID: f.ParentID,
Artist: f.Parent.Name,
IsDir: true,
}
}
func makeArtistFromFolder(f *model.Folder) *subsonic.Artist {
return &subsonic.Artist{
ID: f.ID,
Name: f.Name,
}
}