コード例 #1
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);
        }
コード例 #2
0
 public bool IsAuthed()
 {
     foreach (System.Net.Cookie item in cookies.GetCookies(new Uri(config.base_url)))
     {
         if (item.Name == "cdb_auth")
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #3
0
ファイル: Spider.cs プロジェクト: Ahmad222/Semantic-Search
        /// <summary>
        /// Attempts to download the Uri and (based on it's MimeType) use the DocumentFactory
        /// to get a Document subclass object that is able to parse the downloaded data.
        /// </summary>
        /// <remarks>
        /// http://www.123aspx.com/redir.aspx?res=28320
        /// </remarks>
        protected Document Download(Uri uri)
        {
            bool success = false;

            // Open the requested URL
            System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uri.AbsoluteUri);
            req.AllowAutoRedirect            = true;
            req.MaximumAutomaticRedirections = 3;
            req.UserAgent = Preferences.UserAgent;             //"Mozilla/6.0 (MSIE 6.0; Windows NT 5.1; Searcharoo.NET)";
            req.KeepAlive = true;
            req.Timeout   = Preferences.RequestTimeout * 1000; //prefRequestTimeout

            // SIMONJONES http://codeproject.com/aspnet/spideroo.asp?msg=1421158#xx1421158xx
            req.CookieContainer = new System.Net.CookieContainer();
            req.CookieContainer.Add(_CookieContainer.GetCookies(uri));

            // Get the stream from the returned web response
            System.Net.HttpWebResponse webresponse = null;
            try
            {
                webresponse = (System.Net.HttpWebResponse)req.GetResponse();
            }
            catch (System.Net.WebException we)
            {   //remote url not found, 404; remote url forbidden, 403
                ProgressEvent(this, new ProgressEventArgs(2, "skipped  " + uri.AbsoluteUri + " response exception:" + we.ToString() + ""));
            }

            Document htmldoc = null;

            if (webresponse != null)
            {
                /* SIMONJONES */

                /* **************** this doesn't necessarily work yet...
                 * if (webresponse.ResponseUri != htmldoc.Uri)
                 * {	// we've been redirected,
                 *  if (visited.Contains(webresponse.ResponseUri.ToString().ToLower()))
                 *  {
                 *      return true;
                 *  }
                 *  else
                 *  {
                 *      visited.Add(webresponse.ResponseUri.ToString().ToLower());
                 *  }
                 * }*/

                try
                {
                    webresponse.Cookies = req.CookieContainer.GetCookies(req.RequestUri);
                    // handle cookies (need to do this incase we have any session cookies)
                    foreach (System.Net.Cookie retCookie in webresponse.Cookies)
                    {
                        bool cookieFound = false;
                        foreach (System.Net.Cookie oldCookie in _CookieContainer.GetCookies(uri))
                        {
                            if (retCookie.Name.Equals(oldCookie.Name))
                            {
                                oldCookie.Value = retCookie.Value;
                                cookieFound     = true;
                            }
                        }
                        if (!cookieFound)
                        {
                            _CookieContainer.Add(retCookie);
                        }
                    }
                }
                catch (Exception ex)
                {
                    ProgressEvent(this, new ProgressEventArgs(3, "Cookie processing error : " + ex.Message + ""));
                }
                /* end SIMONJONES */

                htmldoc = DocumentFactory.New(uri, webresponse);
                success = htmldoc.GetResponse(webresponse);
                webresponse.Close();
                ProgressEvent(this, new ProgressEventArgs(2, "Trying index mime type: " + htmldoc.MimeType + " for " + htmldoc.Uri + ""));
            }
            else
            {
                ProgressEvent(this, new ProgressEventArgs(2, "No WebResponse for " + uri + ""));
                success = false;
            }
            return(htmldoc);
        }
コード例 #4
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;
        }
