Rename domain to model
This commit is contained in:
+19
-19
@@ -6,40 +6,40 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/cloudsonic/sonic-server/domain"
|
||||
"github.com/cloudsonic/sonic-server/log"
|
||||
"github.com/cloudsonic/sonic-server/model"
|
||||
"github.com/cloudsonic/sonic-server/utils"
|
||||
)
|
||||
|
||||
type Browser interface {
|
||||
MediaFolders() (domain.MediaFolders, error)
|
||||
Indexes(ifModifiedSince time.Time) (domain.ArtistIndexes, time.Time, error)
|
||||
MediaFolders() (model.MediaFolders, error)
|
||||
Indexes(ifModifiedSince time.Time) (model.ArtistIndexes, time.Time, error)
|
||||
Directory(ctx context.Context, id string) (*DirectoryInfo, error)
|
||||
Artist(ctx context.Context, id string) (*DirectoryInfo, error)
|
||||
Album(ctx context.Context, id string) (*DirectoryInfo, error)
|
||||
GetSong(id string) (*Entry, error)
|
||||
}
|
||||
|
||||
func NewBrowser(pr domain.PropertyRepository, fr domain.MediaFolderRepository, ir domain.ArtistIndexRepository,
|
||||
ar domain.ArtistRepository, alr domain.AlbumRepository, mr domain.MediaFileRepository) Browser {
|
||||
func NewBrowser(pr model.PropertyRepository, fr model.MediaFolderRepository, ir model.ArtistIndexRepository,
|
||||
ar model.ArtistRepository, alr model.AlbumRepository, mr model.MediaFileRepository) Browser {
|
||||
return &browser{pr, fr, ir, ar, alr, mr}
|
||||
}
|
||||
|
||||
type browser struct {
|
||||
propRepo domain.PropertyRepository
|
||||
folderRepo domain.MediaFolderRepository
|
||||
indexRepo domain.ArtistIndexRepository
|
||||
artistRepo domain.ArtistRepository
|
||||
albumRepo domain.AlbumRepository
|
||||
mfileRepo domain.MediaFileRepository
|
||||
propRepo model.PropertyRepository
|
||||
folderRepo model.MediaFolderRepository
|
||||
indexRepo model.ArtistIndexRepository
|
||||
artistRepo model.ArtistRepository
|
||||
albumRepo model.AlbumRepository
|
||||
mfileRepo model.MediaFileRepository
|
||||
}
|
||||
|
||||
func (b *browser) MediaFolders() (domain.MediaFolders, error) {
|
||||
func (b *browser) MediaFolders() (model.MediaFolders, error) {
|
||||
return b.folderRepo.GetAll()
|
||||
}
|
||||
|
||||
func (b *browser) Indexes(ifModifiedSince time.Time) (domain.ArtistIndexes, time.Time, error) {
|
||||
l, err := b.propRepo.DefaultGet(domain.PropLastScan, "-1")
|
||||
func (b *browser) Indexes(ifModifiedSince time.Time) (model.ArtistIndexes, time.Time, error) {
|
||||
l, err := b.propRepo.DefaultGet(model.PropLastScan, "-1")
|
||||
ms, _ := strconv.ParseInt(l, 10, 64)
|
||||
lastModified := utils.ToTime(ms)
|
||||
|
||||
@@ -100,7 +100,7 @@ func (b *browser) Directory(ctx context.Context, id string) (*DirectoryInfo, err
|
||||
return b.Album(ctx, id)
|
||||
default:
|
||||
log.Debug(ctx, "Directory not found", "id", id)
|
||||
return nil, domain.ErrNotFound
|
||||
return nil, model.ErrNotFound
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ func (b *browser) GetSong(id string) (*Entry, error) {
|
||||
return &entry, nil
|
||||
}
|
||||
|
||||
func (b *browser) buildArtistDir(a *domain.Artist, albums domain.Albums) *DirectoryInfo {
|
||||
func (b *browser) buildArtistDir(a *model.Artist, albums model.Albums) *DirectoryInfo {
|
||||
dir := &DirectoryInfo{
|
||||
Id: a.ID,
|
||||
Name: a.Name,
|
||||
@@ -129,7 +129,7 @@ func (b *browser) buildArtistDir(a *domain.Artist, albums domain.Albums) *Direct
|
||||
return dir
|
||||
}
|
||||
|
||||
func (b *browser) buildAlbumDir(al *domain.Album, tracks domain.MediaFiles) *DirectoryInfo {
|
||||
func (b *browser) buildAlbumDir(al *model.Album, tracks model.MediaFiles) *DirectoryInfo {
|
||||
dir := &DirectoryInfo{
|
||||
Id: al.ID,
|
||||
Name: al.Name,
|
||||
@@ -172,7 +172,7 @@ func (b *browser) isAlbum(ctx context.Context, id string) bool {
|
||||
return found
|
||||
}
|
||||
|
||||
func (b *browser) retrieveArtist(id string) (a *domain.Artist, as domain.Albums, err error) {
|
||||
func (b *browser) retrieveArtist(id string) (a *model.Artist, as model.Albums, err error) {
|
||||
a, err = b.artistRepo.Get(id)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("Error reading Artist %s from DB: %v", id, err)
|
||||
@@ -185,7 +185,7 @@ func (b *browser) retrieveArtist(id string) (a *domain.Artist, as domain.Albums,
|
||||
return
|
||||
}
|
||||
|
||||
func (b *browser) retrieveAlbum(id string) (al *domain.Album, mfs domain.MediaFiles, err error) {
|
||||
func (b *browser) retrieveAlbum(id string) (al *model.Album, mfs model.MediaFiles, err error) {
|
||||
al, err = b.albumRepo.Get(id)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("Error reading Album %s from DB: %v", id, err)
|
||||
|
||||
+7
-7
@@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/cloudsonic/sonic-server/domain"
|
||||
"github.com/cloudsonic/sonic-server/model"
|
||||
)
|
||||
|
||||
type Entry struct {
|
||||
@@ -45,7 +45,7 @@ type Entry struct {
|
||||
|
||||
type Entries []Entry
|
||||
|
||||
func FromArtist(ar *domain.Artist) Entry {
|
||||
func FromArtist(ar *model.Artist) Entry {
|
||||
e := Entry{}
|
||||
e.Id = ar.ID
|
||||
e.Title = ar.Name
|
||||
@@ -54,7 +54,7 @@ func FromArtist(ar *domain.Artist) Entry {
|
||||
return e
|
||||
}
|
||||
|
||||
func FromAlbum(al *domain.Album) Entry {
|
||||
func FromAlbum(al *model.Album) Entry {
|
||||
e := Entry{}
|
||||
e.Id = al.ID
|
||||
e.Title = al.Name
|
||||
@@ -76,7 +76,7 @@ func FromAlbum(al *domain.Album) Entry {
|
||||
return e
|
||||
}
|
||||
|
||||
func FromMediaFile(mf *domain.MediaFile) Entry {
|
||||
func FromMediaFile(mf *model.MediaFile) Entry {
|
||||
e := Entry{}
|
||||
e.Id = mf.ID
|
||||
e.Title = mf.Title
|
||||
@@ -111,7 +111,7 @@ func FromMediaFile(mf *domain.MediaFile) Entry {
|
||||
return e
|
||||
}
|
||||
|
||||
func realArtistName(mf *domain.MediaFile) string {
|
||||
func realArtistName(mf *model.MediaFile) string {
|
||||
switch {
|
||||
case mf.Compilation:
|
||||
return "Various Artists"
|
||||
@@ -122,7 +122,7 @@ func realArtistName(mf *domain.MediaFile) string {
|
||||
return mf.Artist
|
||||
}
|
||||
|
||||
func FromAlbums(albums domain.Albums) Entries {
|
||||
func FromAlbums(albums model.Albums) Entries {
|
||||
entries := make(Entries, len(albums))
|
||||
for i, al := range albums {
|
||||
entries[i] = FromAlbum(&al)
|
||||
@@ -130,7 +130,7 @@ func FromAlbums(albums domain.Albums) Entries {
|
||||
return entries
|
||||
}
|
||||
|
||||
func FromMediaFiles(mfs domain.MediaFiles) Entries {
|
||||
func FromMediaFiles(mfs model.MediaFiles) Entries {
|
||||
entries := make(Entries, len(mfs))
|
||||
for i, mf := range mfs {
|
||||
entries[i] = FromMediaFile(&mf)
|
||||
|
||||
+8
-8
@@ -10,7 +10,7 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/cloudsonic/sonic-server/domain"
|
||||
"github.com/cloudsonic/sonic-server/model"
|
||||
"github.com/dhowden/tag"
|
||||
"github.com/nfnt/resize"
|
||||
)
|
||||
@@ -20,11 +20,11 @@ type Cover interface {
|
||||
}
|
||||
|
||||
type cover struct {
|
||||
mfileRepo domain.MediaFileRepository
|
||||
albumRepo domain.AlbumRepository
|
||||
mfileRepo model.MediaFileRepository
|
||||
albumRepo model.AlbumRepository
|
||||
}
|
||||
|
||||
func NewCover(mr domain.MediaFileRepository, alr domain.AlbumRepository) Cover {
|
||||
func NewCover(mr model.MediaFileRepository, alr model.AlbumRepository) Cover {
|
||||
return &cover{mr, alr}
|
||||
}
|
||||
|
||||
@@ -46,18 +46,18 @@ func (c *cover) getCoverPath(id string) (string, error) {
|
||||
return mf.Path, nil
|
||||
}
|
||||
}
|
||||
return "", domain.ErrNotFound
|
||||
return "", model.ErrNotFound
|
||||
}
|
||||
|
||||
func (c *cover) Get(id string, size int, out io.Writer) error {
|
||||
path, err := c.getCoverPath(id)
|
||||
if err != nil && err != domain.ErrNotFound {
|
||||
if err != nil && err != model.ErrNotFound {
|
||||
return err
|
||||
}
|
||||
|
||||
var reader io.Reader
|
||||
|
||||
if err != domain.ErrNotFound {
|
||||
if err != model.ErrNotFound {
|
||||
reader, err = readFromTag(path)
|
||||
} else {
|
||||
var f *os.File
|
||||
@@ -69,7 +69,7 @@ func (c *cover) Get(id string, size int, out io.Writer) error {
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return domain.ErrNotFound
|
||||
return model.ErrNotFound
|
||||
}
|
||||
|
||||
if size > 0 {
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"image"
|
||||
"testing"
|
||||
|
||||
"github.com/cloudsonic/sonic-server/domain"
|
||||
"github.com/cloudsonic/sonic-server/engine"
|
||||
"github.com/cloudsonic/sonic-server/model"
|
||||
"github.com/cloudsonic/sonic-server/persistence"
|
||||
. "github.com/cloudsonic/sonic-server/tests"
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
@@ -54,7 +54,7 @@ func TestCover(t *testing.T) {
|
||||
err := cover.Get("2", 0, out)
|
||||
|
||||
Convey("Then it should return DatNotFound error", func() {
|
||||
So(err, ShouldEqual, domain.ErrNotFound)
|
||||
So(err, ShouldEqual, model.ErrNotFound)
|
||||
})
|
||||
})
|
||||
Convey("When specifying a size", func() {
|
||||
|
||||
+14
-14
@@ -4,7 +4,7 @@ import (
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
"github.com/cloudsonic/sonic-server/domain"
|
||||
"github.com/cloudsonic/sonic-server/model"
|
||||
"github.com/cloudsonic/sonic-server/utils"
|
||||
)
|
||||
|
||||
@@ -22,17 +22,17 @@ type ListGenerator interface {
|
||||
GetRandomSongs(size int) (Entries, error)
|
||||
}
|
||||
|
||||
func NewListGenerator(alr domain.AlbumRepository, mfr domain.MediaFileRepository, npr domain.NowPlayingRepository) ListGenerator {
|
||||
func NewListGenerator(alr model.AlbumRepository, mfr model.MediaFileRepository, npr model.NowPlayingRepository) ListGenerator {
|
||||
return &listGenerator{alr, mfr, npr}
|
||||
}
|
||||
|
||||
type listGenerator struct {
|
||||
albumRepo domain.AlbumRepository
|
||||
mfRepository domain.MediaFileRepository
|
||||
npRepo domain.NowPlayingRepository
|
||||
albumRepo model.AlbumRepository
|
||||
mfRepository model.MediaFileRepository
|
||||
npRepo model.NowPlayingRepository
|
||||
}
|
||||
|
||||
func (g *listGenerator) query(qo domain.QueryOptions, offset int, size int) (Entries, error) {
|
||||
func (g *listGenerator) query(qo model.QueryOptions, offset int, size int) (Entries, error) {
|
||||
qo.Offset = offset
|
||||
qo.Size = size
|
||||
albums, err := g.albumRepo.GetAll(qo)
|
||||
@@ -41,32 +41,32 @@ func (g *listGenerator) query(qo domain.QueryOptions, offset int, size int) (Ent
|
||||
}
|
||||
|
||||
func (g *listGenerator) GetNewest(offset int, size int) (Entries, error) {
|
||||
qo := domain.QueryOptions{SortBy: "CreatedAt", Desc: true, Alpha: true}
|
||||
qo := model.QueryOptions{SortBy: "CreatedAt", Desc: true, Alpha: true}
|
||||
return g.query(qo, offset, size)
|
||||
}
|
||||
|
||||
func (g *listGenerator) GetRecent(offset int, size int) (Entries, error) {
|
||||
qo := domain.QueryOptions{SortBy: "PlayDate", Desc: true, Alpha: true}
|
||||
qo := model.QueryOptions{SortBy: "PlayDate", Desc: true, Alpha: true}
|
||||
return g.query(qo, offset, size)
|
||||
}
|
||||
|
||||
func (g *listGenerator) GetFrequent(offset int, size int) (Entries, error) {
|
||||
qo := domain.QueryOptions{SortBy: "PlayCount", Desc: true}
|
||||
qo := model.QueryOptions{SortBy: "PlayCount", Desc: true}
|
||||
return g.query(qo, offset, size)
|
||||
}
|
||||
|
||||
func (g *listGenerator) GetHighest(offset int, size int) (Entries, error) {
|
||||
qo := domain.QueryOptions{SortBy: "Rating", Desc: true}
|
||||
qo := model.QueryOptions{SortBy: "Rating", Desc: true}
|
||||
return g.query(qo, offset, size)
|
||||
}
|
||||
|
||||
func (g *listGenerator) GetByName(offset int, size int) (Entries, error) {
|
||||
qo := domain.QueryOptions{SortBy: "Name", Alpha: true}
|
||||
qo := model.QueryOptions{SortBy: "Name", Alpha: true}
|
||||
return g.query(qo, offset, size)
|
||||
}
|
||||
|
||||
func (g *listGenerator) GetByArtist(offset int, size int) (Entries, error) {
|
||||
qo := domain.QueryOptions{SortBy: "Artist", Alpha: true}
|
||||
qo := model.QueryOptions{SortBy: "Artist", Alpha: true}
|
||||
return g.query(qo, offset, size)
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ func (g *listGenerator) GetRandomSongs(size int) (Entries, error) {
|
||||
}
|
||||
|
||||
func (g *listGenerator) GetStarred(offset int, size int) (Entries, error) {
|
||||
qo := domain.QueryOptions{Offset: offset, Size: size, Desc: true}
|
||||
qo := model.QueryOptions{Offset: offset, Size: size, Desc: true}
|
||||
albums, err := g.albumRepo.GetStarred(qo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -126,7 +126,7 @@ func (g *listGenerator) GetAllStarred() (Entries, Entries, error) {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
mediaFiles, err := g.mfRepository.GetStarred(domain.QueryOptions{Desc: true})
|
||||
mediaFiles, err := g.mfRepository.GetStarred(model.QueryOptions{Desc: true})
|
||||
|
||||
return albums, FromMediaFiles(mediaFiles), err
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"github.com/cloudsonic/sonic-server/domain"
|
||||
"github.com/cloudsonic/sonic-server/model"
|
||||
)
|
||||
|
||||
func CreateMockNowPlayingRepo() *MockNowPlaying {
|
||||
@@ -12,8 +12,8 @@ func CreateMockNowPlayingRepo() *MockNowPlaying {
|
||||
}
|
||||
|
||||
type MockNowPlaying struct {
|
||||
domain.NowPlayingRepository
|
||||
data []domain.NowPlayingInfo
|
||||
model.NowPlayingRepository
|
||||
data []model.NowPlayingInfo
|
||||
t time.Time
|
||||
err bool
|
||||
}
|
||||
@@ -22,12 +22,12 @@ func (m *MockNowPlaying) SetError(err bool) {
|
||||
m.err = err
|
||||
}
|
||||
|
||||
func (m *MockNowPlaying) Enqueue(info *domain.NowPlayingInfo) error {
|
||||
func (m *MockNowPlaying) Enqueue(info *model.NowPlayingInfo) error {
|
||||
if m.err {
|
||||
return errors.New("Error!")
|
||||
}
|
||||
|
||||
m.data = append(m.data, domain.NowPlayingInfo{})
|
||||
m.data = append(m.data, model.NowPlayingInfo{})
|
||||
copy(m.data[1:], m.data[0:])
|
||||
m.data[0] = *info
|
||||
|
||||
@@ -39,7 +39,7 @@ func (m *MockNowPlaying) Enqueue(info *domain.NowPlayingInfo) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MockNowPlaying) Dequeue(playerId int) (*domain.NowPlayingInfo, error) {
|
||||
func (m *MockNowPlaying) Dequeue(playerId int) (*model.NowPlayingInfo, error) {
|
||||
if len(m.data) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -54,15 +54,15 @@ func (m *MockNowPlaying) Count(playerId int) (int64, error) {
|
||||
return int64(len(m.data)), nil
|
||||
}
|
||||
|
||||
func (m *MockNowPlaying) GetAll() ([]*domain.NowPlayingInfo, error) {
|
||||
func (m *MockNowPlaying) GetAll() ([]*model.NowPlayingInfo, error) {
|
||||
np, err := m.Head(1)
|
||||
if np == nil || err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return []*domain.NowPlayingInfo{np}, err
|
||||
return []*model.NowPlayingInfo{np}, err
|
||||
}
|
||||
|
||||
func (m *MockNowPlaying) Head(playerId int) (*domain.NowPlayingInfo, error) {
|
||||
func (m *MockNowPlaying) Head(playerId int) (*model.NowPlayingInfo, error) {
|
||||
if len(m.data) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -70,7 +70,7 @@ func (m *MockNowPlaying) Head(playerId int) (*domain.NowPlayingInfo, error) {
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
func (m *MockNowPlaying) Tail(playerId int) (*domain.NowPlayingInfo, error) {
|
||||
func (m *MockNowPlaying) Tail(playerId int) (*model.NowPlayingInfo, error) {
|
||||
if len(m.data) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -79,7 +79,7 @@ func (m *MockNowPlaying) Tail(playerId int) (*domain.NowPlayingInfo, error) {
|
||||
}
|
||||
|
||||
func (m *MockNowPlaying) ClearAll() {
|
||||
m.data = make([]domain.NowPlayingInfo, 0)
|
||||
m.data = make([]model.NowPlayingInfo, 0)
|
||||
m.err = false
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package engine
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/cloudsonic/sonic-server/domain"
|
||||
"github.com/cloudsonic/sonic-server/model"
|
||||
)
|
||||
|
||||
func CreateMockPropertyRepo() *MockProperty {
|
||||
@@ -11,7 +11,7 @@ func CreateMockPropertyRepo() *MockProperty {
|
||||
}
|
||||
|
||||
type MockProperty struct {
|
||||
domain.PropertyRepository
|
||||
model.PropertyRepository
|
||||
data map[string]string
|
||||
err bool
|
||||
}
|
||||
|
||||
+7
-7
@@ -4,31 +4,31 @@ import (
|
||||
"context"
|
||||
"sort"
|
||||
|
||||
"github.com/cloudsonic/sonic-server/domain"
|
||||
"github.com/cloudsonic/sonic-server/itunesbridge"
|
||||
"github.com/cloudsonic/sonic-server/log"
|
||||
"github.com/cloudsonic/sonic-server/model"
|
||||
)
|
||||
|
||||
type Playlists interface {
|
||||
GetAll() (domain.Playlists, error)
|
||||
GetAll() (model.Playlists, error)
|
||||
Get(id string) (*PlaylistInfo, error)
|
||||
Create(ctx context.Context, name string, ids []string) error
|
||||
Delete(ctx context.Context, playlistId string) error
|
||||
Update(playlistId string, name *string, idsToAdd []string, idxToRemove []int) error
|
||||
}
|
||||
|
||||
func NewPlaylists(itunes itunesbridge.ItunesControl, pr domain.PlaylistRepository, mr domain.MediaFileRepository) Playlists {
|
||||
func NewPlaylists(itunes itunesbridge.ItunesControl, pr model.PlaylistRepository, mr model.MediaFileRepository) Playlists {
|
||||
return &playlists{itunes, pr, mr}
|
||||
}
|
||||
|
||||
type playlists struct {
|
||||
itunes itunesbridge.ItunesControl
|
||||
plsRepo domain.PlaylistRepository
|
||||
mfileRepo domain.MediaFileRepository
|
||||
plsRepo model.PlaylistRepository
|
||||
mfileRepo model.MediaFileRepository
|
||||
}
|
||||
|
||||
func (p *playlists) GetAll() (domain.Playlists, error) {
|
||||
return p.plsRepo.GetAll(domain.QueryOptions{})
|
||||
func (p *playlists) GetAll() (model.Playlists, error) {
|
||||
return p.plsRepo.GetAll(model.QueryOptions{})
|
||||
}
|
||||
|
||||
type PlaylistInfo struct {
|
||||
|
||||
+7
-7
@@ -3,9 +3,9 @@ package engine
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/cloudsonic/sonic-server/domain"
|
||||
"github.com/cloudsonic/sonic-server/itunesbridge"
|
||||
"github.com/cloudsonic/sonic-server/log"
|
||||
"github.com/cloudsonic/sonic-server/model"
|
||||
"github.com/cloudsonic/sonic-server/utils"
|
||||
)
|
||||
|
||||
@@ -14,15 +14,15 @@ type Ratings interface {
|
||||
SetRating(ctx context.Context, id string, rating int) error
|
||||
}
|
||||
|
||||
func NewRatings(itunes itunesbridge.ItunesControl, mr domain.MediaFileRepository, alr domain.AlbumRepository, ar domain.ArtistRepository) Ratings {
|
||||
func NewRatings(itunes itunesbridge.ItunesControl, mr model.MediaFileRepository, alr model.AlbumRepository, ar model.ArtistRepository) Ratings {
|
||||
return &ratings{itunes, mr, alr, ar}
|
||||
}
|
||||
|
||||
type ratings struct {
|
||||
itunes itunesbridge.ItunesControl
|
||||
mfRepo domain.MediaFileRepository
|
||||
albumRepo domain.AlbumRepository
|
||||
artistRepo domain.ArtistRepository
|
||||
mfRepo model.MediaFileRepository
|
||||
albumRepo model.AlbumRepository
|
||||
artistRepo model.ArtistRepository
|
||||
}
|
||||
|
||||
func (r ratings) SetRating(ctx context.Context, id string, rating int) error {
|
||||
@@ -51,7 +51,7 @@ func (r ratings) SetRating(ctx context.Context, id string, rating int) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return domain.ErrNotFound
|
||||
return model.ErrNotFound
|
||||
}
|
||||
|
||||
func (r ratings) SetStar(ctx context.Context, star bool, ids ...string) error {
|
||||
@@ -79,7 +79,7 @@ func (r ratings) SetStar(ctx context.Context, star bool, ids ...string) error {
|
||||
}
|
||||
continue
|
||||
}
|
||||
return domain.ErrNotFound
|
||||
return model.ErrNotFound
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
+9
-9
@@ -6,9 +6,9 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/cloudsonic/sonic-server/domain"
|
||||
"github.com/cloudsonic/sonic-server/itunesbridge"
|
||||
"github.com/cloudsonic/sonic-server/log"
|
||||
"github.com/cloudsonic/sonic-server/model"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -17,18 +17,18 @@ const (
|
||||
)
|
||||
|
||||
type Scrobbler interface {
|
||||
Register(ctx context.Context, playerId int, trackId string, playDate time.Time) (*domain.MediaFile, error)
|
||||
NowPlaying(ctx context.Context, playerId int, playerName, trackId, username string) (*domain.MediaFile, error)
|
||||
Register(ctx context.Context, playerId int, trackId string, playDate time.Time) (*model.MediaFile, error)
|
||||
NowPlaying(ctx context.Context, playerId int, playerName, trackId, username string) (*model.MediaFile, error)
|
||||
}
|
||||
|
||||
func NewScrobbler(itunes itunesbridge.ItunesControl, mr domain.MediaFileRepository, npr domain.NowPlayingRepository) Scrobbler {
|
||||
func NewScrobbler(itunes itunesbridge.ItunesControl, mr model.MediaFileRepository, npr model.NowPlayingRepository) Scrobbler {
|
||||
return &scrobbler{itunes, mr, npr}
|
||||
}
|
||||
|
||||
type scrobbler struct {
|
||||
itunes itunesbridge.ItunesControl
|
||||
mfRepo domain.MediaFileRepository
|
||||
npRepo domain.NowPlayingRepository
|
||||
mfRepo model.MediaFileRepository
|
||||
npRepo model.NowPlayingRepository
|
||||
}
|
||||
|
||||
func (s *scrobbler) detectSkipped(ctx context.Context, playerId int, trackId string) {
|
||||
@@ -68,7 +68,7 @@ func (s *scrobbler) detectSkipped(ctx context.Context, playerId int, trackId str
|
||||
}
|
||||
}
|
||||
|
||||
func (s *scrobbler) Register(ctx context.Context, playerId int, trackId string, playTime time.Time) (*domain.MediaFile, error) {
|
||||
func (s *scrobbler) Register(ctx context.Context, playerId int, trackId string, playTime time.Time) (*model.MediaFile, error) {
|
||||
s.detectSkipped(ctx, playerId, trackId)
|
||||
|
||||
mf, err := s.mfRepo.Get(trackId)
|
||||
@@ -86,7 +86,7 @@ func (s *scrobbler) Register(ctx context.Context, playerId int, trackId string,
|
||||
return mf, nil
|
||||
}
|
||||
|
||||
func (s *scrobbler) NowPlaying(ctx context.Context, playerId int, playerName, trackId, username string) (*domain.MediaFile, error) {
|
||||
func (s *scrobbler) NowPlaying(ctx context.Context, playerId int, playerName, trackId, username string) (*model.MediaFile, error) {
|
||||
mf, err := s.mfRepo.Get(trackId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -96,6 +96,6 @@ func (s *scrobbler) NowPlaying(ctx context.Context, playerId int, playerName, tr
|
||||
return nil, errors.New(fmt.Sprintf(`ID "%s" not found`, trackId))
|
||||
}
|
||||
|
||||
info := &domain.NowPlayingInfo{TrackID: trackId, Username: username, Start: time.Now(), PlayerId: playerId, PlayerName: playerName}
|
||||
info := &model.NowPlayingInfo{TrackID: trackId, Username: username, Start: time.Now(), PlayerId: playerId, PlayerName: playerName}
|
||||
return mf, s.npRepo.Enqueue(info)
|
||||
}
|
||||
|
||||
+5
-5
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"github.com/cloudsonic/sonic-server/domain"
|
||||
"github.com/cloudsonic/sonic-server/model"
|
||||
"github.com/kennygrant/sanitize"
|
||||
)
|
||||
|
||||
@@ -15,12 +15,12 @@ type Search interface {
|
||||
}
|
||||
|
||||
type search struct {
|
||||
artistRepo domain.ArtistRepository
|
||||
albumRepo domain.AlbumRepository
|
||||
mfileRepo domain.MediaFileRepository
|
||||
artistRepo model.ArtistRepository
|
||||
albumRepo model.AlbumRepository
|
||||
mfileRepo model.MediaFileRepository
|
||||
}
|
||||
|
||||
func NewSearch(ar domain.ArtistRepository, alr domain.AlbumRepository, mr domain.MediaFileRepository) Search {
|
||||
func NewSearch(ar model.ArtistRepository, alr model.AlbumRepository, mr model.MediaFileRepository) Search {
|
||||
s := &search{artistRepo: ar, albumRepo: alr, mfileRepo: mr}
|
||||
return s
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user