2

サーバー側の機能を介してSpotifyプレイリストを操作(追加)することは可能ですか?

Web APIは検索(https://developer.spotify.com/technologies/web-api/)に限定されているようで、機能を持つJavaScript APIリファレンスは、Spotify自体の内部で実際にアプリを構築することに限定されているようです...

4

2 に答える 2

1

はい、できますが、ユーザーが関与する承認プロセスが必要です。これは非常に面倒です。

適切なAPIを使用する必要があります。

ソース: https ://developer.spotify.com/web-api/console/playlists/

たとえば、トラックを追加するには、このエンドポイントが必要になります

https://api.spotify.com/v1/users/ {user_id} / playlists / {playlist_id} / tracks

このコードは、概念を証明するためだけにAppleScriptで機能します。

set userID to "XXXXX"
-- your userID can be retrieved with https://developer.spotify.com/web-api/console/get-current-user/#complete

set SelectedPlaylistID to "YYYY"
-- your target playlist can be retrieved with https://developer.spotify.com/web-api/console/get-playlists/#complete

set BearerID to "ZZZZ"
-- ZZZZ can be retrieved manually on page https://developer.spotify.com/web-api/console/post-playlist-tracks/ 

tell application "Spotify"
    set currentSpotifyID to id of current track as string
end tell
set currentlyPlayingTrack to trim_line(currentSpotifyID, "spotify:track:", 0)


set theURL to "'https://api.spotify.com/v1/users/" & userID & "/playlists/" & SelectedPlaylistID & "/tracks?uris=spotify%3Atrack%3A" & currentlyPlayingTrack & "' -H 'Accept: application/json' -H 'Authorization: Bearer " & BearerID & "'"
-- obtenu de https://developer.spotify.com/web-api/console/post-playlist-tracks/#complete

set theCommand to "curl -X POST " & theURL

do shell script theCommand

ただし、大きな注意点があります。1時間ごとにBearerIDを更新する必要があります。

これは、承認プロセスが必要な場所であり、更新制限をバイパスする場合は複雑になります。

于 2018-01-27T10:46:29.790 に答える
0

残念ながら、現時点では、JS APIを使用してクライアント内にSpotifyアプリケーションを構築するか、libSpotifyを使用してスタンドアロンアプリを構築しない限り、これは不可能です。

于 2012-05-24T07:57:05.030 に答える