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 541227 - Replacing Lastfm API with the new 2.0 API implementation
Replacing Lastfm API with the new 2.0 API implementation
Status: RESOLVED FIXED
Product: banshee
Classification: Other
Component: Last.fm
git master
Other Linux
: Normal major
: 1.x
Assigned To: Banshee Maintainers
: 588062 588522 595617 600480 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2008-07-02 11:30 UTC by Peter de Kraker
Modified: 2010-02-01 02:37 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Backtrace (6.09 KB, text/x-log)
2009-09-05 16:09 UTC, Patrick Niklaus
  Details
Port to the Last.fm radio API 2.0 (58.11 KB, patch)
2009-11-08 13:42 UTC, Bertrand Lorentz
committed Details | Review

Description Peter de Kraker 2008-07-02 11:30:25 UTC
Lastfm has upgraded their API implementation to 2.0.

See: http://www.last.fm/api/intro

It makes use of a API key, so a Banshee key will be needed. The 1req/second rule is however not based on they key, so we don't need a API key for every user.

Since the old api keeps existing, it is not required to move to 2.0, but it's a good idea to do some day.
Comment 1 Warren Seine 2008-11-19 04:05:12 UTC
I'm willing to do it. Especially because I want the "Now playing" feature added in the new API.

If someone is already working on it, please say it.
Comment 2 Warren Seine 2008-11-20 08:14:19 UTC
Bad news, Last.fm is currently experiencing licensing issues. They won't provide access to the radio in the new API unless accepting a commercial agreement and will soon shutdown the old API access (documentation is already offline). Radio will only be avaiblable through their embedded player. In the new API, there is a "radio.tune" web service method, but it requires a special application key. Sounds like someone from the Banshee team will have to send an email to partners <at> last.fm to obtain such a key. User comments show that it won't be free. Sad, really sad news. Business and success destroy all the good initiatives.

Source: http://www.last.fm/group/Last.fm+Web+Services/forum/21604/_/453541

It completely breaks the original idea of having only one API (a same session for radio listening, scrobbling, tagging, etc...). I'm wondering if it is worth trying to implement the new protocol since we have to keep the first to support radio streaming.
Comment 3 Sebastian Krämer 2009-03-25 15:09:23 UTC
More bad news on the way: http://blog.last.fm/2009/03/24/lastfm-radio-announcement (this is not really API-2 related but announces further restriction of the radio in general, regardless the player streaming it).

Would love however to see the "Now playing.." feature.

I think amarok(2?) has it and still allows streaming radio? Not sure..
Comment 4 Alexander Kojevnikov 2009-07-08 13:23:12 UTC
*** Bug 588062 has been marked as a duplicate of this bug. ***
Comment 5 Alexander Kojevnikov 2009-07-08 13:25:17 UTC
As mentioned in bug 588062, the old radio API has been shut down making all Last.fm radio streams unplayable.
Comment 6 Andrew Conkling 2009-07-14 13:07:30 UTC
No longer an enhancement; bumping severity.
Comment 7 Warren Seine 2009-07-14 13:24:05 UTC
I think we can safely delete the radio part of Last.fm (1. because it's not free anymore, 2. because the radio access system has changed).

I don't know if it's possible, but Last.fm subscribers should be able to listen to the radio (by entering their credentials in some configuration box), maybe as a plugin.
Comment 8 Alexander Kojevnikov 2009-07-14 14:11:48 UTC
(In reply to comment #7)
> I think we can safely delete the radio part of Last.fm (1. because it's not
> free anymore, 2. because the radio access system has changed).
>

Last.fm radio is still free for US, UK and DE.
 
> I don't know if it's possible, but Last.fm subscribers should be able to listen
> to the radio (by entering their credentials in some configuration box), maybe
> as a plugin.
> 

That's already how it works. There's a login box; and it's implemented as a plugin.
Comment 9 Warren Seine 2009-07-14 16:08:51 UTC
(In reply to comment #8)
> Last.fm radio is still free for US, UK and DE.

OK. That's so unfair :/

> > I don't know if it's possible, but Last.fm subscribers should be able to listen
> > to the radio (by entering their credentials in some configuration box), maybe
> > as a plugin.
> > 
> 
> That's already how it works. There's a login box; and it's implemented as a
> plugin.

OK. So just ignore my previous mail.
Comment 10 Marcel de Vries 2009-07-14 16:33:33 UTC
(In reply to comment #9)
> > Last.fm radio is still free for US, UK and DE.
> 
> OK. That's so unfair :/
> 

As far as I know; US, UK and DE have commercials (or something a like).

Then again, why remove it completely if it isn't free any more? I think a large portion of banshee's user base, DOES/DID use the Last.fm functionality. Maybe less since it became a paying service. But if you'd removed the plugin entirely, you COULD potentially lose quite a lot of users. (IMHO)
Comment 11 Andrew Conkling 2009-07-14 19:40:20 UTC
(In reply to comment #9)
> (In reply to comment #8)
> > Last.fm radio is still free for US, UK and DE.
> 
> OK. That's so unfair :/

Just for context, Last.fm's reasoning (whether or not it's fair/justified/etc.): http://blog.last.fm/2009/03/30/radio-announcement-revisited
Comment 12 Alexander Kojevnikov 2009-07-15 07:50:38 UTC
*** Bug 588522 has been marked as a duplicate of this bug. ***
Comment 13 Björn van den Heuvel 2009-07-15 08:20:26 UTC
This is a reply to a few of the earlier messages.

I am a paying Last.FM subscriber from The Netherlands and an avid user of banshee.

First of all: I can confirm that Amarok can play Last.FM streams for paying Last.FM subscribers.

I've taken a quick look at the code behind the Last.FM plugin in banshee. From my point of view the only thing that needs to be done is authenticate using an API key before starting a stream and then calling the "tune" method.

I requested an API key (and got it!) and will try to botch up a patch that does exactly that: authenticate using API 2.0 before streaming.

I don't know if I'll have any success; this will be my first Mono experiment.
Comment 14 Rasmus Steinke 2009-07-26 16:17:01 UTC
Any update on this?
Comment 15 Bertrand Lorentz 2009-08-30 21:07:53 UTC
I've started working on this in the "lastfm-api-2.0" branch of my gitorious clone :
http://gitorious.org/~bl8/banshee/bl8-clone

What's working :
- Now Playing (nothing changed, was always working for me)
- Authentication
- Radio stations
- Love/Ban tracks

What needs work :
- The Lasfm.Data stuff is still using the 1.0 feeds. Still works for now.

- Error handling and reporting. Currently most errors returned by the Last.fm API are ignored or cause a crash

- User interaction could be nicer : with the new authentication system, you need to authorize Banshee to access your Last.fm account. In order to do that :
  1/ Go to Tools > Last.fm > Configure...
  2/ Click on "Authorize for Last.fm". This will open a page in your web browser
  3/ In that page, grant access to Banshee
  4/ Go back to banshee and click on "Save and Log In"

Feedback and help is welcome, preferably in the form of merge requests on gitorious ;)
Comment 16 Chris Boyle 2009-09-02 13:41:33 UTC
Re: comment 15: Works for me, thanks! :-) The one tiny problem I'm seeing so far is that if I accidentally try to seek a stream (I should not be able to, that's bug #571242) Last.fm starts failing to get new tracks for all stations, and I need to restart Banshee to fix it.
Comment 17 Rasmus Steinke 2009-09-04 08:24:24 UTC
Not working here.. banshee still fails to receive informations for any station
Comment 18 Rasmus Steinke 2009-09-04 08:30:15 UTC
The error is: [Warn  10:29:05.699] Error Loading Last.fm Station - The remote server returned an error: (403) Forbidden.

Banshee IS listed in my last.fm profile tho
Comment 19 Bertrand Lorentz 2009-09-04 15:58:50 UTC
(In reply to comment #16)
> Re: comment 15: Works for me, thanks! :-) The one tiny problem I'm seeing so
> far is that if I accidentally try to seek a stream (I should not be able to,
> that's bug #571242) Last.fm starts failing to get new tracks for all stations,
> and I need to restart Banshee to fix it.

I'm also seeing weird behavior after seeking a stream. I'll try to see if we can force the Last.fm stream to be considered not seekable.

(In reply to comment #18)
> The error is: [Warn  10:29:05.699] Error Loading Last.fm Station - The remote
> server returned an error: (403) Forbidden.
> 
> Banshee IS listed in my last.fm profile tho

Rasmus, are you a Last.fm subscriber ? Last.fm radios only works for subscribers.
What do you mean by "Banshee is listed in my profile" ? In the "Your Third Party Applications" page ?
Comment 20 Patrick Niklaus 2009-09-05 12:34:34 UTC
For some reason, your branch fails do compile here.

  MCS   ../../../bin/Lastfm.dll
./Lastfm/RadioConnection.cs(189,21): error CS0246: The type or namespace name `LastfmRequest' could not be found. Are you missing a using directive or an assembly reference?
./Lastfm/RadioConnection.cs(222,17): error CS0246: The type or namespace name `LastfmRequest' could not be found. Are you missing a using directive or an assembly reference?
./Lastfm/RadioConnection.cs(324,13): error CS0246: The type or namespace name `LastfmRequest' could not be found. Are you missing a using directive or an assembly reference?
Compilation failed: 3 error(s), 0 warnings

I really don't get that error. LastfmRequest seems to be located correctly in Lastfm/LastfmRequest.cs in the Lastfm namespace.

Has anyone here an idea what is wrong?
Comment 21 Bertrand Lorentz 2009-09-05 13:56:47 UTC
(In reply to comment #20)

You should run ./autogen.sh after switching to the branch, because I've modified a Makefile.am.
Comment 22 Patrick Niklaus 2009-09-05 16:09:52 UTC
Created attachment 142541 [details]
Backtrace
Comment 23 Patrick Niklaus 2009-09-05 16:11:36 UTC
Ok thank you. It compiles now, but I crashes while trying to connect to lastfm. (Some sort of timeout?)

The backtrace is attached.
Comment 24 Patrick Niklaus 2009-09-11 15:25:49 UTC
Ok, the crash was related to a problem with my system proxy. The patch now seems to work fine. :-)
Comment 25 Bertrand Lorentz 2009-09-18 18:44:25 UTC
*** Bug 595617 has been marked as a duplicate of this bug. ***
Comment 26 Alex Bennée 2009-10-14 18:41:50 UTC
Just been prompted by the moaning on launchpad so gave your test branch a spin. Got a 403 warning when trying "stations like". Has the API been changed again?


[Debug 19:39:17.262] Successfully tuned Last.fm to lastfm://artist/Freeform Five/similarartists
[New Thread 0x2aaac0a44950 (LWP 22235)]
[Debug 19:39:17.518] Lastfm GET : http://ws.audioscrobbler.com/2.0/?method=radio.getPlaylist&api_key=344e9141fffeb02201e1ae455d92ae9f&raw=true&sk=&api_sig=0f5bcc0278e343696b69d077a42a20ee
[New Thread 0x2aaac2c1d950 (LWP 22236)]
[Warn  19:39:17.872] Error Loading Last.fm Station - The remote server returned an error: (403) Forbidden.
Comment 27 Alex Bennée 2009-10-14 18:43:49 UTC
Looking at http://www.last.fm/api/show?service=256 it looks like there is no session key being passed to last.fm.
Comment 28 Gabriel Burt 2009-10-27 20:17:39 UTC
Bulk changing the assignee to banshee-maint@gnome.bugs to make it easier for people to get updated on all banshee bugs by following that address.  It's usually quite apparent who is working on a given bug by the comments and/or patches attached.
Comment 29 Bertrand Lorentz 2009-11-02 14:05:22 UTC
(In reply to comment #27)
> Looking at http://www.last.fm/api/show?service=256 it looks like there is no
> session key being passed to last.fm.

Alex, did you authorize Banshee to access your Last.fm account, as described in comment #15 ?
If you didn't, that would explain why the sk parameter is empty in your query.
Comment 30 Bertrand Lorentz 2009-11-02 21:06:04 UTC
I've done some additional work on this. It's still in the "lastfm-api-2.0" branch of my gitorious clone :
http://gitorious.org/~bl8/banshee/bl8-clone

Error handling is now much better, it should be on par with what we had before.

I decided not to change anything in the Lastfm.Data stuff : all of the 1.0 feeds are still working, and the feeds added in 2.0 don't have a lot of interesting stuff. (detailed analysis available on request).

The user experience for the authentication process is still the same as described in comment #15. Suggestions welcome.

In a few days, I'll try to work my changes into some nice patches and post them to this bug for review.
Comment 31 Michael Martin-Smucker 2009-11-02 21:51:21 UTC
*** Bug 600480 has been marked as a duplicate of this bug. ***
Comment 32 Alex Bennée 2009-11-03 21:44:18 UTC
Apologies I'd missed the need for the step described in #15. I did get a crash the first time I clicked Save&Login but unfortunately didn't save the backtrace.

It certainly seems to be streaming tag radio fine now. I shall have a play with the last.fm features and report any problems I find.

What needs doing before it's merged upstream?
Comment 33 Alex Bennée 2009-11-03 21:57:40 UTC
I seem to be getting SIGSEGV's on track changes however the backtrace doesn't really say much (I assume it's in generated code). Is there any additional loggin output I can generate?
Comment 34 Alex Bennée 2009-11-04 08:12:35 UTC
Apologies again for the noise. Banshee doesn't seem to like running the last.fm streams under "make gdb". I can confirm that "make run" testing shows last.fm performing as it should.
Comment 35 Bertrand Lorentz 2009-11-08 13:42:56 UTC
Created attachment 147214 [details] [review]
Port to the Last.fm radio API 2.0

This patch is the diff between master and my lastfm-api-2.0 branch.
You need to apply this to the latest git master, because it needs some recent fixes and additions.

No significant changes since my last comment, only small clean-ups and fixes.

Reviews and comments are welcome.
Comment 36 Gabriel Burt 2009-11-09 06:58:47 UTC
Review of attachment 147214 [details] [review]:

This looks really good, Bertrand.  I'm fine with this being committed as-is, and building on it.  Hope you don't mind the lots of nit-picky things in my review.  :)

::: src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler/AudioscrobblerService.cs
@@ +105,3 @@
             LastfmCore.Account.Updated += delegate (object o, EventArgs args) {
                 actions["AudioscrobblerVisitAction"].Sensitive = LastfmCore.Account.UserName != null 
+                    && LastfmCore.Account.UserName != String.Empty;

Might as well use String.IsNullOrEmpty here

::: src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/StationType.cs
@@ +86,3 @@
             "user/{0}/recommended/100",
             "lastfm-recommended",
+            true

All these station types are subscriber only now?  What types aren't?

::: src/Libraries/Lastfm/Lastfm/Account.cs
@@ +100,3 @@
+            get_token.Send ();
+            
+            Hyena.Json.JsonObject response = get_token.GetResponseObject ();

'var' for this and other variables can make more readable code :)

::: src/Libraries/Lastfm/Lastfm/LastfmRequest.cs
@@ +73,3 @@
+
+        private string method;
+        public string Method {

can make this (and following) public string Method { get; set; }

@@ +222,3 @@
+
+#region HTTP helpers
+        private Stream Get (string uri)

Add newline before this line

::: src/Libraries/Lastfm/Lastfm/RadioConnection.cs
@@ +217,3 @@
                     return null;
                 } catch (Exception e) {
+                    string body = "Unable to get response";

You can set this to null here, and below where you use it in the Log.Warning you can do body ?? "Unable..."

@@ +277,3 @@
+                    return Catalog.GetString ("This station is not available.");
+                case StationError.InvalidParameters:
+                    return Catalog.GetString ("The request is missing a required parameter.");

This isn't a nice error to show to users, since 1) it's not clear what it really means 2) they can't do anything about it

Let's try to avoid sending them cryptic, not useful msgs :)

@@ +292,3 @@
+                case StationError.TokenNotAuthorized:
+                case StationError.ExpiredToken:
+                    return Catalog.GetString ("You need to allow Banshee to access your Last.fm account.");

For this and InvalidSessionKey, would be cool to notice it's this error and add an action to the SetStatus message to authenticate
Comment 37 Bertrand Lorentz 2009-11-09 20:52:20 UTC
Review of attachment 147214 [details] [review]:

I'll file a new bug about improving the error notification, all the other comments have been taken into account.

::: src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/StationType.cs
@@ +86,3 @@
             "user/{0}/recommended/100",
             "lastfm-recommended",
+            true

I was wrong about that : according to http://www.last.fm/help/faq?category=Getting+Started#339 all those stations are still available for non-subscribers in the US, UK and Germany.
I'll revert this, so that these lucky ones can access them, others will see an error message.
Comment 38 Bertrand Lorentz 2009-11-09 20:56:51 UTC
I'm closing this, as the patch has been committed to git master.

Please file new bugs for any issue related to Last.fm.

Thanks to everybody involved !
Comment 39 Alex Lancaster 2010-02-01 02:37:50 UTC
Can only subscribers of last.fm now stream radio stations via Banshee?