diff --git a/.cache b/.cache index 5c88449..278f4d5 100644 --- a/.cache +++ b/.cache @@ -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"} \ No newline at end of file +{"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} \ No newline at end of file diff --git a/spotifycontroller.py b/spotifycontroller.py index c87afc8..0b30694 100644 --- a/spotifycontroller.py +++ b/spotifycontroller.py @@ -54,7 +54,7 @@ password = "Mariposa2502$" # 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) @@ -95,8 +95,10 @@ def controlPrevious(): spotify.previous_track() def likeSong(): - print(spotify.current_playback()["item"]["id"]) - spotify.current_user_saved_tracks_add(tracks=(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"])]) + else: + spotify.current_user_saved_tracks_delete(tracks=[(spotify.current_playback()["item"]["id"])]) def start_playback_on_device(): # global count @@ -302,10 +304,13 @@ def update_song_label(): track_progress_sec = (track_progress//1000)%60 else: track_name = "Loading..." - artist_name = "Loading..." + artist_name = "" 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"): track_progress_formatted = ("{}:{:02d}".format(track_progress_min, track_progress_sec)) progress_bar.config(maximum=track_duration) diff --git a/todo.txt b/todo.txt index 33ab659..80d9f60 100644 --- a/todo.txt +++ b/todo.txt @@ -66,4 +66,7 @@ switch to spotify web api for track information to avoid api limit??? 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. 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. \ No newline at end of file +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. \ No newline at end of file diff --git a/update.py b/update.py index f70ca45..50a5d38 100644 --- a/update.py +++ b/update.py @@ -2,6 +2,8 @@ import urllib from urllib.request import urlopen from zipfile import ZipFile from io import BytesIO +from spotipy import exceptions as SpotipyExceptions +from requests import exceptions as RequestsExceptions while True: try: @@ -16,4 +18,8 @@ try: except urllib.error.HTTPError: pass -exec(open('spotifycontroller.py').read()) \ No newline at end of file +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()) \ No newline at end of file