GNOME Bugzilla – Bug 541227
Replacing Lastfm API with the new 2.0 API implementation
Last modified: 2010-02-01 02:37:50 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.
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.
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.
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..
*** Bug 588062 has been marked as a duplicate of this bug. ***
As mentioned in bug 588062, the old radio API has been shut down making all Last.fm radio streams unplayable.
No longer an enhancement; bumping severity.
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.
(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.
(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.
(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)
(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
*** Bug 588522 has been marked as a duplicate of this bug. ***
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.
Any update on this?
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 ;)
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.
Not working here.. banshee still fails to receive informations for any station
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
(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 ?
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?
(In reply to comment #20) You should run ./autogen.sh after switching to the branch, because I've modified a Makefile.am.
Created attachment 142541 [details] Backtrace
Ok thank you. It compiles now, but I crashes while trying to connect to lastfm. (Some sort of timeout?) The backtrace is attached.
Ok, the crash was related to a problem with my system proxy. The patch now seems to work fine. :-)
*** Bug 595617 has been marked as a duplicate of this bug. ***
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.
Looking at http://www.last.fm/api/show?service=256 it looks like there is no session key being passed to last.fm.
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.
(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.
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.
*** Bug 600480 has been marked as a duplicate of this bug. ***
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?
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?
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.
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.
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
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.
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 !
Can only subscribers of last.fm now stream radio stations via Banshee?