Fixed iTunes location decoding

This commit is contained in:
Deluan
2016-03-12 11:28:59 -05:00
parent 4b09eeccc2
commit 4d7f9ee012
3 changed files with 34 additions and 2 deletions
+8 -2
View File
@@ -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: