Last active
October 5, 2018 21:59
-
-
Save sleggett/f09c0e5e01e67e7e1174f8d2905430ce to your computer and use it in GitHub Desktop.
nba_led
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Game import Game | |
from nba_api.stats.endpoints import scoreboardv2 | |
import time | |
import datetime | |
today = datetime.date.today() #setting todays date | |
#today = '2018-10-04' #use to test past/future events | |
df_today_games = scoreboardv2.ScoreboardV2('0', today, '00').game_header.get_data_frame() #finds games for specific day and includes live status, periods | |
total_games = len(df_today_games.index) | |
ls_games = [Game() for i in range(total_games)] #create list for game objects | |
# #setting game id for each game in ls | |
for i in range(0, total_games):#needs to be changed back to total games | |
ls_games[i].get_game_stats(df_today_games.iloc[i]) | |
df_today_games = scoreboardv2.ScoreboardV2('0', today, '00').game_header.get_data_frame() #finds games for specific day and includes live status, periods | |
games_live = False | |
games_remain = True | |
status_check = 0 | |
while games_remain: | |
final_count = 0 | |
any_live = 0 | |
for i in range(0, total_games): | |
ls_games[i].game_status = df_today_games.iloc[i]["GAME_STATUS_ID"] | |
ls_games[i].get_live_stats() | |
ls_games[i].print_scoreboard() | |
if ls_games[i].game_status == 3: | |
final_count = final_count + 1 | |
if ls_games[i].game_status == 2: | |
any_live = any_live + 1 | |
if final_count == total_games: | |
break | |
time.sleep(15) | |
if status_check >= 8: | |
df_today_games = scoreboardv2.ScoreboardV2('0', today, '00').game_header.get_data_frame() # finds games for specific day and includes live status, periods | |
status_check = 0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment