After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 580743 - Rhythmbox doesn't support the newest audioscrobbler api (libre.fm too)
Rhythmbox doesn't support the newest audioscrobbler api (libre.fm too)
Status: RESOLVED FIXED
Product: rhythmbox
Classification: Other
Component: last.fm
HEAD
Other Linux
: Normal enhancement
: ---
Assigned To: RhythmBox Maintainers
RhythmBox Maintainers
: 563137 579538 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2009-04-29 12:58 UTC by Matt N
Modified: 2009-05-27 22:57 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Make it work, but not well (19.38 KB, patch)
2009-04-29 13:02 UTC, Matt N
none Details | Review
Audioscrobbler 1.2 support (20.74 KB, patch)
2009-05-02 17:30 UTC, Matt N
none Details | Review
Actually good patch (21.82 KB, patch)
2009-05-02 21:28 UTC, Matt N
reviewed Details | Review
w/ fixes Johnathan suggested (21.60 KB, patch)
2009-05-03 18:09 UTC, Matt N
none Details | Review
fixes based on libre.fm folk and get rid of the old timestamp format (22.50 KB, patch)
2009-05-03 21:18 UTC, Matt N
none Details | Review
one debug output fix (22.77 KB, patch)
2009-05-03 21:22 UTC, Matt N
reviewed Details | Review
FIxes as per mailing list (23.09 KB, patch)
2009-05-04 21:20 UTC, Matt N
committed Details | Review

Description Matt N 2009-04-29 12:58:42 UTC
RB doesn't yet support the new protocols for talking to audioscrobbler, which is also the protocol for talking to libre.fm
Comment 1 Matt N 2009-04-29 13:02:10 UTC
Created attachment 133555 [details] [review]
Make it work, but not well

libsoup can't seem to handle the incomplete packets that audioscrobbler responds to posts with.  This patch will work, but error code 7 (connection ended unexpectedly) is treated as success.
Comment 2 Jonathan Matthew 2009-04-29 14:13:59 UTC
*** Bug 579538 has been marked as a duplicate of this bug. ***
Comment 3 Jonathan Matthew 2009-05-02 02:07:28 UTC
The actual problem here is that we're sending requests that look like HTTP 0.9, as the post URI has a newline at the end.  This is happening because we're parsing the handshake response badly.  Change the second parameter to g_strsplit() in rb_audioscrobbler_parse_response to 0 and everything works properly.
Comment 4 Matt N 2009-05-02 17:30:19 UTC
Created attachment 133814 [details] [review]
Audioscrobbler 1.2 support

This works fine.  Libre.fm seems down at the moment, so, I can't confirm it there, but, it works for last.fm, and they're supposed to be the same anyway.
Comment 5 Matt N 2009-05-02 21:28:07 UTC
Created attachment 133830 [details] [review]
Actually good patch

Adds nowplaying to the idle callback so that we don't flood the server if we get track-skipping-happy.  Should fix everything, including the missing unref in the last patch.
Comment 6 Jonathan Matthew 2009-05-03 10:30:46 UTC
This looks pretty good, just a few minor things that need to be fixed up:

+	if (1==0) {//rhythmdb_entry_get_entry_type(rb_entry) == rhythmdb_entry_type_get_by_name (db, "lastfm-track")) {
+		as_entry->source = g_strdup ("L");
+	} else {
+		as_entry->source = g_strdup ("P");
+	}
+
+// Not implemented yet
+//		case RHYTHMDB_STREAM_TYPE:
+//			as_entry->source = g_strdup ("R");

Are you intending to implement this?  If not, remove the commented bits and the if (1==0) and add a comment explaining what needs to be done.  Also, just as a matter of consistency, we don't use c++ style '//' comments.

-	encoded->album = soup_uri_encode (entry->album, 
+	encoded->album = soup_uri_encode (entry->title,

This doesn't look right..

-	strftime (encoded->timestamp, 30, SCROBBLER_DATE_FORMAT, 
-		  gmtime (&entry->play_time));
+	//	strftime (encoded->timestamp, 30, SCROBBLER_DATE_FORMAT, gmtime (&entry->play_time));

If you're going to remove some code, just remove it.

+		} else if (g_str_has_prefix (breaks[0], "BADAUTH")) {
+			rb_debug ("Bad authorization"); // User needs to fix credentials
+			audioscrobbler->priv->status = BADAUTH;
+			audioscrobbler->priv->status_msg = g_strdup ("Bad username or password\n");

We don't need to set status_msg here, the status code already describes the error condition.

+		} else if (g_str_has_prefix (breaks[0], "BADTIME")) {
+			rb_debug ("Bad timestamp"); // timestamp not close enough to server
+

This looks like an error case we should report to the user rather than silently failing.

+	} else if  (msg->status_code == 7) {
+		audioscrobbler->priv->status = STATUS_OK; //Deal with libsoup not being able to deal with http w/o headers.

This shouldn't be here any more since we worked out why the server was sending headerless responses.

Comment 7 Matt N 2009-05-03 14:30:17 UTC
Good catches!

The 'not implemented yet' bit is something that will be in the protocol, but, the API spec says isn't implemented yet.  I figured I'd have the code there for when it is implemented, but, right now that section pretty much just needs P's.

I'll fix these later today, thanks moch.
Comment 8 Matt N 2009-05-03 18:09:32 UTC
Created attachment 133868 [details] [review]
w/ fixes Johnathan suggested

The only thing I didn't change is that there is still the comment about the source parameter which isn't fully implemented on last.fm's side yet.
Comment 9 Matt N 2009-05-03 21:18:57 UTC
Created attachment 133879 [details] [review]
fixes based on libre.fm folk and get rid of the old timestamp format
Comment 10 Matt N 2009-05-03 21:22:08 UTC
Created attachment 133880 [details] [review]
one debug output fix
Comment 11 Jonathan Matthew 2009-05-04 01:37:46 UTC
A couple more things..

rb_audioscrobbler_entry_save_to_string should use 'i' not 'I' for the timestamp (same format), and rb_audioscrobbler_entry_load_from_string should parse 'i' and 'I' the same way (strtol is more reliable than atoi).

'I' was a format extension we added to fix some parsing/timezone problems (bug 508895), but since the official format uses unix style timestamps now, we don't need to use it any more.  We still need to parse it for backwards compatibility, though.

The play time we submit is actually supposed to be the time the song started playing, not the time we decided to submit it, so we should record a timestamp when the song starts, in rb_audioscrobbler_song_changed_cb rather than setting it in maybe_add_current_song_to_queue.

+		status = _("Computer's time isn't close enough to server's");

I'm not sure how best to say this, but I don't think we need to talk about it being different to the server's time, we should just say something like "clock is not set correctly".
Comment 12 Matt N 2009-05-04 21:20:33 UTC
Created attachment 133971 [details] [review]
FIxes as per mailing list

Changed the error message to the one on the mailing list.  Fixed the formatting import.
Comment 13 Jonathan Matthew 2009-05-05 03:41:53 UTC
I fixed up a few more things (a few error messages and implementing the handshake delay as recommended in the protocol spec, mostly), added some notes about determining the playback source, and commited it.  Thanks for working on this.
Comment 14 Jonathan Matthew 2009-05-27 22:57:20 UTC
*** Bug 563137 has been marked as a duplicate of this bug. ***