From e0614cb02c585e23c0f10a3168129038426834ac Mon Sep 17 00:00:00 2001 From: YamiOdymel Date: Wed, 7 Sep 2022 18:14:12 +0800 Subject: [PATCH] Return error and retry if m3u8.Playlist is nil --- main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index ad2d726..4d40d0f 100644 --- a/main.go +++ b/main.go @@ -113,7 +113,10 @@ func parseM3U8Source(url string) (chunks []*m3u8.MediaSegment, wait float64, err // Decode the segment table. p, _, _ := m3u8.DecodeFrom(strings.NewReader(body), true) - media := p.(*m3u8.MediaPlaylist) + media, ok := p.(*m3u8.MediaPlaylist) + if !ok { + return nil, 3, errInternal + } wait = media.TargetDuration / 1.5 // Ignore the empty segments.