public MovieInformation(string url) { Valid = false; if (string.IsNullOrEmpty(url)) { return; } var htmlDocument = new HtmlWeb().Load(url); var json = (from script in htmlDocument.DocumentNode.Descendants("script") select script.InnerText into s where s.Contains("window.DR") select s.Replace("window.DR = {", "{").Replace("};", "}")).FirstOrDefault(); json = json?.Replace(@"\\.\pipe\", ""); var broadcastInformation = JsonConvert.DeserializeObject <BroadcastInformation>(json); //( // from script in htmlDocument.DocumentNode.Descendants("script") // select script.InnerText // into s // where s.Contains("window.DR") // select s.Replace("window.DR = {", "{").Replace("};", "}") // into json // select JsonConvert.DeserializeObject<BroadcastInformation>(json.Replace(@"\\\\.\\pipe\\", "")) //).FirstOrDefault(); var programCard = broadcastInformation?.TV.ProgramCard; if (programCard == null) { return; } var primaryBroadcast = programCard.PrimaryBroadcast; Title = programCard.Title; Url = programCard.PrimaryAsset?.Uri; if (string.IsNullOrEmpty(Url)) { return; } Description = programCard.Description; ProductionYear = primaryBroadcast?.ProductionYear ?? 0; ProductionCountry = primaryBroadcast?.ProductionCountry; var baseFileName = RemoveInvalidChars(Title); using (var webClient = new WebClient()) { TitleImage = new MemoryStream(webClient.DownloadData(programCard.PrimaryImageUri)) { Position = 0 }; ImageFilename = baseFileName + ".jpg"; FileName = baseFileName + ".ts"; SubTitleFile = baseFileName + ".srt"; var m3U8Object = JsonConvert.DeserializeObject <M3u8Object>(webClient.DownloadString(Url)); url = m3U8Object.Links?.FirstOrDefault(x => x.Uri.Contains("m3u8"))?.Uri; if (url == null) { return; } var tmp = webClient.DownloadString(url); if (string.IsNullOrEmpty(tmp)) { return; } StreamInformations = new M3U8File(tmp); SubTitle = StreamInformations.SubtitlesUri; Formats = new List <string>(StreamInformations.Streams.GroupBy(s => s.Resolution).Select(s => s.Key)); } Valid = true; }
public M3U8FileModel(M3U8File m3u) { SourceTarget = m3u; Head = m3u.Head; Segments = m3u.Segments.ToList(); }