public PlaylistParser(string m3UString, SproutData dataObj, M3UParser parser) { _lazyKey = new Lazy <Key>(() => { Match match = Regex.Match(m3UString, "#EXT-X-KEY:.*?URI=\"(.*?)\".*?IV=0x(.*?)$", RegexOptions.Multiline); using HttpClient hc = new(); byte[] bytes = hc.GetByteArrayAsync(dataObj.SignUrl(dataObj.GetBaseUrl() + match.Groups[1].Value)).Result; return(new Key { Iv = Utils.StringToByteArrayFastest(match.Groups[2].Value), Bytes = bytes }); }); _lazySegments = new Lazy <List <Segment> >(() => { MatchCollection matchList = Regex.Matches(m3UString, "^.*?\\.ts$", RegexOptions.Multiline); return(matchList.Cast <Match>().Select(match => new Segment { Folder = parser.GetSegmentsFolder(), Filename = match.Value, Url = dataObj.SignUrl(dataObj.GetBaseUrl() + match.Value) }).ToList()); }); }
public M3UParser(string input, SproutData dataObj) { _dataObj = dataObj; _lazyPlaylists = new Lazy <IEnumerable <Playlist> >(() => { MatchCollection matchList = Regex.Matches(input, @"^#EXT-X-STREAM-INF:.*?BANDWIDTH=(.*?),RESOLUTION.*$\n^(.*?\.m3u8)$", RegexOptions.Multiline); return(matchList.Cast <Match>().Select(match => new Playlist { Quality = match.Groups[2].Value.Replace(".m3u8", "p"), Url = _dataObj.SignUrl(_dataObj.GetBaseUrl() + match.Groups[2].Value), InaccurateSize = long.Parse(match.Groups[1].Value) / 8 * (long)_dataObj.Duration })); }); }