@@ -188,6 +188,7 @@ def get_data(data, team, logo, group):
188
188
names = []
189
189
scores = []
190
190
info = []
191
+ index = 0
191
192
# the team you are following's logo
192
193
bitmap0 = displayio .OnDiskBitmap (logo )
193
194
grid0 = displayio .TileGrid (bitmap0 , pixel_shader = bitmap0 .pixel_shader , x = 2 )
@@ -227,11 +228,40 @@ def get_data(data, team, logo, group):
227
228
# gets info on game
228
229
info .append (event ["status" ]["type" ]["shortDetail" ])
229
230
break
231
+ if playing and len (names ) != 2 :
232
+ print ("did not get expected response, fetching full JSON.." )
233
+ try :
234
+ resp .close ()
235
+ # pylint: disable=broad-except
236
+ except Exception as e :
237
+ print (f"{ e } , continuing.." )
238
+ # pylint: disable=unnecessary-pass
239
+ pass
240
+ names .clear ()
241
+ scores .clear ()
242
+ info .clear ()
243
+ resp = requests .get (data )
244
+ response_as_json = resp .json ()
245
+ for e in response_as_json ["events" ]:
246
+ if team [0 ] in e ["name" ]:
247
+ print (index )
248
+ info .append (response_as_json ["events" ][0 ]["date" ])
249
+ names .append (response_as_json ["events" ][0 ]["competitions" ]
250
+ [0 ]["competitors" ][0 ]["team" ]["abbreviation" ])
251
+ names .append (response_as_json ["events" ][0 ]["competitions" ]
252
+ [0 ]["competitors" ][1 ]["team" ]["abbreviation" ])
253
+ scores .append (response_as_json ["events" ][0 ]["competitions" ]
254
+ [0 ]["competitors" ][0 ]["score" ])
255
+ scores .append (response_as_json ["events" ][0 ]["competitions" ]
256
+ [0 ]["competitors" ][1 ]["score" ])
257
+ info .append (response_as_json ["events" ][0 ]["status" ]["type" ]["shortDetail" ])
258
+ else :
259
+ index += 1
230
260
# debug printing
231
261
print (names )
232
262
print (scores )
233
263
print (info )
234
- if playing :
264
+ if playing and len ( names ) == 2 :
235
265
# pull out the date
236
266
date = info [0 ]
237
267
# convert it to be readable
@@ -301,7 +331,16 @@ def get_data(data, team, logo, group):
301
331
group .append (vs_text )
302
332
group .append (info_text )
303
333
# close the response
304
- resp .close ()
334
+ try :
335
+ # sometimes an OSError is thrown:
336
+ # "invalid syntax for integer with base 16"
337
+ # the code can continue depite it though
338
+ resp .close ()
339
+ # pylint: disable=broad-except
340
+ except Exception as e :
341
+ print (f"{ e } , continuing.." )
342
+ # pylint: disable=unnecessary-pass
343
+ pass
305
344
pixel .fill ((0 , 0 , 0 ))
306
345
# return that data was just fetched
307
346
fetch_status = True
0 commit comments