diff --git a/data/game.py b/data/game.py index 9996bec4..29119ab5 100644 --- a/data/game.py +++ b/data/game.py @@ -19,7 +19,7 @@ SCHEDULE_API_FIELDS = "dates,date,games,status,detailedState,abstractGameState,reason" -GAME_UPDATE_RATE = 10 +GAME_UPDATE_RATE = 7 class Game: @@ -45,6 +45,7 @@ def __init__(self, game_id, date, broadcasts, series_status, delay_in_10s_of_sec self._broadcasts = broadcasts self._series_status = series_status self._status = {} + print(self.game_id) def update(self, force=False) -> UpdateStatus: if force or self.__should_update(): @@ -314,6 +315,105 @@ def current_play_result(self): in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "") ): result += "_looking" + elif result == "field_out" and ( + "flies" + in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "") + ): + result += "_fly" + elif result == "field_out" and ( + "grounds" + in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "") + ): + result += "_ground" + elif result == "field_out" and ( + "lines" + in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "") + ): + result += "_line" + elif result == "field_out" and ( + "pop" + in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "") + ): + result += "_pop" + elif result == "field_out" and ( + "scores" + in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "") + ): + result += "_rbi" + + if result == "field_out_fly" and ( + "scores" + in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "") + ): + result += "_rbi" + elif result == "field_out_ground" and ( + "scores" + in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "") + ): + result += "_rbi" + elif result == "field_out_line" and ( + "scores" + in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "") + ): + result += "_rbi" + elif result == "field_out_pop" and ( + "scores" + in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "") + ): + result += "_rbi" + + if result == "sacrifice_fly" and ( + "scores" + in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "") + ): + result += "_rbi" + elif result == "sacrifice_bunt" and ( + "scores" + in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "") + ): + result += "_rbi" + + if result == "single" and ( + "scores" + in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "") + ): + result += "_rbi" + elif result == "double" and ( + "scores" + in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "") + ): + result += "_rbi" + elif result == "triple" and ( + "scores" + in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "") + ): + result += "_rbi" + elif result == "walk" and ( + "scores" + in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "") + ): + result += "_rbi" + elif result == "hit_by_pitch" and ( + "scores" + in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "") + ): + result += "_rbi" + + if result == "home_run" and ( + "2" + in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("rbi", "") + ): + result += "_2" + elif result == "home_run" and ( + "3" + in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("rbi", "") + ): + result += "_3" + elif result == "home_run" and ( + "4" + in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("rbi", "") + ): + result += "_4" return result def __should_update(self): diff --git a/data/plays.py b/data/plays.py index c1701093..ef3c2010 100644 --- a/data/plays.py +++ b/data/plays.py @@ -1,37 +1,103 @@ SINGLE = "single" DOUBLE = "double" TRIPLE = "triple" -HOME_RUN = "home_run" + +STOLEN_BASE_2B = "stolen_base_2b" +STOLEN_BASE_3B = "stolen_base_3b" +STOLEN_BASE_HOME = "stolen_base_home" WALK = "walk" INTENTIONAL_WALK = "intent_walk" HIT_BY_PITCH = "hit_by_pitch" +SINGLE_RBI = "single_rbi" +DOUBLE_RBI = "double_rbi" +TRIPLE_RBI = "triple_rbi" +WALK_RBI = "walk_rbi" +HIT_BY_PITCH_RBI = "hit_by_pitch_rbi" + +FIELD_OUT_RBI = "field_out_rbi" +FIELD_OUT_FLY_RBI = "field_out_fly_rbi" +FIELD_OUT_LINE_RBI = "field_out_line_rbi" +FIELD_OUT_GROUND_RBI = "field_out_ground_rbi" +FIELD_OUT_POP_RBI = "field_out_pop_rbi" + +HOME_RUN = "home_run" +HOME_RUN_2 = "home_run_2" +HOME_RUN_3 = "home_run_3" +HOME_RUN_4 = "home_run_4" + +SACRIFICE_BUNT = "sac_bunt" +SACRIFICE_FLY = "sac_fly" +SACRIFICE_BUNT_RBI = "sac_bunt_rbi" +SACRIFICE_FLY_RBI = "sac_fly_rbi" + +ERROR = "error" +FIELDERS_CHOICE = "fielders_choice" + STRIKEOUT = "strikeout" STRIKEOUT_ALT = "strike_out" STRIKEOUT_LOOKING = "strikeout_looking" -ERROR = "error" -FIELDERS_CHOICE = "fielders_choice" +FIELD_OUT = "field_out" +FIELD_OUT_FLY = "field_out_fly" +FIELD_OUT_LINE = "field_out_line" +FIELD_OUT_GROUND = "field_out_ground" +FIELD_OUT_POP = "field_out_pop" -HITS = [SINGLE, DOUBLE, TRIPLE] +DOUBLE_PLAY = "double_play" +DOUBLE_PLAY_ALT = "grounded_into_double_play" -WALKS = [WALK, INTENTIONAL_WALK, HIT_BY_PITCH] +HITS = [SINGLE, DOUBLE, TRIPLE, HOME_RUN, HOME_RUN_2, HOME_RUN_3, HOME_RUN_4, SINGLE_RBI, DOUBLE_RBI, TRIPLE_RBI, WALK_RBI, SACRIFICE_FLY_RBI, SACRIFICE_BUNT_RBI, FIELD_OUT, FIELD_OUT_FLY, FIELD_OUT_LINE, FIELD_OUT_GROUND, FIELD_OUT_POP, SACRIFICE_BUNT, SACRIFICE_FLY, ERROR, FIELDERS_CHOICE, DOUBLE_PLAY, DOUBLE_PLAY_ALT] -OTHERS = [ERROR, FIELDERS_CHOICE] +WALKS = [WALK, INTENTIONAL_WALK, HIT_BY_PITCH, STOLEN_BASE_2B, STOLEN_BASE_3B, STOLEN_BASE_HOME, WALK_RBI] + +OUTS = [FIELD_OUT, FIELD_OUT_FLY, FIELD_OUT_LINE, FIELD_OUT_GROUND, FIELD_OUT_POP, DOUBLE_PLAY, DOUBLE_PLAY_ALT] STRIKEOUTS = [STRIKEOUT, STRIKEOUT_ALT, STRIKEOUT_LOOKING] +SCORING = [HOME_RUN, HOME_RUN_2, HOME_RUN_3, HOME_RUN_4, SINGLE_RBI, DOUBLE_RBI, TRIPLE_RBI, STOLEN_BASE_HOME, WALK_RBI, HIT_BY_PITCH_RBI, SACRIFICE_FLY_RBI, SACRIFICE_BUNT_RBI, FIELD_OUT_FLY_RBI, FIELD_OUT_LINE_RBI, FIELD_OUT_GROUND_RBI, FIELD_OUT_POP_RBI, FIELD_OUT_RBI] + +OTHERS = [ERROR, FIELDERS_CHOICE] + PLAY_RESULTS = { SINGLE: {"short": "1B", "long": "Single"}, DOUBLE: {"short": "2B", "long": "Double"}, TRIPLE: {"short": "3B", "long": "Triple"}, + HOME_RUN: {"short": "HR", "long": "Home Run"}, + HOME_RUN_2: {"short": "HR", "long": "HomeRun!"}, + HOME_RUN_3: {"short": "HR", "long": "HomeRn!!"}, + HOME_RUN_4: {"short": "GS", "long": "GrndSlam"}, WALK: {"short": "BB", "long": "Walk"}, - INTENTIONAL_WALK: {"short": "IBB", "long": "Int. Walk"}, - STRIKEOUT: {"short": "K", "long": "K"}, - STRIKEOUT_ALT: {"short": "K", "long": "K"}, - STRIKEOUT_LOOKING: {"short": "ꓘ", "long": "ꓘ"}, + INTENTIONAL_WALK: {"short": "IBB", "long": "Int Walk"}, + STRIKEOUT: {"short": "K", "long": "StrKeout"}, + STRIKEOUT_ALT: {"short": "K", "long": "StrKeout"}, + STRIKEOUT_LOOKING: {"short": "ꓘ", "long": "Strꓘeout"}, HIT_BY_PITCH: {"short": "HBP", "long": "Hit Bttr"}, ERROR: {"short": "E", "long": "Error"}, - FIELDERS_CHOICE: {"short": "FC", "long": "Fielder's Chc"}, + FIELDERS_CHOICE: {"short": "FC", "long": "Fld Chce"}, + FIELD_OUT_FLY: {"short": "FO", "long": "Flyout"}, + FIELD_OUT_LINE: {"short": "LO", "long": "Lineout"}, + FIELD_OUT_GROUND: {"short": "GO", "long": "Grndout"}, + FIELD_OUT_POP: {"short": "PO", "long": "Popout"}, + FIELD_OUT: {"short": "O", "long": "Out"}, + DOUBLE_PLAY: {"short": "DP", "long": "Dbl Play"}, + DOUBLE_PLAY_ALT: {"short": "DP", "long": "Dbl Play"}, + SACRIFICE_BUNT: {"short": "ScB", "long": "Sac Bunt"}, + SACRIFICE_BUNT_RBI: {"short": "ScB", "long": "RBI SBnt"}, + SACRIFICE_FLY: {"short": "ScF", "long": "Sac Fly"}, + SACRIFICE_FLY_RBI: {"short": "ScF", "long": "RBI SFly"}, + SINGLE_RBI: {"short": "1B", "long": "RBI Sngl"}, + DOUBLE_RBI: {"short": "2B", "long": "RBI Dble"}, + TRIPLE_RBI: {"short": "3B", "long": "RBI Trpl"}, + WALK_RBI: {"short": "BB", "long": "RBI Walk"}, + HIT_BY_PITCH_RBI: {"short": "HBP", "long": "RBI HBP"}, + STOLEN_BASE_2B: {"short": "SB", "long": "Stoln Bs"}, + STOLEN_BASE_3B: {"short": "SB", "long": "Stoln Bs"}, + STOLEN_BASE_HOME: {"short": "SB", "long": "Stl Home"}, + FIELD_OUT_FLY_RBI: {"short": "FO", "long": "RBI FlyO"}, + FIELD_OUT_LINE_RBI: {"short": "LO", "long": "RBI LneO"}, + FIELD_OUT_GROUND_RBI: {"short": "GO", "long": "RBI GrdO"}, + FIELD_OUT_POP_RBI: {"short": "PO", "long": "RBI PopO"}, + FIELD_OUT_RBI: {"short": "O", "long": "RBI Out"}, }