Ejemplo n.º 1
0
 public override string GetVideoUrl(string url)
 {
     if (url.ToLower().Contains("/cdn.php") || url.ToLower().Contains("/view.php"))
     {
         string refUrl = RefererUrl;
         //Clear referer
         RefererUrl = null;
         string data = GetWebData(url, referer: refUrl, cache: false, userAgent: "Apple-iPhone/701.341");
         Regex rgx = new Regex(@"<source.*?src=""(?<url>[^""]*)");
         Match m = rgx.Match(data);
         if (m.Success)
         {
             MPUrlSourceFilter.HttpUrl httpUrl = new MPUrlSourceFilter.HttpUrl(m.Groups["url"].Value);
             httpUrl.Referer = url;
             httpUrl.UserAgent = "Apple-iPhone/701.341";
             return httpUrl.ToString();
         }
     }
     else
     {
         //doskabouter impl
         int p = url.IndexOf('?');
         string url2 = url.Insert(p, "iframe.php");
         string webData = WebCache.Instance.GetWebData(url2);
         Match m = Regex.Match(webData, @"document\.write\(unescape\(""(?<data>[^""]*)""\)\);");
         if (m.Success)
         {
             string data = HttpUtility.UrlDecode(m.Groups["data"].Value);
             m = Regex.Match(data, @"file:\s""(?<url>[^""]*)"",");
             if (m.Success)
                 return m.Groups["url"].Value;
         }
     }
     return String.Empty;
 }
