def get_events(): """Returns all events events have three "label":"value" pairs game_id - ######## """ event_list = {} for game_id, game_state in raw_events.items(): home, away = parsemlb.pull_team_names(MLB_SOUP, game_id) event_list[game_id] = {'state':game_state, 'teams':{'home':home, 'away':away}} return event_list
def get_events(): """Returns all events events have three "label":"value" pairs game_id - ######## """ event_list = {} for game_id, game_state in raw_events.items(): home, away = parsemlb.pull_team_names(MLB_SOUP, game_id) event_list[game_id] = { 'state': game_state, 'teams': { 'home': home, 'away': away } } return event_list
def get_game_score(game_id): """Returns the home and away team, the game status, and the score""" game_score = {} home, away = parsemlb.pull_team_names(MLB_SOUP, game_id) hrec, arec = parsemlb.pull_team_records(MLB_SOUP, game_id) game_status = parsemlb.pull_game_status(MLB_SOUP, game_id) awayscore, homescore = parsemlb.pull_game_scores(MLB_SOUP, game_id) home_overall_rec, home_away_rec = hrec.strip('()').replace(',', '').split()[:-1] away_overall_rec, away_away_rec = arec.strip('()').replace(',', '').split()[:-1] home_record = { 'overall_record': home_overall_rec, 'away_record': home_away_rec } away_record = { 'overall_record': away_overall_rec, 'away_record': away_away_rec } ascore = {} hscore = {} ascore['runs'], ascore['hits'], ascore['errors'] = awayscore hscore['runs'], hscore['hits'], hscore['errors'] = homescore game_score['home'], game_score['away'] = home, away game_score['away_score'] = ascore game_score['home_score'] = hscore game_score['home_record'] = home_record game_score['away_record'] = away_record #for preview games the status is a time, i.e. 9:00PM ET, it may be a good #idea to convert this to a more standard time measurement at some point game_score['status'] = game_status game_score['state'] = raw_events[game_id] return game_score
def get_game_score(game_id): """Returns the home and away team, the game status, and the score""" game_score = {} home, away = parsemlb.pull_team_names(MLB_SOUP, game_id) hrec, arec = parsemlb.pull_team_records(MLB_SOUP, game_id) game_status = parsemlb.pull_game_status(MLB_SOUP, game_id) awayscore, homescore = parsemlb.pull_game_scores(MLB_SOUP, game_id) home_overall_rec, home_away_rec = hrec.strip('()').replace(',', '').split()[:-1] away_overall_rec, away_away_rec = arec.strip('()').replace(',', '').split()[:-1] home_record = {'overall_record':home_overall_rec, 'away_record':home_away_rec} away_record = {'overall_record':away_overall_rec, 'away_record':away_away_rec} ascore = {} hscore = {} ascore['runs'], ascore['hits'], ascore['errors'] = awayscore hscore['runs'], hscore['hits'], hscore['errors'] = homescore game_score['home'], game_score['away'] = home, away game_score['away_score'] = ascore game_score['home_score'] = hscore game_score['home_record'] = home_record game_score['away_record'] = away_record #for preview games the status is a time, i.e. 9:00PM ET, it may be a good #idea to convert this to a more standard time measurement at some point game_score['status'] = game_status game_score['state'] = raw_events[game_id] return game_score