Created
September 13, 2023 14:36
-
-
Save 0scvr/1e4f120a21f09e9b092f6e61b7cc9f18 to your computer and use it in GitHub Desktop.
Python script to save song URLs from a Spotify playlist in a text file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import spotipy | |
from spotipy.oauth2 import SpotifyClientCredentials | |
sp = spotipy.Spotify(auth_manager=SpotifyClientCredentials(client_id="XXXX", client_secret="XXXX")) | |
pl = sp.playlist('XXXX') | |
song_urls = [] | |
for x in pl['tracks']['items']: | |
song_url = x['track']['external_urls']['spotify'] | |
song_urls.append(song_url) | |
with open('song_urls.txt', 'w') as file: | |
for url in song_urls: | |
file.write(url + '\n') | |
print('URLs saved in song_urls.txt') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment