banshee r4376 - in trunk/banshee: . src/Libraries/Lastfm/Lastfm
- From: ahixon svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r4376 - in trunk/banshee: . src/Libraries/Lastfm/Lastfm
- Date: Fri, 15 Aug 2008 02:49:58 +0000 (UTC)
Author: ahixon
Date: Fri Aug 15 02:49:58 2008
New Revision: 4376
URL: http://svn.gnome.org/viewvc/banshee?rev=4376&view=rev
Log:
2008-08-15 Alexander Hixon <ahixon gnome org>
* src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs: Only post Now
Playing information to AS servers after all tracks have been uploaded.
Should also fix consecutive Now Playing updates. Closes BGO #524992.
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs
Modified: trunk/banshee/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs
==============================================================================
--- trunk/banshee/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs (original)
+++ trunk/banshee/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs Fri Aug 15 02:49:58 2008
@@ -86,6 +86,7 @@
private int hard_failure_retry_sec = 60;
private HttpWebRequest now_playing_post;
+ private bool now_playing_started;
private string current_now_playing_uri;
private HttpWebRequest current_web_req;
private IAsyncResult current_async_result;
@@ -262,7 +263,7 @@
state = State.WaitingForRequestStream;
current_async_result = current_web_req.BeginGetRequestStream (TransmitGetRequestStream, ts);
if (!(current_async_result.AsyncWaitHandle.WaitOne (TIME_OUT, false))) {
- Hyena.Log.Warning ("Audioscrobbler upload failed",
+ Hyena.Log.Warning ("Audioscrobbler upload failed",
"The request timed out and was aborted", false);
next_interval = DateTime.Now + new TimeSpan (0, 0, RETRY_SECONDS);
hard_failures++;
@@ -507,19 +508,19 @@
uriprefix,
HttpUtility.UrlEncode(artist),
HttpUtility.UrlEncode(title),
- HttpUtility.UrlEncode(album),
+ HttpUtility.UrlEncode(album),
duration.ToString(),
str_track_number,
- mbrainzid);
+ mbrainzid);
+ Console.WriteLine ("Submitting via non-uri handler.");
NowPlaying (uri);
}
private void NowPlaying (string uri)
{
- if (now_playing_post != null) {
- Hyena.Log.DebugFormat ("Now-playing submission already started - aborting.");
- now_playing_post.Abort ();
+ if (now_playing_started) {
+ return;
}
// If the URI begins with #, then we know the URI was created before we
@@ -546,7 +547,13 @@
now_playing_post.Method = "POST";
now_playing_post.ContentType = "application/x-www-form-urlencoded";
now_playing_post.ContentLength = uri.Length;
- now_playing_post.BeginGetResponse (NowPlayingGetResponse, null);
+ if (state == State.Idle) {
+ // Don't actually POST it until we're idle (that is, we
+ // probably have stuff queued which will reset the Now
+ // Playing if we send them first).
+ now_playing_post.BeginGetResponse (NowPlayingGetResponse, null);
+ now_playing_started = true;
+ }
} catch (Exception ex) {
Hyena.Log.Warning ("Audioscrobbler NowPlaying failed",
String.Format ("Exception while creating request: {0}", ex), false);
@@ -580,6 +587,7 @@
} else if (line.StartsWith ("OK")) {
// NowPlaying submitted
Hyena.Log.DebugFormat ("Submitted NowPlaying track to Audioscrobbler");
+ now_playing_started = false;
now_playing_post = null;
current_now_playing_uri = null;
return;
@@ -599,6 +607,7 @@
} else {
// Give up - NowPlaying status information is non-critical.
current_now_playing_uri = null;
+ now_playing_started = false;
now_playing_post = null;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]