Scanning artists and albums too

This commit is contained in:
Deluan
2016-02-28 13:50:05 -05:00
parent bccfeec2d3
commit 14e52576a7
11 changed files with 209 additions and 51 deletions
+34
View File
@@ -0,0 +1,34 @@
package repositories
import (
"github.com/deluan/gosonic/models"
)
type Artist struct {
BaseRepository
}
func NewArtistRepository() *Artist {
r := &Artist{}
r.key = "artist"
return r
}
func (r *Artist) Put(m *models.Artist) (*models.Artist, error) {
if m.Id == "" {
m.Id = r.NewId(m.Name)
}
return m, r.saveOrUpdate(m.Id, m)
}
func (r *Artist) Get(id string) (*models.Artist, error) {
rec := &models.Artist{}
err := readStruct(r.key, id, rec)
return rec, err
}
func (r *Artist) GetByName(name string) (*models.Artist, error) {
id := r.NewId(name)
return r.Get(id)
}