@ -1 +1 @@
|
|||||||
{"stocks": {"time": "14/06/2022 06:42:06", "force": false}, "crypto": {"time": "14/06/2022 06:58:18", "force": false}, "news": {"time": "14/06/2022 05:29:08", "force": false}, "weather": {"time": "14/06/2022 05:29:08", "force": false}, "forex": {"time": "14/06/2022 05:29:14", "force": false}, "sports_l": {"time": "14/06/2022 04:42:37", "force": false}, "sports_p": {"time": "14/06/2022 06:27:34", "force": false}, "sports_u": {"time": "14/06/2022 06:28:34", "force": false}, "sports_t": {"time": "14/06/2022 06:26:23", "force": false}, "commodities": {"time": "14/06/2022 06:51:07", "force": false}, "indices": {"time": "05/10/2022 04:06:10", "force": false}}
|
{"stocks": {"time": "14/06/2022 06:42:06", "force": false}, "crypto": {"time": "14/06/2022 06:58:18", "force": false}, "news": {"time": "14/06/2022 05:29:08", "force": false}, "weather": {"time": "14/06/2022 05:29:08", "force": false}, "forex": {"time": "14/06/2022 05:29:14", "force": false}, "sports_l": {"time": "14/06/2022 04:42:37", "force": false}, "sports_p": {"time": "14/06/2022 06:27:34", "force": false}, "sports_u": {"time": "14/06/2022 06:28:34", "force": false}, "sports_t": {"time": "14/06/2022 06:26:23", "force": false}, "commodities": {"time": "14/06/2022 06:51:07", "force": false}, "indices": {"time": "05/10/2022 04:06:10", "force": false}, "movies": {"time": "05/10/2022 02:31:40", "force": false}}
|
||||||
|
1
csv/live_mlb.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"feature": "Sports (Live Games)", "speed": "medium", "speed2": "medium", "animation": "down", "title": true, "leagues": {"MLB": [[{"home_team": "Columbus Blue Jackets", "home_score": "4", "away_team": "Buffalo Sabres", "away_score": "9", "time": "Final", "date": "2022-12-08", "isLive": "post"}, {"home_team": "Philadelphia Flyers", "home_score": "1", "away_team": "Washington Capitals", "away_score": "4", "time": "Final", "date": "2022-12-08", "isLive": "post"}, {"home_team": "Calgary Flames", "home_score": "5", "away_team": "Minnesota Wild", "away_score": "3", "time": "Final", "date": "2022-12-08", "isLive": "post"}, {"home_team": "Colorado Avalanche", "home_score": "0", "away_team": "Boston Bruins", "away_score": "4", "time": "Final", "date": "2022-12-08", "isLive": "post"}, {"home_team": "Edmonton Oilers", "home_score": "8", "away_team": "Arizona Coyotes", "away_score": "2", "time": "Final", "date": "2022-12-08", "isLive": "post"}, {"home_team": "Vegas Golden Knights", "home_score": "1", "away_team": "New York Rangers", "away_score": "5", "time": "Final", "date": "2022-12-08", "isLive": "post"}, {"home_team": "San Jose Sharks", "home_score": "5", "away_team": "Vancouver Canucks", "away_score": "6", "time": "Final/OT", "date": "2022-12-08", "isLive": "post"}], false, "no_live", "no_upcoming"]}}
|
1
csv/live_mls.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"feature": "Sports (Live Games)", "speed": "medium", "speed2": "medium", "animation": "down", "title": true, "leagues": {"MLS": [[{"home_team": "Columbus Blue Jackets", "home_score": "4", "away_team": "Buffalo Sabres", "away_score": "9", "time": "Final", "date": "2022-12-08", "isLive": "post"}, {"home_team": "Philadelphia Flyers", "home_score": "1", "away_team": "Washington Capitals", "away_score": "4", "time": "Final", "date": "2022-12-08", "isLive": "post"}, {"home_team": "Calgary Flames", "home_score": "5", "away_team": "Minnesota Wild", "away_score": "3", "time": "Final", "date": "2022-12-08", "isLive": "post"}, {"home_team": "Colorado Avalanche", "home_score": "0", "away_team": "Boston Bruins", "away_score": "4", "time": "Final", "date": "2022-12-08", "isLive": "post"}, {"home_team": "Edmonton Oilers", "home_score": "8", "away_team": "Arizona Coyotes", "away_score": "2", "time": "Final", "date": "2022-12-08", "isLive": "post"}, {"home_team": "Vegas Golden Knights", "home_score": "1", "away_team": "New York Rangers", "away_score": "5", "time": "Final", "date": "2022-12-08", "isLive": "post"}, {"home_team": "San Jose Sharks", "home_score": "5", "away_team": "Vancouver Canucks", "away_score": "6", "time": "Final/OT", "date": "2022-12-08", "isLive": "post"}], false, "no_live", "no_upcoming"]}}
|
1
csv/live_nba.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"feature": "Sports (Live Games)", "speed": "medium", "speed2": "medium", "animation": "down", "title": true, "leagues": {"NBA": [[{"home_team": "Orlando Magic", "home_score": "116", "away_team": "LA Clippers", "away_score": "111", "time": "Final/OT", "date": "2022-12-08", "isLive": "post"}, {"home_team": "Brooklyn Nets", "home_score": "122", "away_team": "Charlotte Hornets", "away_score": "116", "time": "Final", "date": "2022-12-08", "isLive": "post"}, {"home_team": "New York Knicks", "home_score": "113", "away_team": "Atlanta Hawks", "away_score": "89", "time": "Final", "date": "2022-12-08", "isLive": "post"}, {"home_team": "Toronto Raptors", "home_score": "126", "away_team": "Los Angeles Lakers", "away_score": "113", "time": "Final", "date": "2022-12-08", "isLive": "post"}, {"home_team": "Chicago Bulls", "home_score": "115", "away_team": "Washington Wizards", "away_score": "111", "time": "Final", "date": "2022-12-08", "isLive": "post"}, {"home_team": "Memphis Grizzlies", "home_score": "123", "away_team": "Oklahoma City Thunder", "away_score": "102", "time": "Final", "date": "2022-12-08", "isLive": "post"}, {"home_team": "Milwaukee Bucks", "home_score": "126", "away_team": "Sacramento Kings", "away_score": "113", "time": "Final", "date": "2022-12-08", "isLive": "post"}, {"home_team": "Minnesota Timberwolves", "home_score": "121", "away_team": "Indiana Pacers", "away_score": "115", "time": "Final", "date": "2022-12-08", "isLive": "post"}, {"home_team": "New Orleans Pelicans", "home_score": "104", "away_team": "Detroit Pistons", "away_score": "98", "time": "Final", "date": "2022-12-08", "isLive": "post"}, {"home_team": "Utah Jazz", "home_score": "124", "away_team": "Golden State Warriors", "away_score": "123", "time": "Final", "date": "2022-12-08", "isLive": "post"}, {"home_team": "Phoenix Suns", "home_score": "98", "away_team": "Boston Celtics", "away_score": "125", "time": "Final", "date": "2022-12-08", "isLive": "post"}], false, "no_live", "no_upcoming"]}}
|
1
csv/live_nfl.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"feature": "Sports (Live Games)", "speed": "medium", "speed2": "medium", "animation": "down", "title": true, "leagues": {"NFL": [[{"home_team": "Charlotte Hornets", "home_score": "117", "away_team": "LA Clippers", "away_score": "119", "time": "Final", "date": "2022-12-06", "isLive": "post"}, {"home_team": "Orlando Magic", "home_score": "102", "away_team": "Milwaukee Bucks", "away_score": "109", "time": "Final", "date": "2022-12-06", "isLive": "post"}, {"home_team": "Atlanta Hawks", "home_score": "114", "away_team": "Oklahoma City Thunder", "away_score": "121", "time": "Final", "date": "2022-12-06", "isLive": "post"}, {"home_team": "Toronto Raptors", "home_score": "110", "away_team": "Boston Celtics", "away_score": "116", "time": "Final", "date": "2022-12-06", "isLive": "post"}, {"home_team": "Houston Rockets", "home_score": "132", "away_team": "Philadelphia 76ers", "away_score": "123", "time": "Final/2OT", "date": "2022-12-06", "isLive": "post"}, {"home_team": "Memphis Grizzlies", "home_score": "101", "away_team": "Miami Heat", "away_score": "93", "time": "Final", "date": "2022-12-06", "isLive": "post"}, {"home_team": "Dallas Mavericks", "home_score": "130", "away_team": "Phoenix Suns", "away_score": "111", "time": "Final", "date": "2022-12-06", "isLive": "post"}, {"home_team": "Golden State Warriors", "home_score": "104", "away_team": "Indiana Pacers", "away_score": "112", "time": "Final", "date": "2022-12-06", "isLive": "post"}], false, "no_live", "no_upcoming"]}}
|
1
csv/live_nhl.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"feature": "Sports (Live Games)", "speed": "medium", "speed2": "medium", "animation": "down", "title": true, "leagues": {"NHL": [[{"home_team": "Columbus Blue Jackets", "home_score": "4", "away_team": "Buffalo Sabres", "away_score": "9", "time": "Final", "date": "2022-12-08", "isLive": "post"}, {"home_team": "Philadelphia Flyers", "home_score": "1", "away_team": "Washington Capitals", "away_score": "4", "time": "Final", "date": "2022-12-08", "isLive": "post"}, {"home_team": "Calgary Flames", "home_score": "5", "away_team": "Minnesota Wild", "away_score": "3", "time": "Final", "date": "2022-12-08", "isLive": "post"}, {"home_team": "Colorado Avalanche", "home_score": "0", "away_team": "Boston Bruins", "away_score": "4", "time": "Final", "date": "2022-12-08", "isLive": "post"}, {"home_team": "Edmonton Oilers", "home_score": "8", "away_team": "Arizona Coyotes", "away_score": "2", "time": "Final", "date": "2022-12-08", "isLive": "post"}, {"home_team": "Vegas Golden Knights", "home_score": "1", "away_team": "New York Rangers", "away_score": "5", "time": "Final", "date": "2022-12-08", "isLive": "post"}, {"home_team": "San Jose Sharks", "home_score": "5", "away_team": "Vancouver Canucks", "away_score": "6", "time": "Final/OT", "date": "2022-12-08", "isLive": "post"}], false, "no_live", "no_upcoming"]}}
|
1
csv/live_pl.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"feature": "Sports (Live Games)", "speed": "medium", "speed2": "medium", "animation": "down", "title": true, "leagues": {"PREMIERLEAGUE": [[{"home_team": "Chelsea", "home_score": "0", "away_team": "Manchester City", "away_score": "1", "time": "FT", "date": "2023-01-05", "isLive": "post"}], false, "no_live", "no_upcoming"]}}
|
1
csv/movie_settings.json
Normal file
@ -1,24 +1,35 @@
|
|||||||
Full Team Name,Team ID,3 Letter ID,Team Color,Logo File name
|
Full Team Name,Team ID,3 Letter ID,Team Color,Logo File name
|
||||||
Atlanta United,135851,ATL,Gold,Atlanta.png
|
Atlanta United,135851,ATL,Gold,Atlanta.png
|
||||||
|
Atlanta United FC,135851,ATL,Gold,Atlanta.png
|
||||||
Austin FC,140079,AUS,Green,Austin.png
|
Austin FC,140079,AUS,Green,Austin.png
|
||||||
CF Montréal,134150,MTL,Gray,Montreal.png
|
CF Montréal,134150,MTL,Gray,Montreal.png
|
||||||
Charlotte FC,140078,CHA,Blue,Charlotte.png
|
Charlotte FC,140078,CHA,Blue,Charlotte.png
|
||||||
Chicago Fire,134154,CHI,Orange,Chicago.png
|
Chicago Fire,134154,CHI,Orange,Chicago.png
|
||||||
|
Chicago Fire FC,134154,CHI,Orange,Chicago.png
|
||||||
Colorado Rapids,134794,COL,Red,Colorado.png
|
Colorado Rapids,134794,COL,Red,Colorado.png
|
||||||
Columbus Crew,134152,CBS,Yellow,Columbus.png
|
Columbus Crew,134152,CBS,Yellow,Columbus.png
|
||||||
DC United,134145,DC,Red,DC.png
|
DC United,134145,DC,Red,DC.png
|
||||||
|
D.C. United,134145,DC,Red,DC.png
|
||||||
FC Cincinnati,136688,CIN,Orange,Cincinnati.png
|
FC Cincinnati,136688,CIN,Orange,Cincinnati.png
|
||||||
FC Dallas,134146,DAL,Blue,Dallas.png
|
FC Dallas,134146,DAL,Blue,Dallas.png
|
||||||
Houston Dynamo,134144,HOU,Orange,Houston.png
|
Houston Dynamo,134144,HOU,Orange,Houston.png
|
||||||
|
Houston Dynamo FC,134144,HOU,Orange,Houston.png
|
||||||
Inter Miami,137699,MIA,Pink,Miami.png
|
Inter Miami,137699,MIA,Pink,Miami.png
|
||||||
|
Inter Miami CF,137699,MIA,Pink,Miami.png
|
||||||
L.A. Galaxy,134153,LA,Yellow,LA-Galaxy.png
|
L.A. Galaxy,134153,LA,Yellow,LA-Galaxy.png
|
||||||
|
LA Galaxy,134153,LA,Yellow,LA-Galaxy.png
|
||||||
Los Angeles FC,136050,LA,Gold,LAFC.png
|
Los Angeles FC,136050,LA,Gold,LAFC.png
|
||||||
|
LAFC,136050,LA,Gold,LAFC.png
|
||||||
Minnesota United,135852,MIN,Light Blue,Minnesota.png
|
Minnesota United,135852,MIN,Light Blue,Minnesota.png
|
||||||
|
Minnesota United FC,135852,MIN,Light Blue,Minnesota.png
|
||||||
Nashville SC,137700,NSH,Yellow,Nashville.png
|
Nashville SC,137700,NSH,Yellow,Nashville.png
|
||||||
New England Rev.,134159,NE,Red,New-England.png
|
New England Rev.,134159,NE,Red,New-England.png
|
||||||
|
New England Revolution,134159,NE,Red,New-England.png
|
||||||
New York City,134630,NYF,Light Blue,NYC.png
|
New York City,134630,NYF,Light Blue,NYC.png
|
||||||
|
New York City FC,134630,NYF,Light Blue,NYC.png
|
||||||
New York Red Bulls,134156,NYR,Red,New-York.png
|
New York Red Bulls,134156,NYR,Red,New-York.png
|
||||||
Orlando City,135292,PHI,Purple,Orlando.png
|
Orlando City,135292,PHI,Purple,Orlando.png
|
||||||
|
Orlando City SC,135292,PHI,Purple,Orlando.png
|
||||||
Philadelphia Union,134142,PHI,Gold,Philadelphia.png
|
Philadelphia Union,134142,PHI,Gold,Philadelphia.png
|
||||||
Portland Timbers,134155,POR,Green,Portland.png
|
Portland Timbers,134155,POR,Green,Portland.png
|
||||||
Real Salt Lake,134158,RSL,Gold,Salt-Lake.png
|
Real Salt Lake,134158,RSL,Gold,Salt-Lake.png
|
||||||
|
|
@ -12,6 +12,7 @@ Golden State Warriors,134865,GSW,Yellow,Golden State.png
|
|||||||
Indiana Pacers,134873,IND,Yellow,Indiana.png
|
Indiana Pacers,134873,IND,Yellow,Indiana.png
|
||||||
Houston Rockets,134876,HOU,Red,Houston.png
|
Houston Rockets,134876,HOU,Red,Houston.png
|
||||||
Los Angeles Clippers,134866,LAC,Red,LA.png
|
Los Angeles Clippers,134866,LAC,Red,LA.png
|
||||||
|
LA Clippers,134866,LAC,Red,LA.png
|
||||||
Los Angeles Lakers,134867,LAL,Purple,LA Lakers.png
|
Los Angeles Lakers,134867,LAL,Purple,LA Lakers.png
|
||||||
Memphis Grizzlies,134877,MEM,Dark blue,Memphis.png
|
Memphis Grizzlies,134877,MEM,Dark blue,Memphis.png
|
||||||
Miami Heat,134882,MIA,Red,Miami.png
|
Miami Heat,134882,MIA,Red,Miami.png
|
||||||
|
|
@ -31,3 +31,4 @@ Seattle Seahawks,134949,SEA,Dark blue,Seattle.png
|
|||||||
Tampa Bay Buccaneers,134945,TB,Red,Tampa Bay.png
|
Tampa Bay Buccaneers,134945,TB,Red,Tampa Bay.png
|
||||||
Tennessee Titans,134929,TEN,Light blue,Tennessee.png
|
Tennessee Titans,134929,TEN,Light blue,Tennessee.png
|
||||||
Washington,134937,WAS,Dark red,Washington.png
|
Washington,134937,WAS,Dark red,Washington.png
|
||||||
|
Washington Commanders,134937,WAS,Dark red,Washington.png
|
||||||
|
|
@ -3,22 +3,30 @@ Arsenal,133604,ARS,Red,Arsenal.png
|
|||||||
Aston Villa,133601,AVL,Light blue,AVFC.png
|
Aston Villa,133601,AVL,Light blue,AVFC.png
|
||||||
Brentford,134355,BRE,Red,Brentford.png
|
Brentford,134355,BRE,Red,Brentford.png
|
||||||
Brighton,133619,BRI,Blue,Brighton.png
|
Brighton,133619,BRI,Blue,Brighton.png
|
||||||
|
Brighton & Hove Albion,133619,BRI,Blue,Brighton.png
|
||||||
Burnley,133623,BUR,Light blue,Burnley.png
|
Burnley,133623,BUR,Light blue,Burnley.png
|
||||||
Chelsea,133610,CHE,Dark blue,Chelsea.png
|
Chelsea,133610,CHE,Dark blue,Chelsea.png
|
||||||
Crystal Palace,133632,CRY,Blue,Crystal Palace.png
|
Crystal Palace,133632,CRY,Blue,Crystal Palace.png
|
||||||
Everton,133615,EVE,Blue,Everton.png
|
Everton,133615,EVE,Blue,Everton.png
|
||||||
Leeds,133635,LEE,Yellow,Leeds.png
|
Leeds,133635,LEE,Yellow,Leeds.png
|
||||||
|
Leeds United,133635,LEE,Yellow,Leeds.png
|
||||||
Leicester,133626,LEI,Blue,Leicester.png
|
Leicester,133626,LEI,Blue,Leicester.png
|
||||||
|
Leicester City,133626,LEI,Blue,Leicester.png
|
||||||
Liverpool,133602,LIV,Red,Liverpool.png
|
Liverpool,133602,LIV,Red,Liverpool.png
|
||||||
Manchester City,133613,MCI,Blue,Manchester City.png
|
Manchester City,133613,MCI,Blue,Manchester City.png
|
||||||
Manchester United,133612,MUN,Red,Man United.png
|
Manchester United,133612,MUN,Red,Man United.png
|
||||||
Newcastle,134777,NEW,Light blue,Newcastle.png
|
Newcastle,134777,NEW,Light blue,Newcastle.png
|
||||||
|
Newcastle United,134777,NEW,Light blue,Newcastle.png
|
||||||
Norwich,133608,NOR,Green,Norwich.png
|
Norwich,133608,NOR,Green,Norwich.png
|
||||||
Southampton,134778,SOU,Red,Southampton.png
|
Southampton,134778,SOU,Red,Southampton.png
|
||||||
Tottenham,133616,TOT,Dark blue,Tottenham.png
|
Tottenham,133616,TOT,Dark blue,Tottenham.png
|
||||||
|
Tottenham Hotspur,133616,TOT,Dark blue,Tottenham.png
|
||||||
Watford,133624,WAT,Red,Watford.png
|
Watford,133624,WAT,Red,Watford.png
|
||||||
West Ham,133636,WHU,Red,West Ham.png
|
West Ham,133636,WHU,Red,West Ham.png
|
||||||
|
West Ham United,133636,WHU,Red,West Ham.png
|
||||||
Wolves,133599,WOL,Yellow,Wolves.png
|
Wolves,133599,WOL,Yellow,Wolves.png
|
||||||
|
Wolverhampton Wanderers,133599,WOL,Yellow,Wolves.png
|
||||||
Fulham,133600,FUL,Red,Fulham.png
|
Fulham,133600,FUL,Red,Fulham.png
|
||||||
Nottingham Forest,133720,FOR,Red,Nottingham Forest.png
|
Nottingham Forest,133720,FOR,Red,Nottingham Forest.png
|
||||||
Bournemouth,134301,BOU,Red,Bournemouth.png
|
Bournemouth,134301,BOU,Red,Bournemouth.png
|
||||||
|
AFC Bournemouth,134301,BOU,Red,Bournemouth.png
|
||||||
|
|
@ -5,12 +5,15 @@
|
|||||||
# This code can not be copied and/or distributed without the express
|
# This code can not be copied and/or distributed without the express
|
||||||
# permission of Fintic
|
# permission of Fintic
|
||||||
|
|
||||||
|
import psutil
|
||||||
import finnhub
|
import finnhub
|
||||||
import time
|
import time
|
||||||
import csv
|
import csv
|
||||||
import pytz
|
import pytz
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
import subprocess
|
||||||
import json
|
import json
|
||||||
|
import urllib.request
|
||||||
import datetime as dt
|
import datetime as dt
|
||||||
import sys, os, base64, hashlib, hmac, select
|
import sys, os, base64, hashlib, hmac, select
|
||||||
import requests
|
import requests
|
||||||
@ -26,7 +29,7 @@ try:
|
|||||||
last_updates = json.load(f)
|
last_updates = json.load(f)
|
||||||
f.close()
|
f.close()
|
||||||
last_updates['stocks']['force'] = True
|
last_updates['stocks']['force'] = True
|
||||||
#last_updates['weather']['force'] = True
|
last_updates['sports_l']['force'] = True
|
||||||
f = open('csv/last_updates.json', 'w')
|
f = open('csv/last_updates.json', 'w')
|
||||||
json.dump(last_updates, f)
|
json.dump(last_updates, f)
|
||||||
f.close()
|
f.close()
|
||||||
@ -157,6 +160,114 @@ def updateCommodities(api_key, logf):
|
|||||||
#logf.close()
|
#logf.close()
|
||||||
|
|
||||||
|
|
||||||
|
def updateMovies(api_key, logf):
|
||||||
|
|
||||||
|
f = open('csv/movie_settings.json', 'r')
|
||||||
|
all_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
|
if all_settings['category'] == 'Popular Movies':
|
||||||
|
url = 'https://api.themoviedb.org/3/trending/movie/day?'
|
||||||
|
movieGenre_url = 'https://api.themoviedb.org/3/genre/movie/list?api_key=' + api_key + '&language=en-US'
|
||||||
|
movieGenre_response = requests.get(movieGenre_url)
|
||||||
|
movie_genres = movieGenre_response.json()
|
||||||
|
|
||||||
|
elif all_settings['category'] == 'Popular TV':
|
||||||
|
url = 'https://api.themoviedb.org/3/trending/tv/day?'
|
||||||
|
tvGenre_url = 'https://api.themoviedb.org/3/genre/tv/list?api_key=' + api_key + '&language=en-US'
|
||||||
|
tvGenre_response = requests.get(tvGenre_url)
|
||||||
|
tv_genres = tvGenre_response.json()
|
||||||
|
|
||||||
|
elif all_settings['category'] == 'Popular All':
|
||||||
|
url = 'https://api.themoviedb.org/3/trending/all/day?'
|
||||||
|
movieGenre_url = 'https://api.themoviedb.org/3/genre/movie/list?api_key=' + api_key + '&language=en-US'
|
||||||
|
movieGenre_response = requests.get(movieGenre_url)
|
||||||
|
movie_genres = movieGenre_response.json()
|
||||||
|
tvGenre_url = 'https://api.themoviedb.org/3/genre/tv/list?api_key=' + api_key + '&language=en-US'
|
||||||
|
tvGenre_response = requests.get(tvGenre_url)
|
||||||
|
tv_genres = tvGenre_response.json()
|
||||||
|
|
||||||
|
url += 'api_key=' + api_key
|
||||||
|
response = requests.get(url)
|
||||||
|
data = response.json()
|
||||||
|
|
||||||
|
this_out = []
|
||||||
|
logo_files = []
|
||||||
|
|
||||||
|
if len(data) > 0:
|
||||||
|
movies = data['results']
|
||||||
|
|
||||||
|
for movie in movies:
|
||||||
|
movie_language = movie['original_language']
|
||||||
|
movie_votes = movie['vote_average']
|
||||||
|
movie_votes = "{:.1f}".format(movie_votes)
|
||||||
|
try:
|
||||||
|
movie_titles = movie['title']
|
||||||
|
movie_date = movie['release_date']
|
||||||
|
except KeyError:
|
||||||
|
movie_titles = movie['name']
|
||||||
|
movie_date = movie['first_air_date']
|
||||||
|
movie_type = movie['media_type']
|
||||||
|
movie_genre = movie['genre_ids']
|
||||||
|
movie_logo = 'https://image.tmdb.org/t/p/w500' + movie['backdrop_path']
|
||||||
|
genrefinal = []
|
||||||
|
|
||||||
|
if all_settings['category'] == 'Popular Movies':
|
||||||
|
for i in movie_genre:
|
||||||
|
for genre in movie_genres['genres']:
|
||||||
|
if genre['name'] == 'Science Fiction':
|
||||||
|
genre['name'] = 'Sci-Fi'
|
||||||
|
if i == genre['id']:
|
||||||
|
i = genre['name']
|
||||||
|
genrefinal.append(i)
|
||||||
|
elif all_settings['category'] == 'Popular TV':
|
||||||
|
for i in movie_genre:
|
||||||
|
for genre in tv_genres['genres']:
|
||||||
|
if i == genre['id']:
|
||||||
|
i = genre['name']
|
||||||
|
genrefinal.append(i)
|
||||||
|
elif all_settings['category'] == 'Popular All':
|
||||||
|
if movie['media_type'] == 'movie':
|
||||||
|
for i in movie_genre:
|
||||||
|
for genre in movie_genres['genres']:
|
||||||
|
if genre['name'] == 'Science Fiction':
|
||||||
|
genre['name'] = 'Sci-Fi'
|
||||||
|
if i == genre['id']:
|
||||||
|
i = genre['name']
|
||||||
|
genrefinal.append(i)
|
||||||
|
elif movie['media_type'] == 'tv':
|
||||||
|
for i in movie_genre:
|
||||||
|
for genre in tv_genres['genres']:
|
||||||
|
if i == genre['id']:
|
||||||
|
i = genre['name']
|
||||||
|
genrefinal.append(i)
|
||||||
|
|
||||||
|
this_out.append({'title':movie_titles,
|
||||||
|
'language':movie_language.upper(),
|
||||||
|
'votes':str(movie_votes),
|
||||||
|
'date':movie_date,
|
||||||
|
'media_type':movie_type.capitalize(),
|
||||||
|
'genre':genrefinal,
|
||||||
|
'backdrop':movie['backdrop_path'][1:],
|
||||||
|
'logo': movie_logo
|
||||||
|
})
|
||||||
|
|
||||||
|
logo_files.append(movie['backdrop_path'][1:])
|
||||||
|
|
||||||
|
urllib.request.urlretrieve(movie_logo,'logos/movies/' + movie['backdrop_path'])
|
||||||
|
|
||||||
|
for file in os.listdir('logos/movies/'):
|
||||||
|
if file not in logo_files:
|
||||||
|
os.remove('logos/movies/'+file)
|
||||||
|
|
||||||
|
all_settings['movies'] = this_out
|
||||||
|
|
||||||
|
f = open('csv/movie_settings.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
def updateIndices(api_key, logf):
|
def updateIndices(api_key, logf):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -566,71 +677,178 @@ def updateLeagueTables(api_key, logf):
|
|||||||
#logf.close()
|
#logf.close()
|
||||||
|
|
||||||
|
|
||||||
|
def updatePLtime():
|
||||||
|
|
||||||
|
f = open('csv/live_games.json')
|
||||||
|
|
||||||
|
try:
|
||||||
|
all_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
try:
|
||||||
|
for league in all_settings['leagues']:
|
||||||
|
if league == 'PREMIERLEAGUE':
|
||||||
|
subprocess.run(["sudo", "pkill", "-f", "live_pl.py"], shell=False)
|
||||||
|
premierleague = subprocess.Popen(["python3", "live_pl.py"], shell=False)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def updateLeagueEvents(api_key, time, logf):
|
def updateLeagueEvents(api_key, time, logf):
|
||||||
|
|
||||||
url = 'https://bm7p954xoh.execute-api.us-east-2.amazonaws.com/default/ScriptsAPI/sports?{}='.format(time)
|
url = 'https://bm7p954xoh.execute-api.us-east-2.amazonaws.com/default/ScriptsAPI/sports?{}='.format(time)
|
||||||
|
|
||||||
if time == 'past':
|
if time == 'past':
|
||||||
|
|
||||||
f = open('csv/past_games.json')
|
f = open('csv/past_games.json')
|
||||||
elif time == 'upcoming':
|
elif time == 'upcoming':
|
||||||
|
|
||||||
f = open('csv/upcoming_games.json')
|
f = open('csv/upcoming_games.json')
|
||||||
elif time == 'livescore':
|
elif time == 'livescore':
|
||||||
f = open('csv/live_games.json')
|
f = open('csv/live_games.json')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
all_settings = json.load(f)
|
all_settings = json.load(f)
|
||||||
|
|
||||||
f.close()
|
f.close()
|
||||||
leagues = all_settings['leagues'].keys()
|
|
||||||
leagues_info = {}
|
|
||||||
|
|
||||||
for league in leagues:
|
if time == 'livescore':
|
||||||
|
try:
|
||||||
|
leagues_info = {}
|
||||||
|
for league in all_settings['leagues']:
|
||||||
|
events = []
|
||||||
|
if league == 'NFL':
|
||||||
|
subprocess.run(["sudo", "pkill", "-f", "live_nfl.py"], shell=False)
|
||||||
|
nfl = subprocess.Popen(["python3", "live_nfl.py"], shell=False)
|
||||||
|
events.append('Filled')
|
||||||
|
leagues_info[league.upper()] = events
|
||||||
|
if league == 'NBA':
|
||||||
|
subprocess.run(["sudo", "pkill", "-f", "live_nba.py"], shell=False)
|
||||||
|
nba = subprocess.Popen(["python3", "live_nba.py"], shell=False)
|
||||||
|
events.append('Filled')
|
||||||
|
leagues_info[league.upper()] = events
|
||||||
|
if league == 'NHL':
|
||||||
|
subprocess.run(["sudo", "pkill", "-f", "live_nhl.py"], shell=False)
|
||||||
|
nhl = subprocess.Popen(["python3", "live_nhl.py"], shell=False)
|
||||||
|
events.append('Filled')
|
||||||
|
leagues_info[league.upper()] = events
|
||||||
|
if league == 'MLB':
|
||||||
|
subprocess.run(["sudo", "pkill", "-f", "live_mlb.py"], shell=False)
|
||||||
|
mlb = subprocess.Popen(["python3", "live_mlb.py"], shell=False)
|
||||||
|
events.append('Filled')
|
||||||
|
leagues_info[league.upper()] = events
|
||||||
|
if league == 'PREMIERLEAGUE':
|
||||||
|
subprocess.run(["sudo", "pkill", "-f", "live_pl.py"], shell=False)
|
||||||
|
premierleague = subprocess.Popen(["python3", "live_pl.py"], shell=False)
|
||||||
|
events.append('Filled')
|
||||||
|
leagues_info[league.upper()] = events
|
||||||
|
if league == 'MLS':
|
||||||
|
subprocess.run(["sudo", "pkill", "-f", "live_mls.py"], shell=False)
|
||||||
|
mls = subprocess.Popen(["python3", "live_mls.py"], shell=False)
|
||||||
|
events.append('Filled')
|
||||||
|
leagues_info[league.upper()] = events
|
||||||
|
|
||||||
if league == 'PREMIERLEAGUE':
|
all_settings['leagues'] = leagues_info
|
||||||
url += 'PREMIERLEAGUE,'
|
|
||||||
else:
|
|
||||||
url += league + ','
|
|
||||||
url = url[:-1] # remove last comma
|
|
||||||
url += '&apiKey=' + api_key
|
|
||||||
|
|
||||||
r = requests.get(url)
|
f = open( "csv/live_games.json", 'w+' )
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
all_data = r.json()
|
else:
|
||||||
|
|
||||||
for league in all_data.keys():
|
leagues = all_settings['leagues'].keys()
|
||||||
events = []
|
leagues_info = {}
|
||||||
for d in all_data[league]:
|
|
||||||
event = {}
|
|
||||||
event['date'] = d['dateEvent']
|
|
||||||
|
|
||||||
if time == 'live':
|
for league in leagues:
|
||||||
|
|
||||||
event['progess'] = d['strProgress']
|
if league == 'PREMIERLEAGUE':
|
||||||
event['status'] = d['strStatus']
|
url += 'PREMIERLEAGUE,'
|
||||||
else:
|
else:
|
||||||
|
url += league + ','
|
||||||
|
url = url[:-1] # remove last comma
|
||||||
|
url += '&apiKey=' + api_key
|
||||||
|
|
||||||
event['round'] = d['intRound']
|
r = requests.get(url)
|
||||||
event['time'] = d['strTime']
|
|
||||||
event['home_team'] = d['strHomeTeam']
|
|
||||||
|
|
||||||
event['away_team'] = d['strAwayTeam']
|
all_data = r.json()
|
||||||
|
|
||||||
if time != 'upcoming':
|
for league in all_data.keys():
|
||||||
event['away_score'] = d['intAwayScore']
|
ten_or_fifteen = slice(None)
|
||||||
event['home_score'] = d['intHomeScore']
|
events = []
|
||||||
|
if (league == 'PGA') or (league == 'LPGA') or (league == 'PGA_EU'):
|
||||||
|
ten_or_fifteen = slice(3)
|
||||||
|
else:
|
||||||
|
ten_or_fifteen = slice(None)
|
||||||
|
for d in all_data[league][ten_or_fifteen]:
|
||||||
|
event = {}
|
||||||
|
event['date'] = d['dateEvent']
|
||||||
|
|
||||||
events.append(event)
|
if time == 'live':
|
||||||
leagues_info[league.upper()] = events
|
event['progess'] = d['strProgress']
|
||||||
all_settings['leagues'] = leagues_info
|
event['status'] = d['strStatus']
|
||||||
|
else:
|
||||||
|
if (league == 'PGA') or (league == 'LPGA') or (league == 'PGA_EU'):
|
||||||
|
event['date'] = d['dateEvent']
|
||||||
|
event['event'] = d['strEvent'].replace("\u2019","'")
|
||||||
|
event['venue'] = d['strVenue'].replace("\u2019","'")
|
||||||
|
event['city'] = d['strCity'].replace("\u2019","'")
|
||||||
|
event['country'] = d['strCountry']
|
||||||
|
event['season'] = d['strSeason']
|
||||||
|
else:
|
||||||
|
event['round'] = d['intRound']
|
||||||
|
event['time'] = d['strTime']
|
||||||
|
event['home_team'] = d['strHomeTeam']
|
||||||
|
event['away_team'] = d['strAwayTeam']
|
||||||
|
|
||||||
f = open( "csv/{}_games.json".format(time), 'w+' )
|
if time != 'upcoming':
|
||||||
json.dump(all_settings, f)
|
if (league == 'PGA') or (league == 'LPGA') or (league == 'PGA_EU'):
|
||||||
f.close()
|
event['golf_standings'] = d['strResult']
|
||||||
|
|
||||||
|
rank = ['n1', 'n2', 'n3', 'n4', 'n5', 'n6', 'n7', 'n8', 'n9', 'n10', 'T1', 'T2', 'T3', 'T4', 'T5',
|
||||||
|
'T6', 'T7', 'T8', 'T9', 'T10']
|
||||||
|
|
||||||
|
def convert(string):
|
||||||
|
string = repr(string).replace('/', '')
|
||||||
|
li = list(string.split('\\'))
|
||||||
|
return li
|
||||||
|
|
||||||
|
str3 = convert(event['golf_standings'])
|
||||||
|
|
||||||
|
players = []
|
||||||
|
|
||||||
|
|
||||||
|
for each in str3:
|
||||||
|
each = each.replace('nT', 'T', 1)
|
||||||
|
if each[:2] in rank:
|
||||||
|
try:
|
||||||
|
first_space = each.find(' ', 1)
|
||||||
|
second_space = each.find(' ', 4)
|
||||||
|
first_name = each[first_space:second_space].lstrip()
|
||||||
|
initial = first_name[0] + '.'
|
||||||
|
each = each.replace(first_name,initial)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
interator = each.find('-')
|
||||||
|
if interator < 0:
|
||||||
|
interator = 0
|
||||||
|
interator2 = each[interator:interator + 3]
|
||||||
|
result = each.split(interator2, 1)[0] + interator2
|
||||||
|
players.append(result.rstrip())
|
||||||
|
|
||||||
|
event['golf_standings'] = players
|
||||||
|
else:
|
||||||
|
event['away_score'] = d['intAwayScore']
|
||||||
|
event['home_score'] = d['intHomeScore']
|
||||||
|
|
||||||
|
events.append(event)
|
||||||
|
leagues_info[league.upper()] = events
|
||||||
|
all_settings['leagues'] = leagues_info
|
||||||
|
|
||||||
|
f = open( "csv/{}_games.json".format(time), 'w+' )
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
#logf = open('log.txt', "a")
|
#logf = open('log.txt', "a")
|
||||||
@ -712,6 +930,10 @@ def updateAll(api_key, weather_key, logf):
|
|||||||
updateWeather(weather_key, logf)
|
updateWeather(weather_key, logf)
|
||||||
|
|
||||||
|
|
||||||
|
past_espn_time = True
|
||||||
|
past_pl_time = True
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
logf = open("log.txt", "a")
|
logf = open("log.txt", "a")
|
||||||
|
|
||||||
@ -721,7 +943,7 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
update_frequencies = {'stocks':2, 'crypto':5, 'forex':60, 'news':120, 'weather': 120, 'sports': 1440, 'commodities': 15, 'indices': 15} #minutes
|
update_frequencies = {'stocks':2, 'crypto':5, 'forex':60, 'news':120, 'weather': 120, 'sports': 1440, 'commodities': 15, 'indices': 15, 'movies': 1440} #minutes
|
||||||
|
|
||||||
NY_zone = pytz.timezone('America/New_York')
|
NY_zone = pytz.timezone('America/New_York')
|
||||||
CET_zone = pytz.timezone('EST')
|
CET_zone = pytz.timezone('EST')
|
||||||
@ -758,7 +980,10 @@ if __name__ == '__main__':
|
|||||||
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||||
logf.close()
|
logf.close()
|
||||||
|
|
||||||
|
try:
|
||||||
|
movie_key = open('movie_api_key.txt').readlines()[0]
|
||||||
|
except Exception as e:
|
||||||
|
movie_key = False
|
||||||
|
|
||||||
|
|
||||||
t = time.time()
|
t = time.time()
|
||||||
@ -792,7 +1017,7 @@ if __name__ == '__main__':
|
|||||||
"news": {"time": "06/03/2022 04:07:09", "force": True}, "weather": {"time": "06/03/2022 04:08:20", "force": True},
|
"news": {"time": "06/03/2022 04:07:09", "force": True}, "weather": {"time": "06/03/2022 04:08:20", "force": True},
|
||||||
"forex": {"time": "06/03/2022 03:54:02", "force": True}, "sports_l": {"time": "06/03/2022 04:10:09", "force": True},
|
"forex": {"time": "06/03/2022 03:54:02", "force": True}, "sports_l": {"time": "06/03/2022 04:10:09", "force": True},
|
||||||
"sports_p": {"time": "06/03/2022 04:10:09", "force": True},
|
"sports_p": {"time": "06/03/2022 04:10:09", "force": True},
|
||||||
"sports_u": {"time": "06/03/2022 04:10:09", "force": True},"sports_t": {"time": "06/03/2022 04:10:09", "force": True}, "commodities": {"time": "06/03/2022 04:10:09", "force": True}, "indices": {"time": "06/03/2022 04:10:09", "force": True}}
|
"sports_u": {"time": "06/03/2022 04:10:09", "force": True},"sports_t": {"time": "06/03/2022 04:10:09", "force": True}, "commodities": {"time": "06/03/2022 04:10:09", "force": True}, "indices": {"time": "06/03/2022 04:10:09", "force": True}, "movies": {"time": "06/03/2022 04:10:09", "force": True}}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -879,6 +1104,22 @@ if __name__ == '__main__':
|
|||||||
update_process.start()
|
update_process.start()
|
||||||
update_processes.append(update_process)
|
update_processes.append(update_process)
|
||||||
|
|
||||||
|
# movies
|
||||||
|
movies_time = datetime.strptime(last_updates['movies']['time'], "%d/%m/%Y %H:%M:%S")
|
||||||
|
|
||||||
|
|
||||||
|
NY_time = datetime.now(NY_zone).replace(tzinfo=None)
|
||||||
|
diff = (NY_time - movies_time).total_seconds()/60 #minutes
|
||||||
|
|
||||||
|
|
||||||
|
if last_updates['movies']['force'] or diff >= update_frequencies['movies']:
|
||||||
|
movies_time = NY_time.strftime("%d/%m/%Y %H:%M:%S")
|
||||||
|
last_updates['movies']['time'] = movies_time
|
||||||
|
last_updates['movies']['force'] = False
|
||||||
|
update_process = Process(target = updateMovies, args = (movie_key,logf))
|
||||||
|
update_process.start()
|
||||||
|
update_processes.append(update_process)
|
||||||
|
|
||||||
# weather
|
# weather
|
||||||
weather_time = datetime.strptime(last_updates['weather']['time'], "%d/%m/%Y %H:%M:%S")
|
weather_time = datetime.strptime(last_updates['weather']['time'], "%d/%m/%Y %H:%M:%S")
|
||||||
|
|
||||||
@ -932,16 +1173,36 @@ if __name__ == '__main__':
|
|||||||
# sports live
|
# sports live
|
||||||
sports_time = datetime.strptime(last_updates['sports_l']['time'], "%d/%m/%Y %H:%M:%S")
|
sports_time = datetime.strptime(last_updates['sports_l']['time'], "%d/%m/%Y %H:%M:%S")
|
||||||
NY_time = datetime.now(NY_zone).replace(tzinfo=None)
|
NY_time = datetime.now(NY_zone).replace(tzinfo=None)
|
||||||
diff = (NY_time - sports_time).total_seconds()/60 #minutes
|
espn_time = "17:00Z"
|
||||||
if last_updates['sports_l']['force'] or diff >= update_frequencies['sports']:# or msg == 'S':
|
espn_time_est = "12:00"
|
||||||
|
# if datetime.now(pytz.utc).strftime("%H:%MZ") < espn_time:
|
||||||
|
if datetime.now(pytz.timezone('America/New_York')).strftime("%H:%M") < espn_time_est:
|
||||||
|
past_espn_time = True
|
||||||
|
if last_updates['sports_l']['force'] or (datetime.now(pytz.timezone('America/New_York')).strftime("%H:%M") >= espn_time_est and past_espn_time):# or msg == 'S':
|
||||||
|
# if last_updates['sports_l']['force'] or (datetime.now(pytz.utc).strftime("%H:%MZ") >= espn_time and past_espn_time):# or msg == 'S':
|
||||||
sports_time = NY_time.strftime("%d/%m/%Y %H:%M:%S")
|
sports_time = NY_time.strftime("%d/%m/%Y %H:%M:%S")
|
||||||
#updateSports(api_key)
|
|
||||||
last_updates['sports_l']['time'] = sports_time
|
last_updates['sports_l']['time'] = sports_time
|
||||||
last_updates['sports_l']['force'] = False
|
last_updates['sports_l']['force'] = False
|
||||||
|
past_espn_time = False
|
||||||
update_process = Process(target = updateLeagueEvents, args = (api_key, 'livescore',logf))
|
update_process = Process(target = updateLeagueEvents, args = (api_key, 'livescore',logf))
|
||||||
update_process.start()
|
update_process.start()
|
||||||
update_processes.append(update_process)
|
update_processes.append(update_process)
|
||||||
|
|
||||||
|
#sports live (premier league)
|
||||||
|
pl_time = "12:00Z"
|
||||||
|
NY_time = datetime.now(NY_zone).replace(tzinfo=None)
|
||||||
|
sports_time = datetime.strptime(last_updates['sports_l']['time'], "%d/%m/%Y %H:%M:%S")
|
||||||
|
if datetime.now(pytz.utc).strftime("%H:%MZ") < pl_time:
|
||||||
|
past_pl_time = True
|
||||||
|
if datetime.now(pytz.utc).strftime("%H:%MZ") >= pl_time and past_pl_time:# or msg == 'S':
|
||||||
|
sports_time = NY_time.strftime("%d/%m/%Y %H:%M:%S")
|
||||||
|
past_pl_time = False
|
||||||
|
last_updates['sports_l']['time'] = sports_time
|
||||||
|
last_updates['sports_l']['force'] = False
|
||||||
|
update_process = Process(target = updatePLtime)
|
||||||
|
update_process.start()
|
||||||
|
update_processes.append(update_process)
|
||||||
|
|
||||||
# sports past
|
# sports past
|
||||||
sports_time = datetime.strptime(last_updates['sports_p']['time'], "%d/%m/%Y %H:%M:%S")
|
sports_time = datetime.strptime(last_updates['sports_p']['time'], "%d/%m/%Y %H:%M:%S")
|
||||||
NY_time = datetime.now(NY_zone).replace(tzinfo=None)
|
NY_time = datetime.now(NY_zone).replace(tzinfo=None)
|
||||||
|
BIN
feature_titles/movies.png
Normal file
After Width: | Height: | Size: 407 B |
BIN
feature_titles/small_feature_titles/movies.png
Normal file
After Width: | Height: | Size: 321 B |
BIN
feature_titles/small_feature_titles/sports_live.png
Normal file
After Width: | Height: | Size: 307 B |
187
live_mlb.py
Normal file
@ -0,0 +1,187 @@
|
|||||||
|
from datetime import datetime, timedelta
|
||||||
|
from time import sleep
|
||||||
|
import pytz
|
||||||
|
import json
|
||||||
|
import requests
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def sortevents(leaguedata, league):
|
||||||
|
|
||||||
|
games = []
|
||||||
|
haslive = False
|
||||||
|
|
||||||
|
for event in leaguedata['events']:
|
||||||
|
|
||||||
|
event_desc = event['status']['type']['shortDetail'] # use this to display time and quarter on ticker
|
||||||
|
event_date = event['date'].split('T')[0]
|
||||||
|
event_liveOrNot = event['status']['type']['state'] # use this to determine if game has ended or not
|
||||||
|
if event_liveOrNot == 'in':
|
||||||
|
haslive = True
|
||||||
|
has_live = 'has_live'
|
||||||
|
no_upcoming = 'no_upcoming'
|
||||||
|
|
||||||
|
for home_away in event['competitions']:
|
||||||
|
for home_away2 in home_away['competitors']:
|
||||||
|
if home_away2['homeAway'] == 'away':
|
||||||
|
if home_away2['team']['displayName'] == 'Washington Commanders':
|
||||||
|
away_team = 'Washington'
|
||||||
|
else:
|
||||||
|
away_team = home_away2['team']['displayName']
|
||||||
|
away_score = home_away2['score']
|
||||||
|
else:
|
||||||
|
if home_away2['team']['displayName'] == 'Washington Commanders':
|
||||||
|
home_team = 'Washington'
|
||||||
|
else:
|
||||||
|
home_team = home_away2['team']['displayName']
|
||||||
|
home_score = home_away2['score']
|
||||||
|
|
||||||
|
if datetime.now(pytz.utc).strftime("%Y-%m-%d") == event['date'].split('T')[0] or event['date'].split('T')[0] <= (datetime.strptime(datetime.now(pytz.utc).strftime("%Y-%m-%dT%H:%MZ"), "%Y-%m-%dT%H:%MZ") + timedelta(days=1)).strftime("%Y-%m-%dT%H:%MZ").split('T')[0]:
|
||||||
|
games.append({
|
||||||
|
'home_team': home_team,
|
||||||
|
'home_score': home_score,
|
||||||
|
'away_team': away_team,
|
||||||
|
'away_score': away_score,
|
||||||
|
'time': event_desc,
|
||||||
|
'date': event_date,
|
||||||
|
'isLive': event_liveOrNot
|
||||||
|
})
|
||||||
|
return games, haslive, has_live, no_upcoming
|
||||||
|
|
||||||
|
|
||||||
|
f = open('csv/live_mlb.json', 'r')
|
||||||
|
all_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
mlb_url = "https://site.api.espn.com/apis/site/v2/sports/baseball/mlb/scoreboard"
|
||||||
|
|
||||||
|
time_now = datetime.now(pytz.utc)
|
||||||
|
time_now2 = time_now.strftime("%Y-%m-%dT%H:%MZ")
|
||||||
|
|
||||||
|
mlb_live_now = False
|
||||||
|
mlb_games_today = False
|
||||||
|
mlb_events = []
|
||||||
|
mlb_fifteenmin = False
|
||||||
|
games_happened = False
|
||||||
|
|
||||||
|
try:
|
||||||
|
mlb_response = requests.get(mlb_url)
|
||||||
|
mlb_data = mlb_response.json()
|
||||||
|
except:
|
||||||
|
sleep(120)
|
||||||
|
mlb_response = requests.get(mlb_url)
|
||||||
|
mlb_data = mlb_response.json()
|
||||||
|
|
||||||
|
for event in mlb_data['events']:
|
||||||
|
if event['status']['type']['state'] == 'in':
|
||||||
|
mlb_live_now = True
|
||||||
|
if time_now2.split('T')[0] <= event['date'].split('T')[0] and event['date'].split('T')[0] <= (datetime.strptime(time_now2, "%Y-%m-%dT%H:%MZ") + timedelta(days=1)).strftime("%Y-%m-%dT%H:%MZ").split('T')[0]:
|
||||||
|
mlb_events.append(event['date'])
|
||||||
|
mlb_games_today = True
|
||||||
|
if mlb_live_now is False and ((datetime.strptime(event['date'], "%Y-%m-%dT%H:%MZ") + timedelta(minutes=20)).strftime("%Y-%m-%dT%H:%MZ") >= datetime.now(pytz.utc).strftime("%Y-%m-%dT%H:%MZ")) and (event['date'] <= datetime.now(pytz.utc).strftime("%Y-%m-%dT%H:%MZ")):
|
||||||
|
mlb_fifteenmin = True
|
||||||
|
|
||||||
|
|
||||||
|
while True:
|
||||||
|
f = open('csv/live_mlb.json', 'r')
|
||||||
|
all_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
if mlb_live_now:
|
||||||
|
try:
|
||||||
|
mlb_response = requests.get(mlb_url)
|
||||||
|
mlb_data = mlb_response.json()
|
||||||
|
mlb_sorted = sortevents(mlb_data, 'MLB')
|
||||||
|
all_settings['leagues']['MLB'] = mlb_sorted
|
||||||
|
games_happened = True
|
||||||
|
|
||||||
|
if mlb_sorted[1]:
|
||||||
|
mlb_live_now = True
|
||||||
|
else:
|
||||||
|
mlb_live_now = False
|
||||||
|
|
||||||
|
f = open('csv/live_mlb.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
sleep(120)
|
||||||
|
except:
|
||||||
|
sleep(120)
|
||||||
|
|
||||||
|
|
||||||
|
elif mlb_fifteenmin:
|
||||||
|
for _ in range (10):
|
||||||
|
try:
|
||||||
|
mlb_response = requests.get(mlb_url)
|
||||||
|
mlb_data = mlb_response.json()
|
||||||
|
mlb_sorted = sortevents(mlb_data, 'MLB')
|
||||||
|
all_settings['leagues']['MLB'] = mlb_sorted
|
||||||
|
|
||||||
|
f = open('csv/live_mlb.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
sleep(120)
|
||||||
|
except:
|
||||||
|
sleep(120)
|
||||||
|
|
||||||
|
if mlb_sorted[1]:
|
||||||
|
mlb_live_now = True
|
||||||
|
mlb_fifteenmin = False
|
||||||
|
games_happened = True
|
||||||
|
else:
|
||||||
|
mlb_live_now = False
|
||||||
|
mlb_fifteenmin = False
|
||||||
|
|
||||||
|
else:
|
||||||
|
mlb_events2 = []
|
||||||
|
|
||||||
|
try:
|
||||||
|
for event in mlb_events:
|
||||||
|
if event >= datetime.now(pytz.utc).strftime("%Y-%m-%dT%H:%MZ"):
|
||||||
|
mlb_events2.append(event)
|
||||||
|
mlb_games_today = True
|
||||||
|
next_mlb = min(mlb_events2)
|
||||||
|
d = datetime.strptime(next_mlb, "%Y-%m-%dT%H:%MZ")
|
||||||
|
mlb_time_left = (d - (datetime.strptime(datetime.now(pytz.utc).strftime("%Y-%m-%dT%H:%MZ"), "%Y-%m-%dT%H:%MZ"))).total_seconds()
|
||||||
|
all_settings['leagues']['MLB'][3] = next_mlb
|
||||||
|
|
||||||
|
f = open('csv/live_mlb.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
except:
|
||||||
|
mlb_games_today = False
|
||||||
|
next_mlb = []
|
||||||
|
all_settings['leagues']['MLB'][3] = 'no_upcoming'
|
||||||
|
|
||||||
|
f = open('csv/live_mlb.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
pass
|
||||||
|
|
||||||
|
if mlb_games_today:
|
||||||
|
sleep(mlb_time_left)
|
||||||
|
mlb_fifteenmin = True
|
||||||
|
|
||||||
|
|
||||||
|
if mlb_live_now is False and mlb_games_today is False and games_happened is True:
|
||||||
|
sleep(7200)
|
||||||
|
all_settings['leagues']['MLB'][2] = 'no_live'
|
||||||
|
all_settings['leagues']['MLB'][3] = 'no_upcoming'
|
||||||
|
|
||||||
|
f = open('csv/live_mlb.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
|
if mlb_live_now is False and mlb_games_today is False and games_happened is False:
|
||||||
|
all_settings['leagues']['MLB'][2] = 'no_live'
|
||||||
|
all_settings['leagues']['MLB'][3] = 'no_upcoming'
|
||||||
|
|
||||||
|
f = open('csv/live_mlb.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
break
|
188
live_mls.py
Normal file
@ -0,0 +1,188 @@
|
|||||||
|
from datetime import datetime, timedelta
|
||||||
|
from time import sleep
|
||||||
|
import pytz
|
||||||
|
import json
|
||||||
|
import requests
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def sortevents(leaguedata, league):
|
||||||
|
|
||||||
|
games = []
|
||||||
|
haslive = False
|
||||||
|
|
||||||
|
for event in leaguedata['events']:
|
||||||
|
|
||||||
|
event_desc = event['status']['type']['shortDetail'] # use this to display time and quarter on ticker
|
||||||
|
event_date = event['date'].split('T')[0]
|
||||||
|
event_liveOrNot = event['status']['type']['state'] # use this to determine if game has ended or not
|
||||||
|
if event_liveOrNot == 'in':
|
||||||
|
haslive = True
|
||||||
|
has_live = 'has_live'
|
||||||
|
no_upcoming = 'no_upcoming'
|
||||||
|
|
||||||
|
for home_away in event['competitions']:
|
||||||
|
for home_away2 in home_away['competitors']:
|
||||||
|
if home_away2['homeAway'] == 'away':
|
||||||
|
if home_away2['team']['displayName'] == 'Washington Commanders':
|
||||||
|
away_team = 'Washington'
|
||||||
|
else:
|
||||||
|
away_team = home_away2['team']['displayName']
|
||||||
|
away_score = home_away2['score']
|
||||||
|
else:
|
||||||
|
if home_away2['team']['displayName'] == 'Washington Commanders':
|
||||||
|
home_team = 'Washington'
|
||||||
|
else:
|
||||||
|
home_team = home_away2['team']['displayName']
|
||||||
|
home_score = home_away2['score']
|
||||||
|
|
||||||
|
if datetime.now(pytz.utc).strftime("%Y-%m-%d") == event['date'].split('T')[0] or event['date'].split('T')[0] <= (datetime.strptime(datetime.now(pytz.utc).strftime("%Y-%m-%dT%H:%MZ"), "%Y-%m-%dT%H:%MZ") + timedelta(days=1)).strftime("%Y-%m-%dT%H:%MZ").split('T')[0]:
|
||||||
|
games.append({
|
||||||
|
'home_team': home_team,
|
||||||
|
'home_score': home_score,
|
||||||
|
'away_team': away_team,
|
||||||
|
'away_score': away_score,
|
||||||
|
'time': event_desc,
|
||||||
|
'date': event_date,
|
||||||
|
'isLive': event_liveOrNot
|
||||||
|
})
|
||||||
|
return games, haslive, has_live, no_upcoming
|
||||||
|
|
||||||
|
|
||||||
|
f = open('csv/live_mls.json', 'r')
|
||||||
|
all_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
mls_url = "https://site.api.espn.com/apis/site/v2/sports/soccer/usa.1/scoreboard"
|
||||||
|
|
||||||
|
time_now = datetime.now(pytz.utc)
|
||||||
|
time_now2 = time_now.strftime("%Y-%m-%dT%H:%MZ")
|
||||||
|
|
||||||
|
mls_live_now = False
|
||||||
|
mls_games_today = False
|
||||||
|
mls_events = []
|
||||||
|
mls_fifteenmin = False
|
||||||
|
games_happened = False
|
||||||
|
|
||||||
|
try:
|
||||||
|
mls_response = requests.get(mls_url)
|
||||||
|
mls_data = mls_response.json()
|
||||||
|
except:
|
||||||
|
sleep(120)
|
||||||
|
mls_response = requests.get(mls_url)
|
||||||
|
mls_data = mls_response.json()
|
||||||
|
|
||||||
|
for event in mls_data['events']:
|
||||||
|
if event['status']['type']['state'] == 'in':
|
||||||
|
mls_live_now = True
|
||||||
|
if time_now2.split('T')[0] <= event['date'].split('T')[0] and event['date'].split('T')[0] <= (datetime.strptime(time_now2, "%Y-%m-%dT%H:%MZ") + timedelta(days=1)).strftime("%Y-%m-%dT%H:%MZ").split('T')[0]:
|
||||||
|
mls_events.append(event['date'])
|
||||||
|
mls_games_today = True
|
||||||
|
if mls_live_now is False and ((datetime.strptime(event['date'], "%Y-%m-%dT%H:%MZ") + timedelta(minutes=20)).strftime("%Y-%m-%dT%H:%MZ") >= datetime.now(pytz.utc).strftime("%Y-%m-%dT%H:%MZ")) and (event['date'] <= datetime.now(pytz.utc).strftime("%Y-%m-%dT%H:%MZ")):
|
||||||
|
mls_fifteenmin = True
|
||||||
|
|
||||||
|
|
||||||
|
while True:
|
||||||
|
f = open('csv/live_mls.json', 'r')
|
||||||
|
all_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
if mls_live_now:
|
||||||
|
try:
|
||||||
|
mls_response = requests.get(mls_url)
|
||||||
|
mls_data = mls_response.json()
|
||||||
|
mls_sorted = sortevents(mls_data, 'MLS')
|
||||||
|
all_settings['leagues']['MLS'] = mls_sorted
|
||||||
|
games_happened = True
|
||||||
|
|
||||||
|
if mls_sorted[1]:
|
||||||
|
mls_live_now = True
|
||||||
|
else:
|
||||||
|
mls_live_now = False
|
||||||
|
|
||||||
|
f = open('csv/live_mls.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
sleep(120)
|
||||||
|
except:
|
||||||
|
sleep(120)
|
||||||
|
|
||||||
|
|
||||||
|
elif mls_fifteenmin:
|
||||||
|
for _ in range (10):
|
||||||
|
try:
|
||||||
|
mls_response = requests.get(mls_url)
|
||||||
|
mls_data = mls_response.json()
|
||||||
|
mls_sorted = sortevents(mls_data, 'MLS')
|
||||||
|
all_settings['leagues']['MLS'] = mls_sorted
|
||||||
|
|
||||||
|
f = open('csv/live_mls.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
sleep(120)
|
||||||
|
except:
|
||||||
|
sleep(120)
|
||||||
|
|
||||||
|
if mls_sorted[1]:
|
||||||
|
mls_live_now = True
|
||||||
|
mls_fifteenmin = False
|
||||||
|
games_happened = True
|
||||||
|
else:
|
||||||
|
mls_live_now = False
|
||||||
|
mls_fifteenmin = False
|
||||||
|
|
||||||
|
else:
|
||||||
|
mls_events2 = []
|
||||||
|
|
||||||
|
try:
|
||||||
|
for event in mls_events:
|
||||||
|
if event >= datetime.now(pytz.utc).strftime("%Y-%m-%dT%H:%MZ"):
|
||||||
|
mls_events2.append(event)
|
||||||
|
mls_games_today = True
|
||||||
|
next_mls = min(mls_events2)
|
||||||
|
d = datetime.strptime(next_mls, "%Y-%m-%dT%H:%MZ")
|
||||||
|
mls_time_left = (d - (datetime.strptime(datetime.now(pytz.utc).strftime("%Y-%m-%dT%H:%MZ"), "%Y-%m-%dT%H:%MZ"))).total_seconds()
|
||||||
|
all_settings['leagues']['MLS'][3] = next_mls
|
||||||
|
|
||||||
|
f = open('csv/live_mls.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
except:
|
||||||
|
mls_games_today = False
|
||||||
|
next_mls = []
|
||||||
|
|
||||||
|
all_settings['leagues']['MLS'][3] = 'no_upcoming'
|
||||||
|
|
||||||
|
f = open('csv/live_mls.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
pass
|
||||||
|
|
||||||
|
if mls_games_today:
|
||||||
|
sleep(mls_time_left)
|
||||||
|
mls_fifteenmin = True
|
||||||
|
|
||||||
|
|
||||||
|
if mls_live_now is False and mls_games_today is False and games_happened is True:
|
||||||
|
sleep(7200)
|
||||||
|
all_settings['leagues']['MLS'][2] = 'no_live'
|
||||||
|
all_settings['leagues']['MLS'][3] = 'no_upcoming'
|
||||||
|
|
||||||
|
f = open('csv/live_mls.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
|
if mls_live_now is False and mls_games_today is False and games_happened is False:
|
||||||
|
all_settings['leagues']['MLS'][2] = 'no_live'
|
||||||
|
all_settings['leagues']['MLS'][3] = 'no_upcoming'
|
||||||
|
|
||||||
|
f = open('csv/live_mls.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
break
|
185
live_nba.py
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
from datetime import datetime, timedelta
|
||||||
|
from time import sleep
|
||||||
|
import pytz
|
||||||
|
import json
|
||||||
|
import requests
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def sortevents(leaguedata, league):
|
||||||
|
|
||||||
|
games = []
|
||||||
|
haslive = False
|
||||||
|
|
||||||
|
for event in leaguedata['events']:
|
||||||
|
|
||||||
|
event_desc = event['status']['type']['shortDetail'] # use this to display time and quarter on ticker
|
||||||
|
event_date = event['date'].split('T')[0]
|
||||||
|
event_liveOrNot = event['status']['type']['state'] # use this to determine if game has ended or not
|
||||||
|
if event_liveOrNot == 'in':
|
||||||
|
haslive = True
|
||||||
|
has_live = 'has_live'
|
||||||
|
no_upcoming = 'no_upcoming'
|
||||||
|
|
||||||
|
for home_away in event['competitions']:
|
||||||
|
for home_away2 in home_away['competitors']:
|
||||||
|
if home_away2['homeAway'] == 'away':
|
||||||
|
if home_away2['team']['displayName'] == 'Washington Commanders':
|
||||||
|
away_team = 'Washington'
|
||||||
|
else:
|
||||||
|
away_team = home_away2['team']['displayName']
|
||||||
|
away_score = home_away2['score']
|
||||||
|
else:
|
||||||
|
if home_away2['team']['displayName'] == 'Washington Commanders':
|
||||||
|
home_team = 'Washington'
|
||||||
|
else:
|
||||||
|
home_team = home_away2['team']['displayName']
|
||||||
|
home_score = home_away2['score']
|
||||||
|
|
||||||
|
if datetime.now(pytz.utc).strftime("%Y-%m-%d") == event['date'].split('T')[0] or event['date'].split('T')[0] <= (datetime.strptime(datetime.now(pytz.utc).strftime("%Y-%m-%dT%H:%MZ"), "%Y-%m-%dT%H:%MZ") + timedelta(days=1)).strftime("%Y-%m-%dT%H:%MZ").split('T')[0]:
|
||||||
|
games.append({
|
||||||
|
'home_team': home_team,
|
||||||
|
'home_score': home_score,
|
||||||
|
'away_team': away_team,
|
||||||
|
'away_score': away_score,
|
||||||
|
'time': event_desc,
|
||||||
|
'date': event_date,
|
||||||
|
'isLive': event_liveOrNot
|
||||||
|
})
|
||||||
|
return games, haslive, has_live, no_upcoming
|
||||||
|
|
||||||
|
|
||||||
|
f = open('csv/live_nba.json', 'r')
|
||||||
|
all_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
nba_url = "https://site.api.espn.com/apis/site/v2/sports/basketball/nba/scoreboard"
|
||||||
|
|
||||||
|
time_now = datetime.now(pytz.utc)
|
||||||
|
time_now2 = time_now.strftime("%Y-%m-%dT%H:%MZ")
|
||||||
|
|
||||||
|
NBA_live_now = False
|
||||||
|
NBA_games_today = False
|
||||||
|
NBA_events = []
|
||||||
|
NBA_fifteenmin = False
|
||||||
|
games_happened = False
|
||||||
|
|
||||||
|
try:
|
||||||
|
nba_response = requests.get(nba_url)
|
||||||
|
nba_data = nba_response.json()
|
||||||
|
except:
|
||||||
|
sleep(120)
|
||||||
|
nba_response = requests.get(nba_url)
|
||||||
|
nba_data = nba_response.json()
|
||||||
|
|
||||||
|
for event in nba_data['events']:
|
||||||
|
if event['status']['type']['state'] == 'in':
|
||||||
|
NBA_live_now = True
|
||||||
|
if time_now2.split('T')[0] <= event['date'].split('T')[0] and event['date'].split('T')[0] <= (datetime.strptime(time_now2, "%Y-%m-%dT%H:%MZ") + timedelta(days=1)).strftime("%Y-%m-%dT%H:%MZ").split('T')[0]:
|
||||||
|
NBA_events.append(event['date'])
|
||||||
|
NBA_games_today = True
|
||||||
|
if NBA_live_now is False and ((datetime.strptime(event['date'], "%Y-%m-%dT%H:%MZ") + timedelta(minutes=20)).strftime("%Y-%m-%dT%H:%MZ") >= datetime.now(pytz.utc).strftime("%Y-%m-%dT%H:%MZ")) and (event['date'] <= datetime.now(pytz.utc).strftime("%Y-%m-%dT%H:%MZ")):
|
||||||
|
NBA_fifteenmin = True
|
||||||
|
|
||||||
|
|
||||||
|
while True:
|
||||||
|
f = open('csv/live_nba.json', 'r')
|
||||||
|
all_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
if NBA_live_now:
|
||||||
|
try:
|
||||||
|
nba_response = requests.get(nba_url)
|
||||||
|
nba_data = nba_response.json()
|
||||||
|
nba_sorted = sortevents(nba_data, 'NBA')
|
||||||
|
all_settings['leagues']['NBA'] = nba_sorted
|
||||||
|
games_happened = True
|
||||||
|
|
||||||
|
if nba_sorted[1]:
|
||||||
|
NBA_live_now = True
|
||||||
|
else:
|
||||||
|
NBA_live_now = False
|
||||||
|
|
||||||
|
f = open('csv/live_nba.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
sleep(120)
|
||||||
|
except:
|
||||||
|
sleep(120)
|
||||||
|
|
||||||
|
|
||||||
|
elif NBA_fifteenmin:
|
||||||
|
for _ in range (10):
|
||||||
|
try:
|
||||||
|
nba_response = requests.get(nba_url)
|
||||||
|
nba_data = nba_response.json()
|
||||||
|
nba_sorted = sortevents(nba_data, 'NBA')
|
||||||
|
all_settings['leagues']['NBA'] = nba_sorted
|
||||||
|
|
||||||
|
f = open('csv/live_nba.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
sleep(120)
|
||||||
|
except:
|
||||||
|
sleep(120)
|
||||||
|
|
||||||
|
if nba_sorted[1]:
|
||||||
|
NBA_live_now = True
|
||||||
|
NBA_fifteenmin = False
|
||||||
|
games_happened = True
|
||||||
|
|
||||||
|
else:
|
||||||
|
NBA_live_now = False
|
||||||
|
NBA_fifteenmin = False
|
||||||
|
|
||||||
|
else:
|
||||||
|
# NBA_events = ['2022-12-06T13:13Z', '2022-12-06T20:30Z', '2022-12-06T21:00Z', '2022-12-06T23:50Z']
|
||||||
|
# NFL_events = ['2022-12-05T14:54Z']
|
||||||
|
|
||||||
|
NBA_events2 = []
|
||||||
|
|
||||||
|
try:
|
||||||
|
for event in NBA_events:
|
||||||
|
if event >= datetime.now(pytz.utc).strftime("%Y-%m-%dT%H:%MZ"):
|
||||||
|
NBA_events2.append(event)
|
||||||
|
NBA_games_today = True
|
||||||
|
next_NBA = min(NBA_events2)
|
||||||
|
d = datetime.strptime(next_NBA, "%Y-%m-%dT%H:%MZ")
|
||||||
|
NBA_time_left = (d - (datetime.strptime(datetime.now(pytz.utc).strftime("%Y-%m-%dT%H:%MZ"), "%Y-%m-%dT%H:%MZ"))).total_seconds()
|
||||||
|
all_settings['leagues']['NBA'][3] = next_NBA
|
||||||
|
f = open('csv/live_nba.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
except:
|
||||||
|
NBA_games_today = False
|
||||||
|
next_NBA = []
|
||||||
|
all_settings['leagues']['NBA'][3] = 'no_upcoming'
|
||||||
|
f = open('csv/live_nba.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
pass
|
||||||
|
|
||||||
|
if NBA_games_today:
|
||||||
|
sleep(NBA_time_left)
|
||||||
|
NBA_fifteenmin = True
|
||||||
|
|
||||||
|
|
||||||
|
if NBA_live_now is False and NBA_games_today is False and games_happened is True:
|
||||||
|
sleep(7200)
|
||||||
|
|
||||||
|
all_settings['leagues']['NBA'][2] = 'no_live'
|
||||||
|
all_settings['leagues']['NBA'][3] = 'no_upcoming'
|
||||||
|
f = open('csv/live_nba.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
|
if NBA_live_now is False and NBA_games_today is False and games_happened is False:
|
||||||
|
all_settings['leagues']['NBA'][2] = 'no_live'
|
||||||
|
all_settings['leagues']['NBA'][3] = 'no_upcoming'
|
||||||
|
f = open('csv/live_nba.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
break
|
189
live_nfl.py
Normal file
@ -0,0 +1,189 @@
|
|||||||
|
from datetime import datetime, timedelta
|
||||||
|
from time import sleep
|
||||||
|
import pytz
|
||||||
|
import json
|
||||||
|
import requests
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def sortevents(leaguedata, league):
|
||||||
|
|
||||||
|
games = []
|
||||||
|
haslive = False
|
||||||
|
|
||||||
|
for event in leaguedata['events']:
|
||||||
|
|
||||||
|
event_desc = event['status']['type']['shortDetail'] # use this to display time and quarter on ticker
|
||||||
|
event_date = event['date'].split('T')[0]
|
||||||
|
event_liveOrNot = event['status']['type']['state'] # use this to determine if game has ended or not
|
||||||
|
if event_liveOrNot == 'in':
|
||||||
|
haslive = True
|
||||||
|
has_live = 'has_live'
|
||||||
|
no_upcoming = 'no_upcoming'
|
||||||
|
|
||||||
|
for home_away in event['competitions']:
|
||||||
|
for home_away2 in home_away['competitors']:
|
||||||
|
if home_away2['homeAway'] == 'away':
|
||||||
|
if home_away2['team']['displayName'] == 'Washington Commanders':
|
||||||
|
away_team = 'Washington'
|
||||||
|
else:
|
||||||
|
away_team = home_away2['team']['displayName']
|
||||||
|
away_score = home_away2['score']
|
||||||
|
else:
|
||||||
|
if home_away2['team']['displayName'] == 'Washington Commanders':
|
||||||
|
home_team = 'Washington'
|
||||||
|
else:
|
||||||
|
home_team = home_away2['team']['displayName']
|
||||||
|
home_score = home_away2['score']
|
||||||
|
|
||||||
|
if datetime.now(pytz.utc).strftime("%Y-%m-%d") == event['date'].split('T')[0] or event['date'].split('T')[0] <= (datetime.strptime(datetime.now(pytz.utc).strftime("%Y-%m-%dT%H:%MZ"), "%Y-%m-%dT%H:%MZ") + timedelta(days=1)).strftime("%Y-%m-%dT%H:%MZ").split('T')[0]:
|
||||||
|
games.append({
|
||||||
|
'home_team': home_team,
|
||||||
|
'home_score': home_score,
|
||||||
|
'away_team': away_team,
|
||||||
|
'away_score': away_score,
|
||||||
|
'time': event_desc,
|
||||||
|
'date': event_date,
|
||||||
|
'isLive': event_liveOrNot
|
||||||
|
})
|
||||||
|
return games, haslive, has_live, no_upcoming
|
||||||
|
|
||||||
|
|
||||||
|
f = open('csv/live_nfl.json', 'r')
|
||||||
|
all_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
nfl_url = "https://site.api.espn.com/apis/site/v2/sports/football/nfl/scoreboard"
|
||||||
|
|
||||||
|
time_now = datetime.now(pytz.utc)
|
||||||
|
time_now2 = time_now.strftime("%Y-%m-%dT%H:%MZ")
|
||||||
|
|
||||||
|
nfl_live_now = False
|
||||||
|
nfl_games_today = False
|
||||||
|
nfl_events = []
|
||||||
|
nfl_fifteenmin = False
|
||||||
|
|
||||||
|
games_happened = False
|
||||||
|
|
||||||
|
try:
|
||||||
|
nfl_response = requests.get(nfl_url)
|
||||||
|
nfl_data = nfl_response.json()
|
||||||
|
except:
|
||||||
|
sleep(120)
|
||||||
|
nfl_response = requests.get(nfl_url)
|
||||||
|
nfl_data = nfl_response.json()
|
||||||
|
|
||||||
|
for event in nfl_data['events']:
|
||||||
|
if event['status']['type']['state'] == 'in':
|
||||||
|
nfl_live_now = True
|
||||||
|
if time_now2.split('T')[0] <= event['date'].split('T')[0] and event['date'].split('T')[0] <= (datetime.strptime(time_now2, "%Y-%m-%dT%H:%MZ") + timedelta(days=1)).strftime("%Y-%m-%dT%H:%MZ").split('T')[0]:
|
||||||
|
nfl_events.append(event['date'])
|
||||||
|
nfl_games_today = True
|
||||||
|
if nfl_live_now is False and ((datetime.strptime(event['date'], "%Y-%m-%dT%H:%MZ") + timedelta(minutes=20)).strftime("%Y-%m-%dT%H:%MZ") >= datetime.now(pytz.utc).strftime("%Y-%m-%dT%H:%MZ")) and (event['date'] <= datetime.now(pytz.utc).strftime("%Y-%m-%dT%H:%MZ")):
|
||||||
|
nfl_fifteenmin = True
|
||||||
|
|
||||||
|
|
||||||
|
while True:
|
||||||
|
f = open('csv/live_nfl.json', 'r')
|
||||||
|
all_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
if nfl_live_now:
|
||||||
|
try:
|
||||||
|
nfl_response = requests.get(nfl_url)
|
||||||
|
nfl_data = nfl_response.json()
|
||||||
|
nfl_sorted = sortevents(nfl_data, 'NFL')
|
||||||
|
all_settings['leagues']['NFL'] = nfl_sorted
|
||||||
|
games_happened = True
|
||||||
|
|
||||||
|
if nfl_sorted[1]:
|
||||||
|
nfl_live_now = True
|
||||||
|
else:
|
||||||
|
nfl_live_now = False
|
||||||
|
|
||||||
|
f = open('csv/live_nfl.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
sleep(120)
|
||||||
|
except:
|
||||||
|
sleep(120)
|
||||||
|
|
||||||
|
elif nfl_fifteenmin:
|
||||||
|
for _ in range (10):
|
||||||
|
try:
|
||||||
|
nfl_response = requests.get(nfl_url)
|
||||||
|
nfl_data = nfl_response.json()
|
||||||
|
nfl_sorted = sortevents(nfl_data, 'NFL')
|
||||||
|
all_settings['leagues']['NFL'] = nfl_sorted
|
||||||
|
|
||||||
|
f = open('csv/live_nfl.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
sleep(120)
|
||||||
|
|
||||||
|
except:
|
||||||
|
sleep(120)
|
||||||
|
|
||||||
|
if nfl_sorted[1]:
|
||||||
|
nfl_live_now = True
|
||||||
|
nfl_fifteenmin = False
|
||||||
|
games_happened = True
|
||||||
|
else:
|
||||||
|
nfl_live_now = False
|
||||||
|
nfl_fifteenmin = False
|
||||||
|
|
||||||
|
else:
|
||||||
|
nfl_events2 = []
|
||||||
|
|
||||||
|
try:
|
||||||
|
for event in nfl_events:
|
||||||
|
if event >= datetime.now(pytz.utc).strftime("%Y-%m-%dT%H:%MZ"):
|
||||||
|
nfl_events2.append(event)
|
||||||
|
nfl_games_today = True
|
||||||
|
next_nfl = min(nfl_events2)
|
||||||
|
d = datetime.strptime(next_nfl, "%Y-%m-%dT%H:%MZ")
|
||||||
|
nfl_time_left = (d - (datetime.strptime(datetime.now(pytz.utc).strftime("%Y-%m-%dT%H:%MZ"), "%Y-%m-%dT%H:%MZ"))).total_seconds()
|
||||||
|
all_settings['leagues']['NFL'][3] = next_nfl
|
||||||
|
|
||||||
|
f = open('csv/live_nfl.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
except:
|
||||||
|
nfl_games_today = False
|
||||||
|
next_nfl = []
|
||||||
|
all_settings['leagues']['NFL'][3] = 'no_upcoming'
|
||||||
|
|
||||||
|
f = open('csv/live_nfl.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
if nfl_games_today:
|
||||||
|
sleep(nfl_time_left)
|
||||||
|
nfl_fifteenmin = True
|
||||||
|
|
||||||
|
|
||||||
|
if nfl_live_now is False and nfl_games_today is False and games_happened is True:
|
||||||
|
sleep(7200)
|
||||||
|
|
||||||
|
all_settings['leagues']['NFL'][2] = 'no_live'
|
||||||
|
all_settings['leagues']['NFL'][3] = 'no_upcoming'
|
||||||
|
|
||||||
|
f = open('csv/live_nfl.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
|
if nfl_live_now is False and nfl_games_today is False and games_happened is False:
|
||||||
|
|
||||||
|
all_settings['leagues']['NFL'][2] = 'no_live'
|
||||||
|
all_settings['leagues']['NFL'][3] = 'no_upcoming'
|
||||||
|
|
||||||
|
f = open('csv/live_nfl.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
break
|
194
live_nhl.py
Normal file
@ -0,0 +1,194 @@
|
|||||||
|
from datetime import datetime, timedelta
|
||||||
|
from time import sleep
|
||||||
|
import pytz
|
||||||
|
import json
|
||||||
|
import requests
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def sortevents(leaguedata, league):
|
||||||
|
|
||||||
|
games = []
|
||||||
|
haslive = False
|
||||||
|
|
||||||
|
for event in leaguedata['events']:
|
||||||
|
|
||||||
|
event_desc = event['status']['type']['shortDetail'] # use this to display time and quarter on ticker
|
||||||
|
event_date = event['date'].split('T')[0]
|
||||||
|
event_liveOrNot = event['status']['type']['state'] # use this to determine if game has ended or not
|
||||||
|
if event_liveOrNot == 'in':
|
||||||
|
haslive = True
|
||||||
|
has_live = 'has_live'
|
||||||
|
no_upcoming = 'no_upcoming'
|
||||||
|
|
||||||
|
for home_away in event['competitions']:
|
||||||
|
for home_away2 in home_away['competitors']:
|
||||||
|
if home_away2['homeAway'] == 'away':
|
||||||
|
if home_away2['team']['displayName'] == 'Washington Commanders':
|
||||||
|
away_team = 'Washington'
|
||||||
|
else:
|
||||||
|
away_team = home_away2['team']['displayName']
|
||||||
|
away_score = home_away2['score']
|
||||||
|
else:
|
||||||
|
if home_away2['team']['displayName'] == 'Washington Commanders':
|
||||||
|
home_team = 'Washington'
|
||||||
|
else:
|
||||||
|
home_team = home_away2['team']['displayName']
|
||||||
|
home_score = home_away2['score']
|
||||||
|
|
||||||
|
if datetime.now(pytz.utc).strftime("%Y-%m-%d") == event['date'].split('T')[0] or event['date'].split('T')[0] <= (datetime.strptime(datetime.now(pytz.utc).strftime("%Y-%m-%dT%H:%MZ"), "%Y-%m-%dT%H:%MZ") + timedelta(days=1)).strftime("%Y-%m-%dT%H:%MZ").split('T')[0]:
|
||||||
|
games.append({
|
||||||
|
'home_team': home_team,
|
||||||
|
'home_score': home_score,
|
||||||
|
'away_team': away_team,
|
||||||
|
'away_score': away_score,
|
||||||
|
'time': event_desc,
|
||||||
|
'date': event_date,
|
||||||
|
'isLive': event_liveOrNot
|
||||||
|
})
|
||||||
|
return games, haslive, has_live, no_upcoming
|
||||||
|
|
||||||
|
|
||||||
|
f = open('csv/live_nhl.json', 'r')
|
||||||
|
all_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
nhl_url = "https://site.api.espn.com/apis/site/v2/sports/hockey/nhl/scoreboard"
|
||||||
|
|
||||||
|
time_now = datetime.now(pytz.utc)
|
||||||
|
time_now2 = time_now.strftime("%Y-%m-%dT%H:%MZ")
|
||||||
|
|
||||||
|
NHL_live_now = False
|
||||||
|
NHL_games_today = False
|
||||||
|
NHL_events = []
|
||||||
|
NHL_fifteenmin = False
|
||||||
|
games_happened = False
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
nhl_response = requests.get(nhl_url)
|
||||||
|
nhl_data = nhl_response.json()
|
||||||
|
except:
|
||||||
|
sleep(120)
|
||||||
|
nhl_response = requests.get(nhl_url)
|
||||||
|
nhl_data = nhl_response.json()
|
||||||
|
|
||||||
|
for event in nhl_data['events']:
|
||||||
|
if event['status']['type']['state'] == 'in':
|
||||||
|
NHL_live_now = True
|
||||||
|
if time_now2.split('T')[0] <= event['date'].split('T')[0] and event['date'].split('T')[0] <= (datetime.strptime(time_now2, "%Y-%m-%dT%H:%MZ") + timedelta(days=1)).strftime("%Y-%m-%dT%H:%MZ").split('T')[0]:
|
||||||
|
NHL_events.append(event['date'])
|
||||||
|
NHL_games_today = True
|
||||||
|
if NHL_live_now is False and ((datetime.strptime(event['date'], "%Y-%m-%dT%H:%MZ") + timedelta(minutes=20)).strftime("%Y-%m-%dT%H:%MZ") >= datetime.now(pytz.utc).strftime("%Y-%m-%dT%H:%MZ")) and (event['date'] <= datetime.now(pytz.utc).strftime("%Y-%m-%dT%H:%MZ")):
|
||||||
|
NHL_fifteenmin = True
|
||||||
|
|
||||||
|
|
||||||
|
while True:
|
||||||
|
f = open('csv/live_nhl.json', 'r')
|
||||||
|
all_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
if NHL_live_now:
|
||||||
|
try:
|
||||||
|
nhl_response = requests.get(nhl_url)
|
||||||
|
nhl_data = nhl_response.json()
|
||||||
|
nhl_sorted = sortevents(nhl_data, 'NHL')
|
||||||
|
all_settings['leagues']['NHL'] = nhl_sorted
|
||||||
|
games_happened = True
|
||||||
|
|
||||||
|
if nhl_sorted[1]:
|
||||||
|
NHL_live_now = True
|
||||||
|
|
||||||
|
else:
|
||||||
|
NHL_live_now = False
|
||||||
|
|
||||||
|
f = open('csv/live_nhl.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
sleep(120)
|
||||||
|
|
||||||
|
except:
|
||||||
|
sleep(120)
|
||||||
|
|
||||||
|
elif NHL_fifteenmin:
|
||||||
|
for _ in range (10):
|
||||||
|
try:
|
||||||
|
nhl_response = requests.get(nhl_url)
|
||||||
|
nhl_data = nhl_response.json()
|
||||||
|
nhl_sorted = sortevents(nhl_data, 'NHL')
|
||||||
|
all_settings['leagues']['NHL'] = nhl_sorted
|
||||||
|
|
||||||
|
f = open('csv/live_nhl.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
sleep(120)
|
||||||
|
|
||||||
|
except:
|
||||||
|
sleep(120)
|
||||||
|
|
||||||
|
if nhl_sorted[1]:
|
||||||
|
NHL_live_now = True
|
||||||
|
NHL_fifteenmin = False
|
||||||
|
games_happened = True
|
||||||
|
|
||||||
|
else:
|
||||||
|
NHL_live_now = False
|
||||||
|
NHL_fifteenmin = False
|
||||||
|
|
||||||
|
else:
|
||||||
|
NHL_events2 = []
|
||||||
|
|
||||||
|
try:
|
||||||
|
for event in NHL_events:
|
||||||
|
if event >= datetime.now(pytz.utc).strftime("%Y-%m-%dT%H:%MZ"):
|
||||||
|
NHL_events2.append(event)
|
||||||
|
NHL_games_today = True
|
||||||
|
next_NHL = min(NHL_events2)
|
||||||
|
d = datetime.strptime(next_NHL, "%Y-%m-%dT%H:%MZ")
|
||||||
|
NHL_time_left = (d - (datetime.strptime(datetime.now(pytz.utc).strftime("%Y-%m-%dT%H:%MZ"), "%Y-%m-%dT%H:%MZ"))).total_seconds()
|
||||||
|
all_settings['leagues']['NHL'][3] = next_NHL
|
||||||
|
|
||||||
|
f = open('csv/live_nhl.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
except:
|
||||||
|
NHL_games_today = False
|
||||||
|
next_NHL = []
|
||||||
|
all_settings['leagues']['NHL'][3] = 'no_upcoming'
|
||||||
|
|
||||||
|
f = open('csv/live_nhl.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
if NHL_games_today:
|
||||||
|
|
||||||
|
sleep(NHL_time_left)
|
||||||
|
NHL_fifteenmin = True
|
||||||
|
|
||||||
|
|
||||||
|
if NHL_live_now is False and NHL_games_today is False and games_happened is True:
|
||||||
|
sleep(7200)
|
||||||
|
|
||||||
|
all_settings['leagues']['NHL'][2] = 'no_live'
|
||||||
|
all_settings['leagues']['NHL'][3] = 'no_upcoming'
|
||||||
|
|
||||||
|
f = open('csv/live_nhl.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
|
if NHL_live_now is False and NHL_games_today is False and games_happened is False:
|
||||||
|
|
||||||
|
all_settings['leagues']['NHL'][2] = 'no_live'
|
||||||
|
all_settings['leagues']['NHL'][3] = 'no_upcoming'
|
||||||
|
|
||||||
|
f = open('csv/live_nhl.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
break
|
193
live_pl.py
Normal file
@ -0,0 +1,193 @@
|
|||||||
|
from datetime import datetime, timedelta
|
||||||
|
from time import sleep
|
||||||
|
import pytz
|
||||||
|
import json
|
||||||
|
import requests
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def sortevents(leaguedata, league):
|
||||||
|
|
||||||
|
games = []
|
||||||
|
haslive = False
|
||||||
|
|
||||||
|
for event in leaguedata['events']:
|
||||||
|
|
||||||
|
event_desc = event['status']['type']['shortDetail'] # use this to display time and quarter on ticker
|
||||||
|
event_date = event['date'].split('T')[0]
|
||||||
|
event_liveOrNot = event['status']['type']['state'] # use this to determine if game has ended or not
|
||||||
|
if event_liveOrNot == 'in':
|
||||||
|
haslive = True
|
||||||
|
has_live = 'has_live'
|
||||||
|
no_upcoming = 'no_upcoming'
|
||||||
|
|
||||||
|
for home_away in event['competitions']:
|
||||||
|
for home_away2 in home_away['competitors']:
|
||||||
|
if home_away2['homeAway'] == 'away':
|
||||||
|
if home_away2['team']['displayName'] == 'Washington Commanders':
|
||||||
|
away_team = 'Washington'
|
||||||
|
else:
|
||||||
|
away_team = home_away2['team']['displayName']
|
||||||
|
away_score = home_away2['score']
|
||||||
|
else:
|
||||||
|
if home_away2['team']['displayName'] == 'Washington Commanders':
|
||||||
|
home_team = 'Washington'
|
||||||
|
else:
|
||||||
|
home_team = home_away2['team']['displayName']
|
||||||
|
home_score = home_away2['score']
|
||||||
|
|
||||||
|
if datetime.now(pytz.utc).strftime("%Y-%m-%d") == event['date'].split('T')[0] or event['date'].split('T')[0] <= (datetime.strptime(datetime.now(pytz.utc).strftime("%Y-%m-%dT%H:%MZ"), "%Y-%m-%dT%H:%MZ") + timedelta(days=1)).strftime("%Y-%m-%dT%H:%MZ").split('T')[0]:
|
||||||
|
games.append({
|
||||||
|
'home_team': home_team,
|
||||||
|
'home_score': home_score,
|
||||||
|
'away_team': away_team,
|
||||||
|
'away_score': away_score,
|
||||||
|
'time': event_desc,
|
||||||
|
'date': event_date,
|
||||||
|
'isLive': event_liveOrNot
|
||||||
|
})
|
||||||
|
return games, haslive, has_live, no_upcoming
|
||||||
|
|
||||||
|
|
||||||
|
f = open('csv/live_pl.json', 'r')
|
||||||
|
all_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
pl_url = "https://site.api.espn.com/apis/site/v2/sports/soccer/eng.1/scoreboard"
|
||||||
|
|
||||||
|
time_now = datetime.now(pytz.utc)
|
||||||
|
time_now2 = time_now.strftime("%Y-%m-%dT%H:%MZ")
|
||||||
|
|
||||||
|
pl_live_now = False
|
||||||
|
pl_games_today = False
|
||||||
|
pl_events = []
|
||||||
|
pl_fifteenmin = False
|
||||||
|
|
||||||
|
games_happened = False
|
||||||
|
|
||||||
|
try:
|
||||||
|
pl_response = requests.get(pl_url)
|
||||||
|
pl_data = pl_response.json()
|
||||||
|
except:
|
||||||
|
sleep(120)
|
||||||
|
pl_response = requests.get(pl_url)
|
||||||
|
pl_data = pl_response.json()
|
||||||
|
|
||||||
|
for event in pl_data['events']:
|
||||||
|
if event['status']['type']['state'] == 'in':
|
||||||
|
pl_live_now = True
|
||||||
|
if time_now2.split('T')[0] <= event['date'].split('T')[0] and event['date'].split('T')[0] <= (datetime.strptime(time_now2, "%Y-%m-%dT%H:%MZ") + timedelta(days=1)).strftime("%Y-%m-%dT%H:%MZ").split('T')[0]:
|
||||||
|
pl_events.append(event['date'])
|
||||||
|
pl_games_today = True
|
||||||
|
if pl_live_now is False and ((datetime.strptime(event['date'], "%Y-%m-%dT%H:%MZ") + timedelta(minutes=20)).strftime("%Y-%m-%dT%H:%MZ") >= datetime.now(pytz.utc).strftime("%Y-%m-%dT%H:%MZ")) and (event['date'] <= datetime.now(pytz.utc).strftime("%Y-%m-%dT%H:%MZ")):
|
||||||
|
pl_fifteenmin = True
|
||||||
|
|
||||||
|
|
||||||
|
while True:
|
||||||
|
f = open('csv/live_pl.json', 'r')
|
||||||
|
all_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
if pl_live_now:
|
||||||
|
try:
|
||||||
|
pl_response = requests.get(pl_url)
|
||||||
|
pl_data = pl_response.json()
|
||||||
|
pl_sorted = sortevents(pl_data, 'PREMIERLEAGUE')
|
||||||
|
all_settings['leagues']['PREMIERLEAGUE'] = pl_sorted
|
||||||
|
games_happened = True
|
||||||
|
|
||||||
|
if pl_sorted[1]:
|
||||||
|
pl_live_now = True
|
||||||
|
else:
|
||||||
|
pl_live_now = False
|
||||||
|
|
||||||
|
f = open('csv/live_pl.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
sleep(120)
|
||||||
|
except:
|
||||||
|
sleep(120)
|
||||||
|
|
||||||
|
|
||||||
|
elif pl_fifteenmin:
|
||||||
|
for _ in range (10):
|
||||||
|
try:
|
||||||
|
pl_response = requests.get(pl_url)
|
||||||
|
pl_data = pl_response.json()
|
||||||
|
pl_sorted = sortevents(pl_data, 'PREMIERLEAGUE')
|
||||||
|
all_settings['leagues']['PREMIERLEAGUE'] = pl_sorted
|
||||||
|
|
||||||
|
f = open('csv/live_pl.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
sleep(120)
|
||||||
|
except:
|
||||||
|
sleep(120)
|
||||||
|
|
||||||
|
if pl_sorted[1]:
|
||||||
|
pl_live_now = True
|
||||||
|
pl_fifteenmin = False
|
||||||
|
games_happened = True
|
||||||
|
|
||||||
|
else:
|
||||||
|
pl_live_now = False
|
||||||
|
pl_fifteenmin = False
|
||||||
|
|
||||||
|
else:
|
||||||
|
pl_events2 = []
|
||||||
|
|
||||||
|
try:
|
||||||
|
for event in pl_events:
|
||||||
|
if event >= datetime.now(pytz.utc).strftime("%Y-%m-%dT%H:%MZ"):
|
||||||
|
pl_events2.append(event)
|
||||||
|
pl_games_today = True
|
||||||
|
next_pl = min(pl_events2)
|
||||||
|
d = datetime.strptime(next_pl, "%Y-%m-%dT%H:%MZ")
|
||||||
|
pl_time_left = (d - (datetime.strptime(datetime.now(pytz.utc).strftime("%Y-%m-%dT%H:%MZ"), "%Y-%m-%dT%H:%MZ"))).total_seconds()
|
||||||
|
all_settings['leagues']['PREMIERLEAGUE'][3] = next_pl
|
||||||
|
|
||||||
|
f = open('csv/live_pl.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
except:
|
||||||
|
pl_games_today = False
|
||||||
|
next_pl = []
|
||||||
|
|
||||||
|
all_settings['leagues']['PREMIERLEAGUE'][3] = 'no_upcoming'
|
||||||
|
|
||||||
|
f = open('csv/live_pl.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
if pl_games_today:
|
||||||
|
sleep(pl_time_left)
|
||||||
|
pl_fifteenmin = True
|
||||||
|
|
||||||
|
|
||||||
|
if pl_live_now is False and pl_games_today is False and games_happened is True:
|
||||||
|
sleep(7200)
|
||||||
|
|
||||||
|
all_settings['leagues']['PREMIERLEAGUE'][2] = 'no_live'
|
||||||
|
all_settings['leagues']['PREMIERLEAGUE'][3] = 'no_upcoming'
|
||||||
|
|
||||||
|
f = open('csv/live_pl.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
|
if pl_live_now is False and pl_games_today is False and games_happened is False:
|
||||||
|
|
||||||
|
all_settings['leagues']['PREMIERLEAGUE'][2] = 'no_live'
|
||||||
|
all_settings['leagues']['PREMIERLEAGUE'][3] = 'no_upcoming'
|
||||||
|
|
||||||
|
f = open('csv/live_pl.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
break
|
BIN
logos/indices/FTSEMIB.MI.png
Normal file
After Width: | Height: | Size: 902 B |
BIN
logos/indices/^IXIC.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
logos/movies/198vrF8k7mfQ4FjDJsBmdQcaiyq.jpg
Normal file
After Width: | Height: | Size: 31 KiB |
BIN
logos/movies/1Iiz2uLcZuLn4Khog2yiKpbl11.jpg
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
logos/movies/24fe6ou97ammOg3O6ShCgaiolp4.jpg
Normal file
After Width: | Height: | Size: 33 KiB |
BIN
logos/movies/6RCf9jzKxyjblYV4CseayK6bcJo.jpg
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
logos/movies/6ovk8nrrSmN1ieT14zBAxcHbMU7.jpg
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
logos/movies/8uyJzaiGbiezZ9K48Cy5wXeqnYw.jpg
Normal file
After Width: | Height: | Size: 44 KiB |
BIN
logos/movies/9I6LgZ5110ycg4pyobJxGTFWFCF.jpg
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
logos/movies/9Md4CqzUGDtK5oEkRRvozLkGc9d.jpg
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
logos/movies/An2M2gm0p8POaiGTcZvP1JnUItH.jpg
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
logos/movies/Yc9q6QuWrMp9nuDm5R8ExNqbEq.jpg
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
logos/movies/bQXAqRx2Fgc46uCVWgoPz5L5Dtr.jpg
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
logos/movies/clO1mWRYT24ogzN3o6LsqHjqrQu.jpg
Normal file
After Width: | Height: | Size: 31 KiB |
BIN
logos/movies/dGOhplPZTL0SKyb0ocTFBHIuKUC.jpg
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
logos/movies/e782pDRAlu4BG0ahd777n8zfPzZ.jpg
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
logos/movies/g9Kb3RaLjsybI1jpqHQ3QZTCYpB.jpg
Normal file
After Width: | Height: | Size: 37 KiB |
BIN
logos/movies/gjNM0odqkq5F7V58OjfTxPJ9p9Z.jpg
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
logos/movies/iHSwvRVsRyxpX7FE7GbviaDvgGZ.jpg
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
logos/movies/nfuPlOK6ywGzKGb0yf7VJKyTFWb.jpg
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
logos/movies/rey2eh6752C2UbGYRileKk1PVTo.jpg
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
logos/movies/uZtYhcnk3WWvUzQkJLqnNywMQpb.jpg
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
logos/sports/league_logos/LPGA.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
logos/sports/league_logos/PGA.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
logos/sports/league_logos/PGA_EU.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
logos/star.png
Normal file
After Width: | Height: | Size: 143 B |
BIN
logos/stocks/AAP.png
Normal file
After Width: | Height: | Size: 4.6 KiB |
BIN
logos/stocks/ACGL.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
logos/stocks/ACVA.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
logos/stocks/AFCG.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
logos/stocks/AHT.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
logos/stocks/AJRD.png
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
logos/stocks/ALNY.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
logos/stocks/AMWD.png
Normal file
After Width: | Height: | Size: 4.3 KiB |
BIN
logos/stocks/APP.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
logos/stocks/APPS.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
logos/stocks/AQN.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
logos/stocks/ARCT.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
logos/stocks/ARWR.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
logos/stocks/ASTE.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
logos/stocks/ATO.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
logos/stocks/ATRO.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
logos/stocks/AVNS.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
logos/stocks/AVY.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
logos/stocks/B.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
logos/stocks/BAND.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
logos/stocks/BBDC.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
logos/stocks/BCPC.png
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
logos/stocks/BERY.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
logos/stocks/BLDR.png
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
logos/stocks/BMRC.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
logos/stocks/BOH.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
logos/stocks/BOLT.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
logos/stocks/BRKR.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
logos/stocks/BURL.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
logos/stocks/BWMN.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
logos/stocks/BYD.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
logos/stocks/CADE.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
logos/stocks/CASY.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
logos/stocks/CBU.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
logos/stocks/CCC.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
logos/stocks/CCS.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
logos/stocks/CG.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
logos/stocks/CHEF.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
logos/stocks/CLFD.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
logos/stocks/CLVS.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
logos/stocks/CLW.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
logos/stocks/CMPS.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
logos/stocks/CMS.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
logos/stocks/CNP.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
logos/stocks/COLD.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
logos/stocks/CONN.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
logos/stocks/CPRI.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
logos/stocks/CPT.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
logos/stocks/CRAI.png
Normal file
After Width: | Height: | Size: 5.5 KiB |
BIN
logos/stocks/CRBP.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
logos/stocks/CRGO.png
Normal file
After Width: | Height: | Size: 4.0 KiB |
BIN
logos/stocks/CRNT.png
Normal file
After Width: | Height: | Size: 2.3 KiB |