seperated controls from artist song frame
this fixes the controls moving if song name long modified updater to restart completely if killed/encounters exception
This commit is contained in:
2
.cache
2
.cache
@@ -1 +1 @@
|
|||||||
{"access_token": "BQBXuUO_bXWOT8jstBrtDrGGP3P_4y_93_E0Ij6FAogp6c8_GFn4J7zUWA7dYq-q4xanGhVgcQCX4PO6GOQIx9W4-9J-1ldb2V_iPot0ibSg-8EmMTGLw4HNQf9-Yn-cbDvzHnxZWMIAp2_VcoYrF7K4BLOIFTi4JPtVM7wpL5jB-IRFRI2sYsLjafTb_gLf29XzTsPVsPloC_ljet1n", "token_type": "Bearer", "expires_in": 3600, "scope": "user-library-modify user-library-read user-modify-playback-state user-read-playback-state", "expires_at": 1679993964, "refresh_token": "AQC5BsmRqj_PhCL7Xj32C6Pz4UeFF09ZufzWv0NU1lGwZCUGaWAQP8F4twJf3Rx5EfKyAg4DIEnHZIFd6e5L4bPQXhPUny2t7A1AA5hCwfFI_LjXWWPij8oKX_0YDr6CXK0"}
|
{"access_token": "BQAlP-N225jrOKxkXWbI3uWIbprdAPRTdpgCbqYXPy4F1ZW5j_50Y5uheK72ndz8aHDMwW93zqIZj0w8lODitTO9pUVCN6OQaKlaPe5DZsLB2MSqi5bn6nXVAfELO76yEqqATSVSXNPqObjbbNzE1BFZJvkEM5pMie2prbadewOtAIPIqogNxsiQXLAvql_gJU6xGm077lIaTyh7pcgM", "token_type": "Bearer", "expires_in": 3600, "refresh_token": "AQAXp9B05jv8qP5hp9cqwkz1nXQ9yTC1KUSJV_6V3LUr0KWA8SxhFHyZXN7tqjlRYQiQTP-43t22DQFDDTwLQRGvRWBcunA7ME_Rj5SnCQJOCpvmcyRRJm6JRwDAFnMkpnU", "scope": "user-library-modify user-library-read user-modify-playback-state user-read-playback-state", "expires_at": 1680996947}
|
||||||
@@ -18,23 +18,29 @@ import numpy
|
|||||||
|
|
||||||
# import speech_recognition as sr
|
# import speech_recognition as sr
|
||||||
if os.name == 'posix':
|
if os.name == 'posix':
|
||||||
|
client_id = "df61ecadf09941eb87e693d37f3ad178"
|
||||||
|
client_secret = "ba97992d614e48d6b0d023998b2957cb"
|
||||||
os.system("xset -display :0 s 21600")
|
os.system("xset -display :0 s 21600")
|
||||||
if os.path.isfile("updated.cfg"):
|
if os.path.isfile("updated.cfg"):
|
||||||
print("NEW VER")
|
print("NEW VER")
|
||||||
os.remove("updated.cfg")
|
os.remove("updated.cfg")
|
||||||
sleep(5)
|
sleep(5)
|
||||||
|
else:
|
||||||
|
client_id = "69b82a34d0fb40be80b020eae8e80f25"
|
||||||
|
client_secret = "455575b0e3db44acbbfaa0c419bc3c10"
|
||||||
|
|
||||||
q = queue.Queue()
|
q = queue.Queue()
|
||||||
|
|
||||||
# import canvas
|
# import canvas
|
||||||
|
|
||||||
# Set the Spotify app's client ID and client secret
|
# development client id and secret (SpotifyGUI)
|
||||||
# client_id = "69b82a34d0fb40be80b020eae8e80f25"
|
# client_id = "69b82a34d0fb40be80b020eae8e80f25"
|
||||||
# client_secret = "455575b0e3db44acbbfaa0c419bc3c10"
|
# client_secret = "455575b0e3db44acbbfaa0c419bc3c10"
|
||||||
redirect_uri = "http://127.0.0.1:8888/callback"
|
redirect_uri = "http://127.0.0.1:8888/callback"
|
||||||
|
|
||||||
client_id = "df61ecadf09941eb87e693d37f3ad178"
|
# embeeded client id and secret (SpotifyGUI 2)
|
||||||
client_secret = "ba97992d614e48d6b0d023998b2957cb"
|
# client_id = "df61ecadf09941eb87e693d37f3ad178"
|
||||||
|
# client_secret = "ba97992d614e48d6b0d023998b2957cb"
|
||||||
|
|
||||||
# Set the user's Spotify username
|
# Set the user's Spotify username
|
||||||
username = "thebrandon45"
|
username = "thebrandon45"
|
||||||
@@ -70,7 +76,7 @@ spotify = spotipy.Spotify(auth_manager=oauth)
|
|||||||
# print(SpotifyOAuth.refresh_access_token(refresh_token=access_token))
|
# print(SpotifyOAuth.refresh_access_token(refresh_token=access_token))
|
||||||
|
|
||||||
bg_color = "#000000"
|
bg_color = "#000000"
|
||||||
# count = 0
|
count = 0
|
||||||
# wait_time = 6500
|
# wait_time = 6500
|
||||||
# hotword = "magical"
|
# hotword = "magical"
|
||||||
|
|
||||||
@@ -163,6 +169,7 @@ def start_playback_on_device():
|
|||||||
spotify.transfer_playback(device_id=device_id)
|
spotify.transfer_playback(device_id=device_id)
|
||||||
|
|
||||||
def get_devices():
|
def get_devices():
|
||||||
|
global count
|
||||||
# global count
|
# global count
|
||||||
# global wait_time
|
# global wait_time
|
||||||
# count +=1
|
# count +=1
|
||||||
@@ -170,6 +177,7 @@ def get_devices():
|
|||||||
# wait_time = 6500
|
# wait_time = 6500
|
||||||
# elif count >= 69:
|
# elif count >= 69:
|
||||||
# wait_time = 3600000
|
# wait_time = 3600000
|
||||||
|
count += 1
|
||||||
list_of_devices = spotify.devices()
|
list_of_devices = spotify.devices()
|
||||||
|
|
||||||
# if list_of_devices == "{'devices': []}":
|
# if list_of_devices == "{'devices': []}":
|
||||||
@@ -177,6 +185,10 @@ def get_devices():
|
|||||||
# loadSearching_Devices()
|
# loadSearching_Devices()
|
||||||
# root.after(1000, get_devices)
|
# root.after(1000, get_devices)
|
||||||
# else:
|
# else:
|
||||||
|
if count > 210:
|
||||||
|
unloadDevices_list()
|
||||||
|
loadSleep()
|
||||||
|
root.after(3600, get_devices)
|
||||||
if spotify.current_playback() != None:
|
if spotify.current_playback() != None:
|
||||||
# unloadSearching_Devices()
|
# unloadSearching_Devices()
|
||||||
unloadDevices_list()
|
unloadDevices_list()
|
||||||
@@ -191,6 +203,10 @@ def get_devices():
|
|||||||
devices_list.insert(num_of_device, list_of_devices["devices"][num_of_device]["name"])
|
devices_list.insert(num_of_device, list_of_devices["devices"][num_of_device]["name"])
|
||||||
root.after(8500, get_devices)
|
root.after(8500, get_devices)
|
||||||
|
|
||||||
|
def wakeup():
|
||||||
|
global count
|
||||||
|
count = 0
|
||||||
|
|
||||||
# def wakeup():
|
# def wakeup():
|
||||||
# global count
|
# global count
|
||||||
# global wait_time
|
# global wait_time
|
||||||
@@ -331,6 +347,7 @@ frame_artist_song = ttk.Frame(root, width=(1280/3), height=400, bg=bg_color)
|
|||||||
album_art_frame = ttk.Frame(root)
|
album_art_frame = ttk.Frame(root)
|
||||||
lyrics_label_frame = ttk.Frame(root, width=(1280/3), height=400, bg=bg_color)
|
lyrics_label_frame = ttk.Frame(root, width=(1280/3), height=400, bg=bg_color)
|
||||||
lyrics_label_frame.grid_propagate(0)
|
lyrics_label_frame.grid_propagate(0)
|
||||||
|
sleep_frame = ttk.Frame(root, width=(1280/3), height=400, bg=bg_color)
|
||||||
|
|
||||||
root.grid_rowconfigure(0, weight=1)
|
root.grid_rowconfigure(0, weight=1)
|
||||||
root.grid_rowconfigure(1, weight=1)
|
root.grid_rowconfigure(1, weight=1)
|
||||||
@@ -344,10 +361,10 @@ lyrics_label_frame.grid_rowconfigure(0, weight=1)
|
|||||||
lyrics_label_frame.grid_columnconfigure(0, weight=1)
|
lyrics_label_frame.grid_columnconfigure(0, weight=1)
|
||||||
|
|
||||||
# Create the media control buttons and a text label
|
# Create the media control buttons and a text label
|
||||||
play_button = ttk.Label(frame_artist_song, image=play_img, borderwidth=0)
|
play_button = ttk.Label(root, image=play_img, borderwidth=0)
|
||||||
pause_button = ttk.Label(frame_artist_song, image=pause_img, borderwidth=0)
|
pause_button = ttk.Label(root, image=pause_img, borderwidth=0)
|
||||||
next_button = ttk.Label(frame_artist_song, image=next_img, borderwidth=0)
|
next_button = ttk.Label(root, image=next_img, borderwidth=0)
|
||||||
previous_button = ttk.Label(frame_artist_song, image=previous_img, borderwidth=0)
|
previous_button = ttk.Label(root, image=previous_img, borderwidth=0)
|
||||||
artist_label = tk.Label(frame_artist_song, text="", font=("Helvetica", 24), wraplength=(1280/3), justify=ttk.CENTER, background=bg_color)
|
artist_label = tk.Label(frame_artist_song, text="", font=("Helvetica", 24), wraplength=(1280/3), justify=ttk.CENTER, background=bg_color)
|
||||||
song_label = tk.Label(frame_artist_song, text="", font=("Helvetica", 32), wraplength=(1280/3), justify=ttk.CENTER, background=bg_color)
|
song_label = tk.Label(frame_artist_song, text="", font=("Helvetica", 32), wraplength=(1280/3), justify=ttk.CENTER, background=bg_color)
|
||||||
get_devices_button = tk.Button(root, text="Get Devices", command=get_devices)
|
get_devices_button = tk.Button(root, text="Get Devices", command=get_devices)
|
||||||
@@ -365,6 +382,7 @@ pause_button.bind("<Button-1>", lambda e:controlPause())
|
|||||||
next_button.bind("<Button-1>", lambda e:controlNext())
|
next_button.bind("<Button-1>", lambda e:controlNext())
|
||||||
previous_button.bind("<Button-1>", lambda e:controlPrevious())
|
previous_button.bind("<Button-1>", lambda e:controlPrevious())
|
||||||
album_art_label.bind("<Button-1>", lambda e:likeSong())
|
album_art_label.bind("<Button-1>", lambda e:likeSong())
|
||||||
|
sleep_frame.bind("<Button-1>", lambda e:wakeup())
|
||||||
# devices_list.bind("<Button-1>", lambda e:wakeup())
|
# devices_list.bind("<Button-1>", lambda e:wakeup())
|
||||||
|
|
||||||
|
|
||||||
@@ -383,15 +401,12 @@ def update_song_label():
|
|||||||
|
|
||||||
root.after(200, get_devices)
|
root.after(200, get_devices)
|
||||||
# Update the song label every 1 second
|
# Update the song label every 1 second
|
||||||
else:
|
elif current_playback.get("item") is not None:
|
||||||
if current_playback.get("item"):
|
|
||||||
track_name = current_playback["item"]["name"]
|
track_name = current_playback["item"]["name"]
|
||||||
track_progress = current_playback["progress_ms"]
|
track_progress = current_playback["progress_ms"]
|
||||||
playing_status = current_playback["is_playing"]
|
playing_status = current_playback["is_playing"]
|
||||||
track_progress_min = track_progress//(1000*60)%60
|
track_progress_min = track_progress//(1000*60)%60
|
||||||
track_progress_sec = (track_progress//1000)%60
|
track_progress_sec = (track_progress//1000)%60
|
||||||
else:
|
|
||||||
track_name = "Loading..."
|
|
||||||
if track_name == song_label.cget("text"):
|
if track_name == song_label.cget("text"):
|
||||||
track_progress_formatted = ("{}:{:02d}".format(track_progress_min, track_progress_sec))
|
track_progress_formatted = ("{}:{:02d}".format(track_progress_min, track_progress_sec))
|
||||||
progress_bar.config(value=track_progress)
|
progress_bar.config(value=track_progress)
|
||||||
@@ -444,22 +459,24 @@ def update_song_label():
|
|||||||
root.after(500, update_song_label)
|
root.after(500, update_song_label)
|
||||||
if playing_status == True:
|
if playing_status == True:
|
||||||
play_button.grid_forget()
|
play_button.grid_forget()
|
||||||
pause_button.grid(row=3, column=1, pady=(100,0))
|
pause_button.grid(row=3, column=1, pady=(0,20))
|
||||||
elif playing_status == False:
|
elif playing_status == False:
|
||||||
pause_button.grid_forget()
|
pause_button.grid_forget()
|
||||||
play_button.grid(row=3, column=1, pady=(100,0))
|
play_button.grid(row=3, column=1, pady=(0,20))
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
else:
|
||||||
|
root.after(1000, get_devices)
|
||||||
|
|
||||||
def loadNow_playing():
|
def loadNow_playing():
|
||||||
frame_artist_song.grid(row=0, column=1, rowspan=3, pady=(20,0))
|
frame_artist_song.grid(row=0, column=1, rowspan=3, pady=(30,0), sticky="n")
|
||||||
device_name_label.grid(row=0, column=1)
|
device_name_label.grid(row=0, column=1)
|
||||||
artist_label.grid(row=2, column=1)
|
artist_label.grid(row=2, column=1)
|
||||||
song_label.grid(row=1, column=1)
|
song_label.grid(row=1, column=1)
|
||||||
previous_button.grid(row=3, column=1, padx=(0,200), pady=(100,0))
|
previous_button.grid(row=3, column=1, padx=(0,200), pady=(0,20))
|
||||||
play_button.grid(row=3, column=1, pady=(100,0))
|
play_button.grid(row=3, column=1, pady=(0,20))
|
||||||
next_button.grid(row=3, column=1, padx=(200,0), pady=(100,0))
|
next_button.grid(row=3, column=1, padx=(200,0), pady=(0,20))
|
||||||
progress_bar.grid(row=3, column=0, columnspan=3)
|
progress_bar.grid(row=3, column=0, columnspan=3, sticky="wse")
|
||||||
album_art_frame.grid(row=0, column=0, rowspan=4)
|
album_art_frame.grid(row=0, column=0, rowspan=4)
|
||||||
album_art_label.grid(sticky="w")
|
album_art_label.grid(sticky="w")
|
||||||
lyrics_label_frame.grid(row=0, column=2, rowspan=4)
|
lyrics_label_frame.grid(row=0, column=2, rowspan=4)
|
||||||
@@ -490,6 +507,9 @@ def loadSearching_Devices():
|
|||||||
def unloadSearching_Devices():
|
def unloadSearching_Devices():
|
||||||
searching_for_devices_label.grid_forget()
|
searching_for_devices_label.grid_forget()
|
||||||
|
|
||||||
|
def loadSleep():
|
||||||
|
sleep_frame.grid()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# def recognize(recognizer, audio):
|
# def recognize(recognizer, audio):
|
||||||
|
|||||||
6
todo.txt
6
todo.txt
@@ -76,3 +76,9 @@ add shuffle and repeat buttons
|
|||||||
|
|
||||||
03/07/2023:
|
03/07/2023:
|
||||||
make it so the displays turns off automatically after some time (maybe depending on time, ie. late at night)
|
make it so the displays turns off automatically after some time (maybe depending on time, ie. late at night)
|
||||||
|
|
||||||
|
04/03/2023:
|
||||||
|
make it so update.py that kills the main script after 6 hours and turn the display off, if the displays wakes up then it will restart the main script
|
||||||
|
|
||||||
|
04/08/2023:
|
||||||
|
background of artist image
|
||||||
36
update.py
36
update.py
@@ -6,29 +6,39 @@ from time import sleep
|
|||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
|
# while True:
|
||||||
|
# try:
|
||||||
|
# urlopen('http://bbrunson.com', timeout=1)
|
||||||
|
# print("Connection to server established.")
|
||||||
|
# break
|
||||||
|
# except:
|
||||||
|
# pass
|
||||||
|
|
||||||
|
|
||||||
|
# try:
|
||||||
|
# print("Checking for updates...")
|
||||||
|
# with ZipFile(BytesIO((urlopen('http://files.bbrunson.com/spotify-gui/update.zip')).read())) as zipObj:
|
||||||
|
# zipObj.extractall()
|
||||||
|
# print("Update successfully installed.")
|
||||||
|
# except urllib.error.HTTPError:
|
||||||
|
# print("No update available.")
|
||||||
|
# pass
|
||||||
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
urlopen('http://bbrunson.com', timeout=1)
|
urlopen('http://bbrunson.com', timeout=1)
|
||||||
print("Connection to server established.")
|
print("Connection to server established.")
|
||||||
break
|
try:
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
|
||||||
print("Checking for updates...")
|
print("Checking for updates...")
|
||||||
with ZipFile(BytesIO((urlopen('http://files.bbrunson.com/spotify-gui/update.zip')).read())) as zipObj:
|
with ZipFile(BytesIO((urlopen('http://files.bbrunson.com/spotify-gui/update.zip')).read())) as zipObj:
|
||||||
zipObj.extractall()
|
zipObj.extractall()
|
||||||
print("Update successfully installed.")
|
print("Update successfully installed.")
|
||||||
except urllib.error.HTTPError:
|
except urllib.error.HTTPError:
|
||||||
print("No update available.")
|
print("No update available.")
|
||||||
pass
|
pass
|
||||||
|
subprocess.check_call(['python3', 'spotifycontroller.py'])
|
||||||
|
|
||||||
while True:
|
|
||||||
try:
|
|
||||||
subprocess.check_call(['python', 'spotifycontroller.py'])
|
|
||||||
except:
|
except:
|
||||||
print("An error has ocurred, reestablishing the application in 10 seconds.")
|
print("An error has ocurred, checking server connection, checking for update, and then reestablishing the application in 10 seconds.")
|
||||||
sleep(10)
|
sleep(10)
|
||||||
continue
|
continue
|
||||||
Reference in New Issue
Block a user