FIXED RECURSION

had some bad recursion in the function, fixed with a while loop
This commit is contained in:
Brandon4466
2023-01-14 18:50:51 -08:00
parent c23b8b01c2
commit 319542f470
6 changed files with 16 additions and 21 deletions

View File

@@ -3,18 +3,14 @@ import spotipy.util
import tkinter as ttk
from tkinter import ttk as tk
import random
import json
import sv_ttk
from urllib.request import urlopen
import requests
from time import sleep
import sys
import os
import pyautogui
import threading
import platform
import syncedlyrics
import textwrap
from PIL import Image, ImageTk
from io import BytesIO
import math
@@ -244,10 +240,10 @@ lyrics_label_frame.grid_rowconfigure(0, weight=1)
lyrics_label_frame.grid_columnconfigure(0, weight=1)
# Create the media control buttons and a text label
play_button = ttk.Button(frame_artist_song, image=play_img, command=play, borderwidth=0, relief=None, background=bg_color)
pause_button = ttk.Button(frame_artist_song, image=pause_img, command=pause, borderwidth=0, background=bg_color)
next_button = ttk.Button(frame_artist_song, image=next_img, command=next, borderwidth=0, background=bg_color)
previous_button = ttk.Button(frame_artist_song, image=previous_img, command=previous, borderwidth=0, background=bg_color)
play_button = ttk.Label(frame_artist_song, image=play_img, borderwidth=0)
pause_button = ttk.Label(frame_artist_song, image=pause_img, borderwidth=0)
next_button = ttk.Label(frame_artist_song, image=next_img, borderwidth=0)
previous_button = ttk.Label(frame_artist_song, image=previous_img, borderwidth=0)
maxvolume_button = tk.Button(root, text="Max Volume", command=maxvolume)
minvolume_button = tk.Button(root, text="Min Volume", command=minvolume)
randomvolume_button = tk.Button(root, text="Random Volume", command=randomvolume)
@@ -277,18 +273,22 @@ album_art_label = tk.Label(album_art_frame, image=album_art_img)
root.bind("<Return>", search)
lyrics_label.bind("<Button-1>", lambda e:unloadLyrics_pressed())
album_art_label.bind("<Button-1>", lambda e:unloadLyrics_pressed())
play_button.bind("<Button-1>", lambda e:play())
pause_button.bind("<Button-1>", lambda e:pause())
next_button.bind("<Button-1>", lambda e:next())
previous_button.bind("<Button-1>", lambda e:previous())
# Function to update the song label with the current track's name
def update_song_label():
global lrc
global album_art_img
# Get the current playback information
try:
current_playback = spotify.current_playback()
except (spotipy.exceptions.SpotifyException, requests.exceptions.HTTPError):
createToken()
current_playback = spotify.current_playback()
while True:
try:
current_playback = spotify.current_playback()
break
except (spotipy.exceptions.SpotifyException, requests.exceptions.HTTPError):
createToken()
# If there is no current playback, set the text of the song label to "No playback"
if current_playback is None:
# nothing_playing_obj = '{"item": {"artists": [{"name": "Nothing Playing"}],"duration_ms": 0,"name": "Nothing Playing"},"progress_ms": 0}'
@@ -296,12 +296,7 @@ def update_song_label():
get_devices()
# Update the song label every 1 second
else:
try:
track_name = current_playback["item"]["name"]
pass
except TypeError:
sleep(1000)
update_song_label()
track_name = current_playback["item"]["name"]
artist_name = current_playback["item"]["artists"][0]["name"]
track_duration = current_playback["item"]["duration_ms"]
track_progress = current_playback["progress_ms"]