try except added for ufc country image fetching

This commit is contained in:
Justin 2023-04-25 18:57:42 +08:00 committed by GitHub
parent 4e7d568ee5
commit 5caf7db1f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -967,10 +967,16 @@ def updateLeagueEvents(api_key, time, logf):
except: except:
pass pass
#country flags #country flags
if each['fighter1country'].split('/')[-1].split('&')[0] not in os.listdir('logos/ufc_countries/'): try:
urllib.request.urlretrieve(each['fighter1country'], 'logos/ufc_countries/' + each['fighter1country'].split('/')[-1].split('&')[0]) if each['fighter1country'].split('/')[-1].split('&')[0] not in os.listdir('logos/ufc_countries/'):
if each['fighter2country'].split('/')[-1].split('&')[0] not in os.listdir('logos/ufc_countries/'): urllib.request.urlretrieve(each['fighter1country'], 'logos/ufc_countries/' + each['fighter1country'].split('/')[-1].split('&')[0])
urllib.request.urlretrieve(each['fighter2country'], 'logos/ufc_countries/' + each['fighter2country'].split('/')[-1].split('&')[0]) except:
pass
try:
if each['fighter2country'].split('/')[-1].split('&')[0] not in os.listdir('logos/ufc_countries/'):
urllib.request.urlretrieve(each['fighter2country'], 'logos/ufc_countries/' + each['fighter2country'].split('/')[-1].split('&')[0])
except:
pass
for file in os.listdir('logos/ufc/'): for file in os.listdir('logos/ufc/'):
if file not in logo_files: if file not in logo_files:
@ -1000,10 +1006,16 @@ def updateLeagueEvents(api_key, time, logf):
except: except:
pass pass
#country flags #country flags
if each['fighter1country'].split('/')[-1].split('&')[0] not in os.listdir('logos/ufc_countries/'): try:
urllib.request.urlretrieve(each['fighter1country'], 'logos/ufc_countries/' + each['fighter1country'].split('/')[-1].split('&')[0]) if each['fighter1country'].split('/')[-1].split('&')[0] not in os.listdir('logos/ufc_countries/'):
if each['fighter2country'].split('/')[-1].split('&')[0] not in os.listdir('logos/ufc_countries/'): urllib.request.urlretrieve(each['fighter1country'], 'logos/ufc_countries/' + each['fighter1country'].split('/')[-1].split('&')[0])
urllib.request.urlretrieve(each['fighter2country'], 'logos/ufc_countries/' + each['fighter2country'].split('/')[-1].split('&')[0]) except:
pass
try:
if each['fighter2country'].split('/')[-1].split('&')[0] not in os.listdir('logos/ufc_countries/'):
urllib.request.urlretrieve(each['fighter2country'], 'logos/ufc_countries/' + each['fighter2country'].split('/')[-1].split('&')[0])
except:
pass
for file in os.listdir('logos/ufc_past/'): for file in os.listdir('logos/ufc_past/'):
if file not in logo_files: if file not in logo_files: