3

Spotifyの API を使用する必要があります。私のクライアントには、登録ユーザーに代わって Spotify に接続し、すべてのプレイリスト名とそのプレイリスト内の曲を取得し、それらの txt ファイルを作成する Spotify アプリケーションが必要です。プレイリスト、以上です。どこから始めればよいか教えてください。PHPでそれを成し遂げる必要があります。

ありがとう

4

2 に答える 2

2

コメントで述べたように、不幸なことにオープン ソースではない libspotify を使用するコードがたくさんあります。提供された API の例では、すべてのプレイリストを反復処理する方法が慎重に省略されています。

あなたは、Spotify に接続できるものが欲しいと述べていますが (オンライン API は、確かに Spotify が誰もが使用することを望んでいるものです)、オフラインでも同じことができると確信しています。あなたが自分で言ったように、ファイルはバックアップできます。

にあります:

~/.config/spotify/ユーザー/名前/

また

{USER_APP_DATA}/Spotify/ユーザー/{USER_ID}

おそらく、私ができることやできないことへのアクセスを制限するプロプライエタリ ライブラリのファンではないことは、すでにおわかりでしょう。そこで、保存されているすべてのプレイリストの名前を出力できる簡単なプログラムを考え出しました。通常、プレイリストごとに 1 つのアルバムを追加するので、これは非常に便利です。

個々のトラックを含めるようにさらに開発できると確信しています。

#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();
            }
        }
    }
}
于 2012-06-18T09:21:52.947 に答える
1

この問題は、playlist.bnk ファイルをバックアップするだけで解決しました。プレイリスト用のファイルが含まれています

于 2011-08-11T09:27:38.423 に答える