yes.
This commit is contained in:
parent
d2a0c8e926
commit
3291a53eeb
1 changed files with 19 additions and 37 deletions
56
main.py
56
main.py
|
@ -53,27 +53,6 @@ font = ImageFont.load_default()
|
|||
|
||||
print('before get_track()')
|
||||
|
||||
def get_access_token():
|
||||
global token
|
||||
sp_oauth = spotipy.SpotifyOAuth(
|
||||
client_id,
|
||||
client_secret,
|
||||
redirect_uri,
|
||||
scope=scope,
|
||||
#cache_path=cache_path,
|
||||
username=username,
|
||||
open_browser=False
|
||||
)
|
||||
token_info = sp_oauth.get_cached_token()
|
||||
|
||||
if not token_info:
|
||||
code = sp_oauth.get_auth_response()
|
||||
token = sp_oauth.get_access_token(code, as_dict=False)
|
||||
else:
|
||||
if sp_oauth.is_token_expired(token_info):
|
||||
token_info = refresh_access_token(token_info)
|
||||
token = token_info["access_token"]
|
||||
|
||||
def get_track():
|
||||
print('getting current song info')
|
||||
sp = spotipy.Spotify(auth=token)
|
||||
|
@ -107,22 +86,6 @@ def showImage(image, offset_x = 0, offset_y = 0):
|
|||
|
||||
|
||||
|
||||
#if token:
|
||||
# sp = spotipy.Spotify(auth=token)
|
||||
# track = sp.currently_playing()
|
||||
# print(track['is_playing'])
|
||||
# print(track['item']['name'] + ' - ' + track['item']['artists'][0]['name'])
|
||||
# imageString = requests.get(track['item']['album']['images'][0]['url'])
|
||||
# image = Image.open(BytesIO(imageString.content))
|
||||
# image = image.resize((32,32))
|
||||
# #image.save("thumbnail.jpg","JPEG")
|
||||
#else:
|
||||
# print("Can't get token for", username)
|
||||
#def main():
|
||||
# x = threading.Thread(target=draw)
|
||||
# x.start()
|
||||
|
||||
|
||||
def drawCanvas():
|
||||
canvas = Image.new('RGB', (192, 128), color = 'black')
|
||||
global last_song
|
||||
|
@ -227,7 +190,26 @@ def scrolling_text(text,offset_x=0,offset_y=0):
|
|||
def main():
|
||||
get_access_token()
|
||||
|
||||
def get_access_token():
|
||||
global token
|
||||
sp_oauth = spotipy.SpotifyOAuth(
|
||||
client_id,
|
||||
client_secret,
|
||||
redirect_uri,
|
||||
scope=scope,
|
||||
#cache_path=cache_path,
|
||||
username=username,
|
||||
open_browser=False
|
||||
)
|
||||
token_info = sp_oauth.get_cached_token()
|
||||
|
||||
if not token_info:
|
||||
code = sp_oauth.get_auth_response()
|
||||
token = sp_oauth.get_access_token(code, as_dict=False)
|
||||
else:
|
||||
if sp_oauth.is_token_expired(token_info):
|
||||
token_info = refresh_access_token(token_info)
|
||||
token = token_info["access_token"]
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Reference in a new issue