sports updates and live sports added

This commit is contained in:
Neythen 2021-06-19 10:53:09 +01:00
parent d84265405c
commit 3378c69d9e
16 changed files with 271 additions and 207 deletions

View File

@ -121,7 +121,7 @@ def updateStockPrices(symbols):
def updateStockPricesIEX(symbols):
try:
symbols_str = ','.join(symbols)
method = 'GET'
host = 'https://cloud.iexapis.com/stable'
@ -175,9 +175,12 @@ def updateStockPricesIEX(symbols):
CSV.write(symbol + ',' + str(current_prices[i]) + ',' + str(opening_prices[i]) + '\n')
CSV.close()
except Exception as e:
print(e)
def updateCrypto(coins, coin_info, unique_bases):
try:
response = coingecko_client.get_price(ids=','.join(coins), vs_currencies = unique_bases, include_24hr_change=True)
CSV = open('csv/crypto.csv', 'w+')
@ -189,11 +192,13 @@ def updateCrypto(coins, coin_info, unique_bases):
CSV.write(info[0] + ',' + coin + ',' + info[1] + ',' +str(response[coin][info[1]]) + ',' + str(response[coin]['usd_24h_change']) + '\n')
CSV.close()
except Exception as e:
print(e)
def updateNews():
try:
try:
#load user settings
@ -217,8 +222,11 @@ def updateNews():
CSV.write(title.replace(',', '^') + ',' + headline_sources[i] + ',' + date + ',' + time + '\n')
CSV.close()
except Exception as e:
print(e)
def updateWeather(api_key):
try:
f = open( "csv/weather_location.txt", 'r' )
location = f.read()
f.close()
@ -265,8 +273,13 @@ def updateWeather(api_key):
json.dump( daily_weather, open( "csv/daily_weather.json", 'w+' ))
except Exception as e:
print(e)
def updateCurrencies(api_key):
try:
base = 'USD'
yesterday = datetime.now() - timedelta(1)
@ -281,7 +294,7 @@ def updateCurrencies(api_key):
c_dict = {}
print(all_data)
@ -294,8 +307,10 @@ def updateCurrencies(api_key):
c_dict[curr] = [current, yesterday]
print(c_dict)
json.dump([base, c_dict], open( "csv/currency.json", 'w+' ))
except Exception as e:
print(e)
def updateLeagueTable(api_key, league_id):
url = 'https://www.thesportsdb.com/api/v1/json/{}/lookuptable.php?l={}&s=2020-2021'.format(api_key, league_id)
@ -306,7 +321,7 @@ def updateLeagueTable(api_key, league_id):
premier_teams = []
print(all_data['table'])
for i in range(len(all_data['table'])):
team = {}
@ -336,9 +351,10 @@ def updateLeagueEvents(api_key, league_id, time):
if time == 'past':
url ='https://www.thesportsdb.com/api/v1/json/{}/eventspastleague.php?id={}'.format(api_key, league_id) #last 15 events on the league (premium only)
else:
elif time == 'future':
url ='https://www.thesportsdb.com/api/v1/json/{}/eventsnextleague.php?id={}'.format(api_key, league_id) #next 15 events on the league (premium only)
elif time == 'live':
url = 'https://thesportsdb.com/api/v2/json/{}/livescore.php?l={}'.format(api_key, league_id)
r = requests.get(url)
all_data = r.json()
@ -354,12 +370,18 @@ def updateLeagueEvents(api_key, league_id, time):
event = {}
event['date'] = all_data['events'][i]['dateEvent']
if time == 'live':
event['time'] = all_data['events'][i]['strEventTime']
event['progess'] = all_data['events'][i]['strProgress']
event['status'] = all_data['events'][i]['strStatus']
else:
event['time'] = all_data['events'][i]['strTime']
event['round'] = all_data['events'][i]['intRound']
event['home_team'] = all_data['events'][i]['strHomeTeam']
event['home_score'] = all_data['events'][i]['intHomeScore']
event['away_team'] = all_data['events'][i]['strAwayTeam']
event['away_score'] = all_data['events'][i]['intAwayScore']
event['round'] = all_data['events'][i]['intRound']
events.append(event)
@ -374,6 +396,7 @@ def updateLeagueEvents(api_key, league_id, time):
def updateSports(api_key):
prem_id = '4328' #prem
NHL_id = '4380'
@ -381,12 +404,14 @@ def updateSports(api_key):
#updateLeagueTable(api_key, prem_id) #prem
updateLeagueEvents(api_key, prem_id, 'past')
updateLeagueEvents(api_key, NHL_id, 'future')
updateLeagueEvents(api_key, NHL_id, 'live')
updateLeagueTable(api_key, NHL_id)
updateLeagueTable(api_key, prem_id)
'https://www.thesportsdb.com/api/v1/json/{}/eventsnext.php?id=133602'.format(api_key) # next five events by team ID (paid) use this for upcoming team games
@ -407,6 +432,7 @@ def updateSports(api_key):
if __name__ == '__main__':
newsapi = NewsApiClient(api_key='cf08652bd17647b89aaf469a1a8198a9')
@ -448,7 +474,9 @@ if __name__ == '__main__':
sports_key = '97436974'
updateSports(sports_key)
sys.exit()
updateCurrencies(currency_key)

