Я пытаюсь извлечь все песни из одного из моих плейлистов в Spotify. Использование пакета spotipy в Python для достижения этой цели. Ниже приведен текущий код, который содержит только 100 треков. Я пытался поискать решения в Интернете, но ничего не получалось. Ниже приведен код, который у меня есть до сих пор.
#Import Library
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
import spotipy
from matplotlib import style
from spotipy import util
from spotipy.oauth2 import SpotifyClientCredentials
#Set up Connection
client_id = 'id' #Need to create developer profile
client_secret = 'secret'
username = 'username' #Store username
scope = 'user-library-read playlist-modify-public playlist-read-private'
redirect_uri='uri'
client_credentials_manager = SpotifyClientCredentials(client_id=client_id,
client_secret=client_secret)#Create manager for ease
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
token = util.prompt_for_user_token(username, scope, client_id,
client_secret, redirect_uri)
if token:
sp = spotipy.Spotify(auth=token)
else:
print("Can't get token for", username)
#Connect to the best playlist, like ever
playlist_id = 'playlist'
playlist = sp.user_playlist(username,playlist_id)
#Extract list of songs/tracks
tracks = playlist["tracks"];
songs = tracks["items"];
track_ids = []
track_names = []
for i in range(0, len(songs)):
if songs[i]['track']['id'] != None: # Removes local tracks, if any
track_ids.append(songs[i]['track']['id'])
track_names.append(songs[i]['track']['name'])