First, let me say a few things:
This Enhancement/Feature request(and maybe, in fute a bug report:P) is
REALLY long, I know! But it's important,too. Else I wouldn't have spend
multiple hours in creating this text(but as you will see, I would have done
it sooner or later in any case :D)
I'm writing my own client, just for fun.
Now, after a big pause(over about a month, because of summer holidays and
some hardware problems) I continued writing it.
Before it worked really fine(except some minor bugs), but when testing it
today, I got serious trouble.
So I fired up my wireshark and my original last.fm client to see if they
made any changes, and yes - there are some.
Due to backwards compatibility the old way works fine yet(that's why I
tested TheLastRipper, I wanted to find out where the bug came), but I
expect they will turn off the old way in a few months or so(do not really
know, sorry).
I've put an attachment to this report, so you can see it yourself.
the main thing they changed is that the songs are now played by some ticket
system, I think.
If you type "http" as filter, take a look on the second line, I understand
only half of it's meaning :
GET
?hs=true&p=1.2&c=ass&v=1.3.1.1&u=tburny&t=1185184244&a=1cdd28c8ffb48462f6cc995ea
86de0a2
here's what I found out for this:
hs: dont't really know, but I think hs stands for "handshake"
p: version of the protocol
c: ---
u: username
t: time since 1970 in seconds, you can calculate it with
"cint((DateTime.UtcNow - New DateTime(1970, 1, 1)).TotalSeconds)" (VB.NET 2005)
a: dont't know, but seems to be some md5...
HTTP/1.1
Host: post.audioscrobbler.com
User-Agent: Last.fm Client 1.3.1.1 (Windows)
HTTP/1.1 200 OK
OK
fe352ebd03b2eeedb8c01fdafdd1854f
http://post.audioscrobbler.com:80/np_1.2
http://87.117.229.205:80/protocol_1.2
the answer is half understandable:
OK means the result ;)
second line is for an argument of the new "np_1.2" file
third line is the url to the "np_1.2"
then another important thing is how the ticket system works, because it
reduces last.fm's traffic which was caused to skip a track(and now you can
build in a track preview or, even better, skip more than one track at
once(but I don't think so)).
the way of changing the station stays the same(atm.) through
"/radio/adjust.php".
but now here comes the ticket system, which makes it easier and nicer to
record tracks than ever.
Be careful, ist a long text, answer is a kind of xml...
GET
/radio/xspf.php?sk=ae1eb54a11615e605d61d6e83dde71bc&discovery=0&desktop=1.3.1.1
HTTP/1.1
Host: ws.audioscrobbler.com
Accept-Language: de, en
User-Agent: Last.fm Client 1.3.1.1 (Windows)
about the request:
-sk: the sessionid which you've got in handshake.php during login
-discovery: self-explanatory
-desktop: current app version
now here's the response(shortened):
HTTP/1.0 200 OK
Connection: close
Content-Type: text/plain;charset=utf-8
<playlist version="1"
xmlns:lastfm="http://www.audioscrobbler.net/dtd/xspf-lastfm">
<title>+%C3%84hnliche+K%C3%BCnstler+wie+Meat+Loaf</title>
<creator>Last.fm</creator>
<link rel="http://www.last.fm/skipsLeft">6</link>
<trackList>
<track>
<location>http://kingpin4.last.fm/user/d87034ad6ab5d7ed388a6dcd2d2df506.mp3</loc
ation>
<title>Killer Queen (Live)</title>
<id>3647300</id>
<album>Live Killers</album>
<creator>Queen</creator>
<duration>118000</duration>
<image>http://images.amazon.com/images/P/B000000OAP.01._SCMZZZZZZZ_.jpg</image>
<lastfm:trackauth>15fcf</lastfm:trackauth>
<lastfm:albumId>2553849</lastfm:albumId>
<lastfm:artistId>1270</lastfm:artistId>
<link
rel="http://www.last.fm/artistpage">http://www.last.fm/music/Queen</link>
<link
rel="http://www.last.fm/albumpage">http://www.last.fm/music/Queen/Live+Killers</
link>
<link
rel="http://www.last.fm/trackpage">http://www.last.fm/music/Queen/_/Killer+Queen
+%28Live%29</link>
<link
rel="http://www.last.fm/buyTrackURL">http://www.last.fm/affiliate_sendto.php?lin
k=uapc&prod=731771&pos=9b944892b67cd2d9f7d9da1c934c5428</link>
<link rel="http://www.last.fm/buyAlbumURL"></link>
<link rel="http://www.last.fm/freeTrackURL"></link>
</track>
<track>
<location>http://kingpin4.last.fm/user/4c0ae6e135aa0d4c4926fa29a633911e.mp3</loc
ation>
<title>Going, Going... Home</title>
<id>4195329</id>
<album></album>
<creator>Mike & The Mechanics</creator>
<duration>269000</duration>
<image></image>
<lastfm:trackauth>86776</lastfm:trackauth>
<lastfm:albumId></lastfm:albumId>
<lastfm:artistId>1000520</lastfm:artistId>
<link
rel="http://www.last.fm/artistpage">http://www.last.fm/music/Mike%2B%2526%2BThe%
2BMechanics</link>
<link rel="http://www.last.fm/albumpage"></link>
<link
rel="http://www.last.fm/trackpage">http://www.last.fm/music/Mike%2B%2526%2BThe%2
BMechanics/_/Going%2C+Going...+Home</link>
<link rel="http://www.last.fm/buyTrackURL"></link>
<link rel="http://www.last.fm/buyAlbumURL"></link>
<link rel="http://www.last.fm/freeTrackURL"></link>
</track>
<track>
<location>http://kingpin4.last.fm/user/4d506d41b059e0bc958bcfcfba7534c7.mp3</loc
ation>
<title>Chinatown (LP Version)</title>
<id>26362688</id>
<album>Livin' on the Fault Line</album>
<creator>The Doobie Brothers</creator>
<duration>299000</duration>
<image>http://cdn.last.fm/coverart/130x130/2124753.jpg</image>
<lastfm:trackauth>0a5dd</lastfm:trackauth>
<lastfm:albumId>2124753</lastfm:albumId>
<lastfm:artistId>5798</lastfm:artistId>
<link
rel="http://www.last.fm/artistpage">http://www.last.fm/music/The+Doobie+Brothers
</link>
<link
rel="http://www.last.fm/albumpage">http://www.last.fm/music/The+Doobie+Brothers/
Livin%27+on+the+Fault+Line</link>
<link
rel="http://www.last.fm/trackpage">http://www.last.fm/music/The+Doobie+Brothers/
_/Chinatown+%28LP+Version%29</link>
<link rel="http://www.last.fm/buyTrackURL"></link>
<link
rel="http://www.last.fm/buyAlbumURL">http://www.last.fm/affiliate_sendto.php?lin
k=catch&prod=2124753&pos=65633c2c6d40fbe9c8bf27ce82d2ca5a</link>
<link rel="http://www.last.fm/freeTrackURL"></link>
</track>
<track>
<location>http://kingpin4.last.fm/user/8e6eacd310f9a32d6619705fe4e51555.mp3</loc
ation>
<title>Magic</title>
<id>6952252</id>
<album>Keys of the Kingdom</album>
<creator>The Moody Blues</creator>
<duration>311000</duration>
<image>http://images.amazon.com/images/P/B000001G1P.01._SCMZZZZZZZ_.jpg</image>
<lastfm:trackauth>03af6</lastfm:trackauth>
<lastfm:albumId>2339631</lastfm:albumId>
<lastfm:artistId>1001383</lastfm:artistId>
<link
rel="http://www.last.fm/artistpage">http://www.last.fm/music/The+Moody+Blues</li
nk>
<link
rel="http://www.last.fm/albumpage">http://www.last.fm/music/The+Moody+Blues/Keys
+of+the+Kingdom</link>
<link
rel="http://www.last.fm/trackpage">http://www.last.fm/music/The+Moody+Blues/_/Ma
gic</link>
<link rel="http://www.last.fm/buyTrackURL"></link>
<link
rel="http://www.last.fm/buyAlbumURL">http://www.last.fm/affiliate_sendto.php?lin
k=catch&prod=2339631&pos=65633c2c6d40fbe9c8bf27ce82d2ca5a</link>
<link rel="http://www.last.fm/freeTrackURL"></link>
</track>
<track>
<location>http://kingpin4.last.fm/user/356aed9c10fc546e14beba29e1559de2.mp3</loc
ation>
<title>Do You Love Me</title>
<id>7711148</id>
<album>Stay With the Hollies (Emi Ltd - Mono/stereo)</album>
<creator>The Hollies</creator>
<duration>132000</duration>
<image>http://panther1.last.fm/depth/catalogue/noimage/cover_med.gif</image>
<lastfm:trackauth>9fe56</lastfm:trackauth>
<lastfm:albumId>2254971</lastfm:albumId>
<lastfm:artistId>1234850</lastfm:artistId>
<link
rel="http://www.last.fm/artistpage">http://www.last.fm/music/The+Hollies</link>
<link
rel="http://www.last.fm/albumpage">http://www.last.fm/music/The+Hollies/Stay%2BW
ith%2Bthe%2BHollies%2B%2528Emi%2BLtd%2B-%2BMono%252Fstereo%2529</link>
<link
rel="http://www.last.fm/trackpage">http://www.last.fm/music/The+Hollies/_/Do+You
+Love+Me</link>
<link
rel="http://www.last.fm/buyTrackURL">http://www.last.fm/affiliate_sendto.php?lin
k=uapc&prod=754829&pos=9b944892b67cd2d9f7d9da1c934c5428</link>
<link rel="http://www.last.fm/buyAlbumURL"></link>
<link rel="http://www.last.fm/freeTrackURL"></link>
</track>
</trackList>
</playlist>
as you might see, this is a playlist. its version is "1" :)
<title> says to the app which title the playlist has
<creator> says the creator is "last.fm"(in this case).
now the first really interesting thing:
the content of the <link> tag says after how many skips(or plays of songs)
the playlist has to be reloaded.
you might also notice(if you copy the response into Notepad++ und set the
language to XML, that's a good way for analyzing all this stuff :D) that
the tracklist contains five(!) "track" nodes. So there are three possibilities:
-the currently playing track isn't counted and listed
-the currently playing track is the first track-node and of the list and a
new one must be loaded when the sixth track is needed
-the people from last.fm can't count xD
now let's take a look on one of the track nodes.
it contains:
-location: the location of the mp3 file/track->where can the client download it
-title: The track title
-id: the id of the track, could be used for adding this track to the
personal playlist(I'll say a few words to this topic later in the text)
-album: The album name
-creator: the Artist
-duration: the duration, in milliseconds(really nonsense, except for id3
tagging maybe :P)
-image: url to the album picture
-lastfm:trackauth: no really idea for what it stands
-lastfm:albumId: Id of the album. seems to be worthless
-lastfm:artistId: same thing as with the album
-links to last.fm's artist-, album- and track pages
-a url from where you can buy the track
-another one for the album(see it as a feature request for TheLastRipper^^)
-freeTrackurl: a really interesting thing, because you can search the
playlist for free tracks, download them and skip the track before even
playing it*nasty laughing*
The advantages of the playlist are the following:
-Less traffic for Last.fm, as control.php isn't used anymore for skipping
tracks(and one playlist list fullfills your needs for five tracks!)
-Pre-Downloading the Pictures and other information
-Search for free tracks and download them
-Maybe skipping multiple track with a kind of skip list(Feature request,
too!): the user creates a file with the names of artists he only wants to
listen to(I've build in this in my own client,works fine!). If "listening",
all other artists are skipped.
The playlist might help(I DIDN'T tested that) to skip, for example, two or
three tracks, which you don't want to have, at once(would be a REALLY BIG
advantage*hehe*)
So far with the "/radio/xspf.php". Now let's go on to np_1.2:
POST /np_1.2 HTTP/1.1
Host: post.audioscrobbler.com
content-type: application/x-www-form-urlencoded
User-Agent: Last.fm Client 1.3.1.1 (Windows)
content-length: 101
s=fe352ebd03b2eeedb8c01fdafdd1854f&a=Queen&t=Killer%20Queen%20%28Live%29&b=Live%
20Killers&l=118&n=&m=
s: the md5 you got from the first request("GET
?hs=true&p=1.2&c=ass&v=1.3.1.1&u=tburny&t=1185184244&a=1cdd28c8ffb48462f6cc995ea
86de0a2
", you might remember(else see beginning))
a: Artist Name, url encoded
t: Track Name, " "
b: Album Name
l: Track-length, in seconds
n: don't know, seems to stay empty in each request
m: see "n"
here is the answer, self-explanatory:
200 OK
Server: Apache-Coyote/1.1
Pragma: no-cache
Cache-Control: no-cache
Content-Type: text/plain;charset=ISO-8859-1
Date: Mon, 23 Jul 2007 10:54:27 GMT
Connection: close
OK
I can imagine this is to verify that the right track is played and mayby to
prevent skipping multiple tracks at once. I didn't find a way to test it.
the last thing is that the track is downloaded from the <location>-tag in
the playlist, e.g. GET /user/9da03dab5f3a840532c6969f97c939b5.mp3
now I'm done, as you can see. will now enjoy plaing c&c 3 - tiberian wars :D
if you have questions, answers for things i don't understand yet, or if you
wish contact(via mail/msn/icq/google chat, whatever), it would be really
nice if you write a comment.
I'm really sorry, but I will NOT send any of my code(maybe/only little
pieces), because I don't want to hurt last.fm. I'm writing my app just for
fun and won't publish it. but maybe we can help each other, your source
code looks a little bit interesting....
Now here's another bug(just found it 1 min ago^^): if you type in an
invalid station, the app will produce a bad timeout exception
output(worthless for the user). maybe you should put it into a log, instead
of a message box:P
so far,
burny