View File

@ -1,3 +1,3 @@
symbol,name,base,current,24hr change
BTC,bitcoin,usd,39051,-4.251547889353901
ETH,ethereum,gbp,1717.96,-6.393401847745126
BTC,bitcoin,usd,35873,-5.21631039241079
ETH,ethereum,gbp,1627.13,-3.8296511296684295

1 symbol name base current 24hr change
2 BTC bitcoin usd 39051 35873 -4.251547889353901 -5.21631039241079
3 ETH ethereum gbp 1717.96 1627.13 -6.393401847745126 -3.8296511296684295

View File

@ -1 +1 @@
{"main_weather": "Clouds", "description": "overcast clouds", "temp": 29.83, "min_temp": 28.91, "max_temp": 30.21, "feels_like": 36.83, "humidity": 79, "clouds": 100, "wind_speed": 0.45, "wind_direction": 27, "visibility": 10000, "uv": 0, "rain_chance": 0.63}
{"main_weather": "Clouds", "description": "overcast clouds", "temp": 31.85, "min_temp": 29.41, "max_temp": 33.03, "feels_like": 38.85, "humidity": 79, "clouds": 98, "wind_speed": 0.45, "wind_direction": 304, "visibility": 10000, "uv": 0.46, "rain_chance": 0.34}

View File

@ -1 +1 @@
[{"main_weather": "Rain", "description": "moderate rain", "min_temp": 28.39, "max_temp": 29.91}, {"main_weather": "Rain", "description": "light rain", "min_temp": 28.62, "max_temp": 30.31}, {"main_weather": "Rain", "description": "light rain", "min_temp": 28.85, "max_temp": 30.66}, {"main_weather": "Rain", "description": "light rain", "min_temp": 28.45, "max_temp": 30.88}, {"main_weather": "Rain", "description": "light rain", "min_temp": 28.72, "max_temp": 30.97}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 26.93, "max_temp": 29.19}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 26.54, "max_temp": 28.14}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 26.46, "max_temp": 27.82}]
[{"main_weather": "Rain", "description": "moderate rain", "min_temp": 28.86, "max_temp": 31.53}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 28.73, "max_temp": 31.16}, {"main_weather": "Rain", "description": "light rain", "min_temp": 29.02, "max_temp": 31.15}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 27.67, "max_temp": 30.15}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 27.04, "max_temp": 28.48}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 26.22, "max_temp": 28.22}, {"main_weather": "Rain", "description": "light rain", "min_temp": 27.58, "max_temp": 28.65}, {"main_weather": "Rain", "description": "light rain", "min_temp": 27.9, "max_temp": 29.14}]

View File

@ -1 +1 @@
17/06/2021 15:03:04
19/06/2021 05:50:09

1 17/06/2021 15:03:04 19/06/2021 05:50:09

View File

