Forum » Controlling a Last.fm Stream

Official Webservice Documentation

 
    • RJ said...
    • Alumni
    • 14 Jan 2005, 10:23

    Official Webservice Documentation

    [Last.fm web service is outdated following relaunch]

    Information wants to be beer.
    Edited by Russ on 15 Aug 2005, 06:20
    • kentaro said...
    • User
    • 14 Jan 2005, 12:23

    There are some problems in handling 'ban' command and 'Change station'

    I'm very glad for your great new Last.fm Radio webservice. Then, I'll report some problems following.

    • When the 'ban' command sent, the webservice always respond 'FAILED' in spite of the right query. On the other hand, 'skip' and 'love' commands seem to work well.


    • It seems that there are some problems in handling 'Changing station'. Any request turns out with getting a error message like this:


    • Notice: Undefined index: user in /web/site/ws.audioscrobbler.com/ws.audioscrobbler.com/php/radio/tune.php on line 5
      Assertion Failed!

      assert("is_string($name)") in /web/site/www.audioscrobbler.com/core/user.php line 457
      user::getbyname("") in /web/site/ws.audioscrobbler.com/ws.audioscrobbler.com/php/radio/tune.php line 5

    Edited by kentaro on 14 Jan 2005, 14:25
    • RJ said...
    • Alumni
    • 14 Jan 2005, 12:52
    Hi,

    Okay.. think both those problems are fixed now.
    I havn't made a client so my testing is rather lame.

    I'll watch the forums, but feel free to pester me on IRC if things are still broken.. Should get a fix quicker that way.
    irc.phasenet.co.uk #audioscrobbler

    RJ

    Information wants to be beer.
    • snej said...
    • User
    • 14 Jan 2005, 15:52

    GET vs POST

    I noted yesterday in email to RJ that the commands that have side-effects (love, skip, ban, change station) should use POST, not GET. He has graciously agreed and will be changing the service to support POST. Thanks, RJ! You're making the Web safe for pedants like me =)

    Here are my supporting arguments from my email, for those curious why it's incorreect to use GET for these commands:

    This is a misuse of HTTP. The GET method is defined as:
    (a) side-effect-free, aka "safe" (i.e. makes no changes on the server,
    just returns the requested data)
    (b) idempotent (i.e. multiple calls are equivalent to a single call)

    The last.fm commands don't meet either of those definitions, since they
    all have significant side effects (including modifying the user's
    persistent state on the server) and the skip command will of course
    skip multiple tracks if called more than once. (However, the
    get-session and now-playing commands are appropriate as GET.)

    You could easily fix this by making those commands be POSTs instead.
    POST is intended for exactly this kind of ad hoc command-sending
    behavior. You can continue to specify the parameters in the URL, or put
    them in the request body as a regular form-based POST would.

    This isn't just nit-picking; the semantics of GET are pretty crucial to
    the way various parts of the Web infrastructure work. Proxy servers
    rely on this to implement caching correctly, and the "sandboxes" of
    interpreted languages like Java and JavaScript can impose extra
    security restrictions on POSTs. Also note that clicking a hyperlink can
    only issue a GET, which theoretically makes it safe from nasty
    surprises for the user.

    • snej said...
    • User
    • 15 Jan 2005, 01:11

    QuickTime won't play the stream

    I've now written a tiny test app for OS X. It's able to create a session and get the stream URL, but when I pass the URL to QuickTime, it hangs forever instead of playing the audio. From the stack, it looks like QT thinks the URL is a file to be downloaded and is trying to fetch all the data before playing it. In other words, QuickTime isn't recognizing your stream as a Shoutcast-style MP3 stream.

    When I look at the server response with the 'curl' tool, I see that you are sending back regular HTTP headers with a Content-Type of audio/mpeg and no Content-Length. By contrast, other MP3 streams (I checked SomaFM and Philosomatika) send back Shoutcast-style headers (which all start with "icy-"). It looks as though QuickTime uses the Shoutcast headers to detect a stream. (However, iTunes can play the stream just fine. Go figure.)

    I'm sort of stuck now. Is it possible you can change the HTTP response headers to be more Shoutcast-like?

  • Simple example script

    Here's a trivial perl script which plays the stream and supports skipping tracks. You'll need to search-and-replace USERNAME and PASSWORD:

    http://caesious.beasts.org/~chris/tmp/20050116/playomatic

    Might be handy as an example or for those like me who prefer, uh, minimal user interfaces.

    Edited by chrislightfoot on 16 Jan 2005, 20:23
  • some python 'bindings'

    I written some python bindings to control last.fm streams.
    Still very new code, so bug reports would be appreciated.

    Anyone interested can get it at: http://perry.freeshell.org/code/

  • a Common Lisp client lib & rudimentary CLIM front-end

    I've written a CLIM front-end (and, obviously, common lisp "bindings") for your web services. It was all pretty easy (330 lines of code, in all). I'm very impressed by the simplicity of the protocol. Thanks for making this service available (and for keeping it simple (-:)

    Find the code at http://boinkor.net/lisp/clim-lastfm-0.0.tar.gz

    (edit: stripped the broken code.

    Edited by antifuchs on 17 Jan 2005, 23:12
    • superic said...
    • User
    • 18 Jan 2005, 02:56
    Anyone interested in my C# wrappers for the ws?

    • superic said...
    • User
    • 18 Jan 2005, 02:57
    Anyone interested in my C# wrappers for the ws?

    EDIT: Oops I hit "back" and it reposted :-( I'm such a n00b

    Edited by superic on 18 Jan 2005, 05:20
    • sneeka2 said...
    • User
    • 21 Jan 2005, 21:10

    Konfab widget

    I'm currently developing a (hopefully) nice front-end in form of a Konfabulator widget. Which brings me to this: Why are the artist, album etc. URLs currently pointing to http://test.audioscrobbler.com?

    • superic said...
    • User
    • 21 Jan 2005, 21:14
    A konfab widget would rule! I would use that on my Mac :-D

    • sneeka2 said...
    • User
    • 21 Jan 2005, 22:34
    I should have a working beta by the end of the weekend... :)

  • PHP

    What PHP function(s) would I use make the commands? XML-RPC? Any suggestions would be greatly apreciated.

    ~mike

    • superic said...
    • User
    • 22 Jan 2005, 23:55

    Re: PHP

    Quoth michaelbach:
    What PHP function(s) would I use make the commands? XML-RPC? Any suggestions would be greatly apreciated.

    ~mike


    Take a look at this, it may help: http://xmlrpc.usefulinc.com/php.html

  • Re: Konfab widget

    Quoth sneeka2:
    I'm currently developing a (hopefully) nice front-end in form of a Konfabulator widget. Which brings me to this: Why are the artist, album etc. URLs currently pointing to http://test.audioscrobbler.com?


    nice sneeka!

    [edit] dajm, konfabulator is the coolest tool i've seen in ages :)

    Edited by litemotiv on 23 Jan 2005, 11:17
    • alex said...
    • User
    • 25 Jan 2005, 15:20

    Session timeouts?

    How quickly does the 32 char session token last if I don't use it, as a plan for my client to remeber it once I've loged in once.

    Sweet interface btw, already got my client running..

    • flippet said...
    • User
    • 25 Jan 2005, 22:02

    Re: Session timeouts?

    Quoth alex:
    How quickly does the 32 char session token last if I don't use it, as a plan for my client to remeber it once I've loged in once.

    The response from requesting a session tries to set a cookie which expires after 24 hours, so I'm guessing that's it.

    I haven't tried restarting a session after that period has expired...

    Phil

    "Cattle Prods solve most of life's little problems."
    • jtjm said...
    • User
    • 17 Feb 2005, 15:34

    Updated playomatic

    playomatic has come on a little since Chris' first post. It now supports all the commands, station changing, etc and is rather more robust. Run perldoc over it for instructions:

    http://www.xenoclast.org/tmp/playomatic

    Edited by jtjm on 17 Feb 2005, 15:43
    • RNR said...
    • Alumni
    • 5 Mar 2005, 21:02

    Re: Re: Session timeouts?

    Quoth flippet:
    The response from requesting a session tries to set a cookie which expires after 24 hours, so I'm guessing that's it.

    the session is valid until you logout, or your browser thinks your cookie is not valid anymore. as far as I know the cookie is valid forever, so it depends on your browser, if it gets deleted in some cleanup.

    again, the session is valid unitl logout/login. however the WS returns a new session at every request. hmm. aha it uses login with the details provided no matter what.

    I have changed that now. If a valid session exists because the user has logged in and not logged out yet on the website the getsession.php returns the current session, or logs in if nothing is there.

    now for storing the session on the client, which i was also puzzling about, writing a forefox extension at the moment, not sure yet.

    if you stored it you have no way of checking if it is still valid, unless you check all the time which is overdoing it a bit. let's see if I can figure something out, I will let you know.

    Both kinds of music: Rock & Roll - SFTRI
    • bic2k said...
    • User
    • 9 Mar 2005, 21:52

    Getting PHP error on command=love

    Hey,

    I'm just testing my library and got the following error:

    post url: http://wsdev.audioscrobbler.com/radio/control.php/session=ff&command=love
    raw: <br />

    raw: <b>Notice</b>: Undefined variable: STREAM_PORT in <b>/web/site/www.audioscrobbler.com/lastfm/streamcommands.php</b> on line <b>26</b><br />

    raw: Unable to open streamserver control socket: No such file or directory<br />

    raw: <b>Warning</b>: Cannot modify header information - headers already sent by (output started at /web/site/www.audioscrobbler.com/lastfm/streamcommands.php:26) in <b>/web/site/ws.audioscrobbler.com/ws.audioscrobbler.com/php/radio/control.php</b> on line <b>37</b><br />

    raw: response=FAILED

    You can turn off verbose error reporting in php as shown here: http://www.php.net/error_reporting

    James

    • RNR said...
    • Alumni
    • 10 Mar 2005, 13:39

    ...

    we like verbose errors as they tell us what is wrong :p

    I am working on this atm. stay tuned. and please post problems in the new "calling all developers" thread. later . . .

    Both kinds of music: Rock & Roll - SFTRI
  • Problem opening stream...

    I can get a session and a stream URL okay, but I cannot open the stream. When I try, I get the following error:

    HTTP/1.0 503 Invalid session - login again

    Does anyone have any hints as to what I might be doing wrong? Any help would be greatly appreciated.

    Thanks,
    -- Miles

    • lenggi said...
    • User
    • 22 May 2005, 17:27

    Re: Problem opening stream...

    (We might be in the wrong topic to discuss this, but ...)

    Quoth cmiles74:
    I can get a session and a stream URL okay, but I cannot open the stream. When I try, I get the following error:

    HTTP/1.0 503 Invalid session - login again


    I had the same problem. It seems to me that some how the sessions between audioscrobbler and last.fm where kind of mixed up.
    I had a different (and older one I think) for audioscrobbler than for last.fm when I checked the cookies of my browser. I logged out and in again at audioscrobbler.com and it worked...

  • what the heck is this fm thing what does it do and how does it work

Anonymous users may not post messages. Please log in or create an account to post in the forums.