Ejemplo n.º 2
0
        public override Dictionary<string, string> GetPlaybackOptions(string url)
        {
            Dictionary<string, string> playbackOptions = new Dictionary<string, string>();
            CookieContainer cc = new CookieContainer();
            string data = GetWebData(url, cookies: cc, cache: false);
            Regex rgx = new Regex(@"""metadataUrl"":""(?<url>[^""]*)");
            Match m = rgx.Match(data);
            if (m.Success)
            {
                JObject json = GetWebData<JObject>(m.Groups["url"].Value, cookies: cc, cache: false);
                JToken videos = json["videos"];
                if (videos != null)
                {
                    foreach(JToken video in videos)
                    {
                        string key = video["key"].Value<string>();
                        string videoUrl = video["url"].Value<string>();
                        MPUrlSourceFilter.HttpUrl httpUrl = new MPUrlSourceFilter.HttpUrl(videoUrl);
                        CookieCollection cookies = cc.GetCookies(new Uri("http://my.mail.ru"));
                        httpUrl.Cookies.Add(cookies);
                        playbackOptions.Add(key, httpUrl.ToString());
                    }
                }
            }
            playbackOptions = 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);

            return playbackOptions;
        }
Ejemplo n.º 3
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>();
                foreach (KeyValuePair <string, string> pair in HlsPlaylistParser.GetPlaybackOptions(GetWebData(playstr), playstr, (x, y) => y.Bandwidth.CompareTo(x.Bandwidth), (x) => x.Width + "x" + x.Height + " (" + x.Bandwidth / 1000 + " Kbps)"))
                {
                    MPUrlSourceFilter.HttpUrl httpUrl = new MPUrlSourceFilter.HttpUrl(pair.Value);
                    httpUrl.Referer   = video.VideoUrl;
                    httpUrl.UserAgent = "Mozilla/5.0 (Windows NT 6.1)";
                    video.PlaybackOptions.Add(pair.Key, httpUrl.ToString());
                }
                playstr = video.PlaybackOptions.First().Value;
            }

            if (!string.IsNullOrEmpty(video.SubtitleUrl) && string.IsNullOrEmpty(video.SubtitleText))
            {
                video.SubtitleText = GetSubtitle(video.SubtitleUrl);
            }
            return(playstr);
        }
Ejemplo n.º 4
0
 public override string GetVideoUrl(string url)
 {
     if (url.ToLower().Contains("/cdn.php") || url.ToLower().Contains("/view.php"))
     {
         string refUrl = RefererUrl;
         //Clear referer
         RefererUrl = null;
         string data = GetWebData(url, referer: refUrl, cache: false, userAgent: "Apple-iPhone/701.341");
         Regex  rgx  = new Regex(@"<source.*?src=""(?<url>[^""]*)");
         Match  m    = rgx.Match(data);
         if (m.Success)
         {
             MPUrlSourceFilter.HttpUrl httpUrl = new MPUrlSourceFilter.HttpUrl(m.Groups["url"].Value);
             httpUrl.Referer   = url;
             httpUrl.UserAgent = "Apple-iPhone/701.341";
             return(httpUrl.ToString());
         }
     }
     else
     {
         //doskabouter impl
         int    p       = url.IndexOf('?');
         string url2    = url.Insert(p, "iframe.php");
         string webData = WebCache.Instance.GetWebData(url2);
         Match  m       = Regex.Match(webData, @"document\.write\(unescape\(""(?<data>[^""]*)""\)\);");
         if (m.Success)
         {
             string data = HttpUtility.UrlDecode(m.Groups["data"].Value);
             m = Regex.Match(data, @"file:\s""(?<url>[^""]*)"",");
             if (m.Success)
             {
                 return(m.Groups["url"].Value);
             }
         }
     }
     return(String.Empty);
 }
Ejemplo n.º 5
0
        private string GetHdStreaming2Url(VideoInfo video, String data)
        {
            Match c = regEx_GetPlaykeys.Match(data);

            if (c.Success)
            {
                String playkey1     = c.Groups["playkey1"].Value;
                String playkey2     = c.Groups["playkey2"].Value;
                String flashPlayer  = c.Groups["flashplayer"].Value + ".swf";
                String flashVersion = c.Groups["flashversion"].Value;


                String playData = GetWebData("http://streamaccess.unas.tv/hdflash/1/hdlaola1_" + playkey1 + ".xml?streamid=" + playkey1 + "&partnerid=1&quality=hdlive&t=.smil");

                Match baseUrls = regEx_GetLiveHdBaseUrls.Match(playData);
                Match sources  = regEx_GetLiveHdSources.Match(playData);

                //TODO: don't rely on the fact, the the quality is sorted (first item = worst quality, third = best)
                if (videoQuality == VideoQuality.Medium)
                {
                    sources = sources.NextMatch();
                }
                else if (videoQuality == VideoQuality.High)
                {
                    sources = sources.NextMatch().NextMatch();
                }


                String httpUrl = baseUrls.Groups["httpbase"].Value + sources.Groups["src"].Value + "&v=2.4.5&fp=WIN%2011,1,102,55&r=" + GetHdLiveRandomString(5) + "&g=" + GetHdLiveRandomString(12);
                httpUrl = httpUrl.Replace("amp;", "");
                MPUrlSourceFilter.HttpUrl url = new MPUrlSourceFilter.HttpUrl(httpUrl);

                return(url.ToString());
            }
            return(null);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// HD streaming from laola1.tv
        /// http://streamaccess.unas.tv/hdflash/1/hdlaola1_70429.xml?streamid=70429&partnerid=1&quality=hdlive&t=.smil
        /// This streaming type is used for many major sport events (e.g. soccer games, ice hockey, etc.) 
        /// </summary>
        /// <param name="video">Video object</param>
        /// <param name="playkey1">Playkey1 for this video</param>
        /// <param name="playkey2">Playkey2 for this video</param>
        /// <returns>Url for streaming</returns>
        private string GetHdStreamingUrl(VideoInfo video, String data)
        {
            //TODO: this isn't working yet. MediaPortal doesn't play the stream for some reason.
            //Downloading works though and the file can be played after that.

            Match c = regEx_GetLiveHdPlaykeys.Match(data);
            if (c.Success)
            {
                String streamAccess = c.Groups["streamaccess"].Value;
                String streamId = c.Groups["streamid"].Value;
                String flashPlayer = c.Groups["flashplayer"].Value + ".swf";
                //String flashVersion = c.Groups["flashversion"].Value;

                //String playData = GetWebData(String.Format("http://streamaccess.laola1.tv/hdflash/1/hdlaola1_{0}.xml?streamid={1}&partnerid=1&quality=hdlive&t=.smil", playkey1, playkey1));

                System.Net.CookieContainer container = new System.Net.CookieContainer();
                String playData = GetWebData(streamAccess, cookies: container);
                Match baseUrls = regEx_GetLiveHdBaseUrls.Match(playData);
                Match sources = regEx_GetLiveHdSources.Match(playData);

                //TODO: don't rely on the fact, the the quality is sorted (first item = worst quality, third = best)
                if (videoQuality == VideoQuality.Medium)
                {
                    sources = sources.NextMatch();
                }
                else if (videoQuality == VideoQuality.High)
                {
                    sources = sources.NextMatch().NextMatch();
                }


                String httpUrl = baseUrls.Groups["httpbase"].Value + sources.Groups["src"].Value;// +"&v=2.6.6&fp=WIN%2011,1,102,62&r=" + GetHdLiveRandomString(5) + "&g=" + GetHdLiveRandomString(12);
                httpUrl = httpUrl.Replace("amp;", "");
                httpUrl = httpUrl.Replace("e=&", "e=" + streamId + "&");
                httpUrl = httpUrl.Replace("p=&", "p=1&");

                /*String rtmpUrl = String.Format("rtmp://{0}:1935/{1}?_fcs_vhost={2}/{3}?auth={4}&p=1&e={5}&u=&t=livevideo&l=&a=&aifp={6}", ip, servertype, url, stream, auth, playkey1, aifp);
                //Log.Info("RTMP Url: " + rtmpUrl);
                String playpath = ReverseProxy.Instance.GetProxyUri(RTMP_LIB.RTMPRequestHandler.Instance,
                        string.Format("http://127.0.0.1/stream.flv?rtmpurl={0}&swfVfy={1}&live={2}",
                        System.Web.HttpUtility.UrlEncode(rtmpUrl),
                        System.Web.HttpUtility.UrlEncode("true"),
                        System.Web.HttpUtility.UrlEncode("true")
                        ));
                String playpath = string.Format("{0}&swfVfy={1}&live={2}",
                        rtmpUrl,
                        System.Web.HttpUtility.UrlEncode("true"),
                        System.Web.HttpUtility.UrlEncode("true")
                        );*/

                //String playpath = ReverseProxy.Instance.GetProxyUri(this, httpUrl);
                MPUrlSourceFilter.HttpUrl url = new MPUrlSourceFilter.HttpUrl(httpUrl);
                //url.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3";
                url.Cookies.Add(container.GetCookies(new Uri(streamAccess)));
                return url.ToString();
            }
            return null;
        }
Ejemplo n.º 7
0
        private string GetHdStreaming2Url(VideoInfo video, String data)
        {
            Match c = regEx_GetPlaykeys.Match(data);
            if (c.Success)
            {
                String playkey1 = c.Groups["playkey1"].Value;
                String playkey2 = c.Groups["playkey2"].Value;
                String flashPlayer = c.Groups["flashplayer"].Value + ".swf";
                String flashVersion = c.Groups["flashversion"].Value;


                String playData = GetWebData("http://streamaccess.unas.tv/hdflash/1/hdlaola1_" + playkey1 + ".xml?streamid=" + playkey1 + "&partnerid=1&quality=hdlive&t=.smil");

                Match baseUrls = regEx_GetLiveHdBaseUrls.Match(playData);
                Match sources = regEx_GetLiveHdSources.Match(playData);

                //TODO: don't rely on the fact, the the quality is sorted (first item = worst quality, third = best)
                if (videoQuality == VideoQuality.Medium)
                {
                    sources = sources.NextMatch();
                }
                else if (videoQuality == VideoQuality.High)
                {
                    sources = sources.NextMatch().NextMatch();
                }


                String httpUrl = baseUrls.Groups["httpbase"].Value + sources.Groups["src"].Value + "&v=2.4.5&fp=WIN%2011,1,102,55&r=" + GetHdLiveRandomString(5) + "&g=" + GetHdLiveRandomString(12);
                httpUrl = httpUrl.Replace("amp;", "");
                MPUrlSourceFilter.HttpUrl url = new MPUrlSourceFilter.HttpUrl(httpUrl);

                return url.ToString();
            }
            return null;
        }
Ejemplo n.º 8
0
 public override string GetVideoUrl(VideoInfo video)
 {
     string result = string.Empty;
     video.PlaybackOptions = new Dictionary<string, string>();
     XmlDocument xml = GetWebData<XmlDocument>(string.Format(videoUrlFormat, siteIdentifier, video.Other));
     if (xml != null)
     {
         string url = string.Empty;
         XmlNode sd = xml.SelectSingleNode(@"//item/url_video_sd");
         if (sd != null)
         {
             url = new MPUrlSourceFilter.HttpUrl(sd.InnerText).ToString();
             video.PlaybackOptions.Add("SD", url);
             result = url;
         }
         XmlNode hd = xml.SelectSingleNode(@"//item/url_video_hd");
         if (hd != null)
         {
             url = new MPUrlSourceFilter.HttpUrl(hd.InnerText).ToString();
             video.PlaybackOptions.Add("HD", url);
             result = url;
         }
     }
     return result;
 }
Ejemplo n.º 9
0
        public override string GetVideoUrl(VideoInfo video)
        {
            string playListUrl = GetPlaylistUrl(video.VideoUrl);
            if (String.IsNullOrEmpty(playListUrl))
                return String.Empty; // if no match, return empty url -> error
            
            Log.Debug(@"video: {0}", video.Title);
            string result = string.Empty;

            string data = GetWebData(playListUrl);
            
            Log.Debug(@"Validation JSON: {0}", data);

            if (!string.IsNullOrEmpty(data))
            {
                JToken json = JToken.Parse(data);
                string url = (string) json["url"];
                if (!string.IsNullOrEmpty(url))
                {
                    string manifestUrl = string.Format(manifestUrlFormat, url, GetRandomChars(12));                
                    result = new MPUrlSourceFilter.HttpUrl(manifestUrl).ToString();
                }
                else
                {
                    throw new OnlineVideosException((string) json["message"]);
                }
            }
            return result;
        }