@ -1,21 +1,21 @@
headline,source,date,time
US scientists develop coating to capture airborne droplets - The Straits Times,The Straits Times,2021-06-16,16:36:07Z
Royal Ascot 2021^ day two: Love wins Prince of Wales Stakes live! - The Guardian,The Guardian,2021-06-16,16:34:37Z
Turkey vs Wales^ Euro 2020 live: score and latest updates from Group A - The Telegraph,Telegraph.co.uk,2021-06-16,16:29:01Z
European Union to recommend lifting travel restrictions on American tourists - USA TODAY,USA Today,2021-06-16,16:18:45Z
PH rep to UNHRC did not consult govt on vote to probe Israel over Gaza abuses Duterte - INQUIRER.net,Inquirer.net,2021-06-16,16:17:00Z
IMF cuts PHL growth projection to 5.4% | Bianca Cuaresma - Business Mirror,Businessmirror.com.ph,2021-06-16,16:16:00Z
Skeletal remains recovered from Crosshaven identified as Barry Coughlan - Irish Examiner,Irish Examiner,2021-06-16,16:14:00Z
Baba Ijesha: Magistrate court rule for Nollywood actor Olarenwaju James to remain for detention till July 13 - BBC News,BBC News,2021-06-16,16:13:46Z
Over-the-counter fungicide holds potential to disrupt steroid hormone levels - News-Medical.Net,News-Medical.Net,2021-06-16,16:12:00Z
How to enable Google's unified Gmail interface - TechRepublic,TechRepublic,2021-06-16,16:07:49Z
New computational topology strategy to identify existing medicines for treating COVID-19 - News-Medical.net,News-Medical.Net,2021-06-16,16:07:00Z
JBL releases new headphones^ earphones for every lifestyle - BusinessWorld Online,BusinessWorld Online,2021-06-16,16:03:16Z
Lina Khan^ Big Tech skeptic^ named FTC chair mere hours after confirmation - Ars Technica,Ars Technica,2021-06-16,16:01:57Z
PHL is polio free again^ thanks to mass inoculation drive | Claudeth Mocon-Ciriaco - Business Mirror,Businessmirror.com.ph,2021-06-16,16:01:00Z
'Confident' A5 residents line up early for COVID-19 vaccination in Manila - GMA News,GMA News,2021-06-16,16:00:52Z
Connecticut confirms 2 Powassan virus infections: What to know about tick-borne illness - Fox News,Fox News,2021-06-16,16:00:35Z
Ghislaine Maxwell subjected to raw sewage in New York jail^ lawyer says - The Guardian,The Guardian,2021-06-16,16:00:00Z
Putin and Biden end summit^ schedule separate news conferences - The Straits Times,The Straits Times,2021-06-16,15:59:18Z
Putin and Biden end summit after less than 4 hours of talks - Rappler,Rappler,2021-06-16,15:57:00Z
Driver has 'heart attack' at the wheel and crashes into cars near school - Liverpool Echo,Liverpool Echo,2021-06-16,15:53:52Z
Hardliner Ebrahim Raisi hailed as Irans new president - The Guardian,The Guardian,2021-06-19,08:37:00Z
153 new COVID-19 deaths raise PHs fatality count to 23^538 - INQUIRER.net,Inquirer.net,2021-06-19,08:20:00Z
Ebrahim Raisi^ ultra-conservative judiciary chief^ set to win Iran's presidential election - CNN ,CNN,2021-06-19,08:18:00Z
PUBG Mobile Lite vs Battlegrounds Mobile India (BGMI): 5 similarities between the famous battle royale titles - Sportskeeda,Sportskeeda,2021-06-19,08:14:19Z
Coronavirus News Live Updates: Centre asks states to ensure lockdown opening up is 'carefully calibrated';... - Moneycontrol,Moneycontrol,2021-06-19,08:10:04Z
Keep an eye out for rare electric-blue noctilucent clouds in the northern sky - CBC.ca,CBC News,2021-06-19,08:00:00Z
Why COVID-19 may now feel like a 'bad cold' — with headache^ runny nose among most-reported symptoms - CBC.ca,CBC News,2021-06-19,08:00:00Z
COVID-19 in Ottawa: Fast Facts for June 19^ 2021 - CTV Edmonton,Ctvnews.ca,2021-06-19,08:00:00Z
Young^ hot and bothered: I was a 31-year-old newlywed and then the menopause hit - The Guardian,The Guardian,2021-06-19,08:00:00Z
My Father Didnt Die Of Covid-19^ But This Is How The Virus Killed Him Anyway - The Rakyat Post,The Rakyat Post,2021-06-19,08:00:00Z
Kathryn Thomas: 'We feel incredibly grateful to share this news'- Kathryn Thomas is pregnant with her second child - Independent.ie,Independent.ie,2021-06-19,07:50:00Z
Police dog Rambo killed while tracking suspect on Queensland highway - 9News,9News,2021-06-19,07:45:53Z
KMJS story on “The Woman Slashed on Her Face” named FINALIST at the 2021 NYF - GMA News,GMA News,2021-06-19,07:43:49Z
World Sickle Cell Day: Symptoms of Sickle Cell Disease in Teenagers^ Consequences Of Delayed Treatment - TheHealthSite,Thehealthsite.com,2021-06-19,07:42:25Z
SA man jailed^ tortured in Equatorial Guinea prison gets R39m in damages - News24,News24,2021-06-19,07:39:54Z
14 new community COVID-19 cases in Singapore^ including 4 unlinked infections - CNA,CNA,2021-06-19,07:37:19Z
Travellers who visited Sydney locations of interest should get tested immediately for Covid-19^ says Ministry of Health - Stuff.co.nz,Stuff.co.nz,2021-06-19,07:26:00Z
Coffee shop owner roasts ministries over RM10^000 fine - Malaysiakini,Malaysiakini,2021-06-19,07:24:21Z
Vaccine: Over five million doses administered nationwide — Adham - The Sun Daily,The Sun Daily,2021-06-19,07:24:00Z
Jason Kelk: UK's longest Covid patient dies after withdrawing treatment - Metro.co.uk,Metro.co.uk,2021-06-19,07:20:00Z

