Skip to content

🎧 Your Personal Streaming Service

Some refactoring

Deluan1a4f783669f5
diff --git a/models/artist.go b/models/artist.go
index 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 string
Name string
Albums 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 file
diff --git a/models/models_test.go b/models/models_test.go
deleted file mode 100644
index 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 file
diff --git a/scanner/scanner.go b/scanner/scanner.go
index 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 *re
func 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.go
new file mode 100644
index 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
+}