package extractor
import "testing"
func TestExtractStreams(t *testing.T) {
html := `
listen
`
streams := ExtractStreams(html)
if len(streams) != 6 {
t.Fatalf("wanted 6 streams, got %d: %v", len(streams), streams)
}
}
func TestExtractPlaylistLinks(t *testing.T) {
html := `
m3u
pls
xspf
json
`
links := ExtractPlaylistLinks(html)
if len(links) != 4 {
t.Fatalf("wanted 4 playlist links, got %d: %v", len(links), links)
}
}
func TestParsePlaylist(t *testing.T) {
m3u := "#EXTM3U\nhttps://example.com/live.mp3\n"
pls := "[playlist]\nFile1=https://example.com/stream.aac\n"
xspf := "https://example.com/hls.m3u8"
if len(ParsePlaylist(m3u, "audio/x-mpegurl")) != 1 {
t.Fatal("expected m3u playlist to yield 1 stream")
}
if len(ParsePlaylist(pls, "audio/x-scpls")) != 1 {
t.Fatal("expected pls playlist to yield 1 stream")
}
if len(ParsePlaylist(xspf, "application/xspf+xml")) != 1 {
t.Fatal("expected xspf playlist to yield 1 stream")
}
}