Пример #1
0
        public override string GetVideoUrl(VideoInfo video)
        {
            JObject data = GetWebData <JObject>(video.VideoUrl);
            string  playstr;

            if (data["streams"]["medium"].Type != JTokenType.Null)
            {
                playstr = data["streams"]["medium"].Value <string>();
                if (playstr.ToLower().StartsWith("rtmp"))
                {
                    int mp4IndexFlash = playstr.ToLower().IndexOf("mp4:");
                    int mp4Index      = mp4IndexFlash >= 0 ? mp4IndexFlash : playstr.ToLower().IndexOf("flv:");
                    if (mp4Index > 0)
                    {
                        playstr = new MPUrlSourceFilter.RtmpUrl(playstr.Substring(0, mp4Index))
                        {
                            PlayPath = playstr.Substring(mp4Index), SwfUrl = redirectedSwfUrl, SwfVerify = true
                        }.ToString();
                    }
                    else
                    {
                        playstr = new MPUrlSourceFilter.RtmpUrl(playstr)
                        {
                            SwfUrl = redirectedSwfUrl, SwfVerify = true
                        }.ToString();
                    }
                }
                else if (playstr.ToLower().EndsWith(".f4m"))
                {
                    playstr += "?hdcore=3.3.0" + "&g=" + OnlineVideos.Sites.Utils.HelperUtils.GetRandomChars(12);
                }
                else if (playstr.ToLower().Contains(".f4m?"))
                {
                    playstr += "&hdcore=3.3.0" + "&g=" + OnlineVideos.Sites.Utils.HelperUtils.GetRandomChars(12);
                }
            }
            else
            {
                playstr = data["streams"]["hls"].Value <string>();
                video.PlaybackOptions = new Dictionary <string, string>();
                OnlineVideos.Sites.Utils.MyHlsPlaylistParser parser = new OnlineVideos.Sites.Utils.MyHlsPlaylistParser(GetWebData(playstr), playstr);
                foreach (OnlineVideos.Sites.Utils.MyHlsStreamInfo streamInfo in parser.StreamInfos)
                {
                    video.PlaybackOptions.Add(streamInfo.Width + "x" + streamInfo.Height + " (" + streamInfo.Bandwidth / 1000 + " kbps)", streamInfo.Url);
                }
                playstr = video.PlaybackOptions.First().Value;
            }

            if (!string.IsNullOrEmpty(video.SubtitleUrl) && string.IsNullOrEmpty(video.SubtitleText))
            {
                video.SubtitleText = GetSubtitle(video.SubtitleUrl);
            }
            return(playstr);
        }
Пример #2
0
        public override Dictionary <string, string> GetPlaybackOptions(string url)
        {
            subtitleUrl = null;
            Dictionary <string, string> playbackOptions = new Dictionary <string, string>();
            JObject json               = GetWebData <JObject>(url);
            JArray  videoReferences    = json["videoReferences"].Value <JArray>();
            JToken  subtitleReferences = json["subtitleReferences"];
            JToken  videoReference     = videoReferences.FirstOrDefault(vr => vr["format"].Value <string>() == "hls");

            if (videoReference != null)
            {
                url = videoReference["url"].Value <string>();
                OnlineVideos.Sites.Utils.MyHlsPlaylistParser parser = new OnlineVideos.Sites.Utils.MyHlsPlaylistParser(GetWebData(url), url);
                foreach (OnlineVideos.Sites.Utils.MyHlsStreamInfo streamInfo in parser.StreamInfos)
                {
                    playbackOptions.Add(streamInfo.Width + "x" + streamInfo.Height + " (" + streamInfo.Bandwidth / 1000 + " kbps)", streamInfo.Url);
                }
            }
            else
            {
                videoReference = videoReferences.FirstOrDefault(vr => vr["format"].Value <string>() == "hds");
                if (videoReference != null)
                {
                    url  = videoReference["url"].Value <string>();
                    url += url.Contains("?") ? "&" : "?";
                    url += "hdcore=3.7.0&g=" + OnlineVideos.Sites.Utils.HelperUtils.GetRandomChars(12);
                    playbackOptions.Add("HDS", url);
                }
            }
            if (playbackOptions.Count == 0)
            {
                return(playbackOptions);
            }

            if (subtitleReferences != null && subtitleReferences.Type == JTokenType.Array)
            {
                JToken subtitleReference = subtitleReferences.FirstOrDefault(sr => sr["format"].Value <string>() == "webvtt");
                if (subtitleReference != null)
                {
                    subtitleUrl = subtitleReference["url"].Value <string>();
                }
            }

            return(playbackOptions);
        }
Пример #3
0
        public override Dictionary<string, string> GetPlaybackOptions(string url)
        {
            subtitleUrl = null;
            Dictionary<string, string> playbackOptions = new Dictionary<string, string>();
            JObject json = GetWebData<JObject>(url);
            JArray videoReferences = json["videoReferences"].Value<JArray>();
            JToken subtitleReferences = json["subtitleReferences"];
            JToken videoReference = videoReferences.FirstOrDefault(vr => vr["format"].Value<string>() == "hls");
            if (videoReference != null)
            {
                url = videoReference["url"].Value<string>();
                OnlineVideos.Sites.Utils.MyHlsPlaylistParser parser = new OnlineVideos.Sites.Utils.MyHlsPlaylistParser(GetWebData(url), url);
                foreach (OnlineVideos.Sites.Utils.MyHlsStreamInfo streamInfo in parser.StreamInfos)
                    playbackOptions.Add(streamInfo.Width + "x" + streamInfo.Height + " (" + streamInfo.Bandwidth / 1000 + " kbps)", streamInfo.Url);
            }
            else
            {
                videoReference = videoReferences.FirstOrDefault(vr => vr["format"].Value<string>() == "hds");
                if (videoReference != null)
                {
                    url = videoReference["url"].Value<string>();
                    url += url.Contains("?") ? "&" : "?";
                    url += "hdcore=3.7.0&g=" + OnlineVideos.Sites.Utils.HelperUtils.GetRandomChars(12);
                    playbackOptions.Add("HDS", url);
                }
            }
            if (playbackOptions.Count == 0)
                return playbackOptions;

            if (subtitleReferences != null && subtitleReferences.Type == JTokenType.Array)
            {
                JToken subtitleReference = subtitleReferences.FirstOrDefault(sr => sr["format"].Value<string>() == "webvtt");
                if (subtitleReference != null)
                    subtitleUrl = subtitleReference["url"].Value<string>();
            }

            return playbackOptions;
        }