mirror of
https://github.com/THIS-IS-NOT-A-BACKUP/zspotify.git
synced 2024-11-29 19:24:34 +01:00
Patched a bug which stopped some playlists from downloading
Sometimes the spotify playlist API query will return None for some song id's which crashed my program further down the pipeline, fixed by added filter to skip those tracks.
This commit is contained in:
parent
545800a53b
commit
11e6323e41
@ -45,7 +45,7 @@ def wait(seconds: int = 3):
|
|||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
def sanitizeData(value):
|
def sanitizeData(value):
|
||||||
return value.replace("\\", "").replace("/", "")
|
return value.replace("\\", "").replace("/", "").replace(":", "").replace("*", "").replace("?", "").replace("'", "").replace("<", "").replace(">", "")
|
||||||
|
|
||||||
def splash():
|
def splash():
|
||||||
print("=================================\n"
|
print("=================================\n"
|
||||||
@ -211,6 +211,7 @@ def search(searchTerm):
|
|||||||
playlistChoice = playlists[position - totalTracks - totalAlbums - 1]
|
playlistChoice = playlists[position - totalTracks - totalAlbums - 1]
|
||||||
playlistSongs = get_playlist_songs(token, playlistChoice['id'])
|
playlistSongs = get_playlist_songs(token, playlistChoice['id'])
|
||||||
for song in playlistSongs:
|
for song in playlistSongs:
|
||||||
|
if song['track']['id'] != None:
|
||||||
downloadTrack(song['track']['id'], sanitizeData(playlistChoice['name'].strip()) + "/")
|
downloadTrack(song['track']['id'], sanitizeData(playlistChoice['name'].strip()) + "/")
|
||||||
print("\n")
|
print("\n")
|
||||||
|
|
||||||
@ -422,7 +423,7 @@ def downloadFromOurPlaylists():
|
|||||||
playlistChoice = input("SELECT A PLAYLIST BY ID: ")
|
playlistChoice = input("SELECT A PLAYLIST BY ID: ")
|
||||||
playlistSongs = get_playlist_songs(token, playlists[int(playlistChoice) - 1]['id'])
|
playlistSongs = get_playlist_songs(token, playlists[int(playlistChoice) - 1]['id'])
|
||||||
for song in playlistSongs:
|
for song in playlistSongs:
|
||||||
|
if song['track']['id'] != None:
|
||||||
downloadTrack(song['track']['id'], sanitizeData(playlists[int(playlistChoice) - 1]['name'].strip()) + "/")
|
downloadTrack(song['track']['id'], sanitizeData(playlists[int(playlistChoice) - 1]['name'].strip()) + "/")
|
||||||
print("\n")
|
print("\n")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user