从网址获取groovehark songId

时间:2013-06-10 07:56:26

标签: api grooveshark

我正在使用groovehark API,我想从网址找到一个sondId。所以我的网址是:

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

我在url中提取“id”:

2IsoC7

但是,与在Url中直接显示ID的专辑和播放列表不同:

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

我不知道怎么找到歌...我试试getSongIDFromTinysongBase62但不行。

如何用grooveshark API确定songID?谢谢!

1 个答案:

答案 0 :(得分:3)

官方API文档中没有包含一些Grooveshark方法,但有一个few repos记录了非官方API并包含这些方法。您正在寻找的方法是getSongFromToken

它需要countrytoken作为参数(token在您的案例中为"2IsoC7")。您还需要将header.client设置为"htmlshark"

以下是cURL请求示例:

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}}}'

那应该给你这样的东西:

"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"
}

不幸的是,其中一些变量名称不太好。 token内的header是您的会话令牌。 token内的parameters是您正在查找的歌曲的ID。

希望有所帮助!