fixed logo retrieving

This commit is contained in:
Justin 2023-04-25 01:01:05 +08:00 committed by GitHub
parent 065d330962
commit dc1a471f88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -944,12 +944,24 @@ def updateLeagueEvents(api_key, time, logf):
try:
logo_files = []
for each in all_data['UFC'][0]['fights']:
if each['fighter1pic'].split('/')[-1].split('&')[0] not in os.listdir('logos/ufc/'):
urllib.request.urlretrieve(each['fighter1pic'],'logos/ufc/' + each['fighter1pic'].split('/')[-1].split('&')[0])
if each['fighter2pic'].split('/')[-1].split('&')[0] not in os.listdir('logos/ufc/'):
urllib.request.urlretrieve(each['fighter2pic'],'logos/ufc/' + each['fighter2pic'].split('/')[-1].split('&')[0])
logo_files.append(each['fighter2pic'].split('/')[-1].split('&')[0])
logo_files.append(each['fighter1pic'].split('/')[-1].split('&')[0])
try:
if each['fighter1pic'].split('/')[-1].split('&')[0] not in os.listdir('logos/ufc/'):
urllib.request.urlretrieve(each['fighter1pic'],'logos/ufc/' + each['fighter1pic'].split('/')[-1].split('&')[0])
except:
pass
try:
if each['fighter2pic'].split('/')[-1].split('&')[0] not in os.listdir('logos/ufc/'):
urllib.request.urlretrieve(each['fighter2pic'],'logos/ufc/' + each['fighter2pic'].split('/')[-1].split('&')[0])
except:
pass
try:
logo_files.append(each['fighter2pic'].split('/')[-1].split('&')[0])
except:
pass
try:
logo_files.append(each['fighter1pic'].split('/')[-1].split('&')[0])
except:
pass
#country flags
if each['fighter1country'].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])
@ -965,12 +977,24 @@ def updateLeagueEvents(api_key, time, logf):
try:
logo_files = []
for each in all_data['UFC'][0]['fights']:
if each['fighter1pic'].split('/')[-1].split('&')[0] not in os.listdir('logos/ufc_past/'):
urllib.request.urlretrieve(each['fighter1pic'],'logos/ufc_past/' + each['fighter1pic'].split('/')[-1].split('&')[0])
if each['fighter2pic'].split('/')[-1].split('&')[0] not in os.listdir('logos/ufc_past/'):
urllib.request.urlretrieve(each['fighter2pic'],'logos/ufc_past/' + each['fighter2pic'].split('/')[-1].split('&')[0])
logo_files.append(each['fighter2pic'].split('/')[-1].split('&')[0])
logo_files.append(each['fighter1pic'].split('/')[-1].split('&')[0])
try:
if each['fighter1pic'].split('/')[-1].split('&')[0] not in os.listdir('logos/ufc_past/'):
urllib.request.urlretrieve(each['fighter1pic'],'logos/ufc_past/' + each['fighter1pic'].split('/')[-1].split('&')[0])
except:
pass
try:
if each['fighter2pic'].split('/')[-1].split('&')[0] not in os.listdir('logos/ufc_past/'):
urllib.request.urlretrieve(each['fighter2pic'],'logos/ufc_past/' + each['fighter2pic'].split('/')[-1].split('&')[0])
except:
pass
try:
logo_files.append(each['fighter2pic'].split('/')[-1].split('&')[0])
except:
pass
try:
logo_files.append(each['fighter1pic'].split('/')[-1].split('&')[0])
except:
pass
#country flags
if each['fighter1country'].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])