Anonymous
Функции Spotipy (python) работают вечно с OAuth
Сообщение
Anonymous » 09 дек 2024, 05:48
Код: Выделить всё
import requests
import json
import spotipy
from credentials import CLIENT_ID, CLIENT_SECRET, REDIRECT_URI
from spotipy.oauth2 import SpotifyOAuth
# auth
print('starting auth')
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(client_id=CLIENT_ID, redirect_uri=REDIRECT_URI, client_secret=CLIENT_SECRET, scope='playlist-modify-public user-library-read'))
print('finished auth')
taylor_uri = 'spotify:artist:06HL4z0CvFAxyc27GXpf02'
print('searching')
results = sp.artist_albums(taylor_uri, album_type='album')
print('done searching')
albums = results['items']
while results['next']:
results = sp.next(results)
albums.extend(results['items'])
for album in albums:
print(album['name'])
Код: Выделить всё
results = sp.artist_albums(taylor_uri, album_type='album')
В строке выше код зависает, я пробовал много других функций, но они будут загружаться вечно...
Подробнее здесь:
https://stackoverflow.com/questions/792 ... with-oauth
1733712497
Anonymous
[code] import requests import json import spotipy from credentials import CLIENT_ID, CLIENT_SECRET, REDIRECT_URI from spotipy.oauth2 import SpotifyOAuth # auth print('starting auth') sp = spotipy.Spotify(auth_manager=SpotifyOAuth(client_id=CLIENT_ID, redirect_uri=REDIRECT_URI, client_secret=CLIENT_SECRET, scope='playlist-modify-public user-library-read')) print('finished auth') taylor_uri = 'spotify:artist:06HL4z0CvFAxyc27GXpf02' print('searching') results = sp.artist_albums(taylor_uri, album_type='album') print('done searching') albums = results['items'] while results['next']: results = sp.next(results) albums.extend(results['items']) for album in albums: print(album['name']) [/code] [code] results = sp.artist_albums(taylor_uri, album_type='album') [/code] В строке выше код зависает, я пробовал много других функций, но они будут загружаться вечно... [img]https://i.sstatic.net/vT8Cwu7o.png[/img] Подробнее здесь: [url]https://stackoverflow.com/questions/79263708/spotipy-python-functions-run-forever-with-oauth[/url]