fixed devices list not loading now playing

added exception handling for token expiration in devices list
This commit is contained in:
Brandon4466
2023-01-11 13:26:54 -08:00
parent bbd9e7a0a3
commit 9162f7194d
2 changed files with 8 additions and 1 deletions

View File

@@ -145,6 +145,11 @@ def search(event):
def start_playback_on_device():
device_selections = devices_list.curselection()
try:
list_of_devices = spotify.devices()
except (spotipy.exceptions.SpotifyException, requests.exceptions.HTTPError):
createToken()
pass
list_of_devices = spotify.devices()
device_id = list_of_devices["devices"][device_selections[0]]["id"]
spotify.transfer_playback(device_id=device_id)
@@ -162,6 +167,7 @@ def get_devices():
if current_playback != None:
unloadSearching_Devices()
unloadDevices_list()
loadNow_playing()
update_song_label()
else:
unloadSearching_Devices()
@@ -246,6 +252,7 @@ loadLyrics_button = ttk.Button(lyrics_button, image=lyrics_img, command=loadLyri
now_playing_button = tk.Button(root, text="Now Playing", command=unloadLyrics_pressed)
root.bind("<Return>", search)
play_button.bind("<<ButtonSelected>>", lambda e: frame_artist_song.focus())
# Function to update the song label with the current track's name
def update_song_label():