[banshee] Last.fm: Better scrobbling error handling
- From: Alexander Kojevnikov <alexk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] Last.fm: Better scrobbling error handling
- Date: Sat, 30 Jun 2012 05:44:12 +0000 (UTC)
commit facaffa09a8337fa40a974941803dd1e6e22b529
Author: Alexander Kojevnikov <alexk gnome org>
Date: Sat Jun 30 01:44:06 2012 -0400
Last.fm: Better scrobbling error handling
.../Lastfm/Lastfm/AudioscrobblerConnection.cs | 14 +++++++++++---
src/Libraries/Lastfm/Lastfm/RadioConnection.cs | 6 +++---
2 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs b/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs
index b315887..ca48e96 100644
--- a/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs
+++ b/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs
@@ -246,12 +246,20 @@ namespace Lastfm
}
var response = current_scrobble_request.GetResponseObject ();
- object error_code;
- if (response.TryGetValue ("error", out error_code)) {
- Log.WarningFormat ("Lastfm scrobbling error {0} : {1}", (int)error_code, (string)response["message"]);
+ var error = current_scrobble_request.GetError ();
+ if (error == StationError.ServiceOffline || error == StationError.TemporarilyUnavailable) {
+ Log.WarningFormat ("Lastfm is temporarily unavailable: {0}", (string)response ["message"]);
next_interval = DateTime.Now + new TimeSpan (0, 0, RETRY_SECONDS);
hard_failures++;
state = State.Idle;
+ } else if (error != StationError.None) {
+ // TODO: If error == StationError.InvalidSessionKey,
+ // suggest to the user to (re)do the Last.fm authentication.
+ Log.WarningFormat ("Lastfm scrobbling error {0} : {1}", (int)error, (string)response ["message"]);
+ hard_failures = 0;
+ queue.RemoveRange (0, nb_tracks_scrobbled);
+ queue.Save ();
+ state = State.Idle;
} else {
try {
var scrobbles = (JsonObject)response["scrobbles"];
diff --git a/src/Libraries/Lastfm/Lastfm/RadioConnection.cs b/src/Libraries/Lastfm/Lastfm/RadioConnection.cs
index 63a3d66..d70fadf 100644
--- a/src/Libraries/Lastfm/Lastfm/RadioConnection.cs
+++ b/src/Libraries/Lastfm/Lastfm/RadioConnection.cs
@@ -84,9 +84,9 @@ namespace Lastfm
InvalidSignature,
TokenNotAuthorized,
ExpiredToken,
-
- SubscriptionRequired = 18,
-
+ TemporarilyUnavailable,
+ Login,
+ SubscriptionRequired,
NotEnoughContent = 20,
NotEnoughMembers,
NotEnoughFans,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]