1 headline source date time
2 US scientists develop coating to capture airborne droplets - The Straits Times Hardliner Ebrahim Raisi hailed as Iran’s new president - The Guardian The Straits Times The Guardian 2021-06-16 2021-06-19 16:36:07Z 08:37:00Z
3 Royal Ascot 2021^ day two: Love wins Prince of Wales Stakes – live! - The Guardian 153 new COVID-19 deaths raise PH’s fatality count to 23^538 - INQUIRER.net The Guardian Inquirer.net 2021-06-16 2021-06-19 16:34:37Z 08:20:00Z
4 Turkey vs Wales^ Euro 2020 live: score and latest updates from Group A - The Telegraph Ebrahim Raisi^ ultra-conservative judiciary chief^ set to win Iran's presidential election - CNN Telegraph.co.uk CNN 2021-06-16 2021-06-19 16:29:01Z 08:18:00Z
5 European Union to recommend lifting travel restrictions on American tourists - USA TODAY PUBG Mobile Lite vs Battlegrounds Mobile India (BGMI): 5 similarities between the famous battle royale titles - Sportskeeda USA Today Sportskeeda 2021-06-16 2021-06-19 16:18:45Z 08:14:19Z
6 PH rep to UNHRC did not consult gov’t on vote to probe Israel over Gaza abuses – Duterte - INQUIRER.net Coronavirus News Live Updates: Centre asks states to ensure lockdown opening up is 'carefully calibrated';... - Moneycontrol Inquirer.net Moneycontrol 2021-06-16 2021-06-19 16:17:00Z 08:10:04Z
7 IMF cuts PHL growth projection to 5.4% | Bianca Cuaresma - Business Mirror Keep an eye out for rare electric-blue noctilucent clouds in the northern sky - CBC.ca Businessmirror.com.ph CBC News 2021-06-16 2021-06-19 16:16:00Z 08:00:00Z
8 Skeletal remains recovered from Crosshaven identified as Barry Coughlan - Irish Examiner Why COVID-19 may now feel like a 'bad cold' — with headache^ runny nose among most-reported symptoms - CBC.ca Irish Examiner CBC News 2021-06-16 2021-06-19 16:14:00Z 08:00:00Z
9 Baba Ijesha: Magistrate court rule for Nollywood actor Olarenwaju James to remain for detention till July 13 - BBC News COVID-19 in Ottawa: Fast Facts for June 19^ 2021 - CTV Edmonton BBC News Ctvnews.ca 2021-06-16 2021-06-19 16:13:46Z 08:00:00Z
10 Over-the-counter fungicide holds potential to disrupt steroid hormone levels - News-Medical.Net Young^ hot and bothered: ‘I was a 31-year-old newlywed – and then the menopause hit’ - The Guardian News-Medical.Net The Guardian 2021-06-16 2021-06-19 16:12:00Z 08:00:00Z
11 How to enable Google's unified Gmail interface - TechRepublic My Father Didn’t Die Of Covid-19^ But This Is How The Virus Killed Him Anyway - The Rakyat Post TechRepublic The Rakyat Post 2021-06-16 2021-06-19 16:07:49Z 08:00:00Z
12 New computational topology strategy to identify existing medicines for treating COVID-19 - News-Medical.net Kathryn Thomas: 'We feel incredibly grateful to share this news'- Kathryn Thomas is pregnant with her second child - Independent.ie News-Medical.Net Independent.ie 2021-06-16 2021-06-19 16:07:00Z 07:50:00Z
13 JBL releases new headphones^ earphones for every lifestyle - BusinessWorld Online Police dog Rambo killed while tracking suspect on Queensland highway - 9News BusinessWorld Online 9News 2021-06-16 2021-06-19 16:03:16Z 07:45:53Z
14 Lina Khan^ Big Tech skeptic^ named FTC chair mere hours after confirmation - Ars Technica KMJS’ story on “The Woman Slashed on Her Face” named FINALIST at the 2021 NYF - GMA News Ars Technica GMA News 2021-06-16 2021-06-19 16:01:57Z 07:43:49Z
15 PHL is polio free again^ thanks to mass inoculation drive | Claudeth Mocon-Ciriaco - Business Mirror World Sickle Cell Day: Symptoms of Sickle Cell Disease in Teenagers^ Consequences Of Delayed Treatment - TheHealthSite Businessmirror.com.ph Thehealthsite.com 2021-06-16 2021-06-19 16:01:00Z 07:42:25Z
16 'Confident' A5 residents line up early for COVID-19 vaccination in Manila - GMA News SA man jailed^ tortured in Equatorial Guinea prison gets R39m in damages - News24 GMA News News24 2021-06-16 2021-06-19 16:00:52Z 07:39:54Z
17 Connecticut confirms 2 Powassan virus infections: What to know about tick-borne illness - Fox News 14 new community COVID-19 cases in Singapore^ including 4 unlinked infections - CNA Fox News CNA 2021-06-16 2021-06-19 16:00:35Z 07:37:19Z
18 Ghislaine Maxwell subjected to raw sewage in New York jail^ lawyer says - The Guardian Travellers who visited Sydney locations of interest should get tested immediately for Covid-19^ says Ministry of Health - Stuff.co.nz The Guardian Stuff.co.nz 2021-06-16 2021-06-19 16:00:00Z 07:26:00Z
19 Putin and Biden end summit^ schedule separate news conferences - The Straits Times Coffee shop owner roasts ministries over RM10^000 fine - Malaysiakini The Straits Times Malaysiakini 2021-06-16 2021-06-19 15:59:18Z 07:24:21Z
20 Putin and Biden end summit after less than 4 hours of talks - Rappler Vaccine: Over five million doses administered nationwide — Adham - The Sun Daily Rappler The Sun Daily 2021-06-16 2021-06-19 15:57:00Z 07:24:00Z
21 Driver has 'heart attack' at the wheel and crashes into cars near school - Liverpool Echo Jason Kelk: UK's longest Covid patient dies after withdrawing treatment - Metro.co.uk Liverpool Echo Metro.co.uk 2021-06-16 2021-06-19 15:53:52Z 07:20:00Z

