/// <summary> /// Updates and Fetches all current information about the current track etc. /// </summary> public void Update() { if (!SpotifyLocalAPIClass.IsSpotifyWebHelperRunning() || !SpotifyLocalAPIClass.IsSpotifyRunning()) { return; } mh.Update(rh.Update()); }
internal async Task <string> QueryAsync(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 a = "http://" + host + ":4380/" + request + parameters; string response = ""; try { //Need to find a better solution using (var wc = new ExtendedWebClientInstance()) { if (SpotifyLocalAPIClass.IsSpotifyRunning()) { response = "[ " + await wc.DownloadStringTaskAsync(new Uri(a)) + " ]"; } } } catch (Exception ex) { Console.WriteLine(ex.Message); return(""); } return(response); }
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 a = "http://" + host + ":4380/" + request + parameters; string response = ""; try { //Need to find a better solution if (SpotifyLocalAPIClass.IsSpotifyRunning()) { response = "[ " + wc.DownloadString(a) + " ]"; } } catch (Exception z) { return(""); } return(response); }