bux
bux

Reputation: 7769

Get grooveshark songId from url

I am using the grooveshark API and i would like to find a sondId from url. So i've url:

http://grooveshark.com/#!/s/T4+Song/2IsoC7?src=5

I extract the "id" in url:

2IsoC7

But, unlike albums and playlists where ids are directly displayeds in Url:

http://grooveshark.com/#!/album/Sexplosive+Locomotive/3624474
http://grooveshark.com/album/Sexplosive+Locomotive/3624474
http://grooveshark.com/#!/playlist/Punish+Yourself/58054955
http://grooveshark.com/playlist/Punish+Yourself/58054955

I don't know how find songId... I've try getSongIDFromTinysongBase62 but not work.

How determine songID with grooveshark API ? Thank's !

Upvotes: 2

Views: 869

Answers (1)

L1fescape
L1fescape

Reputation: 81

There are some Grooveshark methods that are not included in the Official API docs, but there are a few repos that document the Unofficial API and include these methods. The method you're looking for is getSongFromToken.

It requires country and token as parameters (token is "2IsoC7" in your case). You also need to set header.client to "htmlshark".

Here's a sample cURL request:

curl 'http://grooveshark.com/more.php?getSongFromToken' -H 'Content-Type: text/plain' --data-binary '{"header":{"client":"htmlshark","clientRevision":"20130520","uuid":"[YOUR-UUID]","session":"[YOUR-SESSION]","token":"[YOUR-SESSION-TOKEN]"},"method":"getSongFromToken","parameters":{"token":"fESpf","country":{"ID":223,"CC1":0,"CC2":0,"CC3":0,"CC4":1073741824,"DMA":534,"IPR":0}}}'

That should give you something looking like this:

"header": { 
    "session":"[YOUR-SESSION]",
    "serviceVersion":"20100903",
    "prefetchEnabled":true
},
"result": {
    "SongID":"25134723",
    "Name":"T4 Song",
    "Flags":"0",
    "EstimateDuration":"227",
    "AlbumID":"3624474",
    "AlbumName":"Sexplosive Locomotive",
    "CoverArtFilename":"3624474.jpg",
    "ArtistName":"Punish Yourself",
    "ArtistID":"249162"
}

Unfortunately some of these variables are a little poorly named. token inside of header is your session token. token inside of parameters is the id of the song you're looking up.

Hope that helps!

Upvotes: 3

Related Questions