From 9162f7194d39c1520153735db85d4f689af7bbcc Mon Sep 17 00:00:00 2001 From: Brandon4466 Date: Wed, 11 Jan 2023 13:26:54 -0800 Subject: [PATCH] fixed devices list not loading now playing added exception handling for token expiration in devices list --- .cache-thebrandon45 | 2 +- program-embedded.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.cache-thebrandon45 b/.cache-thebrandon45 index 8863fdb..f6bfd49 100644 --- a/.cache-thebrandon45 +++ b/.cache-thebrandon45 @@ -1 +1 @@ -{"access_token": "BQC2e3LU31cnEU0wNqqtrcWUrhsiMvTo7uO4Ypujo-RvZ0eonbYIyb5rwEdZj5GlN60dp3OFUq0xQcsliPiFRYUbGLCEc7de2l6IE4XKq-4WZFRw29RJ4TVHaKLERPI9cGcIgS3koLKHxSAomRGRkIAOOsfAU6Nu5CSTemp793_B22-PRWIC4XR7QMd7gQ", "token_type": "Bearer", "expires_in": 3600, "scope": "user-modify-playback-state user-read-playback-state", "expires_at": 1673465722, "refresh_token": "AQDs4x9WTbYtoqePbR9tvRWCcJHs1Hh3vrXpIHBtBdkJIDJ-Mu14B-vLEqOnowqw1HzZI5H5ytOFS2y9xBCcDyDU0uMA_D0MRPtujyCUYb9sdnD-D6WC2fN7bFiGeoo-YAo"} \ No newline at end of file +{"access_token": "BQDIrlY_zruLGRtHdCeqZQT_R4MJ02E89oYTyzW-aUBxGkwrcuIaYhFAUaNVEZQE-aa-EU3j08rxeI99jaFRvG9WQy5-tsWzD1BsU8NMKLhsFRNXE8jjElDTYHicblA8ihubAP6jekrqvxP3nFXE9ggrX2fvZk8qmOe6pB5LSfli0XSpnKX2-Jjlr1YG3A", "token_type": "Bearer", "expires_in": 3600, "scope": "user-modify-playback-state user-read-playback-state", "expires_at": 1673474531, "refresh_token": "AQDs4x9WTbYtoqePbR9tvRWCcJHs1Hh3vrXpIHBtBdkJIDJ-Mu14B-vLEqOnowqw1HzZI5H5ytOFS2y9xBCcDyDU0uMA_D0MRPtujyCUYb9sdnD-D6WC2fN7bFiGeoo-YAo"} \ No newline at end of file diff --git a/program-embedded.py b/program-embedded.py index a7133cf..dd41a7d 100644 --- a/program-embedded.py +++ b/program-embedded.py @@ -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("", search) +play_button.bind("<>", lambda e: frame_artist_song.focus()) # Function to update the song label with the current track's name def update_song_label():