🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
Some refactoring
Deluan1a4f783669f5
diff --git a/models/artist.go b/models/artist.goindex a1e3978a0..6e7570b12 100644--- a/models/artist.go+++ b/models/artist.go@@ -1,23 +1,7 @@package models-import (- "strings"- "github.com/astaxie/beego"-)-type Artist struct {Id stringName stringAlbums map[string]bool-}--func NoArticle(name string) string {- articles := strings.Split(beego.AppConfig.String("ignoredArticles"), " ")- for _, a := range articles {- n := strings.TrimPrefix(name, a + " ")- if (n != name) {- return n- }- }- return name}\ No newline at end of filediff --git a/models/models_test.go b/models/models_test.godeleted file mode 100644index 75502dbd5..000000000--- a/models/models_test.go+++ /dev/null@@ -1,7 +0,0 @@-package models--import "testing"--func TestEmpty(t *testing.T) {--}\ No newline at end of filediff --git a/scanner/scanner.go b/scanner/scanner.goindex 26c396b50..373608840 100644--- a/scanner/scanner.go+++ b/scanner/scanner.go@@ -5,6 +5,7 @@ import ("github.com/deluan/gosonic/repositories""github.com/deluan/gosonic/models""strings"+"github.com/deluan/gosonic/utils")type Scanner interface {@@ -92,7 +93,7 @@ func persist(mfRepo *repositories.MediaFile, mf *models.MediaFile, albumRepo *refunc collectIndex(a *models.Artist, artistIndex map[string]tempIndex) {name := a.Name- indexName := strings.ToLower(models.NoArticle(name))+ indexName := strings.ToLower(utils.NoArticle(name))if indexName == "" {return}diff --git a/utils/strings.go b/utils/strings.gonew file mode 100644index 000000000..9c3eca8e8--- /dev/null+++ b/utils/strings.go@@ -0,0 +1,17 @@+package utils++import (+ "strings"+ "github.com/astaxie/beego"+)++func NoArticle(name string) string {+ articles := strings.Split(beego.AppConfig.String("ignoredArticles"), " ")+ for _, a := range articles {+ n := strings.TrimPrefix(name, a + " ")+ if (n != name) {+ return n+ }+ }+ return name+}