saving ufc images
This commit is contained in:
parent
b71059d210
commit
da26832906
@ -915,6 +915,46 @@ def updateLeagueEvents(api_key, time, logf):
|
||||
if league == 'UFC':
|
||||
event = all_data['UFC'][0]
|
||||
events.append(event)
|
||||
if time == 'upcoming':
|
||||
try:
|
||||
for each in all_data['UFC'][0]['fights']:
|
||||
if each['fighter1pic'].split('/')[-1] not in os.listdir('logos/ufc/'):
|
||||
urllib.request.urlretrieve(each['fighter1pic'],'logos/ufc/' + each['fighter1pic'].split('/')[-1])
|
||||
if each['fighter2pic'].split('/')[-1] not in os.listdir('logos/ufc/'):
|
||||
urllib.request.urlretrieve(each['fighter2pic'],'logos/ufc/' + each['fighter2pic'].split('/')[-1])
|
||||
logo_files.append(each['fighter2pic'].split('/')[-1])
|
||||
logo_files.append(each['fighter1pic'].split('/')[-1])
|
||||
#country flags
|
||||
if each['fighter1country'].split('/')[-1] not in os.listdir('logos/ufc_countries/'):
|
||||
urllib.request.urlretrieve(each['fighter1country'], 'logos/ufc_countries/' + each['fighter1country'].split('/')[-1])
|
||||
if each['fighter2country'].split('/')[-1] not in os.listdir('logos/ufc_countries/'):
|
||||
urllib.request.urlretrieve(each['fighter2country'], 'logos/ufc_countries/' + each['fighter2country'].split('/')[-1])
|
||||
|
||||
for file in os.listdir('logos/ufc/'):
|
||||
if file not in logo_files:
|
||||
os.remove('logos/ufc/'+ file)
|
||||
except:
|
||||
pass
|
||||
elif time == 'past':
|
||||
try:
|
||||
for each in all_data['UFC'][0]['fights']:
|
||||
if each['fighter1pic'].split('/')[-1] not in os.listdir('logos/ufc_past/'):
|
||||
urllib.request.urlretrieve(each['fighter1pic'],'logos/ufc_past/' + each['fighter1pic'].split('/')[-1])
|
||||
if each['fighter2pic'].split('/')[-1] not in os.listdir('logos/ufc_past/'):
|
||||
urllib.request.urlretrieve(each['fighter2pic'],'logos/ufc_past/' + each['fighter2pic'].split('/')[-1])
|
||||
logo_files.append(each['fighter2pic'].split('/')[-1])
|
||||
logo_files.append(each['fighter1pic'].split('/')[-1])
|
||||
#country flags
|
||||
if each['fighter1country'].split('/')[-1] not in os.listdir('logos/ufc_countries/'):
|
||||
urllib.request.urlretrieve(each['fighter1country'], 'logos/ufc_countries/' + each['fighter1country'].split('/')[-1])
|
||||
if each['fighter2country'].split('/')[-1] not in os.listdir('logos/ufc_countries/'):
|
||||
urllib.request.urlretrieve(each['fighter2country'], 'logos/ufc_countries/' + each['fighter2country'].split('/')[-1])
|
||||
|
||||
for file in os.listdir('logos/ufc_past/'):
|
||||
if file not in logo_files:
|
||||
os.remove('logos/ufc_past/'+ file)
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
for d in all_data[league][ten_or_fifteen]:
|
||||
event = {}
|
||||
|
Loading…
Reference in New Issue
Block a user