added liking by double tapping album art

add exception handling to update.py, prepping for handling script
This commit is contained in:
Brandon4466
2023-03-04 13:46:12 -08:00
parent c66ee19a25
commit 88c877c50f
4 changed files with 23 additions and 9 deletions

2
.cache
View File

@@ -1 +1 @@
{"access_token": "BQDrxTAIyV04s8ELEHxjvK118srmPFqciwk8FVd15twhg-Vh3LOY1sBzU3M6_K6oRH7sODe4740H3SnBZ-aDDSombJOFVCi26WaEEtUM0v8mgTJQvabM1yacXLOUC3uGtWXzZ5twdBfllOJD0sqMRvllkbwvfOsi09QiUifN50vcpaL0uLWHBIZ7SbBoUN4", "token_type": "Bearer", "expires_in": 3600, "scope": "user-modify-playback-state user-read-playback-state", "expires_at": 1677924835, "refresh_token": "AQCOARNKfmTOZ0eINGRwD7Yo5JWarv7bH5LnTvoz_mMEDhXR_luBWsl8wq010xTTbLO3c4XLeCqIKUwmPsJX5uQn4mUP-JWKgETATkkii6vlKTS7xR3DntNwfquOIjV-9CQ"} {"access_token": "BQC05wxeoZyHXRQVuQgm4-1Zqp2Uv8hf7Hg-wMyp0R7IIQMHwzLVINH31DaxsxO3aU_fCt9a3a4hihcgqZbVACu4IZLGU1TtN_P4mBpKbftuIxiDH7UMaOIGuwhvDKKkr0Zm_jqflBuJ0wdcaAD2CkYBzevBfMsXjtO87iD8ZoWwCh5mzWicZKnHho-tAlDaDI0FY-cgU_Xe_fU0S1Hf", "token_type": "Bearer", "expires_in": 3600, "refresh_token": "AQCCSkV9mWV-ysqv_bMMERsUGgz7baaOfBGhqm2-6_3I-lpd2CKy8bs3GS_kNZy2D1YG6Z2dhKVUNTCE7MC0qcKypWZAvRw6nRlsM8816mTP6hpK67WWAuwq_qfnLVia1Oo", "scope": "user-library-modify user-library-read user-modify-playback-state user-read-playback-state", "expires_at": 1677969435}

View File

@@ -54,7 +54,7 @@ password = "Mariposa2502$"
# Get the user's Spotify authorization token # Get the user's Spotify authorization token
scope = "user-read-playback-state,user-modify-playback-state" scope = "user-read-playback-state,user-modify-playback-state,user-library-read,user-library-modify"
oauth = SpotifyOAuth(client_id=client_id, client_secret=client_secret, redirect_uri=redirect_uri, scope=scope, requests_timeout=30) oauth = SpotifyOAuth(client_id=client_id, client_secret=client_secret, redirect_uri=redirect_uri, scope=scope, requests_timeout=30)
@@ -95,8 +95,10 @@ def controlPrevious():
spotify.previous_track() spotify.previous_track()
def likeSong(): def likeSong():
print(spotify.current_playback()["item"]["id"]) if spotify.current_user_saved_tracks_contains(tracks=[(spotify.current_playback()["item"]["id"])])[0] is False:
spotify.current_user_saved_tracks_add(tracks=(spotify.current_playback()["item"]["id"])) spotify.current_user_saved_tracks_add(tracks=[(spotify.current_playback()["item"]["id"])])
else:
spotify.current_user_saved_tracks_delete(tracks=[(spotify.current_playback()["item"]["id"])])
def start_playback_on_device(): def start_playback_on_device():
# global count # global count
@@ -302,10 +304,13 @@ def update_song_label():
track_progress_sec = (track_progress//1000)%60 track_progress_sec = (track_progress//1000)%60
else: else:
track_name = "Loading..." track_name = "Loading..."
artist_name = "Loading..." artist_name = ""
track_duration = 1 track_duration = 1
track_progress = 1 playing_status = True
device_name = ""
album_art_url = ""
track_progress_min = 0
track_progress_sec = 1
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(maximum=track_duration) progress_bar.config(maximum=track_duration)

View File

@@ -66,4 +66,7 @@ switch to spotify web api for track information to avoid api limit???
03/04/2023: 03/04/2023:
new updater, use version numbering to pull updates if server has a newer version and dont update if newer version isnt available. new updater, use version numbering to pull updates if server has a newer version and dont update if newer version isnt available.
create a single json file that has a version list with download links to each version. have updater.py download the json file, read and compare to currently downloaded version. create a single json file that has a version list with download links to each version. have updater.py download the json file, read and compare to currently downloaded version.
if newer version is in json file, follow link in json file to download, otherwise continue to start the program. if newer version is in json file, follow link in json file to download, otherwise continue to start the program.
03/04/2023:
redo background color algo. PROMINENT COLOR not average like it is now.

View File

@@ -2,6 +2,8 @@ import urllib
from urllib.request import urlopen from urllib.request import urlopen
from zipfile import ZipFile from zipfile import ZipFile
from io import BytesIO from io import BytesIO
from spotipy import exceptions as SpotipyExceptions
from requests import exceptions as RequestsExceptions
while True: while True:
try: try:
@@ -16,4 +18,8 @@ try:
except urllib.error.HTTPError: except urllib.error.HTTPError:
pass pass
exec(open('spotifycontroller.py').read()) try:
exec(open('spotifycontroller.py').read())
except (RequestsExceptions.HTTPError, SpotipyExceptions.SpotifyException):
print("An error has ocurred, saving and reestablishing application now.")
exec(open('spotifycontroller.py').read())