Beispiel #1
0
        private void BenchmarkForm_Load(object sender, EventArgs e)
        {
            string cfg = File.ReadAllText(_currentConfig);
            Dictionary <string, object> dict = new Deserializer().Deserialize <Dictionary <string, object> >(cfg);

            _benchmarkURL = dict.ContainsKey("cfw-latency-url") ? dict["cfw-latency-url"].ToString() : "http://www.gstatic.com/generate_204";

            _proxies = _clashAPI.GetProxies();
            if (_clashAPI.config.mode == "Global")
            {
                _groups.Add(_proxies["GLOBAL"].name);
            }
            else     // Rules
            {
                foreach (Proxy proxy in _proxies.Values)
                {
                    if (proxy.proxyType == "Selector" && proxy.name != "GLOBAL")
                    {
                        _groups.Add(proxy.name);
                    }
                }
            }

            groupListBox.DataSource            = _groups;
            groupListBox.SelectedIndexChanged += new EventHandler(groupSelected);

            proxyGridView.AutoGenerateColumns = false;

            if (_groups.Count > 0)
            {
                groupListBox.SelectedIndex = 0;
                groupSelected(groupListBox, null);
            }
        }
Beispiel #2
0
        // The listen/watch links take the user to another page with an embedded player.  Instead of
        // going there, find the direct media URL and send it to Banshee's PlayerEngine.
        private bool TryInterceptListenWatch(string uri)
        {
            bool ret = false;

            if (uri != null && uri.Contains("miroguide.com/items/"))
            {
                int i       = uri.LastIndexOf('/') + 1;
                var item_id = uri.Substring(i, uri.Length - i);

                // Get the actual media URL via the MiroGuide API
                new Hyena.Downloader.HttpStringDownloader()
                {
                    Uri      = new Uri(String.Format("http://www.miroguide.com/api/get_item?datatype=json&id={0}", item_id)),
                    Finished = (d) => {
                        if (d.State.Success)
                        {
                            string media_url = null;
                            var    item      = new Deserializer(d.Content).Deserialize() as JsonObject;
                            if (item.ContainsKey("url"))
                            {
                                media_url = item["url"] as string;
                            }

                            if (media_url != null)
                            {
                                Log.DebugFormat("MiroGuide: streaming straight away {0}", media_url);
                                Banshee.Streaming.RadioTrackInfo.OpenPlay(media_url);
                                Banshee.ServiceStack.ServiceManager.PlaybackController.StopWhenFinished = true;
                                ret = true;
                            }
                        }
                    },
                    AcceptContentTypes = new [] { "text/javascript" }
                }.StartSync();
            }

            return(ret);
        }