api call limits and transitions
This commit is contained in:
parent
2bee635511
commit
54edfb0d1b
220
api_caller.py
220
api_caller.py
@ -96,8 +96,13 @@ def updateUpdate(NY_time):
|
|||||||
f.write(NY_str + '\n')
|
f.write(NY_str + '\n')
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
def updateStockPrices(symbols):
|
def updateStockPrices():
|
||||||
|
finnhubsandboxAPIkey = "sandbox_c24qddqad3ickpckgg8g" #Finnhub
|
||||||
|
finnhubAPIkey = "c24qddqad3ickpckgg80" #Finnhub
|
||||||
|
finnhubClient = finnhub.Client(api_key=finnhubAPIkey)
|
||||||
|
|
||||||
|
|
||||||
|
symbols, stock_info = readCSV('csv/tickers.csv', max_stocks)
|
||||||
try:
|
try:
|
||||||
quotes = [finnhubClient.quote(symbol) for symbol in symbols]
|
quotes = [finnhubClient.quote(symbol) for symbol in symbols]
|
||||||
current_prices = [quote['c'] for quote in quotes]
|
current_prices = [quote['c'] for quote in quotes]
|
||||||
@ -120,7 +125,11 @@ def updateStockPrices(symbols):
|
|||||||
apiCalledError = True
|
apiCalledError = True
|
||||||
|
|
||||||
|
|
||||||
def updateStockPricesIEX(symbols):
|
def updateStockPricesIEX():
|
||||||
|
iexAPIkey = 'pk_68ef6a15902c41f887f0b544a0ca17cf' #IEX
|
||||||
|
iexSandboxAPIkey = 'Tpk_0078dff413ef4f979137f7111452dc4b'
|
||||||
|
max_stocks = 200
|
||||||
|
symbols, stock_info = readCSV('csv/tickers.csv', max_stocks)
|
||||||
try:
|
try:
|
||||||
symbols_str = ','.join(symbols)
|
symbols_str = ','.join(symbols)
|
||||||
method = 'GET'
|
method = 'GET'
|
||||||
@ -179,7 +188,10 @@ def updateStockPricesIEX(symbols):
|
|||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
|
|
||||||
def updateCrypto(coins, coin_info, unique_bases):
|
def updateCrypto():
|
||||||
|
coingecko_client = CoinGeckoAPI()
|
||||||
|
|
||||||
|
coins, coin_info, unique_bases = readCryptoCSV('csv/crypto.csv', max_crypto)
|
||||||
try:
|
try:
|
||||||
response = coingecko_client.get_price(ids=','.join(coins), vs_currencies = unique_bases, include_24hr_change=True)
|
response = coingecko_client.get_price(ids=','.join(coins), vs_currencies = unique_bases, include_24hr_change=True)
|
||||||
|
|
||||||
@ -225,7 +237,9 @@ def updateNews():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
def updateWeather(api_key):
|
def updateWeather():
|
||||||
|
|
||||||
|
api_key = 'bd5d5096a5ba30bbcfb57ead42ab3fee'
|
||||||
try:
|
try:
|
||||||
f = open( "csv/weather_location.txt", 'r' )
|
f = open( "csv/weather_location.txt", 'r' )
|
||||||
location = f.read()
|
location = f.read()
|
||||||
@ -277,8 +291,8 @@ def updateWeather(api_key):
|
|||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
|
|
||||||
def updateCurrencies(api_key):
|
def updateForex():
|
||||||
|
api_key = '862dbb6d1101ce0c5136'
|
||||||
try:
|
try:
|
||||||
base = 'USD'
|
base = 'USD'
|
||||||
yesterday = datetime.now() - timedelta(1)
|
yesterday = datetime.now() - timedelta(1)
|
||||||
@ -401,105 +415,96 @@ def updateLeagueEvents(api_key, league_id, time):
|
|||||||
|
|
||||||
json.dump(events, open( "csv/sports/{}/{}_games.json".format(league, time), 'w+' ))
|
json.dump(events, open( "csv/sports/{}/{}_games.json".format(league, time), 'w+' ))
|
||||||
|
|
||||||
|
def updateSports():
|
||||||
|
#read user settings to decide which sprots to update
|
||||||
|
api_key = '97436974'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def updateSports(api_key):
|
|
||||||
prem_id = '4328' #prem
|
prem_id = '4328' #prem
|
||||||
NHL_id = '4380'
|
NHL_id = '4380'
|
||||||
NBA_id = '4387' #prem
|
NBA_id = '4387' #prem
|
||||||
NFL_id = '4391'
|
NFL_id = '4391'
|
||||||
|
|
||||||
for i in [NHL_id, NBA_id, NFL_id]:
|
for i in [NHL_id]:
|
||||||
updateLeagueEvents(api_key, i, 'live')
|
updateLeagueEvents(api_key, i, 'live')
|
||||||
updateLeagueEvents(api_key, i, 'past')
|
updateLeagueEvents(api_key, i, 'past')
|
||||||
updateLeagueEvents(api_key, i, 'future')
|
updateLeagueEvents(api_key, i, 'future')
|
||||||
|
|
||||||
|
|
||||||
updateLeagueTable(api_key, NHL_id)
|
|
||||||
updateLeagueTable(api_key, prem_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
|
'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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#url = 'https://www.thesportsdb.com/api/v1/json/{}/eventsseason.php?id=4328&s=2020-2021'.format(api_key) # all past events in premier league
|
#url = 'https://www.thesportsdb.com/api/v1/json/{}/eventsseason.php?id=4328&s=2020-2021'.format(api_key) # all past events in premier league
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
url = 'https://www.thesportsdb.com/api/v2/json/{}/livescore.php?l=4380'.format(api_key) #live scores
|
url = 'https://www.thesportsdb.com/api/v2/json/{}/livescore.php?l=4380'.format(api_key) #live scores
|
||||||
|
|
||||||
|
|
||||||
|
def checkStocks(last_update, update_frequency):
|
||||||
|
NY_time = datetime.now(NY_zone).replace(tzinfo=None)
|
||||||
|
opening = NY_time.replace(hour=9, minute=30, second=0, microsecond=0).replace(tzinfo=None)
|
||||||
|
closing = NY_time.replace(hour=16, minute=0, second=0, microsecond=0).replace(tzinfo=None)
|
||||||
|
|
||||||
|
|
||||||
|
symbols, stock_info = readCSV('csv/tickers.csv', max_stocks)
|
||||||
|
|
||||||
|
updated = False
|
||||||
|
|
||||||
|
diff = (NY_time - last_update).total_seconds()/60 #minutes
|
||||||
|
if opening < NY_time < closing and datetime.today().weekday() < 5: # we need to do real time updating
|
||||||
|
|
||||||
|
|
||||||
|
if diff >= update_frequency:
|
||||||
|
updated = True
|
||||||
|
updateStockPrices()
|
||||||
|
|
||||||
|
|
||||||
|
elif emptyInfo(symbols, stock_info): # if theres any empty stocks
|
||||||
|
updated = True
|
||||||
|
updateStockPrices()
|
||||||
|
|
||||||
|
|
||||||
|
else:
|
||||||
|
# update if last update was before the previous days closing
|
||||||
|
yday_closing = closing - dt.timedelta(days=1)
|
||||||
|
yday_str = yday_closing.strftime("%d/%m/%Y %H:%M:%S")
|
||||||
|
yday_closing = datetime.strptime(yday_str, "%d/%m/%Y %H:%M:%S")
|
||||||
|
|
||||||
|
if last_update < yday_closing:
|
||||||
|
updated = True
|
||||||
|
updateStockPrices(symbols)
|
||||||
|
|
||||||
|
return updated
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
|
|
||||||
newsapi = NewsApiClient(api_key='cf08652bd17647b89aaf469a1a8198a9')
|
|
||||||
|
|
||||||
|
|
||||||
finnhubAPIkey = "c24qddqad3ickpckgg80" #Finnhub
|
|
||||||
finnhubsandboxAPIkey = "sandbox_c24qddqad3ickpckgg8g" #Finnhub
|
|
||||||
stock_time = 2 #minutes
|
|
||||||
crypto_time = 10 #minutes
|
|
||||||
news_time = 30 #minutes
|
|
||||||
weather_time = 10 #minutes
|
|
||||||
|
|
||||||
# TODO: different update times for stocks, weather and news
|
|
||||||
finnhubClient = finnhub.Client(api_key=finnhubAPIkey)
|
|
||||||
max_stocks = 200
|
max_stocks = 200
|
||||||
max_crypto = 100
|
max_crypto = 100
|
||||||
|
|
||||||
iexAPIkey = 'pk_68ef6a15902c41f887f0b544a0ca17cf' #IEX
|
newsapi = NewsApiClient(api_key='cf08652bd17647b89aaf469a1a8198a9')
|
||||||
iexSandboxAPIkey = 'Tpk_0078dff413ef4f979137f7111452dc4b'
|
|
||||||
|
|
||||||
#updateStockPricesIEX(symbols)
|
update_frequencies = {'stocks':2, 'crypto':10, 'news':60, 'weather': 10} #minutes
|
||||||
|
|
||||||
finnhubClient = finnhub.Client(api_key=finnhubAPIkey)
|
|
||||||
|
|
||||||
coingecko_client = CoinGeckoAPI()
|
|
||||||
|
|
||||||
NY_zone = pytz.timezone('America/New_York')
|
NY_zone = pytz.timezone('America/New_York')
|
||||||
|
CET_zone = pytz.timezone('Europe/Berlin')
|
||||||
NY_time = datetime.now(NY_zone)
|
|
||||||
opening = NY_time.replace(hour=9, minute=30, second=0, microsecond=0)
|
|
||||||
closing = NY_time.replace(hour=16, minute=0, second=0, microsecond=0)
|
|
||||||
|
|
||||||
NY_time = datetime.now(NY_zone)
|
NY_time = datetime.now(NY_zone)
|
||||||
|
|
||||||
symbols, stock_info = readCSV('csv/tickers.csv', max_stocks)
|
CET_time = datetime.now(CET_zone)
|
||||||
updateStockPrices(symbols)
|
|
||||||
updateUpdate(NY_time)
|
|
||||||
coins, coin_info, unique_bases = readCryptoCSV('csv/crypto.csv', max_crypto)
|
|
||||||
|
|
||||||
weather_key = 'bd5d5096a5ba30bbcfb57ead42ab3fee'
|
NY_str = NY_time.strftime("%d/%m/%Y %H:%M:%S")
|
||||||
|
CET_str = NY_time.strftime("%d/%m/%Y %H:%M:%S")
|
||||||
|
|
||||||
currency_key = '862dbb6d1101ce0c5136'
|
#f = open('csv/last_updates.json', 'w+')
|
||||||
sports_key = '97436974'
|
#update_times = {'stocks':NY_str, 'crypto':NY_str, 'news':NY_str, 'weather': NY_str, 'forex': CET_str} # all in NY time apart from forex in CET
|
||||||
|
#json.dump(update_times, f)
|
||||||
|
#f.close()
|
||||||
|
|
||||||
updateSports(sports_key)
|
f = open('csv/last_updates.json', 'r')
|
||||||
|
last_updates = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
updateCurrencies(currency_key)
|
|
||||||
|
|
||||||
|
|
||||||
updateWeather( weather_key)
|
|
||||||
|
|
||||||
updateCrypto(coins, coin_info, unique_bases)
|
|
||||||
|
|
||||||
updateNews()
|
|
||||||
|
|
||||||
t = time.time()
|
t = time.time()
|
||||||
|
|
||||||
@ -508,55 +513,66 @@ if __name__ == '__main__':
|
|||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
|
NY_time = datetime.now(NY_zone).replace(tzinfo=None)
|
||||||
|
|
||||||
msg = getInput()
|
msg = getInput()
|
||||||
if msg == 'R' or time.time() - t > stock_time*60:
|
|
||||||
|
#stocks
|
||||||
|
stock_time = datetime.strptime(last_updates['stocks'], "%d/%m/%Y %H:%M:%S")
|
||||||
|
stock_frequency = update_frequencies['stocks']
|
||||||
|
if checkStocks(stock_time, stock_frequency):
|
||||||
|
stock_time = NY_time.strftime("%d/%m/%Y %H:%M:%S")
|
||||||
|
last_updates['stocks'] = stock_time
|
||||||
|
|
||||||
|
# crypto
|
||||||
|
crypto_time = datetime.strptime(last_updates['crypto'], "%d/%m/%Y %H:%M:%S")
|
||||||
|
crypto_frequency = update_frequencies['crypto']
|
||||||
|
|
||||||
|
NY_time = datetime.now(NY_zone).replace(tzinfo=None)
|
||||||
|
diff = (NY_time - crypto_time).total_seconds()/60 #minutes
|
||||||
|
if diff >= update_frequencies['crypto']:
|
||||||
|
crypto_time = NY_time.strftime("%d/%m/%Y %H:%M:%S")
|
||||||
|
updateCrypto()
|
||||||
|
last_updates['crypto'] = crypto_time
|
||||||
|
|
||||||
|
|
||||||
|
# weather
|
||||||
|
weather_time = datetime.strptime(last_updates['weather'], "%d/%m/%Y %H:%M:%S")
|
||||||
|
weather_frequency = update_frequencies['weather']
|
||||||
|
|
||||||
|
NY_time = datetime.now(NY_zone).replace(tzinfo=None)
|
||||||
|
diff = (NY_time - weather_time).total_seconds()/60 #minutes
|
||||||
|
if diff >= update_frequencies['weather']:
|
||||||
|
weather_time = NY_time.strftime("%d/%m/%Y %H:%M:%S")
|
||||||
|
updateWeather()
|
||||||
|
last_updates['weather'] = weather_time
|
||||||
|
|
||||||
|
|
||||||
coins, coin_info, unique_bases = readCryptoCSV('csv/crypto.csv', max_stocks)
|
# weather
|
||||||
|
news_time = datetime.strptime(last_updates['news'], "%d/%m/%Y %H:%M:%S")
|
||||||
|
news_frequency = update_frequencies['news']
|
||||||
|
|
||||||
updateCrypto(coins, coin_info, unique_bases)
|
NY_time = datetime.now(NY_zone).replace(tzinfo=None)
|
||||||
updateCurrencies(currency_key)
|
diff = (NY_time - weather_time).total_seconds()/60 #minutes
|
||||||
|
if diff >= update_frequencies['news']:
|
||||||
|
news_time = NY_time.strftime("%d/%m/%Y %H:%M:%S")
|
||||||
updateNews()
|
updateNews()
|
||||||
updateWeather(weather_location, weather_key)
|
last_updates['news'] = news_time
|
||||||
updateSports(sports_key)
|
|
||||||
|
|
||||||
NY_time = datetime.now(NY_zone)
|
#forex updates once every 24hours at 1700 CET
|
||||||
symbols, stock_info = readCSV('csv/tickers.csv', max_stocks)
|
|
||||||
if opening < NY_time < closing and datetime.today().weekday() < 5: # we need to do real time updating
|
|
||||||
print('market open')
|
|
||||||
|
|
||||||
updateStockPrices(symbols)
|
|
||||||
updateUpdate(NY_time)
|
|
||||||
|
|
||||||
elif emptyInfo(symbols, stock_info): # if theres any empty stocks
|
|
||||||
|
|
||||||
updateStockPrices(symbols)
|
|
||||||
updateUpdate(NY_time)
|
|
||||||
|
|
||||||
else:
|
|
||||||
# update if last update was before the previous days closing
|
# update if last update was before the previous days closing
|
||||||
|
forex_time = datetime.strptime(last_updates['forex'], "%d/%m/%Y %H:%M:%S")
|
||||||
|
CET_time = datetime.now(CET_zone)
|
||||||
|
yday_update = (CET_time.replace(hour=17, minute=00, second=0, microsecond=0) - dt.timedelta(days=1)).replace(tzinfo=None)
|
||||||
|
|
||||||
f = open('csv/last_update.csv', 'r')
|
if forex_time < yday_update:
|
||||||
CSV = csv.reader(f)
|
forex_time = CET_time.strftime("%d/%m/%Y %H:%M:%S")
|
||||||
last_update_str = next(CSV)[0]
|
last_updates['forex'] = forex_time
|
||||||
|
updateForex()
|
||||||
|
|
||||||
last_update = datetime.strptime(last_update_str, "%d/%m/%Y %H:%M:%S")
|
|
||||||
|
|
||||||
yday_closing = closing - dt.timedelta(days=1)
|
|
||||||
yday_str = yday_closing.strftime("%d/%m/%Y %H:%M:%S")
|
|
||||||
yday_closing = datetime.strptime(yday_str, "%d/%m/%Y %H:%M:%S")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if last_update < yday_closing:
|
|
||||||
|
|
||||||
updateStockPrices(symbols)
|
|
||||||
|
|
||||||
updateUpdate(NY_time)
|
|
||||||
t = time.time()
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logf.write(srt(e))
|
logf.write(str(e))
|
||||||
|
print(e)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
symbol,name,base,current,24hr change
|
symbol,name,base,current,24hr change
|
||||||
BTC,bitcoin,usd,32955,0.18795236810340699
|
BTC,bitcoin,usd,32675,3.7239980392362217
|
||||||
ETH,ethereum,gbp,1388.1,-1.2416916112022245
|
ETH,ethereum,gbp,1317.79,1.854985374746106
|
||||||
|
|
@ -1 +1 @@
|
|||||||
{"main_weather": "Clouds", "description": "overcast clouds", "temp": 26.64, "min_temp": 25.58, "max_temp": 27.4, "feels_like": 26.64, "humidity": 90, "clouds": 100, "wind_speed": 0.45, "wind_direction": 135, "visibility": 10000, "uv": 0, "rain_chance": 1}
|
{"main_weather": "Rain", "description": "heavy intensity rain", "temp": 29.82, "min_temp": 28.3, "max_temp": 31.03, "feels_like": 36.82, "humidity": 86, "clouds": 100, "wind_speed": 0.45, "wind_direction": 16, "visibility": 10000, "uv": 0.45, "rain_chance": 0.39}
|
@ -1 +1 @@
|
|||||||
[{"main_weather": "Rain", "description": "heavy intensity rain", "min_temp": 24.83, "max_temp": 27.8}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 25.07, "max_temp": 26.83}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 26.55, "max_temp": 29}, {"main_weather": "Rain", "description": "light rain", "min_temp": 27.75, "max_temp": 29.78}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 27.93, "max_temp": 29.4}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 26.61, "max_temp": 28.14}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 27.57, "max_temp": 28.14}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 26.69, "max_temp": 28.13}]
|
[{"main_weather": "Rain", "description": "heavy intensity rain", "min_temp": 28.09, "max_temp": 29.87}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 28.22, "max_temp": 28.97}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 28.19, "max_temp": 29.57}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 28.21, "max_temp": 29.37}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 28.28, "max_temp": 29.31}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 28.27, "max_temp": 29.43}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 28.03, "max_temp": 29.7}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 27.9, "max_temp": 29.98}]
|
@ -1 +1 @@
|
|||||||
22/06/2021 15:05:29
|
27/06/2021 06:04:41
|
||||||
|
|
1
csv/last_updates.json
Normal file
1
csv/last_updates.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"stocks": "27/06/2021 07:05:39", "crypto": "27/06/2021 07:05:39", "news": "27/06/2021 07:05:39", "weather": "27/06/2021 07:05:39", "forex": "27/06/2021 07:05:39"}
|
1
csv/league.txt
Normal file
1
csv/league.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
NHL
|
40
csv/news.csv
40
csv/news.csv
@ -1,21 +1,21 @@
|
|||||||
headline,source,date,time
|
headline,source,date,time
|
||||||
‘I am not a vector’: Oireachtas committee hears from children affected by the pandemic - TheJournal.ie,TheJournal.ie,2021-06-22,18:30:00Z
|
China's Zhurong rover returns landing footage and sounds from Mars - SpaceNews,SpaceNews,2021-06-27,08:42:29Z
|
||||||
Liability conceded in case of couple ‘wrongly advised’ to terminate pregnancy - The Irish Times,The Irish Times,2021-06-22,18:15:58Z
|
Jammu Airport Blasts LIVE Updates: NIA Likely to Probe Case^ Flight Ops Normal; IAF Stations in Punjab & Srinagar on High Alert - News18,News18,2021-06-27,08:41:51Z
|
||||||
Delta COVID-19 variant greatest threat to US pandemic response - Fauci - GMA News Online,GMA News,2021-06-22,18:10:22Z
|
Lacson bares what he expects to hear from Duterte's final SONA - GMA News Online,GMA News,2021-06-27,08:37:03Z
|
||||||
LIVE WTC Final IND vs NZ Live Cricket Score^ Today Match DAY 5 Updates: Kohli-Pujara in; India Lead New Zeala - India.com,India.com,2021-06-22,18:08:55Z
|
A-League grand final LIVE updates: Red-hot City lead 2-1 over 10-man Sydney FC - The Sydney Morning Herald,The Sydney Morning Herald,2021-06-27,08:30:20Z
|
||||||
Prime Day headphone deals you shouldn't miss on AirPods^ Bose^ Beats^ Sony^ Samsung and more - CNET,CNET,2021-06-22,18:03:00Z
|
Why most people who now die with Covid in England have been vaccinated - The Guardian,The Guardian,2021-06-27,08:22:00Z
|
||||||
Jack Grealish^ Bukayo Saka and Harry Maguire start for England against Czech Republic - Sky Sports,Sky Sports,2021-06-22,18:01:14Z
|
Some families frustrated by pace of search and rescue efforts in Florida building collapse - CNN ,CNN,2021-06-27,08:11:00Z
|
||||||
Mother's gestational diabetes is an independent risk factor for fetal hypoxia during labor - News-Medical.Net,News-Medical.Net,2021-06-22,18:01:00Z
|
PH’s COVID-19 cases nears 1.4 million-mark with 6^096 new infections - INQUIRER.net,Inquirer.net,2021-06-27,08:04:00Z
|
||||||
Amazon sees Prime Day sales boost amid supply chain snags - CNA,CNA,2021-06-22,18:00:37Z
|
How to use Alexa Whisper Mode on an Amazon Echo - TechRadar,TechRadar,2021-06-27,08:00:00Z
|
||||||
Twitter opens applications for Ticketed Spaces and Super Follows test - The Verge,The Verge,2021-06-22,18:00:00Z
|
Low vitamin D can raise death risk from Covid by 20% - ETHealthworld.com,The Times of India,2021-06-27,07:58:20Z
|
||||||
Mastercard Foundation Appoints Robin Washington to Board of Directors - Guardian,Guardian Nigeria,2021-06-22,18:00:00Z
|
M5.0 quake strikes near Surigao del Sur - SunStar Philippines,Sunstar.com.ph,2021-06-27,07:56:05Z
|
||||||
Trudeau says border restrictions will be further relaxed 'in the coming weeks' if all goes well - CBC.ca,CBC News,2021-06-22,17:58:29Z
|
Statesmen think of the next generation^ not the next election - Rafidah blasts MCO inconsistency - Malaysiakini,Malaysiakini,2021-06-27,07:54:50Z
|
||||||
Euro 2020 LIVE: Grealish and Maguire start for England^ Mount and Chilwell out of Czech Republic clash^... - talkSPORT.com,TalkSport,2021-06-22,17:47:23Z
|
Long Covid: 'I've blood clots^ a braced leg and damaged heart... but I'm home' - The Samford Crimson,Samfordcrimson.com,2021-06-27,07:54:34Z
|
||||||
Quarter of a million children in England missed school last week due to Covid - The Guardian,The Guardian,2021-06-22,17:46:00Z
|
Guns of the west: Hot Dogs dominate Eagles in Perth - AFL,Afl.com.au,2021-06-27,07:53:00Z
|
||||||
'I am appalled': Billie Eilish apologizes for mouthing racial slur in resurfaced video - CBC.ca,CBC News,2021-06-22,17:45:46Z
|
China releases videos of rover on Mars - Yahoo News,Yahoo Entertainment,2021-06-27,07:53:00Z
|
||||||
U.S. to narrowly miss Biden’s July 4 vaccination goal^ White House says - The Washington Post,The Washington Post,2021-06-22,17:45:00Z
|
Five dead^ 156 still missing in Florida building collapse as searchers race against time - News24,News24,2021-06-27,07:44:27Z
|
||||||
Vin Diesel explains feud with Dwayne Johnson: 'A lot of tough love' - Fox News,Fox News,2021-06-22,17:41:14Z
|
Singapore detects 14 new COVID-19 cases; 12 in community - Yahoo Singapore News,Yahoo Entertainment,2021-06-27,07:44:23Z
|
||||||
Today’s coronavirus news: Two-thirds of Canadians say governments shouldn’t lift all restrictions; Construction complete on new vaccine-manufacturing plant in Montreal; Ontario reporting 296 cases - Toronto Star,Toronto Star,2021-06-22,17:37:30Z
|
Indonesia commends JTF Tawi-Tawi for rescue of 4 kidnap victims - GMA News Online,GMA News,2021-06-27,07:41:53Z
|
||||||
‘Tembisa 10’: Piet Rampedi pens apology to Independent Media staff for baby saga - News24,News24,2021-06-22,17:33:26Z
|
Don't copy Bollywood: Imran Khan's advice to Pakistani filmmakers - Hindustan Times,Hindustan Times,2021-06-27,07:41:00Z
|
||||||
Stinging secret: research reveals how venom from Australian caterpillars could be used in medicines - The Guardian,The Guardian,2021-06-22,17:31:00Z
|
Rugby league: New Zealand Warriors to lose Euan Aitken and Josh Curran for two weeks after Covid-19 scare - New Zealand Herald,New Zealand Herald,2021-06-27,07:39:23Z
|
||||||
Doc Rivers not giving up on Ben Simmons^ says 76ers have a plan in place to improve his shooting struggles - CBS Sports,CBS Sports,2021-06-22,17:28:00Z
|
Watch the incredible moment Massey High School player sinks wild three-point buzzer-beater - Stuff.co.nz,Stuff.co.nz,2021-06-27,07:39:00Z
|
||||||
|
|
@ -1 +1 @@
|
|||||||
[{"date": "2021-06-23", "time": "01:00:00", "round": "0", "home_team": "Phoenix Suns", "home_score": null, "away_team": "Los Angeles Clippers", "away_score": null}, {"date": "2021-06-24", "time": "00:30:00", "round": "0", "home_team": "Milwaukee Bucks", "home_score": null, "away_team": "Atlanta Hawks", "away_score": null}, {"date": "2021-06-25", "time": "01:00:00", "round": "0", "home_team": "Los Angeles Clippers", "home_score": null, "away_team": "Phoenix Suns", "away_score": null}, {"date": "2021-06-26", "time": "00:30:00", "round": "0", "home_team": "Milwaukee Bucks", "home_score": null, "away_team": "Atlanta Hawks", "away_score": null}, {"date": "2021-06-27", "time": "01:00:00", "round": "0", "home_team": "Los Angeles Clippers", "home_score": null, "away_team": "Phoenix Suns", "away_score": null}, {"date": "2021-06-28", "time": "00:30:00", "round": "0", "home_team": "Atlanta Hawks", "home_score": null, "away_team": "Milwaukee Bucks", "away_score": null}, {"date": "2021-06-30", "time": "00:30:00", "round": "0", "home_team": "Atlanta Hawks", "home_score": null, "away_team": "Milwaukee Bucks", "away_score": null}]
|
[{"date": "2021-06-27", "time": "01:00:00", "round": "0", "home_team": "Los Angeles Clippers", "home_score": "80", "away_team": "Phoenix Suns", "away_score": "84"}, {"date": "2021-06-28", "time": "00:30:00", "round": "0", "home_team": "Atlanta Hawks", "home_score": null, "away_team": "Milwaukee Bucks", "away_score": null}, {"date": "2021-06-29", "time": "01:00:00", "round": "0", "home_team": "Phoenix Suns", "home_score": null, "away_team": "Los Angeles Clippers", "away_score": null}, {"date": "2021-06-30", "time": "00:30:00", "round": "0", "home_team": "Atlanta Hawks", "home_score": null, "away_team": "Milwaukee Bucks", "away_score": null}]
|
@ -1 +1 @@
|
|||||||
[]
|
[{"date": "2021-06-27", "time": "01:00", "progess": "", "status": "FT", "home_team": "Los Angeles Clippers", "home_score": "80", "away_team": "Phoenix Suns", "away_score": "84"}]
|
@ -1 +1 @@
|
|||||||
[{"date": "2021-06-21", "time": "00:00:00", "round": "0", "home_team": "Philadelphia 76ers", "home_score": "96", "away_team": "Atlanta Hawks", "away_score": "103"}, {"date": "2021-06-20", "time": "19:30:00", "round": "0", "home_team": "Phoenix Suns", "home_score": "120", "away_team": "Los Angeles Clippers", "away_score": "114"}, {"date": "2021-06-20", "time": "00:30:00", "round": "0", "home_team": "Brooklyn Nets", "home_score": "111", "away_team": "Milwaukee Bucks", "away_score": "115"}, {"date": "2021-06-19", "time": "02:00:00", "round": "0", "home_team": "Los Angeles Clippers", "home_score": "131", "away_team": "Utah Jazz", "away_score": "119"}, {"date": "2021-06-18", "time": "23:30:00", "round": "0", "home_team": "Atlanta Hawks", "home_score": "99", "away_team": "Philadelphia 76ers", "away_score": "104"}, {"date": "2021-06-18", "time": "00:30:00", "round": "0", "home_team": "Milwaukee Bucks", "home_score": "104", "away_team": "Brooklyn Nets", "away_score": "89"}, {"date": "2021-06-17", "time": "02:00:00", "round": "0", "home_team": "Utah Jazz", "home_score": "111", "away_team": "Los Angeles Clippers", "away_score": "119"}, {"date": "2021-06-16", "time": "00:30:00", "round": "0", "home_team": "Brooklyn Nets", "home_score": "114", "away_team": "Milwaukee Bucks", "away_score": "108"}, {"date": "2021-06-16", "time": "23:30:00", "round": "0", "home_team": "Philadelphia 76ers", "home_score": "106", "away_team": "Atlanta Hawks", "away_score": "109"}, {"date": "2021-06-15", "time": "02:00:00", "round": "0", "home_team": "Los Angeles Clippers", "home_score": "118", "away_team": "Utah Jazz", "away_score": "104"}, {"date": "2021-06-14", "time": "23:30:00", "round": "0", "home_team": "Atlanta Hawks", "home_score": "103", "away_team": "Philadelphia 76ers", "away_score": "100"}, {"date": "2021-06-14", "time": "00:00:00", "round": "0", "home_team": "Denver Nuggets", "home_score": "118", "away_team": "Phoenix Suns", "away_score": "125"}, {"date": "2021-06-13", "time": "00:30:00", "round": "0", "home_team": "Los Angeles Clippers", "home_score": "132", "away_team": "Utah Jazz", "away_score": "106"}, {"date": "2021-06-13", "time": "19:00:00", "round": "0", "home_team": "Milwaukee Bucks", "home_score": "107", "away_team": "Brooklyn Nets", "away_score": "96"}, {"date": "2021-06-12", "time": "02:00:00", "round": "0", "home_team": "Denver Nuggets", "home_score": "102", "away_team": "Phoenix Suns", "away_score": "116"}]
|
[{"date": "2021-06-26", "time": "00:30:00", "round": "0", "home_team": "Milwaukee Bucks", "home_score": "125", "away_team": "Atlanta Hawks", "away_score": "91"}, {"date": "2021-06-25", "time": "01:00:00", "round": "0", "home_team": "Los Angeles Clippers", "home_score": "106", "away_team": "Phoenix Suns", "away_score": "92"}, {"date": "2021-06-24", "time": "00:30:00", "round": "0", "home_team": "Milwaukee Bucks", "home_score": "113", "away_team": "Atlanta Hawks", "away_score": "116"}, {"date": "2021-06-23", "time": "01:00:00", "round": "0", "home_team": "Phoenix Suns", "home_score": "104", "away_team": "Los Angeles Clippers", "away_score": "103"}, {"date": "2021-06-21", "time": "00:00:00", "round": "0", "home_team": "Philadelphia 76ers", "home_score": "96", "away_team": "Atlanta Hawks", "away_score": "103"}, {"date": "2021-06-20", "time": "19:30:00", "round": "0", "home_team": "Phoenix Suns", "home_score": "120", "away_team": "Los Angeles Clippers", "away_score": "114"}, {"date": "2021-06-20", "time": "00:30:00", "round": "0", "home_team": "Brooklyn Nets", "home_score": "111", "away_team": "Milwaukee Bucks", "away_score": "115"}, {"date": "2021-06-19", "time": "02:00:00", "round": "0", "home_team": "Los Angeles Clippers", "home_score": "131", "away_team": "Utah Jazz", "away_score": "119"}, {"date": "2021-06-18", "time": "23:30:00", "round": "0", "home_team": "Atlanta Hawks", "home_score": "99", "away_team": "Philadelphia 76ers", "away_score": "104"}, {"date": "2021-06-18", "time": "00:30:00", "round": "0", "home_team": "Milwaukee Bucks", "home_score": "104", "away_team": "Brooklyn Nets", "away_score": "89"}, {"date": "2021-06-17", "time": "02:00:00", "round": "0", "home_team": "Utah Jazz", "home_score": "111", "away_team": "Los Angeles Clippers", "away_score": "119"}, {"date": "2021-06-16", "time": "00:30:00", "round": "0", "home_team": "Brooklyn Nets", "home_score": "114", "away_team": "Milwaukee Bucks", "away_score": "108"}, {"date": "2021-06-16", "time": "23:30:00", "round": "0", "home_team": "Philadelphia 76ers", "home_score": "106", "away_team": "Atlanta Hawks", "away_score": "109"}, {"date": "2021-06-15", "time": "02:00:00", "round": "0", "home_team": "Los Angeles Clippers", "home_score": "118", "away_team": "Utah Jazz", "away_score": "104"}, {"date": "2021-06-14", "time": "23:30:00", "round": "0", "home_team": "Atlanta Hawks", "home_score": "103", "away_team": "Philadelphia 76ers", "away_score": "100"}]
|
@ -1 +1 @@
|
|||||||
[{"date": "2021-06-22", "time": "00:00:00", "round": "0", "home_team": "Tampa Bay Lightning", "home_score": "8", "away_team": "New York Islanders", "away_score": "0"}, {"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}, {"date": "2021-06-24", "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-25", "time": "00:00:00", "round": "0", "home_team": "Montreal Canadiens", "home_score": null, "away_team": "Vegas Golden Knights", "away_score": null}]
|
[]
|
@ -1 +1 @@
|
|||||||
[{"date": "2021-06-22", "time": "00:00", "progess": "", "status": "FT", "home_team": "Tampa Bay Lightning", "home_score": "8", "away_team": "New York Islanders", "away_score": "0"}]
|
[]
|
@ -1 +1 @@
|
|||||||
[{"date": "2021-06-21", "time": "00:00:00", "round": "0", "home_team": "Montreal Canadiens", "home_score": "1", "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": "3", "away_team": "Tampa Bay Lightning", "away_score": "2"}, {"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-18", "time": "00:00:00", "round": "0", "home_team": "New York Islanders", "home_score": "1", "away_team": "Tampa Bay Lightning", "away_score": "2"}, {"date": "2021-06-17", "time": "01:00:00", "round": "0", "home_team": "Vegas Golden Knights", "home_score": "2", "away_team": "Montreal Canadiens", "away_score": "3"}, {"date": "2021-06-16", "time": "00:00:00", "round": "0", "home_team": "Tampa Bay Lightning", "home_score": "4", "away_team": "New York Islanders", "away_score": "2"}, {"date": "2021-06-15", "time": "01:00:00", "round": "0", "home_team": "Vegas Golden Knights", "home_score": "4", "away_team": "Montreal Canadiens", "away_score": "1"}, {"date": "2021-06-13", "time": "19:00:00", "round": "0", "home_team": "Tampa Bay Lightning", "home_score": "1", "away_team": "New York Islanders", "away_score": "2"}, {"date": "2021-06-11", "time": "01:00:00", "round": "0", "home_team": "Vegas Golden Knights", "home_score": "6", "away_team": "Colorado Avalanche", "away_score": "3"}, {"date": "2021-06-09", "time": "23:30:00", "round": "0", "home_team": "New York Islanders", "home_score": "6", "away_team": "Boston Bruins", "away_score": "2"}, {"date": "2021-06-09", "time": "01:00:00", "round": "0", "home_team": "Colorado Avalanche", "home_score": "2", "away_team": "Vegas Golden Knights", "away_score": "3"}, {"date": "2021-06-08", "time": "22:30:00", "round": "0", "home_team": "Carolina Hurricanes", "home_score": "0", "away_team": "Tampa Bay Lightning", "away_score": "2"}, {"date": "2021-06-08", "time": "00:00:00", "round": "0", "home_team": "Montreal Canadiens", "home_score": "3", "away_team": "Winnipeg Jets", "away_score": "2"}, {"date": "2021-06-07", "time": "22:30:00", "round": "0", "home_team": "Boston Bruins", "home_score": "4", "away_team": "New York Islanders", "away_score": "5"}, {"date": "2021-06-07", "time": "00:30:00", "round": "0", "home_team": "Vegas Golden Knights", "home_score": "5", "away_team": "Colorado Avalanche", "away_score": "1"}]
|
[{"date": "2021-06-26", "time": "00:00:00", "round": "0", "home_team": "Tampa Bay Lightning", "home_score": "1", "away_team": "New York Islanders", "away_score": "0"}, {"date": "2021-06-25", "time": "00:00:00", "round": "0", "home_team": "Montreal Canadiens", "home_score": "3", "away_team": "Vegas Golden Knights", "away_score": "2"}, {"date": "2021-06-24", "time": "00:00:00", "round": "0", "home_team": "New York Islanders", "home_score": "3", "away_team": "Tampa Bay Lightning", "away_score": "2"}, {"date": "2021-06-23", "time": "01:00:00", "round": "0", "home_team": "Vegas Golden Knights", "home_score": "1", "away_team": "Montreal Canadiens", "away_score": "4"}, {"date": "2021-06-22", "time": "00:00:00", "round": "0", "home_team": "Tampa Bay Lightning", "home_score": "8", "away_team": "New York Islanders", "away_score": "0"}, {"date": "2021-06-21", "time": "00:00:00", "round": "0", "home_team": "Montreal Canadiens", "home_score": "1", "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": "3", "away_team": "Tampa Bay Lightning", "away_score": "2"}, {"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-18", "time": "00:00:00", "round": "0", "home_team": "New York Islanders", "home_score": "1", "away_team": "Tampa Bay Lightning", "away_score": "2"}, {"date": "2021-06-17", "time": "01:00:00", "round": "0", "home_team": "Vegas Golden Knights", "home_score": "2", "away_team": "Montreal Canadiens", "away_score": "3"}, {"date": "2021-06-16", "time": "00:00:00", "round": "0", "home_team": "Tampa Bay Lightning", "home_score": "4", "away_team": "New York Islanders", "away_score": "2"}, {"date": "2021-06-15", "time": "01:00:00", "round": "0", "home_team": "Vegas Golden Knights", "home_score": "4", "away_team": "Montreal Canadiens", "away_score": "1"}, {"date": "2021-06-13", "time": "19:00:00", "round": "0", "home_team": "Tampa Bay Lightning", "home_score": "1", "away_team": "New York Islanders", "away_score": "2"}, {"date": "2021-06-11", "time": "01:00:00", "round": "0", "home_team": "Vegas Golden Knights", "home_score": "6", "away_team": "Colorado Avalanche", "away_score": "3"}, {"date": "2021-06-09", "time": "23:30:00", "round": "0", "home_team": "New York Islanders", "home_score": "6", "away_team": "Boston Bruins", "away_score": "2"}]
|
1
csv/table_league.txt
Normal file
1
csv/table_league.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
premier_league
|
@ -1,4 +1,4 @@
|
|||||||
name,current,opening
|
name,current,opening
|
||||||
MSFT,265.24,262.72
|
MSFT,265.02,266.23
|
||||||
NFLX,511.198,498.54
|
NFLX,527.07,528.84
|
||||||
GOOG,2536.73,2529
|
GOOG,2539.9,2539.14
|
||||||
|
|
Binary file not shown.
BIN
display_images/daily_weather.ppm
Normal file
BIN
display_images/daily_weather.ppm
Normal file
Binary file not shown.
Binary file not shown.
BIN
display_images/league_games.ppm
Normal file
BIN
display_images/league_games.ppm
Normal file
Binary file not shown.
BIN
display_images/league_table.ppm
Normal file
BIN
display_images/league_table.ppm
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
display_images/today_weather.ppm
Normal file
BIN
display_images/today_weather.ppm
Normal file
Binary file not shown.
2
setup.sh
2
setup.sh
@ -7,7 +7,7 @@ pip3 install pexpect
|
|||||||
sudo apt-get install libopenjp2-7
|
sudo apt-get install libopenjp2-7
|
||||||
sudo apt-get install libtiff5
|
sudo apt-get install libtiff5
|
||||||
|
|
||||||
chmod ugo+rwx display_images/*
|
chmod -R ugo+rwx display_images
|
||||||
cd rpi-rgb-led-matrix
|
cd rpi-rgb-led-matrix
|
||||||
sudo apt-get update && sudo apt-get install python3-dev python3-pillow -y
|
sudo apt-get update && sudo apt-get install python3-dev python3-pillow -y
|
||||||
make build-python PYTHON=$(which python3)
|
make build-python PYTHON=$(which python3)
|
||||||
|
204
stockTicker.py
204
stockTicker.py
@ -219,14 +219,15 @@ class StockTicker():
|
|||||||
|
|
||||||
def scrollFunctionsAnimated(self, options, animation = 'continuous'):
|
def scrollFunctionsAnimated(self, options, animation = 'continuous'):
|
||||||
# scrolls trhough all functions with animation. Updates functions and remakes images when each function not being dispplayed
|
# scrolls trhough all functions with animation. Updates functions and remakes images when each function not being dispplayed
|
||||||
self.updateMultiple(options)
|
|
||||||
|
self.updateMultiple([options[0]])
|
||||||
|
|
||||||
print('done update')
|
print('done update')
|
||||||
kill = False
|
kill = False
|
||||||
i = 0 # keep track of which image we are displaying
|
i = 0 # keep track of which image we are displaying
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
update_process = Process(target = self.updateMultiple, args = (options,))
|
update_process = Process(target = self.updateMultiple, args = ([options[(i+1) % len(options)]],))
|
||||||
update_process.start()
|
update_process.start()
|
||||||
print('display_images/' + options[i % len(options)] +'.ppm')
|
print('display_images/' + options[i % len(options)] +'.ppm')
|
||||||
|
|
||||||
@ -244,26 +245,31 @@ class StockTicker():
|
|||||||
#first scroll image in from bottom
|
#first scroll image in from bottom
|
||||||
|
|
||||||
if animation == 'up':
|
if animation == 'up':
|
||||||
offset_y = 32
|
offset_y = 33
|
||||||
while offset_y > 0:
|
while offset_y > 0:
|
||||||
|
|
||||||
self.setImage(image, offset_x = offset_x, offset_y = offset_y)
|
|
||||||
offset_y -= 1
|
offset_y -= 1
|
||||||
|
self.setImage(image, offset_x = offset_x, offset_y = offset_y)
|
||||||
|
|
||||||
time.sleep(self.delay)
|
time.sleep(self.delay)
|
||||||
kill = self.checkKilled()
|
kill = self.checkKilled()
|
||||||
if kill: break
|
if kill: break
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
elif animation == 'down':
|
elif animation == 'down':
|
||||||
offset_y = -32
|
offset_y = -33
|
||||||
while offset_y < 0:
|
while offset_y < 0:
|
||||||
|
|
||||||
self.setImage(image, offset_x = offset_x, offset_y = offset_y)
|
|
||||||
offset_y += 1
|
offset_y += 1
|
||||||
|
self.setImage(image, offset_x = offset_x, offset_y = offset_y)
|
||||||
|
|
||||||
time.sleep(self.delay)
|
time.sleep(self.delay)
|
||||||
kill = self.checkKilled()
|
kill = self.checkKilled()
|
||||||
if kill: break
|
if kill: break
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -302,7 +308,7 @@ class StockTicker():
|
|||||||
i+=1
|
i+=1
|
||||||
|
|
||||||
|
|
||||||
def textImage(self, text, font, r = 255, g = 255, b = 255, matrix_height = False, buff = 0):
|
def textImage(self, text, font, r = 255, g = 255, b = 255, matrix_height = False, w_buff = 3, h_buff = 3):
|
||||||
'''
|
'''
|
||||||
creates and returns a ppm image containing the text in the supplied font and colour
|
creates and returns a ppm image containing the text in the supplied font and colour
|
||||||
'''
|
'''
|
||||||
@ -311,7 +317,7 @@ class StockTicker():
|
|||||||
|
|
||||||
if matrix_height:
|
if matrix_height:
|
||||||
height = 32
|
height = 32
|
||||||
img = Image.new('RGB', (width + buff + 3, height+3))
|
img = Image.new('RGB', (width + w_buff, height + h_buff))
|
||||||
d = ImageDraw.Draw(img)
|
d = ImageDraw.Draw(img)
|
||||||
|
|
||||||
d.text((0, 0), text, fill=(r, g, b), font=font)
|
d.text((0, 0), text, fill=(r, g, b), font=font)
|
||||||
@ -336,64 +342,6 @@ class StockTicker():
|
|||||||
img = self.textImage(text, font, int(r), int(g), int(b), True, buff = 50)
|
img = self.textImage(text, font, int(r), int(g), int(b), True, buff = 50)
|
||||||
return img
|
return img
|
||||||
|
|
||||||
|
|
||||||
def getNewsImage(self):
|
|
||||||
headline_font = ImageFont.load("./fonts/10x20.pil")
|
|
||||||
source_font = ImageFont.load("./fonts/10x20.pil")
|
|
||||||
|
|
||||||
image_list = []
|
|
||||||
|
|
||||||
headlines = []
|
|
||||||
source_date_times = []
|
|
||||||
|
|
||||||
f = open('csv/news.csv', 'r')
|
|
||||||
CSV = csv.reader(f)
|
|
||||||
next(CSV)
|
|
||||||
for row in CSV:
|
|
||||||
headline, source, date, time = row
|
|
||||||
headlines.append(headline)
|
|
||||||
source_date_times.append(source + ': ' + date + ' ' + time)
|
|
||||||
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for i, headline in enumerate(headlines):
|
|
||||||
headline = headline.replace("^", ",")
|
|
||||||
headline = headline.replace("’", "'")
|
|
||||||
headline = headline.replace("‘", "'")
|
|
||||||
headline = headline.replace('“', '"')
|
|
||||||
headline = headline.replace('”', '"')
|
|
||||||
|
|
||||||
headline_img = self.textImage(headline, headline_font, matrix_height = True)
|
|
||||||
source_img = self.textImage(source_date_times[i], source_font, r=255, g=255, b=0, matrix_height = True)
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
|
||||||
logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'news_logos')
|
|
||||||
|
|
||||||
logo = Image.open(os.path.join(logos_path, 'techcrunch' + '.png'))
|
|
||||||
|
|
||||||
img = Image.new('RGB', (headline_img.size[0], 32))
|
|
||||||
img.paste(headline_img, (2, -3))
|
|
||||||
img.paste(source_img, (2,16))
|
|
||||||
|
|
||||||
img= self.stitchImage([logo,img])
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
print(e)
|
|
||||||
img = Image.new('RGB', (headline_img.size[0], 32))
|
|
||||||
img.paste(headline_img, (0,0))
|
|
||||||
img.paste(source_img, (0,16))
|
|
||||||
|
|
||||||
image_list.append(img)
|
|
||||||
|
|
||||||
news_image = self.stitchImage(image_list)
|
|
||||||
|
|
||||||
return news_image
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def displayGIF(self, gif):
|
def displayGIF(self, gif):
|
||||||
# To iterate through the entire gif
|
# To iterate through the entire gif
|
||||||
i = 0
|
i = 0
|
||||||
@ -696,11 +644,78 @@ class StockTicker():
|
|||||||
return finalDisplayImage
|
return finalDisplayImage
|
||||||
|
|
||||||
|
|
||||||
def getLeagueImage(self, league, time):
|
def getNewsImage(self):
|
||||||
|
font = ImageFont.load("./fonts/texgyre-27.pil")
|
||||||
|
title_img = self.textImage('NEWS', font, matrix_height = True)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
headline_font = ImageFont.load("./fonts/10x20.pil")
|
||||||
|
source_font = ImageFont.load("./fonts/10x20.pil")
|
||||||
|
|
||||||
|
image_list = [title_img]
|
||||||
|
|
||||||
|
headlines = []
|
||||||
|
source_date_times = []
|
||||||
|
|
||||||
|
f = open('csv/news.csv', 'r')
|
||||||
|
CSV = csv.reader(f)
|
||||||
|
next(CSV)
|
||||||
|
for row in CSV:
|
||||||
|
headline, source, date, time = row
|
||||||
|
headlines.append(headline)
|
||||||
|
source_date_times.append(source + ': ' + date + ' ' + time)
|
||||||
|
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for i, headline in enumerate(headlines):
|
||||||
|
headline = headline.replace("^", ",")
|
||||||
|
headline = headline.replace("’", "'")
|
||||||
|
headline = headline.replace("‘", "'")
|
||||||
|
headline = headline.replace('“', '"')
|
||||||
|
headline = headline.replace('”', '"')
|
||||||
|
|
||||||
|
headline_img = self.textImage(headline, headline_font, matrix_height = True)
|
||||||
|
source_img = self.textImage(source_date_times[i], source_font, r=255, g=255, b=0, matrix_height = True)
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'news_logos')
|
||||||
|
|
||||||
|
logo = Image.open(os.path.join(logos_path, 'techcrunch' + '.png'))
|
||||||
|
|
||||||
|
img = Image.new('RGB', (headline_img.size[0], 32))
|
||||||
|
img.paste(headline_img, (2, -3))
|
||||||
|
img.paste(source_img, (2,16))
|
||||||
|
|
||||||
|
img= self.stitchImage([logo,img])
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
img = Image.new('RGB', (headline_img.size[0], 32))
|
||||||
|
img.paste(headline_img, (0,0))
|
||||||
|
img.paste(source_img, (0,16))
|
||||||
|
|
||||||
|
image_list.append(img)
|
||||||
|
|
||||||
|
news_image = self.stitchImage(image_list)
|
||||||
|
|
||||||
|
return news_image
|
||||||
|
|
||||||
|
def getLeagueImage(self, league=False, time = 'past'):
|
||||||
|
|
||||||
|
if not league:
|
||||||
|
f = open( "csv/league.txt", 'r' )
|
||||||
|
league = f.read().replace('\n', '')
|
||||||
|
f.close()
|
||||||
|
|
||||||
img = Image.new('RGB', (10000, 32))
|
img = Image.new('RGB', (10000, 32))
|
||||||
league_info = json.load(open('csv/sports/{}/{}_games.json'.format(league, time), 'r'))
|
league_info = json.load(open('csv/sports/{}/{}_games.json'.format(league, time), 'r'))
|
||||||
|
|
||||||
print(league_info[0].keys())
|
print(league_info[0].keys())
|
||||||
|
|
||||||
small_font = ImageFont.load("./fonts/5x7.pil")
|
small_font = ImageFont.load("./fonts/5x7.pil")
|
||||||
med_font = ImageFont.load("./fonts/7x14B.pil")
|
med_font = ImageFont.load("./fonts/7x14B.pil")
|
||||||
large_font = ImageFont.load("./fonts/9x18B.pil")
|
large_font = ImageFont.load("./fonts/9x18B.pil")
|
||||||
@ -743,16 +758,7 @@ class StockTicker():
|
|||||||
away_logo = self.textImage(away_team.replace(' ', '\n'), small_font, r = 255, g = 255, b = 255)
|
away_logo = self.textImage(away_team.replace(' ', '\n'), small_font, r = 255, g = 255, b = 255)
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#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 = 255)
|
date_timage = self.textImage(date, small_font, r = 255, g = 255, b = 255)
|
||||||
#round_timage = self.textImage('round:' + rond, small_font, r = 255, g = 255, b = 255)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
img.paste(home_logo, (x_offset,0))
|
img.paste(home_logo, (x_offset,0))
|
||||||
|
|
||||||
@ -761,9 +767,6 @@ class StockTicker():
|
|||||||
|
|
||||||
if time == 'future':
|
if time == 'future':
|
||||||
img.paste(date_timage, (x_offset+5, 0))
|
img.paste(date_timage, (x_offset+5, 0))
|
||||||
#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))
|
|
||||||
|
|
||||||
h_colour = mcolors.to_rgb(sports_info[home_team]['colour'].replace(' ', ''))
|
h_colour = mcolors.to_rgb(sports_info[home_team]['colour'].replace(' ', ''))
|
||||||
a_colour = mcolors.to_rgb(sports_info[away_team]['colour'].replace(' ', ''))
|
a_colour = mcolors.to_rgb(sports_info[away_team]['colour'].replace(' ', ''))
|
||||||
@ -779,9 +782,7 @@ class StockTicker():
|
|||||||
x_offset += max( date_timage.size[0], hc_timage.size[0] + vs_timage.size[0] + ac_timage.size[0])
|
x_offset += max( date_timage.size[0], hc_timage.size[0] + vs_timage.size[0] + ac_timage.size[0])
|
||||||
else:
|
else:
|
||||||
|
|
||||||
|
score_image = self.textImage(home_score + '-' + away_score, large_font, h_buff = 5, r = 255, g = 255, b = 255)
|
||||||
|
|
||||||
score_image = self.textImage(home_score + '-' + away_score, large_font, r = 255, g = 255, b = 255)
|
|
||||||
|
|
||||||
#vs_timage = self.textImage(sports_info[home_team]['code'] + 'vs' + sports_info[away_team]['code'], small_font, r = 255, g = 255, b = 255)
|
#vs_timage = self.textImage(sports_info[home_team]['code'] + 'vs' + sports_info[away_team]['code'], small_font, r = 255, g = 255, b = 255)
|
||||||
|
|
||||||
@ -832,10 +833,18 @@ class StockTicker():
|
|||||||
x_offset += buff_size
|
x_offset += buff_size
|
||||||
img = img.crop((0,0,x_offset ,32))
|
img = img.crop((0,0,x_offset ,32))
|
||||||
|
|
||||||
return img
|
font = ImageFont.load("./fonts/texgyre-27.pil")
|
||||||
|
title_img = self.textImage(time.upper() + ' GAMES', font, matrix_height = True)
|
||||||
|
|
||||||
def getTeamsImage(self, league):
|
return self.stitchImage([title_img, img])
|
||||||
|
|
||||||
|
def getLeagueTableImage(self, league = False):
|
||||||
|
|
||||||
|
|
||||||
|
if not league:
|
||||||
|
f = open( "csv/table_league.txt", 'r' )
|
||||||
|
league = f.read().replace('\n', '')
|
||||||
|
f.close()
|
||||||
img = Image.new('RGB', (10000, 32))
|
img = Image.new('RGB', (10000, 32))
|
||||||
team_info = json.load(open('csv/sports/{}/team_stats.json'.format(league), 'r'))
|
team_info = json.load(open('csv/sports/{}/team_stats.json'.format(league), 'r'))
|
||||||
|
|
||||||
@ -886,7 +895,10 @@ class StockTicker():
|
|||||||
|
|
||||||
img = img.crop((0,0,x_offset ,32))
|
img = img.crop((0,0,x_offset ,32))
|
||||||
|
|
||||||
return img
|
font = ImageFont.load("./fonts/texgyre-27.pil")
|
||||||
|
title_img = self.textImage('LEAGUE TABLE', font, matrix_height = True)
|
||||||
|
|
||||||
|
return self.stitchImage([title_img, img])
|
||||||
|
|
||||||
|
|
||||||
def getTodayWeatherImage(self):
|
def getTodayWeatherImage(self):
|
||||||
@ -993,7 +1005,10 @@ class StockTicker():
|
|||||||
vtext_img = self.textImage(str(current_weather['visibility']/1000) + 'km', small_font)
|
vtext_img = self.textImage(str(current_weather['visibility']/1000) + 'km', small_font)
|
||||||
img.paste(vtext_img, (168, 22))
|
img.paste(vtext_img, (168, 22))
|
||||||
|
|
||||||
return img
|
font = ImageFont.load("./fonts/texgyre-27.pil")
|
||||||
|
title_img = self.textImage('WEATHER', font, matrix_height = True)
|
||||||
|
|
||||||
|
return self.stitchImage([title_img, img])
|
||||||
|
|
||||||
def getDailyWeatherImageAlt(self):
|
def getDailyWeatherImageAlt(self):
|
||||||
|
|
||||||
@ -1313,9 +1328,11 @@ class StockTicker():
|
|||||||
|
|
||||||
img1 = img.crop((0,0,x_offset ,32))
|
img1 = img.crop((0,0,x_offset ,32))
|
||||||
|
|
||||||
|
# add the image text
|
||||||
|
font = ImageFont.load("./fonts/texgyre-27.pil")
|
||||||
|
title_img = self.textImage('WEATHER', font, matrix_height = True)
|
||||||
|
|
||||||
|
return self.stitchImage([title_img, img1])
|
||||||
return img1
|
|
||||||
|
|
||||||
|
|
||||||
#Retrieve symbols and stock info from the csv file
|
#Retrieve symbols and stock info from the csv file
|
||||||
@ -1503,8 +1520,8 @@ class StockTicker():
|
|||||||
|
|
||||||
stock_ticker.scrollImageTransition(['display_images/league.ppm', 'display_images/league.ppm'], stocks = False)
|
stock_ticker.scrollImageTransition(['display_images/league.ppm', 'display_images/league.ppm'], stocks = False)
|
||||||
|
|
||||||
elif msg == 't': #teams
|
elif msg == 't': #legue tble
|
||||||
img = self.getTeamsImage('premier_league')
|
img = self.getLeagueTableImage('premier_league')
|
||||||
img.save('display_images/teams.ppm')
|
img.save('display_images/teams.ppm')
|
||||||
|
|
||||||
stock_ticker.scrollImageTransition(['display_images/teams.ppm', 'display_images/teams.ppm'], stocks = False)
|
stock_ticker.scrollImageTransition(['display_images/teams.ppm', 'display_images/teams.ppm'], stocks = False)
|
||||||
@ -1512,9 +1529,10 @@ class StockTicker():
|
|||||||
elif msg == 'A': #everything
|
elif msg == 'A': #everything
|
||||||
|
|
||||||
self.functions = {'stocks': self.getStockImage, 'crypto': self.getCryptoImage, 'forex': self.getForexImage,
|
self.functions = {'stocks': self.getStockImage, 'crypto': self.getCryptoImage, 'forex': self.getForexImage,
|
||||||
'weather':self.getDailyWeatherImage} #put this somewhere else
|
'daily_weather':self.getDailyWeatherImage, 'today_weather': self.getDailyWeatherImage, 'league_table': self.getLeagueTableImage,
|
||||||
|
'league_games': self.getLeagueImage, 'news':self.getNewsImage} #put this somewhere else
|
||||||
|
|
||||||
userSettings = ['stocks', 'crypto', 'forex'] # these wil be read from csv, just for demo
|
userSettings = ['stocks', 'crypto', 'forex', 'today_weather', 'daily_weather', 'league_table', 'league_games', 'news'] # these wil be read from csv, just for demo
|
||||||
#userSettings = ['stocks', 'crypto'] # these wil be read from csv, just for demo
|
#userSettings = ['stocks', 'crypto'] # these wil be read from csv, just for demo
|
||||||
#userSettings = [ 'forex', 'weather'] # these wil be read from csv, just for demo
|
#userSettings = [ 'forex', 'weather'] # these wil be read from csv, just for demo
|
||||||
|
|
||||||
@ -1530,7 +1548,7 @@ if __name__ == '__main__':
|
|||||||
stock_ticker = StockTicker()
|
stock_ticker = StockTicker()
|
||||||
|
|
||||||
#stock_ticker.process_msg('P')
|
#stock_ticker.process_msg('P')
|
||||||
#stock_ticker.process_msg('A')
|
stock_ticker.process_msg('P')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user