@@ -85,7 +85,7 @@ def check(self):
8585
8686class index :
8787 def GET (self ):
88- return "SpotifyControl ver. 0.0 "
88+ return "SpotifyControl ver. 0.1 "
8989
9090class player :
9191 def __init__ (self ):
@@ -98,10 +98,13 @@ def GET(self):
9898 global tkn
9999 global receivedPin
100100
101+ screenList = ['next' , 'previous' ]
102+
101103 GPIO .output (receivedPin , GPIO .HIGH )
102104
103- lcd .clear ()
104- lcd .message = self .message
105+ if self .command in screenList :
106+ lcd .clear ()
107+ lcd .message = self .message
105108
106109 tkn .check ()
107110
@@ -149,9 +152,6 @@ def GET(self):
149152
150153 GPIO .output (receivedPin , GPIO .HIGH )
151154
152- lcd .clear ()
153- lcd .message = 'Shuffle'
154-
155155 tkn .check ()
156156
157157 reply = requests .get ('https://api.spotify.com/v1/me/player' , headers = {'Accept' : 'application/json' , 'Content-Type' : 'application/json' , 'Authorization' : f'Bearer { tkn .authTk } ' })
@@ -167,8 +167,10 @@ def GET(self):
167167 print (req )
168168 print (f' with tk: { tkn .authTk [0 :10 ]} , exp: { tkn .authExp } ' )
169169
170- lcd .clear ()
171- lcd .message = 'Shuffle ' + st
170+ if state :
171+ GPIO .output (shufflePin , GPIO .LOW )
172+ else :
173+ GPIO .output (shufflePin , GPIO .HIGH )
172174
173175 GPIO .output (receivedPin , GPIO .LOW )
174176
@@ -223,6 +225,15 @@ def POST(self):
223225 trackId = data [0 ]
224226 event = data [1 ]
225227
228+ reply = requests .get ('https://api.spotify.com/v1/me/player' , headers = {'Accept' : 'application/json' , 'Content-Type' : 'application/json' , 'Authorization' : f'Bearer { tkn .authTk } ' })
229+
230+ shuffleState = reply .json ()['shuffle_state' ]
231+
232+ if shuffleState :
233+ GPIO .output (shufflePin , GPIO .HIGH )
234+ else :
235+ GPIO .output (shufflePin , GPIO .LOW )
236+
226237 print (f'onEvent: { event } ' )
227238
228239 if event in screenEvents :
0 commit comments