View File

@ -1,2 +1,2 @@
speed,brightness
f,9
m,9
1 speed brightness
2 f m 9

View File

@ -1 +1 @@
[{"date": "2021-06-17", "time": "01:00:00", "home_team": "Vegas Golden Knights", "home_score": "2", "away_team": "Montreal Canadiens", "away_score": "3", "round": "0"}, {"date": "2021-06-18", "time": "00:00:00", "home_team": "New York Islanders", "home_score": null, "away_team": "Tampa Bay Lightning", "away_score": null, "round": "0"}, {"date": "2021-06-19", "time": "00:00:00", "home_team": "Montreal Canadiens", "home_score": null, "away_team": "Vegas Golden Knights", "away_score": null, "round": "0"}, {"date": "2021-06-20", "time": "00:00:00", "home_team": "New York Islanders", "home_score": null, "away_team": "Tampa Bay Lightning", "away_score": null, "round": "0"}, {"date": "2021-06-21", "time": "00:00:00", "home_team": "Montreal Canadiens", "home_score": null, "away_team": "Vegas Golden Knights", "away_score": null, "round": "0"}]
[{"date": "2021-06-19", "time": "00:00:00", "round": "0", "home_team": "Montreal Canadiens", "home_score": "3", "away_team": "Vegas Golden Knights", "away_score": "2"}, {"date": "2021-06-20", "time": "00:00:00", "round": "0", "home_team": "New York Islanders", "home_score": null, "away_team": "Tampa Bay Lightning", "away_score": null}, {"date": "2021-06-21", "time": "00:00:00", "round": "0", "home_team": "Montreal Canadiens", "home_score": null, "away_team": "Vegas Golden Knights", "away_score": null}, {"date": "2021-06-22", "time": "00:00:00", "round": "0", "home_team": "Tampa Bay Lightning", "home_score": null, "away_team": "New York Islanders", "away_score": null}, {"date": "2021-06-23", "time": "01:00:00", "round": "0", "home_team": "Vegas Golden Knights", "home_score": null, "away_team": "Montreal Canadiens", "away_score": null}]

