Skip to content

Commit

Permalink
修正AppleTV逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
nilaoda committed Mar 25, 2021
1 parent 71d69de commit 8b520d0
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions N_m3u8DL-CLI/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,11 @@ public void Parse()
//针对AppleTv修正
if (m3u8Content.Contains("#EXT-X-DISCONTINUITY") && m3u8Content.Contains("#EXT-X-MAP") && M3u8Url.Contains(".apple.com/"))
{
//第一个不连续标记之后
var sub = m3u8Content.Substring(m3u8Content.IndexOf("#EXT-X-DISCONTINUITY"));
Regex ykmap = new Regex("#EXT-X-MAP:URI=\\\"(.*?)\\\"");
if (ykmap.IsMatch(sub))
//只取加密部分即可
Regex ykmap = new Regex("(#EXT-X-KEY:[\\s\\S]*?)#EXT-X-DISCONTINUITY");
if (ykmap.IsMatch(m3u8Content))
{
var nSub = Regex.Replace(sub, "#EXT-X-MAP:URI=\\\"(.*?)\\\"", "#EXTINF:0,\r\n$1");
m3u8Content = m3u8Content.Replace(sub, nSub).Replace("#EXT-X-DISCONTINUITY", "");
m3u8Content = "#EXTM3U\r\n" + ykmap.Match(m3u8Content).Groups[1].Value + "\r\n#EXT-X-ENDLIST";
}
}

Expand Down

0 comments on commit 8b520d0

Please sign in to comment.