mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-15 03:30:39 +03:00
Support local paths as urls in playlists.
This commit is contained in:
parent
bcafe88ef9
commit
e9d0abe0bc
@ -5,6 +5,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
@ -82,6 +83,10 @@ func (s *playlistSync) parsePlaylist(ctx context.Context, playlistFile string, b
|
|||||||
if strings.HasPrefix(path, "#") {
|
if strings.HasPrefix(path, "#") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if strings.HasPrefix(path, "file://") {
|
||||||
|
path = strings.TrimPrefix(path, "file://")
|
||||||
|
path, _ = url.QueryUnescape(path)
|
||||||
|
}
|
||||||
if !filepath.IsAbs(path) {
|
if !filepath.IsAbs(path) {
|
||||||
path = filepath.Join(baseDir, path)
|
path = filepath.Join(baseDir, path)
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,15 @@ var _ = Describe("playlistSync", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("parses well-formed playlists", func() {
|
It("parses well-formed playlists", func() {
|
||||||
|
pls, err := ps.parsePlaylist(ctx, "playlists/pls1.m3u", "tests/fixtures")
|
||||||
|
Expect(err).To(BeNil())
|
||||||
|
Expect(pls.Tracks).To(HaveLen(3))
|
||||||
|
Expect(pls.Tracks[0].Path).To(Equal("tests/fixtures/test.mp3"))
|
||||||
|
Expect(pls.Tracks[1].Path).To(Equal("tests/fixtures/test.ogg"))
|
||||||
|
Expect(pls.Tracks[2].Path).To(Equal("/tests/fixtures/01 Invisible (RED) Edit Version.mp3"))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("parses playlists using LF ending", func() {
|
||||||
pls, err := ps.parsePlaylist(ctx, "lf-ended.m3u", "tests/fixtures/playlists")
|
pls, err := ps.parsePlaylist(ctx, "lf-ended.m3u", "tests/fixtures/playlists")
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
Expect(pls.Tracks).To(HaveLen(2))
|
Expect(pls.Tracks).To(HaveLen(2))
|
||||||
|
3
tests/fixtures/playlists/pls1.m3u
vendored
Normal file
3
tests/fixtures/playlists/pls1.m3u
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
test.mp3
|
||||||
|
test.ogg
|
||||||
|
file:///tests/fixtures/01%20Invisible%20(RED)%20Edit%20Version.mp3
|
Loading…
x
Reference in New Issue
Block a user