public override string GetVideoUrl(string url) { JToken videoToken = GetWebData<JObject>(url + "?output=json")["video"]; url = ""; subtitleText = ""; try { var subtitleReferences = videoToken["subtitleReferences"].Where(sr => ((string)sr["url"] ?? "").EndsWith("srt") || ((string)sr["url"] ?? "").EndsWith("index.m3u8")); if (subtitleReferences != null && subtitleReferences.Count() > 0) { url = (string)subtitleReferences.First()["url"]; if (!string.IsNullOrEmpty(url)) { if (url.EndsWith("index.m3u8")) { string baseUrl = url.Replace("index.m3u8", string.Empty); //try with all.vtt subtitleText = GetWebData(baseUrl + "all.vtt"); /* Could be used as fallback, but very slow making hundreds of gets if (string.IsNullOrWhiteSpace(subtitleText)) { string plist = GetWebData(url); Regex rgx = new Regex(@"(?<url>.*?\.vtt)"); foreach (Match m in rgx.Matches(plist)) { subtitleText += GetWebData(baseUrl + m.Groups["url"].Value); } }*/ CleanSubtitle(true); } else { subtitleText = GetWebData(url); CleanSubtitle(); } } } } catch { } JToken videoReference = videoToken["videoReferences"].FirstOrDefault(vr => (string)vr["playerType"] == "flash" && !string.IsNullOrEmpty((string)vr["url"])); if (videoReference == null) { url = ""; } else { Boolean live = false; JValue liveVal = (JValue)videoToken["live"]; if (liveVal != null) live = liveVal.Value<bool>(); url = (string)videoReference["url"] + "?hdcore=3.7.0&g=" + OnlineVideos.Sites.Utils.HelperUtils.GetRandomChars(12); url = new MPUrlSourceFilter.AfhsManifestUrl(url) { LiveStream = live, Referer = "http://media.svt.se/swf/video/svtplayer-2015.01.swf" }.ToString(); } return url; }
public override string GetVideoUrl(VideoInfo video) { string url = ""; if (!video.VideoUrl.StartsWith("http")) { Uri result; if (!Uri.TryCreate(video.VideoUrl, UriKind.Absolute, out result)) { Uri.TryCreate(new Uri(baseUrl), video.VideoUrl, out result); } video.VideoUrl = result.ToString(); } JToken videoToken = GetWebData <JObject>(video.VideoUrl + "?output=json")["video"]; if (RetrieveSubtitles) { try { var subtitleReferences = videoToken["subtitleReferences"].Where(sr => ((string)sr["url"] ?? "").EndsWith("srt")); if (subtitleReferences != null && subtitleReferences.Count() > 0) { url = (string)subtitleReferences.First()["url"]; if (!string.IsNullOrEmpty(url)) { video.SubtitleText = CleanSubtitle(GetWebData(url)); } } } catch { } } JToken videoReference = videoToken["videoReferences"].FirstOrDefault(vr => (string)vr["playerType"] == "flash" && !string.IsNullOrEmpty((string)vr["url"])); if (videoReference == null) { url = ""; } else { Boolean live = false; JValue liveVal = (JValue)videoToken["live"]; if (liveVal != null) { live = liveVal.Value <bool>(); } url = (string)videoReference["url"] + "?hdcore=" + hdcore + "&g=" + OnlineVideos.Sites.Utils.HelperUtils.GetRandomChars(12); url = new MPUrlSourceFilter.AfhsManifestUrl(url) { LiveStream = live, Referer = swfUrl }.ToString(); } return(url); }
public override string GetVideoUrl(string url) { JToken videoToken = GetWebData <JObject>(url + "?output=json")["video"]; url = ""; subtitleText = ""; try { var subtitleReferences = videoToken["subtitleReferences"].Where(sr => ((string)sr["url"] ?? "").EndsWith("srt") || ((string)sr["url"] ?? "").EndsWith("index.m3u8")); if (subtitleReferences != null && subtitleReferences.Count() > 0) { url = (string)subtitleReferences.First()["url"]; if (!string.IsNullOrEmpty(url)) { if (url.EndsWith("index.m3u8")) { string baseUrl = url.Replace("index.m3u8", string.Empty); //try with all.vtt subtitleText = GetWebData(baseUrl + "all.vtt"); /* Could be used as fallback, but very slow making hundreds of gets * if (string.IsNullOrWhiteSpace(subtitleText)) * { * string plist = GetWebData(url); * Regex rgx = new Regex(@"(?<url>.*?\.vtt)"); * foreach (Match m in rgx.Matches(plist)) * { * subtitleText += GetWebData(baseUrl + m.Groups["url"].Value); * } * }*/ CleanSubtitle(true); } else { subtitleText = GetWebData(url); CleanSubtitle(); } } } } catch { } JToken videoReference = videoToken["videoReferences"].FirstOrDefault(vr => (string)vr["playerType"] == "flash" && !string.IsNullOrEmpty((string)vr["url"])); if (videoReference == null) { url = ""; } else { Boolean live = false; JValue liveVal = (JValue)videoToken["live"]; if (liveVal != null) { live = liveVal.Value <bool>(); } url = (string)videoReference["url"] + "?hdcore=3.7.0&g=" + OnlineVideos.Sites.Utils.HelperUtils.GetRandomChars(12); url = new MPUrlSourceFilter.AfhsManifestUrl(url) { LiveStream = live, Referer = "http://media.svt.se/swf/video/svtplayer-2015.01.swf" }.ToString(); } return(url); }
public override string GetVideoUrl(VideoInfo video) { bool isArchive = video.GetOtherAsString() == cArchiveCategory; string archiveUrl = ""; if (isArchive) { Regex archiveRgx = new Regex(@".*(?<prefix>\d-)(?<id>\d*)"); Match archiveMatch = archiveRgx.Match(video.VideoUrl); if (archiveMatch.Success) { Regex mediakantaIdRegex = new Regex(@"""mediakantaId"":""(?<id>[^""]*)"); string id = archiveMatch.Groups["id"].Value; Match mediakantaIdMatch = mediakantaIdRegex.Match(GetWebData(string.Format(cUrlArchiveEmbedFormat, id, id))); if (mediakantaIdMatch.Success) { archiveUrl = archiveMatch.Groups["prefix"].Value + mediakantaIdMatch.Groups["id"].Value; } } } string url = string.Format(cUrlHdsFormat, isArchive ? archiveUrl : video.VideoUrl); JObject json = GetWebData<JObject>(url, cache: false); JToken hdsStream = json["data"]["media"]["HDS"].FirstOrDefault(h => h["subtitles"] != null && h["subtitles"].Count() > 0); if (hdsStream == null) { hdsStream = json["data"]["media"]["HDS"].First; } else { JToken subtitle = hdsStream["subtitles"].FirstOrDefault(s => s["lang"].Value<string>() == ApiLanguage); if (subtitle == null) subtitle = hdsStream["subtitles"].FirstOrDefault(s => s["lang"].Value<string>() == ApiOtherLanguage); if (subtitle != null && subtitle["uri"] != null) video.SubtitleUrl = subtitle["uri"].Value<string>(); } string data = hdsStream["url"].Value<string>(); byte[] bytes = Convert.FromBase64String(data); RijndaelManaged rijndael = new RijndaelManaged(); byte[] iv = new byte[16]; Array.Copy(bytes, iv, 16); rijndael.IV = iv; rijndael.Key = Encoding.ASCII.GetBytes("yjuap4n5ok9wzg43"); rijndael.Mode = CipherMode.CFB; rijndael.Padding = PaddingMode.Zeros; ICryptoTransform decryptor = rijndael.CreateDecryptor(rijndael.Key, rijndael.IV); int padLen = 16 - bytes.Length % 16; byte[] newbytes = new byte[bytes.Length - 16 + padLen]; Array.Copy(bytes, 16, newbytes, 0, bytes.Length - 16); Array.Clear(newbytes, newbytes.Length - padLen, padLen); string result = null; using (MemoryStream msDecrypt = new MemoryStream(newbytes)) { using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read)) { using (StreamReader srDecrypt = new StreamReader(csDecrypt)) { result = srDecrypt.ReadToEnd(); } } } Regex r; if (video.GetOtherAsString() == cApiContentTypeTvLive) r = new Regex(@"(?<url>.*\.f4m)"); else r = new Regex(@"(?<url>.*hmac=[a-z0-9]*)"); Match m = r.Match(result); if (m.Success) { result = m.Groups["url"].Value; } if (video.GetOtherAsString() == cApiContentTypeTvLive) { result += "?g=" + HelperUtils.GetRandomChars(12) + "&hdcore=3.3.0&plugin=flowplayer-3.3.0.0"; MPUrlSourceFilter.AfhsManifestUrl f4mUrl = new MPUrlSourceFilter.AfhsManifestUrl(result) { LiveStream = true }; result = f4mUrl.ToString(); } else { result += "&g=" + HelperUtils.GetRandomChars(12) + "&hdcore=3.3.0&plugin=flowplayer-3.3.0.0"; } return result; }
public override string GetVideoUrl(VideoInfo video) { bool isArchive = video.GetOtherAsString() == cArchiveCategory; string archiveUrl = ""; if (isArchive) { Regex archiveRgx = new Regex(@".*(?<prefix>\d-)(?<id>\d*)"); Match archiveMatch = archiveRgx.Match(video.VideoUrl); if (archiveMatch.Success) { Regex mediakantaIdRegex = new Regex(@"""mediakantaId"":""(?<id>[^""]*)"); string id = archiveMatch.Groups["id"].Value; Match mediakantaIdMatch = mediakantaIdRegex.Match(GetWebData(string.Format(cUrlArchiveEmbedFormat, id, id))); if (mediakantaIdMatch.Success) { archiveUrl = archiveMatch.Groups["prefix"].Value + mediakantaIdMatch.Groups["id"].Value; } } } string url = string.Format(cUrlHdsFormat, isArchive ? archiveUrl : video.VideoUrl); JObject json = GetWebData <JObject>(url, cache: false); JToken hdsStream = json["data"]["media"]["HDS"].FirstOrDefault(h => h["subtitles"] != null && h["subtitles"].Count() > 0); if (hdsStream == null) { hdsStream = json["data"]["media"]["HDS"].First; } else { JToken subtitle = hdsStream["subtitles"].FirstOrDefault(s => s["lang"].Value <string>() == ApiLanguage); if (subtitle == null) { subtitle = hdsStream["subtitles"].FirstOrDefault(s => s["lang"].Value <string>() == ApiOtherLanguage); } if (subtitle != null && subtitle["uri"] != null) { video.SubtitleUrl = subtitle["uri"].Value <string>(); } } string data = hdsStream["url"].Value <string>(); byte[] bytes = Convert.FromBase64String(data); RijndaelManaged rijndael = new RijndaelManaged(); byte[] iv = new byte[16]; Array.Copy(bytes, iv, 16); rijndael.IV = iv; rijndael.Key = Encoding.ASCII.GetBytes("yjuap4n5ok9wzg43"); rijndael.Mode = CipherMode.CFB; rijndael.Padding = PaddingMode.Zeros; ICryptoTransform decryptor = rijndael.CreateDecryptor(rijndael.Key, rijndael.IV); int padLen = 16 - bytes.Length % 16; byte[] newbytes = new byte[bytes.Length - 16 + padLen]; Array.Copy(bytes, 16, newbytes, 0, bytes.Length - 16); Array.Clear(newbytes, newbytes.Length - padLen, padLen); string result = null; using (MemoryStream msDecrypt = new MemoryStream(newbytes)) { using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read)) { using (StreamReader srDecrypt = new StreamReader(csDecrypt)) { result = srDecrypt.ReadToEnd(); } } } Regex r; if (video.GetOtherAsString() == cApiContentTypeTvLive) { r = new Regex(@"(?<url>.*\.f4m)"); } else { r = new Regex(@"(?<url>.*hmac=[a-z0-9]*)"); } Match m = r.Match(result); if (m.Success) { result = m.Groups["url"].Value; } if (video.GetOtherAsString() == cApiContentTypeTvLive) { result += "?g=" + HelperUtils.GetRandomChars(12) + "&hdcore=3.3.0&plugin=flowplayer-3.3.0.0"; MPUrlSourceFilter.AfhsManifestUrl f4mUrl = new MPUrlSourceFilter.AfhsManifestUrl(result) { LiveStream = true }; result = f4mUrl.ToString(); } else { result += "&g=" + HelperUtils.GetRandomChars(12) + "&hdcore=3.3.0&plugin=flowplayer-3.3.0.0"; } return(result); }