go fmt
This commit is contained in:
@@ -7,7 +7,7 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
type ItunesScanner struct {}
|
||||
type ItunesScanner struct{}
|
||||
|
||||
func (s *ItunesScanner) LoadFolder(path string) []Track {
|
||||
xml, _ := os.Open(path)
|
||||
@@ -35,8 +35,8 @@ func (s *ItunesScanner) LoadFolder(path string) []Track {
|
||||
}
|
||||
|
||||
func unescape(s string) string {
|
||||
s,_ = url.QueryUnescape(s)
|
||||
s, _ = url.QueryUnescape(s)
|
||||
return strings.Replace(s, "&", "&", -1)
|
||||
}
|
||||
|
||||
var _ Scanner = (*ItunesScanner)(nil)
|
||||
var _ Scanner = (*ItunesScanner)(nil)
|
||||
|
||||
+18
-18
@@ -1,14 +1,14 @@
|
||||
package scanner
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/deluan/gosonic/persistence"
|
||||
"github.com/deluan/gosonic/domain"
|
||||
"strings"
|
||||
"github.com/deluan/gosonic/utils"
|
||||
"github.com/deluan/gosonic/consts"
|
||||
"time"
|
||||
"fmt"
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/deluan/gosonic/consts"
|
||||
"github.com/deluan/gosonic/domain"
|
||||
"github.com/deluan/gosonic/persistence"
|
||||
"github.com/deluan/gosonic/utils"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Scanner interface {
|
||||
@@ -29,7 +29,7 @@ func doImport(mediaFolder string, scanner Scanner) {
|
||||
beego.Info("Finished importing", len(files), "files")
|
||||
}
|
||||
|
||||
func importLibrary(files []Track) (err error){
|
||||
func importLibrary(files []Track) (err error) {
|
||||
indexGroups := utils.ParseIndexGroups(beego.AppConfig.String("indexGroups"))
|
||||
mfRepo := persistence.NewMediaFileRepository()
|
||||
albumRepo := persistence.NewAlbumRepository()
|
||||
@@ -65,20 +65,20 @@ func importLibrary(files []Track) (err error){
|
||||
|
||||
func parseTrack(t *Track) (*domain.MediaFile, *domain.Album, *domain.Artist) {
|
||||
mf := &domain.MediaFile{
|
||||
Id: t.Id,
|
||||
Album: t.Album,
|
||||
Artist: t.Artist,
|
||||
Id: t.Id,
|
||||
Album: t.Album,
|
||||
Artist: t.Artist,
|
||||
AlbumArtist: t.AlbumArtist,
|
||||
Title: t.Title,
|
||||
Title: t.Title,
|
||||
Compilation: t.Compilation,
|
||||
Path: t.Path,
|
||||
CreatedAt: t.CreatedAt,
|
||||
UpdatedAt: t.UpdatedAt,
|
||||
Path: t.Path,
|
||||
CreatedAt: t.CreatedAt,
|
||||
UpdatedAt: t.UpdatedAt,
|
||||
}
|
||||
|
||||
album := &domain.Album{
|
||||
Name: t.Album,
|
||||
Year: t.Year,
|
||||
Name: t.Album,
|
||||
Year: t.Year,
|
||||
Compilation: t.Compilation,
|
||||
}
|
||||
|
||||
@@ -145,4 +145,4 @@ func saveIndex(artistIndex map[string]tempIndex) error {
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
package scanner
|
||||
|
||||
import (
|
||||
"testing"
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
"github.com/deluan/gosonic/utils"
|
||||
"github.com/deluan/gosonic/domain"
|
||||
"github.com/deluan/gosonic/tests"
|
||||
"github.com/deluan/gosonic/tests"
|
||||
"github.com/deluan/gosonic/utils"
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCollectIndex(t *testing.T) {
|
||||
tests.Init(t, false)
|
||||
|
||||
ig := utils.IndexGroups{"A":"A", "B":"B", "Tom":"Tom", "X":"X-Z"}
|
||||
ig := utils.IndexGroups{"A": "A", "B": "B", "Tom": "Tom", "X": "X-Z"}
|
||||
|
||||
Convey("Simple Name", t, func() {
|
||||
a := &domain.Artist{Name: "Björk"}
|
||||
|
||||
+3
-3
@@ -18,11 +18,11 @@ type Track struct {
|
||||
}
|
||||
|
||||
func (m *Track) RealArtist() string {
|
||||
if (m.Compilation) {
|
||||
if m.Compilation {
|
||||
return "Various Artists"
|
||||
}
|
||||
if (m.AlbumArtist != "") {
|
||||
if m.AlbumArtist != "" {
|
||||
return m.AlbumArtist
|
||||
}
|
||||
return m.Artist
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user