View File

@ -1 +1 @@
[{"date": "2021-05-23", "time": "15:00:00", "home_team": "Wolves", "home_score": "1", "away_team": "Man United", "away_score": "2", "round": "38"}, {"date": "2021-05-23", "time": "15:00:00", "home_team": "West Ham", "home_score": "3", "away_team": "Southampton", "away_score": "0", "round": "38"}, {"date": "2021-05-23", "time": "15:00:00", "home_team": "Sheffield United", "home_score": "1", "away_team": "Burnley", "away_score": "0", "round": "38"}, {"date": "2021-05-23", "time": "15:00:00", "home_team": "Man City", "home_score": "5", "away_team": "Everton", "away_score": "0", "round": "38"}, {"date": "2021-05-23", "time": "15:00:00", "home_team": "Liverpool", "home_score": "2", "away_team": "Crystal Palace", "away_score": "0", "round": "38"}, {"date": "2021-05-23", "time": "15:00:00", "home_team": "Leicester", "home_score": "2", "away_team": "Tottenham", "away_score": "4", "round": "38"}, {"date": "2021-05-23", "time": "15:00:00", "home_team": "Leeds", "home_score": "3", "away_team": "West Brom", "away_score": "1", "round": "38"}, {"date": "2021-05-23", "time": "15:00:00", "home_team": "Fulham", "home_score": "0", "away_team": "Newcastle", "away_score": "2", "round": "38"}, {"date": "2021-05-23", "time": "15:00:00", "home_team": "Aston Villa", "home_score": "2", "away_team": "Chelsea", "away_score": "1", "round": "38"}, {"date": "2021-05-23", "time": "15:00:00", "home_team": "Arsenal", "home_score": "2", "away_team": "Brighton", "away_score": "0", "round": "38"}, {"date": "2021-05-19", "time": "19:15:00", "home_team": "West Brom", "home_score": "1", "away_team": "West Ham", "away_score": "3", "round": "37"}, {"date": "2021-05-19", "time": "17:00:00", "home_team": "Tottenham", "home_score": "1", "away_team": "Aston Villa", "away_score": "2", "round": "37"}, {"date": "2021-05-19", "time": "17:00:00", "home_team": "Newcastle", "home_score": "1", "away_team": "Sheffield United", "away_score": "0", "round": "37"}, {"date": "2021-05-19", "time": "17:00:00", "home_team": "Everton", "home_score": "1", "away_team": "Wolves", "away_score": "0", "round": "37"}, {"date": "2021-05-19", "time": "18:00:00", "home_team": "Crystal Palace", "home_score": "1", "away_team": "Arsenal", "away_score": "3", "round": "37"}]
[{"date": "2021-05-23", "time": "15:00:00", "round": "38", "home_team": "Wolves", "home_score": "1", "away_team": "Man United", "away_score": "2"}, {"date": "2021-05-23", "time": "15:00:00", "round": "38", "home_team": "West Ham", "home_score": "3", "away_team": "Southampton", "away_score": "0"}, {"date": "2021-05-23", "time": "15:00:00", "round": "38", "home_team": "Sheffield United", "home_score": "1", "away_team": "Burnley", "away_score": "0"}, {"date": "2021-05-23", "time": "15:00:00", "round": "38", "home_team": "Man City", "home_score": "5", "away_team": "Everton", "away_score": "0"}, {"date": "2021-05-23", "time": "15:00:00", "round": "38", "home_team": "Liverpool", "home_score": "2", "away_team": "Crystal Palace", "away_score": "0"}, {"date": "2021-05-23", "time": "15:00:00", "round": "38", "home_team": "Leicester", "home_score": "2", "away_team": "Tottenham", "away_score": "4"}, {"date": "2021-05-23", "time": "15:00:00", "round": "38", "home_team": "Leeds", "home_score": "3", "away_team": "West Brom", "away_score": "1"}, {"date": "2021-05-23", "time": "15:00:00", "round": "38", "home_team": "Fulham", "home_score": "0", "away_team": "Newcastle", "away_score": "2"}, {"date": "2021-05-23", "time": "15:00:00", "round": "38", "home_team": "Aston Villa", "home_score": "2", "away_team": "Chelsea", "away_score": "1"}, {"date": "2021-05-23", "time": "15:00:00", "round": "38", "home_team": "Arsenal", "home_score": "2", "away_team": "Brighton", "away_score": "0"}, {"date": "2021-05-19", "time": "19:15:00", "round": "37", "home_team": "West Brom", "home_score": "1", "away_team": "West Ham", "away_score": "3"}, {"date": "2021-05-19", "time": "17:00:00", "round": "37", "home_team": "Tottenham", "home_score": "1", "away_team": "Aston Villa", "away_score": "2"}, {"date": "2021-05-19", "time": "17:00:00", "round": "37", "home_team": "Newcastle", "home_score": "1", "away_team": "Sheffield United", "away_score": "0"}, {"date": "2021-05-19", "time": "17:00:00", "round": "37", "home_team": "Everton", "home_score": "1", "away_team": "Wolves", "away_score": "0"}, {"date": "2021-05-19", "time": "18:00:00", "round": "37", "home_team": "Crystal Palace", "home_score": "1", "away_team": "Arsenal", "away_score": "3"}]

