Skip to content

Instantly share code, notes, and snippets.

@0scvr
Created September 13, 2023 14:36
Show Gist options
  • Save 0scvr/1e4f120a21f09e9b092f6e61b7cc9f18 to your computer and use it in GitHub Desktop.
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
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