feat(ipc): expand remote player controls
This commit is contained in:
@@ -162,6 +162,16 @@ func TestArgsRemoteAudioURLBecomesTrack(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestURLResolvesRawStream(t *testing.T) {
|
||||
tracks, err := URL("https://example.com/live.mp3")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(tracks) != 1 || tracks[0].Path != "https://example.com/live.mp3" {
|
||||
t.Fatalf("tracks = %#v", tracks)
|
||||
}
|
||||
}
|
||||
|
||||
func TestArgsLocalM3U(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
// Write a local m3u that points at a dummy audio file.
|
||||
|
||||
@@ -188,6 +188,24 @@ func Remote(urls []string) ([]playlist.Track, error) {
|
||||
return tracks, nil
|
||||
}
|
||||
|
||||
// URL resolves one interactive URL using the same classification as command-line
|
||||
// arguments, including raw streams, feeds, remote playlists, and video pages.
|
||||
func URL(rawURL string) ([]playlist.Track, error) {
|
||||
result, err := Args([]string{rawURL})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
tracks := result.Tracks
|
||||
if len(result.Pending) > 0 {
|
||||
remote, err := Remote(result.Pending)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
tracks = append(tracks, remote...)
|
||||
}
|
||||
return tracks, nil
|
||||
}
|
||||
|
||||
// sniffFeedURL does a HEAD request and returns true if the Content-Type
|
||||
// indicates an RSS/Atom feed. Used as a fallback when the URL has no
|
||||
// recognizable file extension (e.g. https://feeds.megaphone.fm/GLT1412515089).
|
||||
|
||||
Reference in New Issue
Block a user