我需要使用Spotify的 api我的客户需要有一个 Spotify 应用程序,该应用程序将代表注册用户连接到 Spotify,并将获取这些播放列表中的所有播放列表名称及其歌曲,并制作一个 txt 文件那些播放列表,就是这样。请帮我从哪里开始,我需要用 php 完成它。
谢谢
正如评论中提到的,有很多使用不幸的非开源 libspotify 的代码。提供的 API 示例小心地省略了遍历所有播放列表的方法。
你提到你想要一些可以连接到 Spotify 的东西(在线 API 肯定是 Spotify 希望每个人都使用的),但我很确定同样可以离线完成。正如您自己所说,可以备份文件。
位于:
~/.config/spotify/用户/名称/
或者
{USER_APP_DATA}/Spotify/用户/{USER_ID}
您可能已经告诉我,我不喜欢限制访问我能做或不能做的事情的专有库。所以我想出了一个简单的程序,可以打印所有存储的播放列表的名称。这很有帮助,因为我通常会为每个播放列表添加一张专辑。
我很确定它可以进一步开发以包含单独的曲目。
#include <fstream>
#include <iostream>
#include <sstream>
#include <vector>
int main(int argc, char *argv[]) {
std::vector<char> vbuf;
unsigned int len;
std::vector<char>::iterator bpos,dpos,epos;
std::ifstream in("playlist.bnk", std::ios::in|std::ios::binary);
if (in) {
in.seekg(0,std::ios::end);
len = in.tellg();
vbuf.resize(len);
in.seekg(0,std::ios::beg);
in.read(&vbuf[0],len);
for(std::vector<char>::iterator it = vbuf.begin(); it != vbuf.end(); ++it) {
if (*it == (char)0x02 && *(it+1) == (char)0x09) {
bpos = it+3;
}
if (*it == (char)0xE2 && *(it+1) == (char)0x80 && *(it+2) == (char)0x93 && bpos != vbuf.end()) {
dpos = it;
}
if (*it == (char)0x18 && *(it+1) == (char)0x01 && *(it+2) == (char)0x19 && dpos != vbuf.end()) {
epos = it;
}
if (bpos != vbuf.end() && dpos != vbuf.end() && epos != vbuf.end()) {
for(std::vector<char>::iterator it2 = bpos; it2 < dpos; ++it2) {
std::cout << *it2;
}
for(std::vector<char>::iterator it2 = dpos; it2 < epos; ++it2) {
std::cout << *it2;
}
std::cout << std::endl;
bpos = vbuf.end();
dpos = vbuf.end();
epos = vbuf.end();
}
}
}
}
只需备份 playlist.bnk 文件即可解决问题。其中包含播放列表的文件