From 7e6de528b44d07a6142229b27504a1410eec7fe9 Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Sun, 19 Jul 2020 03:47:21 +0200 Subject: [PATCH] Update Last.fm error codes --- src/scrobbler/scrobblingapi20.cpp | 63 +++++++++++++++++++++++-------- src/scrobbler/scrobblingapi20.h | 32 ++++++++-------- 2 files changed, 62 insertions(+), 33 deletions(-) diff --git a/src/scrobbler/scrobblingapi20.cpp b/src/scrobbler/scrobblingapi20.cpp index fd8aad05c..71e28a62f 100644 --- a/src/scrobbler/scrobblingapi20.cpp +++ b/src/scrobbler/scrobblingapi20.cpp @@ -428,7 +428,10 @@ QByteArray ScrobblingAPI20::GetReplyData(QNetworkReply *reply) { reply->error() == QNetworkReply::ContentOperationNotPermittedError || reply->error() == QNetworkReply::AuthenticationRequiredError || error_code == ScrobbleErrorCode::InvalidSessionKey || - error_code == ScrobbleErrorCode::AuthenticationFailed + error_code == ScrobbleErrorCode::UnauthorizedToken || + error_code == ScrobbleErrorCode::LoginRequired || + error_code == ScrobbleErrorCode::AuthenticationFailed || + error_code == ScrobbleErrorCode::APIKeySuspended ){ // Session is probably expired Logout(); @@ -994,38 +997,66 @@ void ScrobblingAPI20::Error(const QString &error, const QVariant &debug) { QString ScrobblingAPI20::ErrorString(const ScrobbleErrorCode error) const { switch (error) { + case ScrobbleErrorCode::NoError: + return QString("This error does not exist."); case ScrobbleErrorCode::InvalidService: - return QString("Invalid service - This service does not exist"); + return QString("Invalid service - This service does not exist."); case ScrobbleErrorCode::InvalidMethod: - return QString("Invalid Method - No method with that name in this package"); + return QString("Invalid Method - No method with that name in this package."); case ScrobbleErrorCode::AuthenticationFailed: - return QString("Authentication Failed - You do not have permissions to access the service"); + return QString("Authentication Failed - You do not have permissions to access the service."); case ScrobbleErrorCode::InvalidFormat: - return QString("Invalid format - This service doesn't exist in that format"); + return QString("Invalid format - This service doesn't exist in that format."); case ScrobbleErrorCode::InvalidParameters: - return QString("Invalid parameters - Your request is missing a required parameter"); + return QString("Invalid parameters - Your request is missing a required parameter."); case ScrobbleErrorCode::InvalidResourceSpecified: return QString("Invalid resource specified"); case ScrobbleErrorCode::OperationFailed: - return QString("Operation failed - Something else went wrong"); + return QString("Operation failed - Most likely the backend service failed. Please try again."); case ScrobbleErrorCode::InvalidSessionKey: - return QString("Invalid session key - Please re-authenticate"); + return QString("Invalid session key - Please re-authenticate."); case ScrobbleErrorCode::InvalidApiKey: - return QString("Invalid API key - You must be granted a valid key by last.fm"); + return QString("Invalid API key - You must be granted a valid key by last.fm."); case ScrobbleErrorCode::ServiceOffline: return QString("Service Offline - This service is temporarily offline. Try again later."); + case ScrobbleErrorCode::SubscribersOnly: + return QString("Subscribers Only - This station is only available to paid last.fm subscribers."); case ScrobbleErrorCode::InvalidMethodSignature: - return QString("Invalid method signature supplied"); - case ScrobbleErrorCode::TempError: - return QString("There was a temporary error processing your request. Please try again"); - case ScrobbleErrorCode::SuspendedAPIKey: + return QString("Invalid method signature supplied."); + case ScrobbleErrorCode::UnauthorizedToken: + return QString("Unauthorized Token - This token has not been authorized."); + case ScrobbleErrorCode::ItemUnavailable: + return QString("This item is not available for streaming."); + case ScrobbleErrorCode::TemporarilyUnavailable: + return QString("The service is temporarily unavailable, please try again."); + case ScrobbleErrorCode::LoginRequired: + return QString("Login: User requires to be logged in."); + case ScrobbleErrorCode::TrialExpired: + return QString("Trial Expired - This user has no free radio plays left. Subscription required."); + case ScrobbleErrorCode::ErrorDoesNotExist: + return QString("This error does not exist."); + case ScrobbleErrorCode::NotEnoughContent: + return QString("Not Enough Content - There is not enough content to play this station."); + case ScrobbleErrorCode::NotEnoughMembers: + return QString("Not Enough Members - This group does not have enough members for radio."); + case ScrobbleErrorCode::NotEnoughFans: + return QString("Not Enough Fans - This artist does not have enough fans for for radio."); + case ScrobbleErrorCode::NotEnoughNeighbours: + return QString("Not Enough Neighbours - There are not enough neighbours for radio."); + case ScrobbleErrorCode::NoPeakRadio: + return QString("No Peak Radio - This user is not allowed to listen to radio during peak usage."); + case ScrobbleErrorCode::RadioNotFound: + return QString("Radio Not Found - Radio station not found."); + case ScrobbleErrorCode::APIKeySuspended: return QString("Suspended API key - Access for your account has been suspended, please contact Last.fm"); + case ScrobbleErrorCode::Deprecated: + return QString("Deprecated - This type of request is no longer supported."); case ScrobbleErrorCode::RateLimitExceeded: - return QString("Rate limit exceeded - Your IP has made too many requests in a short period"); - default: - return QString("Unknown error"); + return QString("Rate limit exceeded - Your IP has made too many requests in a short period."); } + return QString("Unknown error."); + } void ScrobblingAPI20::CheckScrobblePrevSong() { diff --git a/src/scrobbler/scrobblingapi20.h b/src/scrobbler/scrobblingapi20.h index 546a358fd..d0d829a52 100644 --- a/src/scrobbler/scrobblingapi20.h +++ b/src/scrobbler/scrobblingapi20.h @@ -88,7 +88,6 @@ class ScrobblingAPI20 : public ScrobblerService { private: enum ScrobbleErrorCode { - Unknown = 0, NoError = 1, InvalidService = 2, InvalidMethod = 3, @@ -100,23 +99,22 @@ class ScrobblingAPI20 : public ScrobblerService { InvalidSessionKey = 9, InvalidApiKey = 10, ServiceOffline = 11, - Reserved12 = 12, + SubscribersOnly = 12, InvalidMethodSignature = 13, - Reserved14 = 14, - Reserved15 = 15, - TempError = 16, - Reserved17 = 17, - Reserved18 = 18, - Reserved19 = 19, - Reserved20 = 20, - Reserved21 = 21, - Reserved22 = 22, - Reserved23 = 23, - Reserved24 = 24, - Reserved25 = 25, - SuspendedAPIKey = 26, - Reserved27 = 27, - Reserved28 = 28, + UnauthorizedToken = 14, + ItemUnavailable = 15, + TemporarilyUnavailable = 16, + LoginRequired = 17, + TrialExpired = 18, + ErrorDoesNotExist = 19, + NotEnoughContent = 20, + NotEnoughMembers = 21, + NotEnoughFans = 22, + NotEnoughNeighbours = 23, + NoPeakRadio = 24, + RadioNotFound = 25, + APIKeySuspended = 26, + Deprecated = 27, RateLimitExceeded = 29, };