mirror of
https://github.com/KevinMidboe/spotify-downloader.git
synced 2025-10-29 18:00:15 +00:00
Update mechanism for fetching playlist tracks
This commit is contained in:
24
spotdl.py
24
spotdl.py
@@ -128,6 +128,7 @@ def feed_playlist(username):
|
||||
playlists = spotify.next(playlists)
|
||||
else:
|
||||
break
|
||||
|
||||
print('')
|
||||
# let user select playlist
|
||||
playlist = misc.input_link(links)
|
||||
@@ -137,14 +138,23 @@ def feed_playlist(username):
|
||||
# slugify removes any special characters
|
||||
file = slugify(playlist['name'], ok='-_()[]{}') + '.txt'
|
||||
print('Feeding ' + str(playlist['tracks']['total']) + ' tracks to ' + file)
|
||||
|
||||
tracks = results['tracks']
|
||||
# write tracks to file
|
||||
misc.feed_tracks(file, tracks)
|
||||
# check if there are more pages
|
||||
# 1 page = 50 results
|
||||
while tracks['next']:
|
||||
tracks = spotify.next(tracks)
|
||||
misc.feed_tracks(file, tracks)
|
||||
with open(file, 'a') as fout:
|
||||
while True:
|
||||
for item in tracks['items']:
|
||||
track = item['track']
|
||||
try:
|
||||
fout.write(track['external_urls']['spotify'] + '\n')
|
||||
except KeyError:
|
||||
title = track['name'] + ' by '+ track['artists'][0]['name']
|
||||
print('Skipping track ' + title + ' (local only?)')
|
||||
# 1 page = 50 results
|
||||
# check if there are more pages
|
||||
if tracks['next']:
|
||||
tracks = spotify.next(tracks)
|
||||
else:
|
||||
break
|
||||
|
||||
def download_song(content):
|
||||
if args.input_ext == '.webm':
|
||||
|
||||
Reference in New Issue
Block a user