diff --git a/conf/app.conf b/conf/app.conf index ac3fe3196..14f5c8c8d 100644 --- a/conf/app.conf +++ b/conf/app.conf @@ -24,6 +24,7 @@ disableValidation = true enableAdmin = true [test] +enableAdmin = false disableValidation = false httpPort = 8081 user = deluan diff --git a/scanner/itunes_scanner.go b/scanner/itunes_scanner.go index 53263f29c..e939fbec8 100644 --- a/scanner/itunes_scanner.go +++ b/scanner/itunes_scanner.go @@ -193,8 +193,7 @@ func (s *ItunesScanner) collectMediaFiles(t *itl.Track) *domain.MediaFile { } mf.BitRate = t.BitRate - path, _ := url.QueryUnescape(t.Location) - path = strings.TrimPrefix(unescape(path), "file://") + path := extractPath(t.Location) mf.Path = path mf.Suffix = strings.TrimPrefix(filepath.Ext(path), ".") @@ -300,6 +299,13 @@ func unescape(str string) string { return html.UnescapeString(str) } +func extractPath(loc string) string { + path := strings.Replace(loc, "+", "%2B", -1) + path, _ = url.QueryUnescape(path) + path = html.UnescapeString(path) + return strings.TrimPrefix(path, "file://") +} + func realArtistName(t *itl.Track) string { switch { case t.Compilation: diff --git a/scanner/itunes_scanner_test.go b/scanner/itunes_scanner_test.go new file mode 100644 index 000000000..89cacbcc3 --- /dev/null +++ b/scanner/itunes_scanner_test.go @@ -0,0 +1,25 @@ +package scanner + +import ( + "testing" + + . "github.com/smartystreets/goconvey/convey" +) + +func TestExtractLocation(t *testing.T) { + + Convey("Given a path with a plus (+) signal", t, func() { + location := "file:///Users/deluan/Music/iTunes%201/iTunes%20Media/Music/Chance/Six%20Through%20Ten/03%20Forgive+Forget.m4a" + + Convey("When I decode it", func() { + path := extractPath(location) + + Convey("I get the correct path", func() { + So(path, ShouldEqual, "/Users/deluan/Music/iTunes 1/iTunes Media/Music/Chance/Six Through Ten/03 Forgive+Forget.m4a") + }) + + }) + + }) + +}