# check if in season season = nhl.check_season() if season: # check game gameday = nhl.check_if_game(team_id) if gameday: # check end of game game_end = nhl.check_game_end(team_id) if not game_end: # Check CAR score online and save score new_score = nhl.fetch_score(team_id) # new function fetch_game(team_id) # returns home_score, home_team, away_score, away_team try: home_score, home_team, away_score, away_team, live_stats_link = nhl.fetch_game( team_id) except: print("nhl.fetch_game error encountered") # print("Home team: {0} Home score: {1} Away team: {2} Away score: {3}".format( teams[home_team], home_score, teams[away_team], away_score)) # get stats from the game try: current_period, home_sog, away_sog, home_powerplay, away_powerplay, time_remaining = nhl.fetch_live_stats( live_stats_link) except:
def score(team_id): # Fetch and return the current score of the team response = { 'score': nhl.fetch_score(team_id) } return jsonify(response)
# check if in season season = nhl.check_season() if season: # check game gameday = nhl.check_if_game(team_id) if gameday: # check end of game game_end = nhl.check_game_end(team_id) if not game_end: # Check score online and save score new_score = nhl.fetch_score(team_id) # If score change... if new_score != old_score: time.sleep(delay) if new_score > old_score: # save new score print("GOAL!") # activate_goal_light() light.activate_goal_light() old_score = new_score else: print("Game Over!") old_score = 0 # Reset for new game
season = nhl.check_season() if season: # check game gameday = nhl.check_if_game(team_id) if gameday: # check end of game game_end = nhl.check_game_end(team_id) opposition_id = nhl.get_opposition_id(team_id) if not game_end: # Check score online and save score new_score = nhl.fetch_score(team_id) new_opposition_score = nhl.fetch_score(opposition_id) light.writeScore(new_score) light.writeOppositionScore(new_opposition_score) # If score change... if new_opposition_score != old_opposition_score: print("Opposition Scores: {0}".format( new_opposition_score)) light.writeOppositionScore(new_opposition_score) if new_score != old_score: time.sleep(delay) if new_score > old_score: # save new score print("GOAL!")