当前位置: 首页 > 知识库问答 >
问题:

如何使用echonest api获取特定歌曲的Spotify ID

澹台权
2023-03-14

我试图用艺术家姓名和歌曲名称查询echonest,并让它返回歌曲的spotify ID。目前我只能让艺术家返回。

我正在读留档,但它毫无意义,我认为它可能是过时的,想知道是否有人能帮我。

这是我正在使用的文档的链接(http://developer.echonest.com/sandbox/spotify.html)API示例是上一个示例的第二个示例,即:

http://developer.echonest.com/api/v4/song/search?api_key=FILDTEOIK2HBORODV&format=json&results=1&artist=radiohead&title=karma%20police&bucket=id:spotify&bucket=tracks&limit=true

艺人:Radiohead歌曲标题:Karma Police

在文档中作为示例返回的是

songs: [
{
    title: "Karma Police"
    artist_name: "Radiohead"
    id: "SOHJOLH12A6310DFE5"
    tracks: [
              {
              "catalog": "spotify",
              "foreign_id": "spotify:track:3L7BcXHCG8uT92viO6Tikl",
              "id": "TRAVAWH13386461C1A"
              }    
           ]
  }
]   

我想得到Spotify:曲目:NUMBER_HERE

但当我在浏览器中实际运行api时,我得到了完全不同的结果。

我明白了

{"response": {"status": {"version": "4.2", "code": 0, "message": "Success"}, "songs": [{"title": "Karma Police", "artist_name": "Radiohead", "artist_foreign_ids": [{"catalog": "spotify", "foreign_id": "spotify:artist:4Z8W4fKeB5YxbusRsdQVPb"}], "tracks": [{"album_type": "album", "album_date": "1997-07", "foreign_release_id": "spotify:album:4ofIyjnuLMspKVVEM5k7KA", "catalog": "spotify", "foreign_id": "spotify:track:0CheWtm72bDFyuqxxJm7Jl", "album_name": "Karma Police", "id": "TRMKRIH144D09912F7"}, {"album_type": "album", "album_date": "1997-07", "foreign_release_id": "spotify:album:3Y0KfwfHGnuuSqVQAxODb9", "catalog": "spotify", "foreign_id": "spotify:track:4MBMrG8UypQfADJTg3cfPl", "album_name": "Karma Police", "id": "TRTEKIH144D14B88AB"}, {"album_type": "unknown", "album_date": "1997-05-21", "foreign_release_id": "spotify:album:2fGCAYUMssLKiUAoNdxGLx", "catalog": "spotify", "foreign_id": "spotify:track:4toSP60xmDNCFuXly8ywNZ", "album_name": "OK Computer", "id": "TREZAIC144D16517CA"}, {"album_type": "other", "album_date": "1999-02-16", "foreign_release_id": "spotify:album:2xYrPRSUPI1Q33xbyFhEN2", "catalog": "spotify", "foreign_id": "spotify:track:5YtKNQRPr4WE4EW1q2KJ8y", "album_name": "Ka-Boom: 16 Rippin' Tunes!", "id": "TRJIACH144D1845ABD"}, {"album_type": "other", "album_date": "2006", "foreign_release_id": "spotify:album:2ravCeM1o3ZoDZkMbRA2Df", "catalog": "spotify", "foreign_id": "spotify:track:3L7BcXHCG8uT92viO6Tikl", "album_name": "Essential Bands", "id": "TRGUGNY144D11B4378"}, {"album_type": "other", "album_date": "2008-06-02", "foreign_release_id": "spotify:album:1ouYZxiEjRSlUdoldMJyNF", "catalog": "spotify", "foreign_id": "spotify:track:4NGagGvZxVZ1ox7NsOSMDU", "album_name": "The Best Of", "id": "TRITWZK144D147AB62"}, {"album_type": "other", "album_date": "2008-06-02", "foreign_release_id": "spotify:album:58ukFMtQgwjVD9vMlfnSi9", "catalog": "spotify", "foreign_id": "spotify:track:116R91XyWtWQUHw1VZD3pu", "album_name": "The Best Of", "id": "TRQZPLJ144D0B965CE"}, {"album_type": "other", "album_date": "2008-06-02", "foreign_release_id": "spotify:album:3hWomTJKGucGKv6EPpiHK9", "catalog": "spotify", "foreign_id": "spotify:track:36OTdTMwBC0SQvc0TMxqgf", "album_name": "The Best Of", "id": "TRMJVDN144D114268C"}, {"album_type": "other", "album_date": "2008-06-02", "foreign_release_id": "spotify:album:0YbEgKS7zN6HkDW8bATFn3", "catalog": "spotify", "foreign_id": "spotify:track:3FWvP216t2YLltarju8fIt", "album_name": "The Best Of", "id": "TRVHZKK144D1175CDB"}, {"album_type": "other", "album_date": "2008-06-02", "foreign_release_id": "spotify:album:30bTqpK0cUWDD4VxHVjv0f", "catalog": "spotify", "foreign_id": "spotify:track:57GM3IdxqmCX15rGBw7C0Q", "album_name": "The Best Of", "id": "TRUBASC144D1704E37"}, {"album_type": "other", "album_date": "2008-06-02", "foreign_release_id": "spotify:album:4ZbRrwQyYPoYLg689BLOdG", "catalog": "spotify", "foreign_id": "spotify:track:7afVhhphp8iwwb5c6zDD4M", "album_name": "The Best Of", "id": "TRHDXVW144D1D82BF6"}, {"album_type": "other", "album_date": "2008-06-02", "foreign_release_id": "spotify:album:40i2i4LZN75liVKAjbMKP5", "catalog": "spotify", "foreign_id": "spotify:track:4rl2PAW1pb9uvn5BrjCUPd", "album_name": "The Best Of", "id": "TRCOWWN144D1635B08"}, {"album_type": "other", "album_date": "2008-06-02", "foreign_release_id": "spotify:album:1WsOWlFxZ3u7bW2GigFhoS", "catalog": "spotify", "foreign_id": "spotify:track:0REhU4YzXin94yj5VIhfXR", "album_name": "The Best Of", "id": "TRVGGHY144D0A2A56F"}, {"album_type": "other", "album_date": "2008-06-02", "foreign_release_id": "spotify:album:4wciNwfgbL74SJG9BFlf2R", "catalog": "spotify", "foreign_id": "spotify:track:0hCW6LbmFCYwM1uGmnjjNe", "album_name": "The Best Of", "id": "TRFHBAP144D0AC7509"}, {"album_type": "other", "album_date": "2008-06-02", "foreign_release_id": "spotify:album:5lEQ9RF9W2jBIKT369b6XA", "catalog": "spotify", "foreign_id": "spotify:track:0w13hCzWc9x2ODo0lhW3AT", "album_name": "The Best Of", "id": "TRIJWLD144D0B70EB1"}, {"album_type": "other", "album_date": "2008-06-02", "foreign_release_id": "spotify:album:0kiElBKf2UH2AL51cSnjFs", "catalog": "spotify", "foreign_id": "spotify:track:7jglhg35UU1rHKo3TMMlhs", "album_name": "The Best Of", "id": "TRDAANY144D1DDC1B0"}, {"album_type": "other", "album_date": "2009-11-16", "foreign_release_id": "spotify:album:2ARSMRIAl1RrPIYODKpSvn", "catalog": "spotify", "foreign_id": "spotify:track:7IGdoYPZjwkFZObVrnhQwB", "album_name": "101 Indie Classics", "id": "TRATJQY144D1D34F86"}, {"album_type": "other", "foreign_release_id": "spotify:album:4VaGdGXKBYsDSOZpZb33YH", "catalog": "spotify", "foreign_id": "spotify:track:4TDPAhRJvIIxC2iOj3tfnJ", "album_name": "Personal Effects", "id": "TRODNEI144D15055F1"}, {"album_type": "other", "foreign_release_id": "spotify:album:3JVhCJ0KrRNNyqAbDtuUlR", "catalog": "spotify", "foreign_id": "spotify:track:7bm4xECd4E5BagR8tzshXR", "album_name": "L'album pop rock 1980-1999, Volume 2", "id": "TRIAUMZ144D1CE6B92"}, {"foreign_release_id": "spotify:album:37bbqRNY7TYPMVchZAkant", "catalog": "spotify", "foreign_id": "spotify:track:1H9Fdn0ufWXoaOZhaA3XhW", "id": "TRUOSTZ144D0C565DA"}, {"foreign_release_id": "spotify:album:2QlyISc2f7wPcwdggl8k6x", "catalog": "spotify", "foreign_id": "spotify:track:1Y6Nw0Xfh2hCBpu27F0Xce", "id": "TRLULHG144D0D0E0A8"}, {"foreign_release_id": "spotify:album:7vHLtDbWD2N2PUdWorYvL6", "catalog": "spotify", "foreign_id": "spotify:track:31VtM8plvEaBKEkwmJ5iVx", "id": "TRSAUZY144D110B9F0"}, {"foreign_release_id": "spotify:album:5VHphzoQ5AmAUv1NTXTgeA", "catalog": "spotify", "foreign_id": "spotify:track:4722k1npcMc5e1kBiWWIYI", "id": "TRBVBET144D1423032"}, {"foreign_release_id": "spotify:album:2bKod32TblM1nReRDi9gTG", "catalog": "spotify", "foreign_id": "spotify:track:6MRtrRQVOwyk6cMZY3Smnl", "id": "TRSEEQW144D1A7817C"}, {"foreign_release_id": "spotify:album:1ssRgLbh4dOEpu57bImChh", "catalog": "spotify", "foreign_id": "spotify:track:01puceOqImrzSfKDAcd1Ia", "id": "TRBHSFP144D0923CC6"}, {"foreign_release_id": "spotify:album:1EAJOr9xA3rHzhS5rWpziG", "catalog": "spotify", "foreign_id": "spotify:track:2Mvy2Ob0m1MIaOwjieDSdD", "id": "TRWBMXG144D0F402E2"}, {"foreign_release_id": "spotify:album:5bNn3KPcrlgLmhRXj4d2EX", "catalog": "spotify", "foreign_id": "spotify:track:4BFAWLRycYNSbhUgZFijc9", "id": "TRSXGVY144D1438433"}, {"foreign_release_id": "spotify:album:4195NRmc5jxkCw9jcmd4rt", "catalog": "spotify", "foreign_id": "spotify:track:5MIblG9hLxBnQcrDwdWF98", "id": "TRBLQPB144D17B11CC"}, {"foreign_release_id": "spotify:album:6vjzhxwIgTtDVW34bteGyG", "catalog": "spotify", "foreign_id": "spotify:track:10u0TOqp3bd1DAPNskHvK8", "id": "TRPIDKB144D0BA6CBC"}, {"foreign_release_id": "spotify:album:6uhBsv0PbcwolrbhgCDqDR", "catalog": "spotify", "foreign_id": "spotify:track:6XPGNyB95TZwYiqe2t964T", "id": "TRGUQDL144D1B040D8"}, {"foreign_release_id": "spotify:album:45wvzRUVtoEPsXsiNtO2TX", "catalog": "spotify", "foreign_id": "spotify:track:3u7TUfV1fjAvxJtqvtUbGO", "id": "TRNPOOC147B6E30B68"}, {"foreign_release_id": "spotify:album:3Hl5wRTlE9vNuXdZ54okbn", "catalog": "spotify", "foreign_id": "spotify:track:1vDio38orbAGqrXAR13RD3", "id": "TRHKSFX144D0E0D5DC"}, {"foreign_release_id": "spotify:album:3fjD2coxF2SQwLRcjm0ctg", "catalog": "spotify", "foreign_id": "spotify:track:6IJW8YFpoJ5DQ0YiBITqfq", "id": "TRTHCOU144D1A55B13"}, {"foreign_release_id": "spotify:album:4VYcoe0QDAGJmZA5zpgvgq", "catalog": "spotify", "foreign_id": "spotify:track:6oeIc0gfmKLlYe5gkJ3cJP", "id": "TRDVZZZ144D1B59768"}, {"foreign_release_id": "spotify:album:7eQtS9KqZmqCGkbieox4fV", "catalog": "spotify", "foreign_id": "spotify:track:6ZGOmPtSvx1hxwjwqpdKQ7", "id": "TRIBYGA144D1A9AF3B"}, {"foreign_release_id": "spotify:album:6Bjl48Ev6V97G6Uc37IRTw", "catalog": "spotify", "foreign_id": "spotify:track:6eomr7dBfWTGdRHuPwJFU6", "id": "TROCBGU14735BF0753"}, {"foreign_release_id": "spotify:album:1AAI2vNGAwA7DhCmEyYAwU", "catalog": "spotify", "foreign_id": "spotify:track:2NBB9erm0zzcM6i41Nrbux", "id": "TRDMBVL144D0F3D96F"}], "artist_id": "ARH6W4X1187B99274F", "id": "SOHJOLH12A6310DFE5"}]}}

请有人给我指一下我正在俯瞰的方向好吗。

如有任何帮助、指导和建议,我们将不胜感激。我的最终状态是,我可以获得spotify曲目id,这样我就可以通过编程建立自己的播放列表。如果有更好的方法,我愿意接受建议

共有1个答案

李泓
2023-03-14

查看从The Echo Nest的API获得的响应,轨道URI位于response.songs[0]。轨道[0]。foreign_id。所以留档是正确的,只是它没有覆盖歌曲数组所在的响应对象。

希望这能有所帮助!

 类似资料:
  • 另外,如果我在浏览器上访问,它在web界面中只显示当前歌曲。 有人能指导我如何完成这件事吗?

  • 问题内容: 我正在查看的页面包含: 我想获取div中的所有文本,除了中的文本。(我想获得“文本1”,“文本3”和“文本4”)。可能有几个元素,或者根本没有。而且可能有一些元素,甚至一个元素都在另一个元素之中,或者根本没有。 我想通过获取div的所有html源并使用正则表达式删除元素来做到这一点。但是selenium.get_text不会返回html,而只是返回文本(全部!)。 我知道我可以使用正则

  • 问题内容: 有没有办法使用jQuery获得块内容的第5行(第一个字母的偏移量)? 我的意思是可视线,浏览器计算的线,而不是源代码中的线。 问题答案: jQuery.fn.line: 用法: 示例: http : //jsbin.com/akave 这个怎么运作: 它遍历整个元素(实际上是元素的克隆),并 在每个单词中插入一个元素。跨度的最高偏移量已缓存- 当此偏移量更改时,我们可以假定我们在新行上

  • 假设我有一个Jextfield数组(例如JTextfield[10])。我将它们添加到框架中。现在用户在文本字段中随机输入文本,例如用户首先输入索引为5的文本字段,然后是9,然后是2,依此类推。不一定要填充所有的文本字段。 我的问题是,如何获取文本字段的索引,并在用户输入文本时同时打印索引,这意味着如果用户在文本字段中输入索引5,我应该能够获得索引5,然后如果填充了索引9的文本字段,则打印9,依此

  • 我是android和Room Persistence library的新手,我将数据保存在一个名为的实体中,它有很多行,其中一个是PrimaryKey cadID(一个int字段)。我需要从用户刚刚输入的最后一个条目中获取cadID。 对于这个问题,我试图使用以下逻辑来获得它: 但是,当程序到达这一点时,它抛出一个NullPointerException异常: 这就是我在ViewModel(Vie

  • 语境: 给定一个WooCommerce和WooCommerce订阅的WordPress网站,我试图获取特定用户订阅的列表。在最近的更新之前,这一行代码已经为我解决了这个问题。以下是我一直在使用的代码: 其中$user\u id是WordPress中的有效用户id。 问题: 自上次更新以来,我们经常看到以下错误: 致命错误:在/home/warfarep/public_html/wp content