View File

@ -1,4 +1,4 @@
name,current,opening
MSFT,260.94,256.065
NFLX,499,490.25
GOOG,2535.55,2510.46
MSFT,259.43,259.63
NFLX,500.77,496.4
GOOG,2511.35,2514.11

1 name current opening
2 MSFT 260.94 259.43 256.065 259.63
3 NFLX 499 500.77 490.25 496.4
4 GOOG 2535.55 2511.35 2510.46 2514.11

BIN
final.ppm

Binary file not shown.

Binary file not shown.

View File

@ -321,11 +321,19 @@ def matrix():
LastCommand = 'Run display'
elif "Run League" in request.form:
elif "Past NHL" in request.form:
ticker.sendline('K')
ticker.sendline('P')
elif "Future NHL" in request.form:
ticker.sendline('K')
ticker.sendline('F')
elif "Live NHL" in request.form:
ticker.sendline('K')
ticker.sendline('L')
elif "Run Teams" in request.form:
elif "Premier league table" in request.form:
print('teams')
ticker.sendline('K')
ticker.sendline('t')

View File

@ -591,6 +591,7 @@ class StockTicker():
league_info = json.load(open('csv/sports/{}/{}_games.json'.format(league, time), 'r'))
print(league_info[0].keys())
small_font = ImageFont.load("./fonts/5x7.pil")
med_font = ImageFont.load("./fonts/7x14B.pil")
large_font = ImageFont.load("./fonts/10x20.pil")
@ -610,9 +611,9 @@ class StockTicker():
home_score = match['home_score']
away_score = match['away_score']
date = match['date']
date = match['date'].replace('-', '.')
rond = match['round']
#rond = match['round']
try:
@ -635,34 +636,44 @@ class StockTicker():
home_timage = self.textImage(sports_info[home_team]['code'], small_font, r = 255, g = 255, b = 255)
away_timage = self.textImage(sports_info[away_team]['code'], small_font, r = 255, g = 255, b = 255)
#away_timage = self.textImage(sports_info[away_team]['code'], small_font, r = 255, g = 255, b = 255)
date_timage = self.textImage(date, small_font, r = 255, g = 255, b = 0)
round_timage = self.textImage('round:' + rond, small_font, r = 255, g = 255, b = 255)
#round_timage = self.textImage('round:' + rond, small_font, r = 255, g = 255, b = 255)
if time == 'past':
score_image = self.textImage(home_score + '-' + away_score, large_font, r = 255, g = 255, b = 255)
img.paste(score_image, (x_offset+10, 15))
img.paste(home_logo, (x_offset,0))
x_offset += home_logo.size[0] + 2
img.paste(date_timage, (x_offset, 0))
if time == 'future':
vs_timage = self.textImage(sports_info[home_team]['code'] + 'vs' + sports_info[away_team]['code'], med_font, r = 255, g = 255, b = 255)
img.paste(vs_timage, (x_offset, 12))
else:
score_image = self.textImage(home_score + '-' + away_score, large_font, r = 255, g = 255, b = 255)
img.paste(score_image, (x_offset + 10, 15))
vs_timage = self.textImage(sports_info[home_team]['code'] + 'vs' + sports_info[away_team]['code'], small_font, r = 255, g = 255, b = 255)
img.paste(vs_timage, (x_offset+4, 9))
#if league == 'NHL':
# img.paste(home_timage, (x_offset, 0))
# img.paste(away_timage, (x_offset, 5))
#
img.paste(date_timage, (x_offset, 0))
img.paste(round_timage, (x_offset+ 7, 8))
#img.paste(round_timage, (x_offset+ 7, 8))
#x_offset += max(home_timage.size[0], away_timage.size[0], date_timage.size[0], round_timage.size[0], score_image.size[0])
if time == 'past':
x_offset += max( date_timage.size[0], round_timage.size[0], score_image.size[0])
x_offset += max( date_timage.size[0], vs_timage.size[0], score_image.size[0])
else:
x_offset += max( date_timage.size[0], round_timage.size[0])
x_offset += max( date_timage.size[0], vs_timage.size[0])
img.paste(away_logo, (x_offset,0))
@ -678,7 +689,7 @@ class StockTicker():
team_info = json.load(open('csv/sports/{}/team_stats.json'.format(league), 'r'))
small_font = ImageFont.load("./fonts/5x7.pil")
med_font = ImageFont.load("./fonts/7x14.pil")
med_font = ImageFont.load("./fonts/8x13B.pil")
large_font = ImageFont.load("./fonts/10x20.pil")
if league =='NHL': # read the NHl info from the csv, prem will need this as well
@ -710,10 +721,10 @@ class StockTicker():
img.paste(name_timage, (x_offset, -2))
img.paste(wins_timage, (x_offset, 11))
img.paste(loss_timage, (x_offset, 18))
img.paste(draw_timage, (x_offset, 25))
img.paste(name_timage, (x_offset, -1))
img.paste(wins_timage, (x_offset, 12))
img.paste(loss_timage, (x_offset, 19))
img.paste(draw_timage, (x_offset, 26))
x_offset += max( wins_timage.size[0], loss_timage.size[0], draw_timage.size[0])
img.paste(points_timage, (x_offset, 14))
@ -728,6 +739,8 @@ class StockTicker():
def getTodayWeatherImage(self):
img = Image.new('RGB', (200, 32))
@ -1312,12 +1325,24 @@ class StockTicker():
#self.setImage( image)
self.scrollImageTransition(['weather.ppm', 'weather.ppm'], stocks = False)
elif msg == 'L': # league
elif msg == 'P': # past league
img = self.getLeagueImage('NHL', 'past')
img.save('league.ppm')
stock_ticker.scrollImageTransition(['league.ppm', 'league.ppm'], stocks = False)
elif msg == 'F': # future league
img = self.getLeagueImage('NHL', 'future')
img.save('league.ppm')
stock_ticker.scrollImageTransition(['league.ppm', 'league.ppm'], stocks = False)
elif msg == 'L': # live game
img = self.getLeagueImage('NHL', 'live')
img.save('league.ppm')
stock_ticker.scrollImageTransition(['league.ppm', 'league.ppm'], stocks = False)
elif msg == 't': #teams
img = self.getTeamsImage('premier_league')
img.save('teams.ppm')
@ -1333,6 +1358,7 @@ if __name__ == '__main__':
with open('log.txt', "w") as log:
try:
stock_ticker = StockTicker()
#stock_ticker.process_msg('L')

BIN
teams.ppm

Binary file not shown.

View File

@ -14,8 +14,10 @@
<input type="submit" name="Run News" value="Run News" style="height:50px" >
<input type="submit" name="Run Weather" value="Run Weather" style="height:50px" >
<input type="submit" name="Run Daily Weather" value="Run Daily Weather" style="height:50px" >
<input type="submit" name="Run League" value="Run League" style="height:50px" >
<input type="submit" name="Run Teams" value="Run Teams" style="height:50px" >
<input type="submit" name="Past NHL" value="Past NHL" style="height:50px" >
<input type="submit" name="Future NHL" value="Future NHL" style="height:50px" >
<input type="submit" name="Live NHL" value="Live NHL" style="height:50px" >
<input type="submit" name="Premier league table" value="Premier league table" style="height:50px" >
<input type="submit" name="Stop Display" value="Stop Display"style="height:50px">
<input type="submit" name="Shutdown the pi" value="Shutdown the pi"style="height:50px">
</form>