spotipy可以检索当前队列吗?

问题描述 投票:0回答:1

正如标题所说,我想获取队列中当前存在的所有曲目的信息。 与

current_user_playing_track
类似,但不是接下来播放的所有歌曲。我在 documentationexamples 中找不到任何内容,所以我不知道这是否可能。

如有任何帮助,我们将不胜感激!

spotify spotipy
1个回答
0
投票

请求用户队列在版本 2.22.0(2022 年 12 月 10 日)中可用。 Spotipy 的文档中提到了

queue()
方法,但没有详细说明。根据Spotify官方文档获取用户队列请求需要两个授权范围:
user-read-currently-playing
user-read-playback-state
。成功的响应包含
currently_playing
(曲目或剧集)和
queue
(曲目或剧集列表)。使用示例:

# spotify = spotipy.Spotify(...)

users_queue = spotify.queue()

currently_playing_track_or_episode = users_queue['currently_playing']
print(f"Currently playing: {currently_playing_track_or_episode['name']}")

for track_or_episode in users_queue['queue']:
    print(f"Queued: {track_or_episode['name']}")
© www.soinside.com 2019 - 2024. All rights reserved.