コード例 #5
0
        async void Refresh()
        {
            if (EditorApplication.isPlayingOrWillChangePlaymode)
            {
                return;
            }

            try
            {
                updating     = true;
                ErrorMessage = "";
                Simulator.Web.Config.ParseConfigFile();

                if (DeveloperSimulation.Cluster == null)
                {
                    DeveloperSimulation.Cluster = new ClusterData()
                    {
                        Name      = "DeveloperSettingsDummy",
                        Instances = new[]
                        {
                            new InstanceData
                            {
                                HostName   = "dummy.developer.settings",
                                Ip         = new [] { "127.0.0.1" },
                                MacAddress = "00:00:00:00:00:00"
                            }
                        }
                    };
                }

                if (string.IsNullOrEmpty(Config.CloudProxy))
                {
                    API = new CloudAPI(new Uri(Config.CloudUrl), cookieContainer);
                }
                else
                {
                    API = new CloudAPI(new Uri(Config.CloudUrl), cookieContainer, new Uri(Config.CloudProxy));
                }

                DatabaseManager.Init();
                var            csservice = new Simulator.Database.Services.ClientSettingsService();
                ClientSettings cls       = csservice.GetOrMake();
                Config.SimID = cls.simid;
                if (String.IsNullOrEmpty(Config.CloudUrl))
                {
                    ErrorMessage = "Cloud URL not set";
                    return;
                }
                if (String.IsNullOrEmpty(Config.SimID))
                {
                    ErrorMessage = "Simulator not linked";
                    return;
                }

                if (cookieContainer.GetCookies(new Uri(Config.CloudUrl)).Count == 0)
                {
                    authenticated = false;
                }

                if (authenticated)
                {
                    var ret = await API.GetLibrary <VehicleDetailData>();

                    CloudVehicles = ret.ToList();
                }
                else
                {
                    CloudVehicles = new List <VehicleDetailData>();
                }

                string[] guids = AssetDatabase.FindAssets("t:Prefab", new[] { "Assets/External/Vehicles" });
                LocalVehicles = guids.Select(g => AssetDatabase.GUIDToAssetPath(g)).ToList();

                string idOrPath = null;
                if (DeveloperSimulation.Vehicles != null) // get previously selected thing
                {
                    // we abuse VehicleData.Id to store the prefab path
                    idOrPath = DeveloperSimulation.Vehicles[0].Id;
                }

                if (idOrPath != null)
                {
                    // find index of previously selected thing in new dataset
                    var foundIndex = VehicleChoices.FindIndex(v => v.cloudIdOrPrefabPath == idOrPath && (v.IsLocal || v.configId == Settings.VehicleConfigId));
                    SetVehicleFromSelectionIndex(foundIndex);

                    await UpdateCloudVehicleDetails();
                }

                DeveloperSimulation.NPCs = Config.NPCVehicles.Values.ToArray(); // TODO get from cloud and refresh config.cs LoadExternalAssets()
            }
            catch (CloudAPI.NoSuccessException ex)
            {
                if (ex.StatusCode == System.Net.HttpStatusCode.BadRequest)
                {
                    authenticated = false;
                    ClearCookie();
                }
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
                ErrorMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    ErrorMessage += "\n" + ex.InnerException.Message;
                }
            }
            finally
            {
                updating = false;
                Repaint();
            }
        }
        /// <summary>
        /// Attempts to download the Uri and (based on it's MimeType) use the DocumentFactory
        /// to get a Document subclass object that is able to parse the downloaded data.
        /// </summary>
        /// <remarks>
        /// http://www.123aspx.com/redir.aspx?res=28320
        /// </remarks>
        protected Document Download(Uri uri)
        {
            bool success = false;

            // Open the requested URL

            System.Net.WebProxy proxyObject = null;
            if (Preferences.UseProxy)
            {   // [v6] stephenlane80 suggested proxy code
                proxyObject             = new System.Net.WebProxy(Preferences.ProxyUrl, true);
                proxyObject.Credentials = System.Net.CredentialCache.DefaultCredentials;
            }
            // [v6] Erick Brown [work] suggested fix for & in querystring
            string unescapedUri = Regex.Replace(uri.AbsoluteUri, @"&amp;amp;", @"&", RegexOptions.IgnoreCase);

            System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(unescapedUri);

            req.AllowAutoRedirect            = true;
            req.MaximumAutomaticRedirections = 3;
            req.UserAgent = Preferences.UserAgent;             //"Mozilla/6.0 (MSIE 6.0; Windows NT 5.1; Searcharoo.NET; robot)";
            req.KeepAlive = true;
            req.Timeout   = Preferences.RequestTimeout * 1000; //prefRequestTimeout
            if (Preferences.UseProxy)
            {
                req.Proxy = proxyObject;                       // [v6] stephenlane80
            }
            // SIMONJONES http://codeproject.com/aspnet/spideroo.asp?msg=1421158#xx1421158xx
            req.CookieContainer = new System.Net.CookieContainer();
            req.CookieContainer.Add(_CookieContainer.GetCookies(uri));

            // Get the stream from the returned web response
            System.Net.HttpWebResponse webresponse = null;
            try
            {
                webresponse = (System.Net.HttpWebResponse)req.GetResponse();
            }
            catch (System.Net.WebException we)
            {   //remote url not found, 404; remote url forbidden, 403
                ProgressEvent(this, new ProgressEventArgs(2, "skipped  " + uri.AbsoluteUri + " response exception:" + we.ToString() + ""));
            }

            Document currentUriDocument = null;

            if (webresponse != null)
            {
                /* SIMONJONES */

                /* **************** this doesn't necessarily work yet...
                 * if (webresponse.ResponseUri != htmldoc.Uri)
                 * {	// we've been redirected,
                 *  if (visited.Contains(webresponse.ResponseUri.ToString().ToLower()))
                 *  {
                 *      return true;
                 *  }
                 *  else
                 *  {
                 *      visited.Add(webresponse.ResponseUri.ToString().ToLower());
                 *  }
                 * }*/

                try
                {
                    webresponse.Cookies = req.CookieContainer.GetCookies(req.RequestUri);
                    // handle cookies (need to do this in case we have any session cookies)
                    foreach (System.Net.Cookie retCookie in webresponse.Cookies)
                    {
                        bool cookieFound = false;
                        foreach (System.Net.Cookie oldCookie in _CookieContainer.GetCookies(uri))
                        {
                            if (retCookie.Name.Equals(oldCookie.Name))
                            {
                                oldCookie.Value = retCookie.Value;
                                cookieFound     = true;
                            }
                        }
                        if (!cookieFound)
                        {
                            _CookieContainer.Add(retCookie);
                        }
                    }
                }
                catch (Exception ex)
                {
                    ProgressEvent(this, new ProgressEventArgs(3, "Cookie processing error : " + ex.Message + ""));
                }
                /* end SIMONJONES */

                currentUriDocument = DocumentFactory.New(uri, webresponse);
                success            = currentUriDocument.GetResponse(webresponse);
                webresponse.Close();
                ProgressEvent(this, new ProgressEventArgs(2, "Trying index mime type: " + currentUriDocument.MimeType + " for " + currentUriDocument.Uri + ""));

                _Visited.Add(currentUriDocument.Uri);   // [v7] [email protected] capture redirected Urls
                                                        // relies on Document 'capturing' the final Uri
                                                        // this.Uri = webresponse.ResponseUri;
            }
            else
            {
                ProgressEvent(this, new ProgressEventArgs(2, "No WebResponse for " + uri + ""));
                success = false;
            }
            return(currentUriDocument);
        }