Ejemplo n.º 1
0
        internal string Query(string request, bool oauth, bool cfid, int wait)
        {
            string parameters = "?&ref=&cors=&_=" + GetTimestamp();
            if (request.Contains("?"))
            {
                parameters = parameters.Substring(1);
            }

            if (oauth)
            {
                parameters += "&oauth=" + OauthKey;
            }
            if (cfid)
            {
                parameters += "&csrf=" + CfidKey;
            }

            if (wait != -1)
            {
                parameters += "&returnafter=" + wait;
                parameters += "&returnon=login%2Clogout%2Cplay%2Cpause%2Cerror%2Cap";
            }

            string address = "http://" + Host + ":4380/" + request + parameters;
            string response = "";
            try
            {
                using (var wc = new ExtendedWebClient())
                {
                    if (SpotifyLocalAPI.IsSpotifyRunning())
                        response = "[ " + wc.DownloadString(address) + " ]";
                }
            }
            catch
            {
                return String.Empty;
            }

            return response;
        }