sports updates and live sports added
This commit is contained in:
parent
d84265405c
commit
3378c69d9e
330
api_caller.py
330
api_caller.py
@ -121,181 +121,196 @@ def updateStockPrices(symbols):
|
||||
|
||||
|
||||
def updateStockPricesIEX(symbols):
|
||||
|
||||
symbols_str = ','.join(symbols)
|
||||
method = 'GET'
|
||||
host = 'https://cloud.iexapis.com/stable'
|
||||
lastEndpoint = '/tops/last'
|
||||
querystring = '?symbols=' + symbols_str +'&token='+iexAPIkey
|
||||
|
||||
last_request_url = host + lastEndpoint + querystring
|
||||
|
||||
|
||||
print('\nBEGIN REQUEST++++++++++++++++++++++++++++++++++++')
|
||||
print('Request URL = ' + last_request_url)
|
||||
last_response = requests.get(last_request_url)
|
||||
|
||||
if last_response.status_code == 200:
|
||||
print('last success')
|
||||
|
||||
current_prices = []
|
||||
for stock in last_response.json():
|
||||
current_prices.append(stock['price'])
|
||||
|
||||
|
||||
for symbol in symbols:
|
||||
symbol = 'MSFT'
|
||||
try:
|
||||
symbols_str = ','.join(symbols)
|
||||
method = 'GET'
|
||||
host = 'https://cloud.iexapis.com/stable'
|
||||
lastEndpoint = '/tops/last'
|
||||
intradayEndpoint = '/stock/'+ symbol+ '/intraday-prices'
|
||||
querystring = '?chartIEXOnly=true&token='+iexAPIkey
|
||||
|
||||
intraday_request_url = host + intradayEndpoint + querystring
|
||||
querystring = '?symbols=' + symbols_str +'&token='+iexAPIkey
|
||||
|
||||
last_request_url = host + lastEndpoint + querystring
|
||||
|
||||
|
||||
print('\nBEGIN REQUEST++++++++++++++++++++++++++++++++++++')
|
||||
print('Request URL = ' + intraday_request_url)
|
||||
intraday_response = requests.get(intraday_request_url)
|
||||
print('Request URL = ' + last_request_url)
|
||||
last_response = requests.get(last_request_url)
|
||||
|
||||
print('\nRESPONSE++++++++++++++++++++++++++++++++++++')
|
||||
print('Response code: %d\n' % intraday_response.status_code)
|
||||
|
||||
if last_response.status_code == 200:
|
||||
print('last success')
|
||||
|
||||
current_prices = []
|
||||
for stock in last_response.json():
|
||||
current_prices.append(stock['price'])
|
||||
|
||||
|
||||
for symbol in symbols:
|
||||
symbol = 'MSFT'
|
||||
method = 'GET'
|
||||
host = 'https://cloud.iexapis.com/stable'
|
||||
lastEndpoint = '/tops/last'
|
||||
intradayEndpoint = '/stock/'+ symbol+ '/intraday-prices'
|
||||
querystring = '?chartIEXOnly=true&token='+iexAPIkey
|
||||
|
||||
intraday_request_url = host + intradayEndpoint + querystring
|
||||
|
||||
print('\nBEGIN REQUEST++++++++++++++++++++++++++++++++++++')
|
||||
print('Request URL = ' + intraday_request_url)
|
||||
intraday_response = requests.get(intraday_request_url)
|
||||
|
||||
print('\nRESPONSE++++++++++++++++++++++++++++++++++++')
|
||||
print('Response code: %d\n' % intraday_response.status_code)
|
||||
|
||||
|
||||
print(intraday_response.text)
|
||||
|
||||
for time_point in intraday_response.json():
|
||||
print(time_point['date'])
|
||||
print(time_point['open'])
|
||||
|
||||
print(intraday_response.text)
|
||||
|
||||
for time_point in intraday_response.json():
|
||||
print(time_point['date'])
|
||||
print(time_point['open'])
|
||||
|
||||
CSV = open('csv/tickers.csv', 'w+')
|
||||
CSV.write('name,current,opening\n')
|
||||
for i, symbol in enumerate(symbols):
|
||||
|
||||
|
||||
|
||||
CSV = open('csv/tickers.csv', 'w+')
|
||||
CSV.write('name,current,opening\n')
|
||||
for i, symbol in enumerate(symbols):
|
||||
|
||||
CSV.write(symbol + ',' + str(current_prices[i]) + ',' + str(opening_prices[i]) + '\n')
|
||||
CSV.close()
|
||||
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):
|
||||
response = coingecko_client.get_price(ids=','.join(coins), vs_currencies = unique_bases, include_24hr_change=True)
|
||||
|
||||
CSV = open('csv/crypto.csv', 'w+')
|
||||
CSV.write('symbol,name,base,current,24hr change\n')
|
||||
|
||||
for coin in coins:
|
||||
info = coin_info[coin]
|
||||
print(info)
|
||||
try:
|
||||
response = coingecko_client.get_price(ids=','.join(coins), vs_currencies = unique_bases, include_24hr_change=True)
|
||||
|
||||
CSV.write(info[0] + ',' + coin + ',' + info[1] + ',' +str(response[coin][info[1]]) + ',' + str(response[coin]['usd_24h_change']) + '\n')
|
||||
CSV.close()
|
||||
CSV = open('csv/crypto.csv', 'w+')
|
||||
CSV.write('symbol,name,base,current,24hr change\n')
|
||||
|
||||
for coin in coins:
|
||||
info = coin_info[coin]
|
||||
print(info)
|
||||
|
||||
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:
|
||||
#load user settings
|
||||
|
||||
settings = json.load(open('csv/news_settings.json', 'r'))
|
||||
|
||||
print(settings)
|
||||
headlines = newsapi.get_top_headlines(**settings)
|
||||
except:
|
||||
#if no settings just get top headlines
|
||||
headlines = newsapi.get_top_headlines()
|
||||
try:
|
||||
#load user settings
|
||||
|
||||
settings = json.load(open('csv/news_settings.json', 'r'))
|
||||
|
||||
headline_titles = [headline['title'] for headline in headlines['articles']]
|
||||
headline_sources = [headline['source']['name'] for headline in headlines['articles']]
|
||||
headline_times = [headline['publishedAt']for headline in headlines['articles']]
|
||||
print(settings)
|
||||
headlines = newsapi.get_top_headlines(**settings)
|
||||
except:
|
||||
#if no settings just get top headlines
|
||||
headlines = newsapi.get_top_headlines()
|
||||
|
||||
headline_titles = [headline['title'] for headline in headlines['articles']]
|
||||
headline_sources = [headline['source']['name'] for headline in headlines['articles']]
|
||||
headline_times = [headline['publishedAt']for headline in headlines['articles']]
|
||||
|
||||
CSV = open('csv/news.csv', 'w+')
|
||||
CSV.write('headline,source,date,time\n')
|
||||
|
||||
CSV = open('csv/news.csv', 'w+')
|
||||
CSV.write('headline,source,date,time\n')
|
||||
|
||||
for i, title in enumerate(headline_titles):
|
||||
date, time = headline_times[i].split('T')
|
||||
CSV.write(title.replace(',', '^') + ',' + headline_sources[i] + ',' + date + ',' + time + '\n')
|
||||
|
||||
CSV.close()
|
||||
for i, title in enumerate(headline_titles):
|
||||
date, time = headline_times[i].split('T')
|
||||
CSV.write(title.replace(',', '^') + ',' + headline_sources[i] + ',' + date + ',' + time + '\n')
|
||||
|
||||
CSV.close()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def updateWeather(api_key):
|
||||
f = open( "csv/weather_location.txt", 'r' )
|
||||
location = f.read()
|
||||
f.close()
|
||||
url = "https://api.openweathermap.org/data/2.5/weather?q={}&units=metric&appid={}".format(location, api_key)
|
||||
r = requests.get(url)
|
||||
weather = r.json()
|
||||
print(weather)
|
||||
current_weather = {}
|
||||
try:
|
||||
f = open( "csv/weather_location.txt", 'r' )
|
||||
location = f.read()
|
||||
f.close()
|
||||
url = "https://api.openweathermap.org/data/2.5/weather?q={}&units=metric&appid={}".format(location, api_key)
|
||||
r = requests.get(url)
|
||||
weather = r.json()
|
||||
print(weather)
|
||||
current_weather = {}
|
||||
|
||||
coords = weather['coord']
|
||||
lat = coords['lat']
|
||||
lon = coords['lon']
|
||||
url = 'https://api.openweathermap.org/data/2.5/onecall?lat={}&units=metric&lon={}&appid={}'.format(lat, lon, api_key)
|
||||
r = requests.get(url)
|
||||
|
||||
current_weather['main_weather'] = weather['weather'][0]['main']
|
||||
current_weather['description'] = weather['weather'][0]['description']
|
||||
current_weather['temp'] = weather['main']['temp']
|
||||
current_weather['min_temp'] = weather['main']['temp_min']
|
||||
current_weather['max_temp'] = weather['main']['temp_max']
|
||||
current_weather['feels_like'] = weather['main']['feels_like']
|
||||
current_weather['humidity'] = weather['main']['humidity']
|
||||
current_weather['clouds'] = weather['clouds']['all']
|
||||
current_weather['wind_speed'] = weather['wind']['speed']
|
||||
current_weather['wind_direction'] = weather['wind']['deg']
|
||||
current_weather['visibility'] = weather['visibility']
|
||||
current_weather['uv'] = r.json()['current']['uvi']
|
||||
current_weather['rain_chance'] = r.json()['hourly'][0]['pop']
|
||||
|
||||
|
||||
json.dump( current_weather, open( "csv/current_weather.json", 'w+' ))
|
||||
|
||||
|
||||
daily_weather = []
|
||||
daily = r.json()['daily']
|
||||
|
||||
for day in daily:
|
||||
dct = {}
|
||||
dct['main_weather'] = day['weather'][0]['main']
|
||||
dct['description'] = day['weather'][0]['description']
|
||||
dct['min_temp'] = day['temp']['min']
|
||||
dct['max_temp'] = day['temp']['max']
|
||||
daily_weather.append(dct)
|
||||
|
||||
json.dump( daily_weather, open( "csv/daily_weather.json", 'w+' ))
|
||||
|
||||
coords = weather['coord']
|
||||
lat = coords['lat']
|
||||
lon = coords['lon']
|
||||
url = 'https://api.openweathermap.org/data/2.5/onecall?lat={}&units=metric&lon={}&appid={}'.format(lat, lon, api_key)
|
||||
r = requests.get(url)
|
||||
|
||||
current_weather['main_weather'] = weather['weather'][0]['main']
|
||||
current_weather['description'] = weather['weather'][0]['description']
|
||||
current_weather['temp'] = weather['main']['temp']
|
||||
current_weather['min_temp'] = weather['main']['temp_min']
|
||||
current_weather['max_temp'] = weather['main']['temp_max']
|
||||
current_weather['feels_like'] = weather['main']['feels_like']
|
||||
current_weather['humidity'] = weather['main']['humidity']
|
||||
current_weather['clouds'] = weather['clouds']['all']
|
||||
current_weather['wind_speed'] = weather['wind']['speed']
|
||||
current_weather['wind_direction'] = weather['wind']['deg']
|
||||
current_weather['visibility'] = weather['visibility']
|
||||
current_weather['uv'] = r.json()['current']['uvi']
|
||||
current_weather['rain_chance'] = r.json()['hourly'][0]['pop']
|
||||
|
||||
|
||||
json.dump( current_weather, open( "csv/current_weather.json", 'w+' ))
|
||||
|
||||
|
||||
daily_weather = []
|
||||
daily = r.json()['daily']
|
||||
|
||||
for day in daily:
|
||||
dct = {}
|
||||
dct['main_weather'] = day['weather'][0]['main']
|
||||
dct['description'] = day['weather'][0]['description']
|
||||
dct['min_temp'] = day['temp']['min']
|
||||
dct['max_temp'] = day['temp']['max']
|
||||
daily_weather.append(dct)
|
||||
|
||||
json.dump( daily_weather, open( "csv/daily_weather.json", 'w+' ))
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
|
||||
def updateCurrencies(api_key):
|
||||
base = 'USD'
|
||||
yesterday = datetime.now() - timedelta(1)
|
||||
|
||||
str_tod = datetime.strftime(datetime.now(), '%Y-%m-%d')
|
||||
str_yest = datetime.strftime(yesterday, '%Y-%m-%d')
|
||||
|
||||
url = 'https://api.frankfurter.app/{}..{}?from={}'.format(str_yest, str_tod, base)
|
||||
r = requests.get(url)
|
||||
all_data = r.json()
|
||||
|
||||
currencies = ['AUD', 'CAD', 'CHF', 'EUR', 'GBP', 'JPY', 'NZD']
|
||||
|
||||
c_dict = {}
|
||||
|
||||
print(all_data)
|
||||
|
||||
|
||||
|
||||
for curr in currencies:
|
||||
try:
|
||||
base = 'USD'
|
||||
yesterday = datetime.now() - timedelta(1)
|
||||
|
||||
current = all_data['rates'][str_tod][curr]
|
||||
yesterday = all_data['rates'][str_yest][curr]
|
||||
str_tod = datetime.strftime(datetime.now(), '%Y-%m-%d')
|
||||
str_yest = datetime.strftime(yesterday, '%Y-%m-%d')
|
||||
|
||||
url = 'https://api.frankfurter.app/{}..{}?from={}'.format(str_yest, str_tod, base)
|
||||
r = requests.get(url)
|
||||
all_data = r.json()
|
||||
|
||||
change = current - yesterday
|
||||
currencies = ['AUD', 'CAD', 'CHF', 'EUR', 'GBP', 'JPY', 'NZD']
|
||||
|
||||
c_dict[curr] = [current, yesterday]
|
||||
c_dict = {}
|
||||
|
||||
print(c_dict)
|
||||
json.dump([base, c_dict], open( "csv/currency.json", 'w+' ))
|
||||
|
||||
|
||||
|
||||
|
||||
for curr in currencies:
|
||||
|
||||
current = all_data['rates'][str_tod][curr]
|
||||
yesterday = all_data['rates'][str_yest][curr]
|
||||
|
||||
change = current - yesterday
|
||||
|
||||
c_dict[curr] = [current, yesterday]
|
||||
|
||||
|
||||
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']
|
||||
|
||||
event['time'] = all_data['events'][i]['strTime']
|
||||
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)
|
||||
|
||||
|
||||
@ -370,8 +392,9 @@ def updateLeagueEvents(api_key, league_id, time):
|
||||
|
||||
json.dump(events, open( "csv/sports/{}/{}_games.json".format(league, time), 'w+' ))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def updateSports(api_key):
|
||||
@ -381,9 +404,11 @@ 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)
|
||||
|
||||
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
|
@ -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 +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}
|
@ -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}]
|
@ -1 +1 @@
|
||||
17/06/2021 15:03:04
|
||||
19/06/2021 05:50:09
|
||||
|
|
40
csv/news.csv
40
csv/news.csv
@ -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 gov’t 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 Iran’s new president - The Guardian,The Guardian,2021-06-19,08:37:00Z
|
||||
153 new COVID-19 deaths raise PH’s 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 Didn’t 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,2 +1,2 @@
|
||||
speed,brightness
|
||||
f,9
|
||||
m,9
|
|
@ -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}]
|
@ -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"}]
|
@ -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
|
||||
|
|
BIN
league.ppm
BIN
league.ppm
Binary file not shown.
12
server.py
12
server.py
@ -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')
|
||||
|
@ -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))
|
||||
@ -725,7 +736,9 @@ class StockTicker():
|
||||
img = img.crop((0,0,x_offset ,32))
|
||||
|
||||
return img
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def getTodayWeatherImage(self):
|
||||
@ -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')
|
||||
|
||||
|
||||
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user