[banshee/stable] Support setting an API URL for the audio scrobbler engine



commit 14dd6b5843a909613f337fc685940609b8c5bbac
Author: Aaron Bockover <abockover novell com>
Date:   Thu Apr 23 18:41:45 2009 -0400

    Support setting an API URL for the audio scrobbler engine
    
    This patch allows a user to run 'gconftool-2 --set /apps/banshee-1/plugins/audioscrobbler/api_url --type string http://turtle.libre.fm/' for example to have the AudioScrobbler engine scrobble to the new libre.fm service, which implements the last.fm scrobbling web service API.
    
    Proper multiple account support is needed however to have both last.fm and libre.fm work together. Setting this value is for the elite freedom lovers only right now.
---
 .../AudioscrobblerService.cs                       |    8 ++++++++
 src/Libraries/Lastfm/Lastfm/Account.cs             |    6 ++++++
 .../Lastfm/Lastfm/AudioscrobblerConnection.cs      |    9 ++++++++-
 3 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler/AudioscrobblerService.cs b/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler/AudioscrobblerService.cs
index ced2327..d951b69 100644
--- a/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler/AudioscrobblerService.cs
+++ b/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler/AudioscrobblerService.cs
@@ -82,6 +82,7 @@ namespace Banshee.Lastfm.Audioscrobbler
             if (account.UserName == null) {
                 account.UserName = LastUserSchema.Get ();
                 account.CryptedPassword = LastPassSchema.Get ();
+                account.ScrobbleUrl = LastScrobbleUrlSchema.Get ();
             }
             
             if (LastfmCore.UserAgent == null) {
@@ -316,6 +317,13 @@ namespace Banshee.Lastfm.Audioscrobbler
             "plugins.lastfm", "password_hash", "", "Last.fm password", "Last.fm password (hashed)"
         );
    
+        public static readonly SchemaEntry<string> LastScrobbleUrlSchema = new SchemaEntry<string> (
+            "plugins.audioscrobbler", "api_url",
+            null,
+            "AudioScrobbler API URL",
+            "URL for the AudioScrobbler API (supports turtle.libre.fm, for instance)"
+        );
+
         public static readonly SchemaEntry<bool> EngineEnabledSchema = new SchemaEntry<bool> (
             "plugins.audioscrobbler", "engine_enabled",
             false,
diff --git a/src/Libraries/Lastfm/Lastfm/Account.cs b/src/Libraries/Lastfm/Lastfm/Account.cs
index f95d96c..b5aba1c 100644
--- a/src/Libraries/Lastfm/Lastfm/Account.cs
+++ b/src/Libraries/Lastfm/Lastfm/Account.cs
@@ -66,6 +66,12 @@ namespace Lastfm
             set { password = String.IsNullOrEmpty (value) ? null : value; }
         }
 
+        private string scrobble_url;
+        public string ScrobbleUrl {
+            get { return scrobble_url; }
+            set { scrobble_url = value; }
+        }
+
         public void SignUp ()
         {
             Browser.Open ("http://www.last.fm/join";);
diff --git a/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs b/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs
index b74384e..6df9f83 100644
--- a/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs
+++ b/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs
@@ -385,9 +385,16 @@ namespace Lastfm
             string timestamp = UnixTime();
             string security_token = Hyena.CryptoUtil.Md5Encode
                 (LastfmCore.Account.CryptedPassword + timestamp);
+            
+            string api_url = LastfmCore.Account.ScrobbleUrl;
+            if (String.IsNullOrEmpty (api_url)) {
+                api_url = SCROBBLER_URL;
+            } else {
+                Log.DebugFormat ("Scrobbling to non-standard API URL: {0}", api_url);
+            }
 
             string uri = String.Format ("{0}?hs=true&p={1}&c={2}&v={3}&u={4}&t={5}&a={6}",
-                                        SCROBBLER_URL,
+                                        api_url,
                                         SCROBBLER_VERSION,
                                         CLIENT_ID, CLIENT_VERSION,
                                         HttpUtility.UrlEncode (LastfmCore.Account.UserName),



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]