Spotify api 获取用户的播放列表

发布于 2024-11-17 13:23:57 字数 227 浏览 3 评论 0原文

我需要使用 Spotify 的 api 我的客户需要有一个能够连接到的 Spotify 应用程序Spotify 代表注册用户,将获取所有播放列表名称及其在这些播放列表中的歌曲,并将制作这些播放列表的 txt 文件,就是这样。 请帮助我我应该从哪里开始,我需要用 php 来完成它。

谢谢

i need to use the api of Spotify my client needs to have a spotify application that will connect to the spotify on behalf of the registered user and will fetch all the playlist names and their songs in those playlist, and will make a txt file of those playlist, thats it.
please help me where should i start , i need to get it done with php.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

陈年往事 2024-11-24 13:23:57

正如评论中提到的,有很多代码使用不幸的非开源 libspotify。提供的 API 示例小心地省略了迭代所有播放列表的方法。

你提到你想要一些可以连接到 Spotify 的东西(在线 API 肯定是 Spotify 希望每个人都使用的),但我很确定同样可以离线完成。正如您自己所说,文件可以备份。

位于:

~/.config/spotify/Users/name/

{USER_APP_DATA}/Spotify/Users/{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();
            }
        }
    }
}

As mentioned in the comments, there is a lot of code circling around using the unfortunate not open source libspotify. The API examples provided, carefully omitting a way to iterate over all playlists.

You mention that you want something that can connect to spotify (the online API is certainly what Spotify would like everyone to use) but I'm pretty sure the same can be done offline. As you said yourself, the files can be backed up.

Located in:

~/.config/spotify/Users/name/

or

{USER_APP_DATA}/Spotify/Users/{USER_ID}

You can probably already tell I'm not a fan of proprietary libraries restricting access to what I can or can not do. So I came up with a simple program that can print the names of all stored playlists. This is helpful enough because I usually add one album per playlist.

I'm pretty sure it can be developed further to include individual tracks.

#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();
            }
        }
    }
}
2024-11-24 13:23:57

只需备份 playlist.bnk 文件即可解决该问题。其中包含播放列表的文件

The Problem was solved by just backing up the playlist.bnk file. which contains the files for playslists

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文