예제 #1
0
        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
            });
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }