當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。