// Last.fm requires you to 'tune' to a station before requesting a track list/playing it public bool ChangeToThisStation() { if (lastfm.Connection.Station == Station) { return(false); } Log.Debug(String.Format("Tuning Last.fm to {0}", Name), null); SetStatus(Catalog.GetString("Tuning Last.fm to {0}."), false); StationError error = lastfm.Connection.ChangeStationTo(Station); if (error == StationError.None) { Log.Debug(String.Format("Successfully tuned Last.fm to {0}", station), null); return(true); } else { Log.Debug(String.Format("Failed to tune Last.fm to {0}", Name), RadioConnection.ErrorMessageFor(error)); SetStatus(String.Format( // Translators: {0} is an error message sentence from RadioConnection.cs. Catalog.GetString("Failed to tune in station. {0}"), RadioConnection.ErrorMessageFor(error)), true ); return(false); } }
public StationError ChangeStationTo(string station) { lock (this) { if (Station == station) { return(StationError.None); } try { LastfmRequest radio_tune = new LastfmRequest("radio.tune", RequestType.Write, ResponseFormat.Json); radio_tune.AddParameter("station", station); radio_tune.Send(); StationError error = radio_tune.GetError(); if (error != StationError.None) { return(error); } this.station = station; return(StationError.None); } catch (Exception e) { Log.Error(e); return(StationError.Unknown); } } }
private void OnNowPlayingResponse(IAsyncResult ar) { try { current_now_playing_request.EndSend(ar); } catch (Exception e) { Log.Exception("Failed to complete the NowPlaying request", e); state = State.Idle; current_now_playing_request = null; return; } StationError error = current_now_playing_request.GetError(); // API docs say "Now Playing requests that fail should not be retried". if (error == StationError.InvalidSessionKey) { Log.Warning("Audioscrobbler NowPlaying failed", "Session ID sent was invalid", false); // TODO: Suggest to the user to (re)do the Last.fm authentication ? } else if (error != StationError.None) { Log.WarningFormat("Audioscrobbler NowPlaying failed: {0}", error.ToString()); } else { Log.Debug("Submitted NowPlaying track to Audioscrobbler"); now_playing_started = false; } current_now_playing_request = null; }
// Translated error message strings public static string ErrorMessageFor(StationError error) { switch (error) { case StationError.InvalidService: case StationError.InvalidMethod: return(Catalog.GetString("This service does not exist.")); case StationError.AuthenticationFailed: case StationError.SubscriptionError: case StationError.SubscriptionRequired: return(Catalog.GetString("This station is only available to subscribers.")); case StationError.InvalidFormat: return(Catalog.GetString("This station is not available.")); case StationError.InvalidParameters: return(Catalog.GetString("The request is missing a required parameter.")); case StationError.InvalidResource: return(Catalog.GetString("The specified resource is invalid.")); case StationError.TokenFailure: return(Catalog.GetString("Server error, please try again later.")); case StationError.InvalidSessionKey: return(Catalog.GetString("Invalid authentication information, please re-authenticate.")); case StationError.InvalidApiKey: return(Catalog.GetString("The API key used by this application is invalid.")); case StationError.ServiceOffline: return(Catalog.GetString("The streaming system is offline for maintenance, please try again later.")); case StationError.InvalidSignature: return(Catalog.GetString("The method signature is invalid.")); case StationError.TokenNotAuthorized: case StationError.ExpiredToken: return(Catalog.GetString("You need to allow Banshee to access your Last.fm account.")); case StationError.NotEnoughContent: return(Catalog.GetString("There is not enough content to play this station.")); case StationError.NotEnoughMembers: return(Catalog.GetString("This group does not have enough members for radio.")); case StationError.NotEnoughFans: return(Catalog.GetString("This artist does not have enough fans for radio.")); case StationError.NotEnoughNeighbours: return(Catalog.GetString("There are not enough neighbours for this station.")); case StationError.Unknown: return(Catalog.GetString("There was an unknown error.")); } return(String.Empty); }
private void validateStation() { if (String.IsNullOrEmpty(StationTextBox.Text)) { StationError.SetError(StationTextBox, "You must enter a Station."); } else { StationError.SetError(StationTextBox, String.Empty); } }
public StationError GetError() { StationError error = StationError.None; SetResponseString(); if (response_string == null) { return(StationError.Unknown); } if (response_string.Contains("<lfm status=\"failed\">")) { // XML reply indicates an error Match match = Regex.Match(response_string, "<error code=\"(\\d+)\">"); if (match.Success) { error = (StationError)Int32.Parse(match.Value); Log.WarningFormat("Lastfm error {0}", error); } else { error = StationError.Unknown; } } if (response_format == ResponseFormat.Json && response_string.Contains("\"error\":")) { // JSON reply indicates an error Deserializer deserializer = new Deserializer(response_string); JsonObject json = deserializer.Deserialize() as JsonObject; if (json != null && json.ContainsKey("error")) { error = (StationError)json["error"]; Log.WarningFormat("Lastfm error {0} : {1}", error, (string)json["message"]); } } return(error); }
// Translated error message strings public static string ErrorMessageFor(StationError error) { switch (error) { case StationError.InvalidService: case StationError.InvalidMethod: return(Catalog.GetString("This service does not exist.")); case StationError.AuthenticationFailed: case StationError.SubscriptionError: case StationError.SubscriptionRequired: return(Catalog.GetString("Stations are only available to paying Last.fm subscribers.")); case StationError.InvalidFormat: return(Catalog.GetString("This station is not available.")); case StationError.InvalidParameters: return(Catalog.GetString("The request is missing a required parameter.")); case StationError.InvalidResource: return(Catalog.GetString("The specified resource is invalid.")); case StationError.TokenFailure: return(Catalog.GetString("Server error, please try again later.")); case StationError.InvalidSessionKey: return(Catalog.GetString("Invalid authentication information, please re-authenticate.")); case StationError.InvalidApiKey: return(Catalog.GetString("The API key used by this application is invalid.")); case StationError.ServiceOffline: return(Catalog.GetString("The streaming system is offline for maintenance, please try again later.")); case StationError.InvalidSignature: return(Catalog.GetString("The method signature is invalid.")); case StationError.TokenNotAuthorized: case StationError.ExpiredToken: return(Catalog.GetString("You need to allow Banshee to access your Last.fm account.")); case StationError.NotEnoughContent: return(Catalog.GetString("There is not enough content to play this station.")); case StationError.NotEnoughMembers: return(Catalog.GetString("This group does not have enough members for radio.")); case StationError.NotEnoughFans: return(Catalog.GetString("This artist does not have enough fans for radio.")); case StationError.NotEnoughNeighbours: return(Catalog.GetString("There are not enough neighbours for this station.")); case StationError.NoPeakRadio: return(Catalog.GetString("This user is not allowed to listen to radio during peak usage")); case StationError.RadioNotFound: return(Catalog.GetString("Radio station not found")); case StationError.ApiKeySuspended: return(Catalog.GetString("This application is not allowed to make requests to the web services")); case StationError.Deprecated: return(Catalog.GetString("This type of request is no longer supported")); case StationError.RateLimitExceded: return(Catalog.GetString("Your IP has made too many requests in a short period, exceeding our API guidelines")); case StationError.Unknown: return(Catalog.GetString("There was an unknown error.")); } return(String.Empty); }
// Translated error message strings public static string ErrorMessageFor (StationError error) { switch (error) { case StationError.InvalidService: case StationError.InvalidMethod: return Catalog.GetString ("This service does not exist."); case StationError.AuthenticationFailed: case StationError.SubscriptionError: case StationError.SubscriptionRequired: return Catalog.GetString ("Stations are only available to paying Last.fm subscribers."); case StationError.InvalidFormat: return Catalog.GetString ("This station is not available."); case StationError.InvalidParameters: return Catalog.GetString ("The request is missing a required parameter."); case StationError.InvalidResource: return Catalog.GetString ("The specified resource is invalid."); case StationError.TokenFailure: return Catalog.GetString ("Server error, please try again later."); case StationError.InvalidSessionKey: return Catalog.GetString ("Invalid authentication information, please re-authenticate."); case StationError.InvalidApiKey: return Catalog.GetString ("The API key used by this application is invalid."); case StationError.ServiceOffline: return Catalog.GetString ("The streaming system is offline for maintenance, please try again later."); case StationError.InvalidSignature: return Catalog.GetString ("The method signature is invalid."); case StationError.TokenNotAuthorized: case StationError.ExpiredToken: return Catalog.GetString ("You need to allow Banshee to access your Last.fm account."); case StationError.NotEnoughContent: return Catalog.GetString ("There is not enough content to play this station."); case StationError.NotEnoughMembers: return Catalog.GetString ("This group does not have enough members for radio."); case StationError.NotEnoughFans: return Catalog.GetString ("This artist does not have enough fans for radio."); case StationError.NotEnoughNeighbours: return Catalog.GetString ("There are not enough neighbours for this station."); case StationError.Unknown: return Catalog.GetString ("There was an unknown error."); } return String.Empty; }
// Translated error message strings public static string ErrorMessageFor (StationError error) { switch (error) { case StationError.InvalidService: case StationError.InvalidMethod: return Catalog.GetString ("This service does not exist."); case StationError.AuthenticationFailed: case StationError.SubscriptionError: case StationError.SubscriptionRequired: return Catalog.GetString ("Stations are only available to paying Last.fm subscribers."); case StationError.InvalidFormat: return Catalog.GetString ("This station is not available."); case StationError.InvalidParameters: return Catalog.GetString ("The request is missing a required parameter."); case StationError.InvalidResource: return Catalog.GetString ("The specified resource is invalid."); case StationError.TokenFailure: return Catalog.GetString ("Server error, please try again later."); case StationError.InvalidSessionKey: return Catalog.GetString ("Invalid authentication information, please re-authenticate."); case StationError.InvalidApiKey: return Catalog.GetString ("The API key used by this application is invalid."); case StationError.ServiceOffline: return Catalog.GetString ("The streaming system is offline for maintenance, please try again later."); case StationError.InvalidSignature: return Catalog.GetString ("The method signature is invalid."); case StationError.TokenNotAuthorized: case StationError.ExpiredToken: return Catalog.GetString ("You need to allow Banshee to access your Last.fm account."); case StationError.NotEnoughContent: return Catalog.GetString ("There is not enough content to play this station."); case StationError.NotEnoughMembers: return Catalog.GetString ("This group does not have enough members for radio."); case StationError.NotEnoughFans: return Catalog.GetString ("This artist does not have enough fans for radio."); case StationError.NotEnoughNeighbours: return Catalog.GetString ("There are not enough neighbours for this station."); case StationError.NoPeakRadio: return Catalog.GetString ("This user is not allowed to listen to radio during peak usage"); case StationError.RadioNotFound: return Catalog.GetString ("Radio station not found"); case StationError.ApiKeySuspended: return Catalog.GetString ("This application is not allowed to make requests to the web services"); case StationError.Deprecated: return Catalog.GetString ("This type of request is no longer supported"); case StationError.RateLimitExceded: return Catalog.GetString ("Your IP has made too many requests in a short period, exceeding our API guidelines"); case StationError.Unknown: return Catalog.GetString ("There was an unknown error."); } return String.Empty; }
public void GetStationError() { StationError err = jbc_api.GetStationError(station_id); Trace.WriteLine("STATION ERROR: " + err.ToString()); }