[rhythmbox] audioscrobbler: fix radio parsing to work with changed Last.fm tune response
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] audioscrobbler: fix radio parsing to work with changed Last.fm tune response
- Date: Tue, 21 Sep 2010 10:55:03 +0000 (UTC)
commit a71e38269863ecc8b10c8cc5977eeefd7b0383ce
Author: Jamie Nicol <jamie thenicols net>
Date: Thu Aug 12 17:27:49 2010 +0100
audioscrobbler: fix radio parsing to work with changed Last.fm tune response
.../rb-audioscrobbler-radio-source.c | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c b/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c
index 9a9a067..7a21aa1 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c
+++ b/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c
@@ -722,12 +722,13 @@ tune_response_cb (SoupSession *session,
JsonObject *root_object;
root_object = json_node_get_object (json_parser_get_root (parser));
- if (json_object_has_member (root_object, "station")) {
- JsonObject *station_object;
-
- station_object = json_object_get_object_member (root_object, "station");
- /* TODO: do something fun with this information */
-
+ /* Noticed on 2010-08-12 that Last.fm now responds with a "{ status:ok }"
+ * instead of providing a "station" object with various properties.
+ * Checking for a "station" or "status" member ensures compatibility with
+ * both Last.fm and Libre.fm.
+ */
+ if (json_object_has_member (root_object, "station") ||
+ strcmp (json_object_get_string_member (root_object, "status"), "ok") == 0) {
rb_debug ("tune request was successful");
/* get the playlist */
@@ -770,6 +771,10 @@ tune_response_cb (SoupSession *session,
source->priv->is_busy = FALSE;
}
+ } else {
+ rb_debug ("unexpected response from tune request: %s", msg->response_body->data);
+ display_error_info_bar(source, _("Error tuning station: unexpected response"));
+ source->priv->is_busy = FALSE;
}
} else {
rb_debug ("invalid response from tune request: %s", msg->response_body->data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]