当前位置: 首页>>代码示例>>Python>>正文


Python spotipy.util方法代码示例

本文整理汇总了Python中spotipy.util方法的典型用法代码示例。如果您正苦于以下问题:Python spotipy.util方法的具体用法?Python spotipy.util怎么用?Python spotipy.util使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在spotipy的用法示例。


在下文中一共展示了spotipy.util方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_new_token

# 需要导入模块: import spotipy [as 别名]
# 或者: from spotipy import util [as 别名]
def get_new_token(self):
        token = spotipy.util.prompt_for_user_token(
            self.spotify_username,
            client_id=self.spotify_client_id,
            client_secret=self.spotify_client_secret,
            redirect_uri=self.spotify_redirect_uri,
            scope="playlist-read-private user-library-read",
        )
        return token 
开发者ID:regisb,项目名称:spotify-onthego,代码行数:11,代码来源:auth.py

示例2: getToken

# 需要导入模块: import spotipy [as 别名]
# 或者: from spotipy import util [as 别名]
def getToken(self):
        try:
            token = util.prompt_for_user_token(self.username, 'playlist-modify-public', self.client_id, self.client_secret, self.redirect)

        except:
            # os.remove(f".cache-{username}")
            token = util.prompt_for_user_token(self.username, 'playlist-modify-public', self.client_id, self.client_secret, self.redirect)

        return token 
开发者ID:amcquade,项目名称:fresh_script,代码行数:11,代码来源:models.py

示例3: spotify_client

# 需要导入模块: import spotipy [as 别名]
# 或者: from spotipy import util [as 别名]
def spotify_client(bot):
    """Spotify access requires user authorization. The refresh token is stored
    in memory to circumvent logging in after the initial authorization."""
    try:
        spotify_client_id = bot.config.get_by_path(
            ["spotify", "spotify", "client_id"])
        spotify_client_secret = bot.config.get_by_path(
            ["spotify", "spotify", "client_secret"])
        spotify_redirect_uri = bot.config.get_by_path(
            ["spotify", "spotify", "redirect_uri"])
        spotify_user = bot.config.get_by_path(["spotify", "spotify", "user"])
    except (KeyError, TypeError) as e:
        logger.error("<b>Spotify authorization isn't configured:</b> {}"
                     .format(e))
        return None

    if bot.memory.exists(["spotify", "token"]):
        old_spotify_token = bot.memory.get_by_path(["spotify", "token"])
    else:
        old_spotify_token = ""

    spotify_token = spotipy.util.prompt_for_user_token(
        spotify_user,
        scope="playlist-modify-public playlist-modify-private",
        client_id=spotify_client_id,
        client_secret=spotify_client_secret,
        redirect_uri=spotify_redirect_uri)

    if old_spotify_token and old_spotify_token != spotify_token:
        bot.memory.set_by_path(["spotify", "token"], spotify_token)

    return spotipy.Spotify(auth=spotify_token) 
开发者ID:hangoutsbot,项目名称:hangoutsbot,代码行数:34,代码来源:spotify.py

示例4: _get_auth_spotify

# 需要导入模块: import spotipy [as 别名]
# 或者: from spotipy import util [as 别名]
def _get_auth_spotify(user):
    # deprecated
    global auth_sp
    if auth_sp == None:
        scope = 'playlist-modify-public playlist-modify-private'
        token = spotipy.util.prompt_for_user_token(user, scope)
        if token:
            auth_sp = spotipy.Spotify(auth=token)

    return auth_sp 
开发者ID:plamere,项目名称:pbl,代码行数:12,代码来源:spotify_plugs.py


注:本文中的spotipy.util方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。