mirror of
https://github.com/THIS-IS-NOT-A-BACKUP/zspotify.git
synced 2024-12-02 04:23:57 +01:00
Fixed crash from variable reference before assignment
This commit is contained in:
parent
c4ff812ac3
commit
0b51951b5f
3
.gitignore
vendored
3
.gitignore
vendored
@ -151,3 +151,6 @@ ZSpotify\ Podcasts/
|
|||||||
|
|
||||||
# Intellij
|
# Intellij
|
||||||
.idea
|
.idea
|
||||||
|
|
||||||
|
#Configuration json file
|
||||||
|
zs_config.json
|
||||||
|
@ -33,12 +33,14 @@ def client() -> None:
|
|||||||
elif sys.argv[1] == '-ls' or sys.argv[1] == '--liked-songs':
|
elif sys.argv[1] == '-ls' or sys.argv[1] == '--liked-songs':
|
||||||
for song in get_saved_tracks():
|
for song in get_saved_tracks():
|
||||||
if not song[TRACK][NAME]:
|
if not song[TRACK][NAME]:
|
||||||
print('### SKIPPING: SONG DOES NOT EXIST ON SPOTIFY ANYMORE ###')
|
print(
|
||||||
|
'### SKIPPING: SONG DOES NOT EXIST ON SPOTIFY ANYMORE ###')
|
||||||
else:
|
else:
|
||||||
download_track(song[TRACK][ID], 'Liked Songs/')
|
download_track(song[TRACK][ID], 'Liked Songs/')
|
||||||
print('\n')
|
print('\n')
|
||||||
else:
|
else:
|
||||||
track_id, album_id, playlist_id, episode_id, show_id, artist_id = regex_input_for_urls(sys.argv[1])
|
track_id, album_id, playlist_id, episode_id, show_id, artist_id = regex_input_for_urls(
|
||||||
|
sys.argv[1])
|
||||||
|
|
||||||
if track_id is not None:
|
if track_id is not None:
|
||||||
download_track(track_id)
|
download_track(track_id)
|
||||||
@ -64,7 +66,8 @@ def client() -> None:
|
|||||||
while len(search_text) == 0:
|
while len(search_text) == 0:
|
||||||
search_text = input('Enter search or URL: ')
|
search_text = input('Enter search or URL: ')
|
||||||
|
|
||||||
track_id, album_id, playlist_id, episode_id, show_id, artist_id = regex_input_for_urls(search_text)
|
track_id, album_id, playlist_id, episode_id, show_id, artist_id = regex_input_for_urls(
|
||||||
|
search_text)
|
||||||
|
|
||||||
if track_id is not None:
|
if track_id is not None:
|
||||||
download_track(track_id)
|
download_track(track_id)
|
||||||
@ -114,7 +117,6 @@ def search(search_term):
|
|||||||
raise ValueError('Invalid limit passed. Max is 50.\n')
|
raise ValueError('Invalid limit passed. Max is 50.\n')
|
||||||
params['limit'] = splits[index+1]
|
params['limit'] = splits[index+1]
|
||||||
|
|
||||||
|
|
||||||
if split == '-t' or split == '-type':
|
if split == '-t' or split == '-type':
|
||||||
|
|
||||||
allowed_types = ['track', 'playlist', 'album', 'artist']
|
allowed_types = ['track', 'playlist', 'album', 'artist']
|
||||||
@ -148,6 +150,7 @@ def search(search_term):
|
|||||||
counter = 1
|
counter = 1
|
||||||
dics = []
|
dics = []
|
||||||
|
|
||||||
|
total_tracks = 0
|
||||||
if TRACK in params['type'].split(','):
|
if TRACK in params['type'].split(','):
|
||||||
tracks = resp[TRACKS][ITEMS]
|
tracks = resp[TRACKS][ITEMS]
|
||||||
if len(tracks) > 0:
|
if len(tracks) > 0:
|
||||||
@ -169,13 +172,13 @@ def search(search_term):
|
|||||||
|
|
||||||
counter += 1
|
counter += 1
|
||||||
total_tracks = counter - 1
|
total_tracks = counter - 1
|
||||||
print(tabulate(track_data, headers=['S.NO', 'Name', 'Artists'], tablefmt='pretty'))
|
print(tabulate(track_data, headers=[
|
||||||
|
'S.NO', 'Name', 'Artists'], tablefmt='pretty'))
|
||||||
print('\n')
|
print('\n')
|
||||||
del tracks
|
del tracks
|
||||||
del track_data
|
del track_data
|
||||||
else:
|
|
||||||
total_tracks = 0
|
|
||||||
|
|
||||||
|
total_albums = 0
|
||||||
if ALBUM in params['type'].split(','):
|
if ALBUM in params['type'].split(','):
|
||||||
albums = resp[ALBUMS][ITEMS]
|
albums = resp[ALBUMS][ITEMS]
|
||||||
if len(albums) > 0:
|
if len(albums) > 0:
|
||||||
@ -192,13 +195,13 @@ def search(search_term):
|
|||||||
|
|
||||||
counter += 1
|
counter += 1
|
||||||
total_albums = counter - total_tracks - 1
|
total_albums = counter - total_tracks - 1
|
||||||
print(tabulate(album_data, headers=['S.NO', 'Album', 'Artists'], tablefmt='pretty'))
|
print(tabulate(album_data, headers=[
|
||||||
|
'S.NO', 'Album', 'Artists'], tablefmt='pretty'))
|
||||||
print('\n')
|
print('\n')
|
||||||
del albums
|
del albums
|
||||||
del album_data
|
del album_data
|
||||||
else:
|
|
||||||
total_albums = 0
|
|
||||||
|
|
||||||
|
total_artists = 0
|
||||||
if ARTIST in params['type'].split(','):
|
if ARTIST in params['type'].split(','):
|
||||||
artists = resp[ARTISTS][ITEMS]
|
artists = resp[ARTISTS][ITEMS]
|
||||||
if len(artists) > 0:
|
if len(artists) > 0:
|
||||||
@ -213,20 +216,21 @@ def search(search_term):
|
|||||||
})
|
})
|
||||||
counter += 1
|
counter += 1
|
||||||
total_artists = counter - total_tracks - total_albums - 1
|
total_artists = counter - total_tracks - total_albums - 1
|
||||||
print(tabulate(artist_data, headers=['S.NO', 'Name'], tablefmt='pretty'))
|
print(tabulate(artist_data, headers=[
|
||||||
|
'S.NO', 'Name'], tablefmt='pretty'))
|
||||||
print('\n')
|
print('\n')
|
||||||
del artists
|
del artists
|
||||||
del artist_data
|
del artist_data
|
||||||
else:
|
|
||||||
total_artists = 0
|
|
||||||
|
|
||||||
|
total_playlists = 0
|
||||||
if PLAYLIST in params['type'].split(','):
|
if PLAYLIST in params['type'].split(','):
|
||||||
playlists = resp[PLAYLISTS][ITEMS]
|
playlists = resp[PLAYLISTS][ITEMS]
|
||||||
if len(playlists) > 0:
|
if len(playlists) > 0:
|
||||||
print('### PLAYLISTS ###')
|
print('### PLAYLISTS ###')
|
||||||
playlist_data = []
|
playlist_data = []
|
||||||
for playlist in playlists:
|
for playlist in playlists:
|
||||||
playlist_data.append([counter, playlist[NAME], playlist[OWNER][DISPLAY_NAME]])
|
playlist_data.append(
|
||||||
|
[counter, playlist[NAME], playlist[OWNER][DISPLAY_NAME]])
|
||||||
dics.append({
|
dics.append({
|
||||||
ID: playlist[ID],
|
ID: playlist[ID],
|
||||||
NAME: playlist[NAME],
|
NAME: playlist[NAME],
|
||||||
@ -234,12 +238,11 @@ def search(search_term):
|
|||||||
})
|
})
|
||||||
counter += 1
|
counter += 1
|
||||||
total_playlists = counter - total_artists - total_tracks - total_albums - 1
|
total_playlists = counter - total_artists - total_tracks - total_albums - 1
|
||||||
print(tabulate(playlist_data, headers=['S.NO', 'Name', 'Owner'], tablefmt='pretty'))
|
print(tabulate(playlist_data, headers=[
|
||||||
|
'S.NO', 'Name', 'Owner'], tablefmt='pretty'))
|
||||||
print('\n')
|
print('\n')
|
||||||
del playlists
|
del playlists
|
||||||
del playlist_data
|
del playlist_data
|
||||||
else:
|
|
||||||
total_playlists = 0
|
|
||||||
|
|
||||||
if total_tracks + total_albums + total_artists + total_playlists == 0:
|
if total_tracks + total_albums + total_artists + total_playlists == 0:
|
||||||
print('NO RESULTS FOUND - EXITING...')
|
print('NO RESULTS FOUND - EXITING...')
|
||||||
@ -261,4 +264,3 @@ def search(search_term):
|
|||||||
download_artist_albums(dic[ID])
|
download_artist_albums(dic[ID])
|
||||||
else:
|
else:
|
||||||
download_playlist(dic)
|
download_playlist(dic)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user