🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
Fixed AlbumId generation. Some code cleanup
Deluan375fd300452d
diff --git a/.gopmfile b/.gopmfileindex 229c4850c..86cb5b50a 100644--- a/.gopmfile+++ b/.gopmfile@@ -6,6 +6,7 @@ github.com/astaxie/beego = commit:92d0b9agithub.com/dhowden/itl = commit:35d15a3github.com/siddontang/ledisdb = commit:713b229github.com/smartystreets/goconvey = commit:899ed5a+github.com/karlkfi/inject = commit:fe06da2[res]-include = conf\ No newline at end of file+include = confdiff --git a/api/get_license_test.go b/api/get_license_test.goindex 8fc4078ec..22bd9ecf6 100644--- a/api/get_license_test.go+++ b/api/get_license_test.go@@ -12,7 +12,7 @@ func TestGetLicense(t *testing.T) {_, w := Get(AddParams("/rest/getLicense.view"), "TestGetLicense")- Convey("Subject: GetLicense Endpoint\n", t, func() {+ Convey("Subject: GetLicense Endpoint", t, func() {Convey("Status code should be 200", func() {So(w.Code, ShouldEqual, 200)})diff --git a/api/get_music_folders_test.go b/api/get_music_folders_test.goindex a7ae9a039..cfd727b64 100644--- a/api/get_music_folders_test.go+++ b/api/get_music_folders_test.go@@ -13,7 +13,7 @@ func TestGetMusicFolders(t *testing.T) {_, w := Get(AddParams("/rest/getMusicFolders.view"), "TestGetMusicFolders")- Convey("Subject: GetMusicFolders Endpoint\n", t, func() {+ Convey("Subject: GetMusicFolders Endpoint", t, func() {Convey("Status code should be 200", func() {So(w.Code, ShouldEqual, 200)})diff --git a/api/ping_test.go b/api/ping_test.goindex f44c012bd..4f78345de 100644--- a/api/ping_test.go+++ b/api/ping_test.go@@ -13,7 +13,7 @@ func TestPing(t *testing.T) {_, w := Get(AddParams("/rest/ping.view"), "TestPing")- Convey("Subject: Ping Endpoint\n", t, func() {+ Convey("Subject: Ping Endpoint", t, func() {Convey("Status code should be 200", func() {So(w.Code, ShouldEqual, 200)})diff --git a/main.go b/main.goindex 7fdbb9cc9..ba007e2da 100644--- a/main.go+++ b/main.go@@ -2,38 +2,10 @@ package mainimport (_ "github.com/deluan/gosonic/routers"-"github.com/astaxie/beego")func main() {- //// open a new index- //itunes.LoadFolder("iTunes Music Library.xml")- //- //mapping := bleve.NewIndexMapping()- //index, err := bleve.New("example.bleve", mapping)- //if (err != nil) {- // index, err = bleve.Open("example.bleve")- //}- //- //// index some data- //doc := struct {- // Id string- // Value string- //}{- // Id: "01",- // Value: "deluan cotts quintao",- //}- //err = index.Index("01", doc)- //fmt.Println(err)- //- //// search for some text- //query := bleve.NewMatchQuery("*cotts*")- //search := bleve.NewSearchRequest(query)- //searchResults, err := index.Search(search)- //fmt.Println(err)- //fmt.Println(searchResults.Hits)-if beego.BConfig.RunMode == "dev" {beego.BConfig.WebConfig.DirectoryIndex = truebeego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"diff --git a/repositories/album_repository.go b/repositories/album_repository.goindex 1303b4d5a..81ef54324 100644--- a/repositories/album_repository.go+++ b/repositories/album_repository.go@@ -16,7 +16,7 @@ func NewAlbumRepository() *Album {func (r *Album) Put(m *models.Album) error {if m.Id == "" {- m.Id = r.NewId(m.Name)+ m.Id = r.NewId(m.ArtistId, m.Name)}return r.saveOrUpdate(m.Id, m)}@@ -25,10 +25,4 @@ func (r *Album) Get(id string) (*models.Album, error) {var rec interface{}rec, err := r.readEntity(id)return rec.(*models.Album), err-}--func (r *Album) GetByName(name string) (*models.Album, error) {- id := r.NewId(name)- return r.Get(id)-}-+}\ No newline at end of filediff --git a/repositories/index_repository.go b/repositories/index_repository.goindex a9cd83110..26e3fff01 100644--- a/repositories/index_repository.go+++ b/repositories/index_repository.go@@ -5,30 +5,36 @@ import ("errors")-type ArtistIndex struct {+type ArtistIndex interface {+ Put(m *models.ArtistIndex) error+ Get(id string) (*models.ArtistIndex, error)+ GetAll() ([]models.ArtistIndex, error)+}++type artistIndex struct {BaseRepository}-func NewArtistIndexRepository() *ArtistIndex {- r := &ArtistIndex{}+func NewArtistIndexRepository() ArtistIndex {+ r := &artistIndex{}r.init("index", &models.ArtistIndex{})return r}-func (r *ArtistIndex) Put(m *models.ArtistIndex) error {+func (r *artistIndex) Put(m *models.ArtistIndex) error {if m.Id == "" {return errors.New("Id is not set")}return r.saveOrUpdate(m.Id, m)}-func (r *ArtistIndex) Get(id string) (*models.ArtistIndex, error) {+func (r *artistIndex) Get(id string) (*models.ArtistIndex, error) {var rec interface{}rec, err := r.readEntity(id)return rec.(*models.ArtistIndex), err}-func (r *ArtistIndex) GetAll() ([]models.ArtistIndex, error) {+func (r *artistIndex) GetAll() ([]models.ArtistIndex, error) {var indices = make([]models.ArtistIndex, 0)err := r.loadAll(&indices)return indices, errdiff --git a/repositories/index_repository_test.go b/repositories/index_repository_test.goindex b184e04a2..e8a6f6b68 100644--- a/repositories/index_repository_test.go+++ b/repositories/index_repository_test.go@@ -23,7 +23,7 @@ func TestIndexRepository(t *testing.T) {So(s, shouldBeEqual, i)})- Convey("Put() should return error if Id is not set", func() {+ Convey("Method Put() should return error if Id is not set", func() {i := &models.ArtistIndex{}err := repo.Put(i)