【问题标题】:Can't skip to next song on Spotify API (via Spotipy)无法跳到 Spotify API 上的下一首歌曲(通过 Spotipy)
【发布时间】:2018-10-10 07:24:59
【问题描述】:

我正在使用spotipy 实现一个简单的应用程序。
我想跳过下一首曲目,但输出中出现此错误:

spotipy.client.SpotifyException:http 状态:403,代码:-1 - https://api.spotify.com/v1/me/player/next: 当前用户不可用

我的代码:

import os
import spotipy
import spotipy.util as util
from json.decoder import JSONDecodeError


# Set data client, redirect URL and username
username = 'xxxx'
client_id = 'xxxxxxxx'
client_secret = 'xxxxxxxx'
redirect_uri = 'https://www.xxxxx.it/'
scope = 'user-modify-playback-state'


# Erase cache and prompt for user permission
try:
    token = util.prompt_for_user_token(username, scope, client_id, client_secret, redirect_uri)
except (AttributeError, JSONDecodeError):
    os.remove(f".cache-{username}")
    token = util.prompt_for_user_token(username, scope, client_id, client_secret, redirect_uri)


# Configure Spotify
sp = spotipy.Spotify(auth=token)
current = sp.next_track()

【问题讨论】:

    标签: python spotify spotipy


    【解决方案1】:

    您只能跳过高级用户的歌曲。
    查看这些文章:

    仅供参考,Error 403 是授权错误:

    HTTP 403 Forbidden 客户端错误状态响应码表示 服务器理解请求但拒绝授权。

    此状态类似于401,但在这种情况下,重新认证 不会有任何区别。访问被永久禁止并绑定 到应用程序逻辑,例如对资源的权限不足。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-11
    • 2017-10-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-04
    相关资源
    最近更新 更多