diff --git a/.cache b/.cache index 9936314..2a2b4b2 100644 --- a/.cache +++ b/.cache @@ -1 +1 @@ -{"access_token": "BQAwNuSTPsxO_L1DyV-7sSX_5ymdMsBTCQl1K7JBu0S2dTa6sHzUbgwKECv3zMdlKwiopbW7a7tz1yVllgKqGAMZxgFeitoAenswfmYaT2buecmrYiA28bWh14PW26Ypdg_bJWz3x40bT9QP4dF-8vu23d_-FOVUTT0EcO7t6zI95GtB2Awp2z98VAQ_MdUFWohptYtD5HXg7qK2nnvi", "token_type": "Bearer", "expires_in": 3600, "scope": "user-library-modify user-library-read user-modify-playback-state user-read-playback-state", "expires_at": 1679465977, "refresh_token": "AQC5BsmRqj_PhCL7Xj32C6Pz4UeFF09ZufzWv0NU1lGwZCUGaWAQP8F4twJf3Rx5EfKyAg4DIEnHZIFd6e5L4bPQXhPUny2t7A1AA5hCwfFI_LjXWWPij8oKX_0YDr6CXK0"} \ No newline at end of file +{"access_token": "BQA33plRMZf_O-Cr91vOocSFUB4RMzjSPuXvxoFjVsVYuFPahghyGXQxYtQqMgkHh_Pga_Pg5FIwGrInUDQ-Npz9Dd_oFOWjs0Grg34hKxQTUJG21SNKtybjgLaOqDP08PUWZ2ubtReWY4yS2dpSYwixrAsvu8QCPH9LmkYq4qO20vQzevFNGh0TLmDTM31zSPqa0tWOTqnO35SaQr4u", "token_type": "Bearer", "expires_in": 3600, "scope": "user-library-modify user-library-read user-modify-playback-state user-read-playback-state", "expires_at": 1679903241, "refresh_token": "AQC5BsmRqj_PhCL7Xj32C6Pz4UeFF09ZufzWv0NU1lGwZCUGaWAQP8F4twJf3Rx5EfKyAg4DIEnHZIFd6e5L4bPQXhPUny2t7A1AA5hCwfFI_LjXWWPij8oKX_0YDr6CXK0"} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 0c0c3ae..bb035a0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ librespot Pillow -PyAutoGUI requests spotipy sv_ttk -syncedlyrics \ No newline at end of file +syncedlyrics +numpy \ No newline at end of file diff --git a/spotifycontroller.prof b/spotifycontroller.prof new file mode 100644 index 0000000..63ac7dd Binary files /dev/null and b/spotifycontroller.prof differ diff --git a/spotifycontroller.py b/spotifycontroller.py index ce3a942..717baeb 100644 --- a/spotifycontroller.py +++ b/spotifycontroller.py @@ -12,6 +12,7 @@ import math from time import sleep import threading import queue +import numpy # SpotifyGUI - Made by Brandon Brunson @@ -251,24 +252,58 @@ def addCorners(im, rad): # return back -def get_colors(image_file, numcolors=1, resize=150): +# def get_colors(image_file, resize=150): +# # Resize image to speed up processing +# image_file.thumbnail((resize, resize)) + +# max_count_index = numpy.argmax(numpy.unique(numpy.array(image_file).reshape(-1, numpy.array(image_file).shape[-1]), axis=0, return_counts=True)[1]) + +# # colors = list() +# # for i in range(numcolors): +# # palette_index = color_counts[i][1] +# # dominant_color = palette[palette_index*3:palette_index*3+3] +# # colors.append(tuple(dominant_color)) + +# return tuple(numpy.unique(numpy.array(image_file).reshape(-1, numpy.array(image_file).shape[-1]), axis=0, return_counts=True)[0][max_count_index]) + +def get_colors(image_file, resize=150): # Resize image to speed up processing image_file.thumbnail((resize, resize)) # Reduce to palette - paletted = image_file.convert('P', palette=Image.ADAPTIVE, colors=numcolors) + numpy_array = numpy.array(image_file) + + pixels = numpy_array.reshape(-1, numpy_array.shape[-1]) + color_counts = numpy.unique(pixels, axis=0, return_counts=True) + max_count_index = numpy.argmax(color_counts[1]) - # Find dominant colors - palette = paletted.getpalette() - # color_counts = sorted(paletted.getcolors(), reverse=True) - dominant_color = (palette[0], palette[1], palette[2]) # colors = list() # for i in range(numcolors): # palette_index = color_counts[i][1] # dominant_color = palette[palette_index*3:palette_index*3+3] # colors.append(tuple(dominant_color)) - return dominant_color + return tuple(color_counts[0][max_count_index]) + +# def get_colors(image_file, numcolors=1, resize=150): +# # Resize image to speed up processing +# image_file.thumbnail((resize, resize)) + +# # Reduce to palette +# paletted = image_file.convert('P', palette=Image.ADAPTIVE, colors=numcolors) + +# # Find dominant colors +# palette = paletted.getpalette() +# # color_counts = sorted(paletted.getcolors(), reverse=True) +# dominant_color = (palette[0], palette[1], palette[2]) +# # colors = list() +# # for i in range(numcolors): +# # palette_index = color_counts[i][1] +# # dominant_color = palette[palette_index*3:palette_index*3+3] +# # colors.append(tuple(dominant_color)) + +# return dominant_color + def getLyrics(artist_name, track_name): lrc = syncedlyrics.search("[" + track_name + "] [" + artist_name + "]") @@ -489,8 +524,11 @@ def unloadSearching_Devices(): # Start updating the song label # setup() + +# Run the GUI + + loadNow_playing() update_song_label() -# Run the GUI root.mainloop() \ No newline at end of file diff --git a/spotifycontroller_condensed.prof b/spotifycontroller_condensed.prof new file mode 100644 index 0000000..7aef4e0 Binary files /dev/null and b/spotifycontroller_condensed.prof differ diff --git a/spotifycontroller_spread.prof b/spotifycontroller_spread.prof new file mode 100644 index 0000000..b35b2c3 Binary files /dev/null and b/spotifycontroller_spread.prof differ diff --git a/update.py b/update.py index c1e17ad..e64bae7 100644 --- a/update.py +++ b/update.py @@ -3,6 +3,7 @@ from urllib.request import urlopen from zipfile import ZipFile from io import BytesIO from time import sleep +import subprocess while True: @@ -23,9 +24,11 @@ except urllib.error.HTTPError: print("No update available.") pass -try: - exec(open('spotifycontroller.py').read()) -except: - print("An error has ocurred, reestablishing the application in 10 seconds.") - sleep(10) - exec(open('spotifycontroller.py').read()) \ No newline at end of file + +while True: + try: + subprocess.check_call(['python', 'spotifycontroller.py']) + except: + print("An error has ocurred, reestablishing the application in 10 seconds.") + sleep(10) + continue \ No newline at end of file