public override List <string> GetMultipleVideoUrls(VideoInfo video, bool inPlaylist = false) { List <Hoster.HosterBase> hosters = Hoster.HosterFactory.GetAllHosters(); video.PlaybackOptions = new Dictionary <string, string>(); string doc = GetWebData <string>(video.VideoUrl, cookies: GetCookie()); Regex rgx = new Regex(@"id=""page\d+""[^\(]*\(.*?swe.zzz\('([^']*)"); int playerIndex = 1; foreach (Match m in rgx.Matches(doc)) { try { string data = m.Groups[1].Value; string decodedBase64 = System.Text.Encoding.UTF8.GetString(System.Convert.FromBase64String(data)); Regex urlRgx = new Regex(@"src=""([^""]*)"); Match urlMatch = urlRgx.Match(decodedBase64); if (urlMatch.Success) { string url = urlMatch.Groups[1].Value; Hoster.HosterBase hoster = hosters.FirstOrDefault(h => url.ToLower().Contains(h.GetHosterUrl().ToLower())); if (hoster != null) { if (hoster is Hoster.IReferer) { (hoster as Hoster.IReferer).RefererUrl = video.VideoUrl; } Dictionary <string, string> hosterPo = hoster.GetPlaybackOptions(url); if (hosterPo != null) { foreach (string key in hosterPo.Keys) { if (!string.IsNullOrEmpty(hosterPo[key])) { video.PlaybackOptions.Add((hoster.GetType().Name != key ? hoster.GetType().Name + " " : "") + key + " (Player " + playerIndex + ")", hosterPo[key]); } } } } else { Log.Debug("Swefilmer, no hoster found for Player {0} url: {1}", playerIndex, url); } playerIndex++; } } catch { } } string firstUrl = video.PlaybackOptions.Count() > 0 ? video.PlaybackOptions.First().Value : string.Empty; if (inPlaylist) { video.PlaybackOptions.Clear(); } return(new List <string>() { firstUrl }); }
public override List <string> GetMultipleVideoUrls(VideoInfo video, bool inPlaylist = false) { List <Hoster.HosterBase> hosters = Hoster.HosterFactory.GetAllHosters(); string url = null; video.PlaybackOptions = new Dictionary <string, string>(); if ((video.Other as ITrackingInfo).VideoKind == VideoKind.Movie) { url = video.VideoUrl; } else if ((video.Other as ITrackingInfo).VideoKind == VideoKind.TvSeries) { JObject json = GetWebData <JObject>(string.Format("{0}CMS/modules/series/ajax.php", baseUrl), string.Format("action=showmovie&id={0}", video.VideoUrl)); string iframe = json["url"].Value <string>(); url = GetIframeUrl(iframe); } if (!string.IsNullOrEmpty(url)) { url = url.Replace("ok.ru/", string.Format("vkpass.com/token/{0}/", vkpassToken)); Hoster.HosterBase hoster = hosters.FirstOrDefault(h => url.ToLower().Contains(h.GetHosterUrl().ToLower())); if (hoster != null) { if (hoster is IReferer) { (hoster as IReferer).RefererUrl = baseUrl; } Dictionary <string, string> hosterPo = hoster.GetPlaybackOptions(url); if (hosterPo != null) { foreach (string key in hosterPo.Keys) { if (!string.IsNullOrEmpty(hosterPo[key])) { video.PlaybackOptions.Add((hoster.GetType().Name != key ? hoster.GetType().Name + " " : "") + key, hosterPo[key]); } } } if (hoster is ISubtitle) { video.SubtitleText = (hoster as ISubtitle).SubtitleText; } } else { Log.Debug("Dreamfilm, no hoster found for url: {0}", url); } } url = video.PlaybackOptions.Count == 0 ? "" : video.PlaybackOptions.FirstOrDefault().Value; if (inPlaylist) { video.PlaybackOptions.Clear(); } return(new List <string>() { url }); }
public override List <string> GetMultipleVideoUrls(VideoInfo video, bool inPlaylist = false) { List <Hoster.HosterBase> hosters = Hoster.HosterFactory.GetAllHosters(); string url = video.VideoUrl;; video.PlaybackOptions = new Dictionary <string, string>(); url = url.Replace("ok.ru/", string.Format("vkpass.com/token/{0}/", vkpassToken)); Hoster.HosterBase hoster = hosters.FirstOrDefault(h => url.ToLower().Contains(h.GetHosterUrl().ToLower())); if (hoster != null) { if (hoster is IReferer) { (hoster as IReferer).RefererUrl = baseUrl; } Dictionary <string, string> hosterPo = hoster.GetPlaybackOptions(url); if (hosterPo != null) { foreach (string key in hosterPo.Keys) { if (!string.IsNullOrEmpty(hosterPo[key])) { video.PlaybackOptions.Add((hoster.GetType().Name != key ? hoster.GetType().Name + " " : "") + key, hosterPo[key]); } } } if (!forceSubtitle && hoster is ISubtitle) { video.SubtitleText = (hoster as ISubtitle).SubtitleText; } } else { Log.Debug("Dreamfilm, no hoster found for url: {0}", url); } url = video.PlaybackOptions.Count == 0 ? "" : video.PlaybackOptions.FirstOrDefault().Value; if (inPlaylist) { video.PlaybackOptions.Clear(); } if (!string.IsNullOrWhiteSpace(url) && subtitleSource != SubtitleSource.None) { sh.SetSubtitleText(video, GetTrackingInfo, false); } return(new List <string>() { url }); }
public override string GetPlaybackOptionUrl(string option) { string u = this.PlaybackOptions[option]; this.LatestOption = option; Hoster.HosterBase hoster = Hoster.HosterFactory.GetAllHosters().FirstOrDefault(h => u.ToLowerInvariant().Contains(h.GetHosterUrl().ToLowerInvariant())); if (hoster != null) { string theUrl = hoster.GetVideoUrl(u); if (hoster is ISubtitle && string.IsNullOrWhiteSpace(SubtitleText)) { this.SubtitleText = (hoster as ISubtitle).SubtitleText; } return(theUrl); } return(""); }
public override List <string> GetMultipleVideoUrls(VideoInfo video, bool inPlaylist = false) { HtmlDocument doc = GetWebData <HtmlDocument>(video.VideoUrl); HtmlNode iframe = doc.DocumentNode.SelectSingleNode("//div[@class = 'movieplay']/iframe"); string url = iframe.GetAttributeValue("src", ""); if (video.Other is ITrackingInfo) { Regex rgx = new Regex(@"href=""http://www.imdb.com/title/(?<imdb>tt\d+)/"); Match m = rgx.Match(doc.DocumentNode.InnerHtml); if (m.Success) { string imdb = m.Groups["imdb"].Value; (video.Other as ITrackingInfo).ID_IMDB = imdb; } } Hoster.HosterBase host = Hoster.HosterFactory.GetAllHosters().FirstOrDefault(h => url.ToLowerInvariant().Contains(h.GetHosterUrl().ToLowerInvariant())); if (host == null) { video.PlaybackOptions = new Dictionary <string, string>(); return(new List <string>()); } else { if (inPlaylist) { video.PlaybackOptions = new Dictionary <string, string>(); return(new List <string>() { host.GetVideoUrl(url) }); } else { video.PlaybackOptions = host.GetPlaybackOptions(url); return(new List <string>() { video.PlaybackOptions.First().Value }); } } }
private Dictionary <string, string> GetPlaybackOptionsFromIFrame(string data, string refUrl) { List <Hoster.HosterBase> hosters = Hoster.HosterFactory.GetAllHosters(); Dictionary <string, string> playbackOptions = new Dictionary <string, string>(); Regex rgx = new Regex(@"<iframe[^>]*?src='(?<url>[^']*)"); Match m = rgx.Match(data); if (m.Success) { string url = m.Groups["url"].Value; Hoster.HosterBase hoster = hosters.FirstOrDefault(h => url.ToLower().StartsWith("http://" + h.GetHosterUrl().ToLower())); if (hoster != null) { if (hoster is IReferer) { (hoster as IReferer).RefererUrl = refUrl; } playbackOptions = hoster.GetPlaybackOptions(url); } } return(playbackOptions); }
public override string GetVideoUrl(VideoInfo video) { string data = GetWebData(video.VideoUrl); Match m2 = Regex.Match(data, "<script>(?<script>\\s*func.*?)</script>", RegexOptions.Singleline); ScriptEngine engine = new ScriptEngine(); engine.Global["window"] = engine.Global; engine.Global["document"] = engine.Global; engine.Global["navigator"] = engine.Global; engine.Execute(m2.Groups["script"].Value); Regex r = new Regex(@"<tr class=""linkTr"">.*?""serverLink\sserverLink[^\s]*\sid=""(?<id>[^""]*)"".*?""linkQuality[^>]*>(?<q>[^<]*)<.*?linkHiddenFormat[^>]*>(?<f>[^<]*)<.*?linkHiddenCode[^>]*>(?<c>[^<]*)<.*?</tr", RegexOptions.Singleline); Dictionary <string, string> d = new Dictionary <string, string>(); List <Hoster.HosterBase> hosters = Hoster.HosterFactory.GetAllHosters(); foreach (Match m in r.Matches(data)) { string id = m.Groups["id"].Value.Replace("serverLink", ""); if (!string.IsNullOrEmpty(id)) { string c = engine.CallGlobalFunction("dec_" + id, m.Groups["c"].Value).ToString(); string u = m.Groups["f"].Value.Replace("%s", c); if (u.StartsWith("//")) { u = "http:" + u; } Hoster.HosterBase hoster = hosters.FirstOrDefault(h => u.ToLowerInvariant().Contains(h.GetHosterUrl().ToLowerInvariant())); if (hoster != null) { string format = hoster.GetHosterUrl() + " [" + m.Groups["q"].Value + "] " + "({0})"; int count = 1; while (d.ContainsKey(string.Format(format, count))) { count++; } d.Add(string.Format(format, count), u); } else { Log.Debug("Skipped hoster:" + m.Groups["f"].Value); } } else { Log.Debug("Skipped decription and hoster for: " + m.Groups["f"].Value); } } d = d.OrderBy((p) => { return(p.Key); }).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); video.PlaybackOptions = d; if (d.Count == 0) { return(""); } if ((video as LosMoviesVideoInfo).TrackingInfo == null) { (video as LosMoviesVideoInfo).TrackingInfo = new TrackingInfo(); } var ti = (video as LosMoviesVideoInfo).TrackingInfo; if (string.IsNullOrEmpty(ti.ID_IMDB)) { ti.VideoKind = VideoKind.Movie; ti.Title = video.Title; ti.Year = GetRelesaseYear(data); ti.ID_IMDB = GetImdbId(data); } sh.SetSubtitleText(video, GetTrackingInfo, false); string latestOption = (video is LosMoviesVideoInfo) ? (video as LosMoviesVideoInfo).LatestOption : ""; if (string.IsNullOrEmpty(latestOption)) { return(d.First().Value); } if (d.ContainsKey(latestOption)) { return(d[latestOption]); } return(d.First().Value); }
public override List <string> GetMultipleVideoUrls(VideoInfo video, bool inPlaylist = false) { bool isVimeo = video.VideoUrl.Contains("vimeo.com"); bool isYoutube = video.VideoUrl.Contains("youtube.com"); video.PlaybackOptions = new Dictionary <string, string>(); if (isVimeo || isYoutube) { Hoster.HosterBase hoster = Hoster.HosterFactory.GetAllHosters().FirstOrDefault(h => video.VideoUrl.ToLowerInvariant().Contains(h.GetHosterUrl().ToLowerInvariant())); if (hoster != null) { video.PlaybackOptions = hoster.GetPlaybackOptions(video.VideoUrl); } if (isYoutube) { video.PlaybackOptions = video.PlaybackOptions.Reverse().ToDictionary(kvp => kvp.Key, kvp => kvp.Value); } else if (isVimeo) { video.PlaybackOptions = video.PlaybackOptions.OrderByDescending((p) => { string resKey = p.Key.Replace("p", ""); int parsedRes = 0; int.TryParse(resKey, out parsedRes); return(parsedRes); }).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); } } else { string data = ExtendedWebCache.Instance.GetWebData(video.VideoUrl, cookies: Cookies); Regex r = new Regex(@"playMovie\('[^']*','(?<id>[^']*)'\s*?\)"">"); //Regex r = new Regex(@";media_id":"(?<id>.*?)""); //super secret regex... Match m = r.Match(data); if (m.Success) { JObject json = ExtendedWebCache.Instance.GetWebData <JObject>("https://video.arkena.com/api/v1/public/accounts/571358/medias/" + m.Groups["id"].Value); JToken videoRenditions = json["asset"]?["resources"]?.FirstOrDefault(resource => resource["type"].Value <string>() == "video")?["renditions"]; if (videoRenditions != null) { foreach (JToken rendition in videoRenditions) { string key = (rendition["videos"].First()["bitrate"].Value <int>() / 1000) + "kbps"; if (!video.PlaybackOptions.ContainsKey(key)) { video.PlaybackOptions.Add(key, rendition["links"].First()["href"].Value <string>()); } } if (video.PlaybackOptions.Count > 0) { video.PlaybackOptions = video.PlaybackOptions.OrderByDescending((p) => { string resKey = p.Key.Replace("kbps", ""); int parsedRes = 0; int.TryParse(resKey, out parsedRes); return(parsedRes); }).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); video.SubtitleText = GetSubtitle(json); r = new Regex(@"http://www.imdb.com/title/(?<imdb>tt\d+)"); m = r.Match(data); if (m.Success) { video.Other = new TrackingInfo() { VideoKind = VideoKind.Movie, ID_IMDB = m.Groups["imdb"].Value }; } } } } else { throw new OnlineVideosException("Kontrollera dina inloggningsuppgifter"); } } string url = video.PlaybackOptions.First().Value; if (inPlaylist) { video.PlaybackOptions.Clear(); } return(new List <string>() { url }); }
public override string GetVideoUrl(VideoInfo video) { string data; if (video.Other is string && !string.IsNullOrWhiteSpace(video.GetOtherAsString())) { data = video.GetOtherAsString(); } else { data = GetWebData(video.VideoUrl); } Regex r = new Regex(@"<tr class=""linkTr"">.*?""linkQuality[^>]*>(?<q>[^<]*)<.*?linkHiddenUrl[^>]*>(?<u>[^<]*)<.*?</tr", RegexOptions.Singleline); Dictionary <string, string> d = new Dictionary <string, string>(); List <Hoster.HosterBase> hosters = Hoster.HosterFactory.GetAllHosters(); foreach (Match m in r.Matches(data)) { string u = m.Groups["u"].Value; if (u.StartsWith("//")) { u = "http:" + u; } Hoster.HosterBase hoster = hosters.FirstOrDefault(h => u.ToLowerInvariant().Contains(h.GetHosterUrl().ToLowerInvariant())); if (hoster != null) { string format = hoster.GetHosterUrl() + " [" + m.Groups["q"].Value + "] " + "({0})"; int count = 1; while (d.ContainsKey(string.Format(format, count))) { count++; } d.Add(string.Format(format, count), u); } else { Log.Debug("Skipped hoster:" + m.Groups["u"].Value); } } d = d.OrderBy((p) => { return(p.Key); }).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); video.PlaybackOptions = d; if (d.Count == 0) { return(""); } if ((video as LosMoviesVideoInfo).TrackingInfo == null) { (video as LosMoviesVideoInfo).TrackingInfo = new TrackingInfo(); } var ti = (video as LosMoviesVideoInfo).TrackingInfo; if (string.IsNullOrEmpty(ti.ID_IMDB)) { ti.VideoKind = VideoKind.Movie; ti.Title = video.Title; ti.Year = GetRelesaseYear(data); ti.ID_IMDB = GetImdbId(data); } sh.SetSubtitleText(video, GetTrackingInfo, false); string latestOption = (video is LosMoviesVideoInfo) ? (video as LosMoviesVideoInfo).LatestOption : ""; if (string.IsNullOrEmpty(latestOption)) { return(d.First().Value); } if (d.ContainsKey(latestOption)) { return(d[latestOption]); } return(d.First().Value); }