PARSING_SCHEME = {
    'name': 'a',
    'league': 'td[data-stat="lg_ID"]:first',
    'games': 'td[data-stat="G"]:first',
    'wins': 'td[data-stat="W"]:first',
    'losses': 'td[data-stat="L"]:first',
    'win_percentage': 'td[data-stat="win_loss_perc"]:first',
    'streak': 'td[data-stat="winning_streak"]:first',
    'runs': 'td[data-stat="R"]:first',
    'runs_against': 'td[data-stat="RA"]:first',
    'run_difference': 'td[data-stat="run_diff"]:first',
    'strength_of_schedule': 'td[data-stat="strength_of_schedule"]:first',
    'simple_rating_system': 'td[data-stat="simple_rating_system"]:first',
    'pythagorean_win_loss': 'td[data-stat="record_pythag"]:first',
    'luck': 'td[data-stat="luck_pythag"]:first',
    'interleague_record': 'td[data-stat="record_interleague"]:first',
    'home_record': 'td[data-stat="record_home"]:first',
    'away_record': 'td[data-stat="record_road"]:first',
    'extra_inning_record': 'td[data-stat="record_xinn"]:first',
    'single_run_record': 'td[data-stat="record_one_run"]:first',
    'record_vs_right_handed_pitchers': 'td[data-stat="record_vs_rhp"]:first',
    'record_vs_left_handed_pitchers': 'td[data-stat="record_vs_lhp"]:first',
    'record_vs_teams_over_500': 'td[data-stat="record_vs_over_500"]:first',
    'record_vs_teams_under_500': 'td[data-stat="record_vs_under_500"]:first',
    'last_ten_games_record': 'td[data-stat="record_last_10"]:first',
    'last_twenty_games_record': 'td[data-stat="record_last_20"]:first',
    'last_thirty_games_record': 'td[data-stat="record_last_30"]:first',
    'number_players_used': 'td[data-stat="batters_used"]:first',
    'average_batter_age': 'td[data-stat="age_bat"]:first',
    'plate_appearances': 'td[data-stat="PA"]:first',
    'at_bats': 'td[data-stat="AB"]:first',
    'total_runs': 'td[data-stat="R"]:first',
    'hits': 'td[data-stat="H"]:first',
    'doubles': 'td[data-stat="2B"]:first',
    'triples': 'td[data-stat="3B"]:first',
    'home_runs': 'td[data-stat="HR"]:first',
    'runs_batted_in': 'td[data-stat="RBI"]:first',
    'stolen_bases': 'td[data-stat="SB"]:first',
    'times_caught_stealing': 'td[data-stat="CS"]:first',
    'bases_on_balls': 'td[data-stat="BB"]:first',
    'times_struck_out': 'td[data-stat="SO"]:first',
    'batting_average': 'td[data-stat="batting_avg"]:first',
    'on_base_percentage': 'td[data-stat="onbase_perc"]:first',
    'slugging_percentage': 'td[data-stat="slugging_perc"]:first',
    'on_base_plus_slugging_percentage':
    'td[data-stat="onbase_plus_slugging"]:first',
    'on_base_plus_slugging_percentage_plus':
    'td[data-stat="onbase_plus_slugging_plus"]:first',
    'total_bases': 'td[data-stat="TB"]:first',
    'grounded_into_double_plays': 'td[data-stat="GIDP"]:first',
    'times_hit_by_pitch': 'td[data-stat="HBP"]:first',
    'sacrifice_hits': 'td[data-stat="SH"]:first',
    'sacrifice_flies': 'td[data-stat="SF"]:first',
    'intentional_bases_on_balls': 'td[data-stat="IBB"]:first',
    'runners_left_on_base': 'td[data-stat="LOB"]:first',
    'number_of_pitchers': 'td[data-stat="pitchers_used"]:first',
    'average_pitcher_age': 'td[data-stat="age_pitch"]:first',
    'runs_allowed_per_game': 'td[data-stat="runs_allowed_per_game"]:first',
    'earned_runs_against': 'td[data-stat="earned_run_avg"]:first',
    'games_finished': 'td[data-stat="GF"]:first',
    'complete_games': 'td[data-stat="CG"]:first',
    'shutouts': 'td[data-stat="SHO_team"]:first',
    'complete_game_shutouts': 'td[data-stat="SHO_cg"]:first',
    'saves': 'td[data-stat="SV"]:first',
    'innings_pitched': 'td[data-stat="IP"]:first',
    'hits_allowed': 'td[data-stat="H"]:first',
    'home_runs_against': 'td[data-stat="HR"]:first',
    'bases_on_walks_given': 'td[data-stat="BB"]:first',
    'strikeouts': 'td[data-stat="SO"]:first',
    'hit_pitcher': 'td[data-stat="HBP"]:first',
    'balks': 'td[data-stat="BK"]:first',
    'wild_pitches': 'td[data-stat="WP"]:first',
    'batters_faced': 'td[data-stat="batters_faced"]:first',
    'earned_runs_against_plus': 'td[data-stat="earned_run_avg_plus"]:first',
    'fielding_independent_pitching': 'td[data-stat="fip"]:first',
    'whip': 'td[data-stat="whip"]:first',
    'hits_per_nine_innings': 'td[data-stat="hits_per_nine"]:first',
    'home_runs_per_nine_innings': 'td[data-stat="home_runs_per_nine"]:first',
    'bases_on_walks_given_per_nine_innings':
    'td[data-stat="bases_on_balls_per_nine"]:first',
    'strikeouts_per_nine_innings': 'td[data-stat="strikeouts_per_nine"]:first',
    'strikeouts_per_base_on_balls':
    'td[data-stat="strikeouts_per_base_on_balls"]:first',
    'opposing_runners_left_on_base': 'td[data-stat="LOB"]:first'
}

SCHEDULE_SCHEME = {
    'game': 'th[data-stat="team_game"]:first',
    'date': 'td[data-stat="date_game"]:first',
    'location': 'td[data-stat="homeORvis"]:first',
    'opponent_abbr': 'td[data-stat="opp_ID"]:first',
    'result': 'td[data-stat="win_loss_result"]:first',
    'runs_scored': 'td[data-stat="R"]:first',
    'runs_allowed': 'td[data-stat="RA"]:first',
    'innings': 'td[data-stat="extra_innings"]:first',
    'record': 'td[data-stat="win_loss_record"]:first',
    'rank': 'td[data-stat="rank"]:first',
    'games_behind': 'td[data-stat="games_back"]:first',
    'winner': 'td[data-stat="winning_pitcher"]:first',
    'loser': 'td[data-stat="losing_pitcher"]:first',
    'save': 'td[data-stat="saving_pitcher"]:first',
    'game_duration': 'td[data-stat="time_of_game"]:first',
    'day_or_night': 'td[data-stat="day_or_night"]:first',
    'attendance': 'td[data-stat="attendance"]:first',
    'streak': 'td[data-stat="win_loss_streak"]:first'
}

ELEMENT_INDEX = {
    'total_runs': 1,
    'bases_on_walks_given': 1,
    'hits_allowed': 1,
    'strikeouts': 1,
    'home_runs_against': 1,
    'opposing_runners_left_on_base': 1
}

BOXSCORE_SCHEME = {
    'date': 'div[class="scorebox_meta"]',
    'time': 'div[class="scorebox_meta"]',
    'attendance': 'div[class="scorebox_meta"]',
    'venue': 'div[class="scorebox_meta"]',
    'time_of_day': 'div[class="scorebox_meta"]',
    'duration': 'div[class="scorebox_meta"]',
    'away_name': 'a[itemprop="name"]:first',
    'home_name': 'a[itemprop="name"]:last',
    'winner': 'td[data-stat=""]',
    'winning_name': 'td[data-stat=""]',
    'winning_abbr': 'td[data-stat=""]',
    'losing_name': 'td[data-stat=""]',
    'losing_abbr': 'td[data-stat=""]',
    'losing_abbr': 'td[data-stat=""]',
    'away_at_bats': 'tfoot td[data-stat="AB"]',
    'away_runs': 'tfoot td[data-stat="R"]',
    'away_hits': 'tfoot td[data-stat="H"]',
    'away_rbi': 'tfoot td[data-stat="RBI"]',
    'away_earned_runs': 'tfoot td[data-stat="earned_run_avg"]',
    'away_bases_on_balls': 'tfoot td[data-stat="BB"]',
    'away_strikeouts': 'tfoot td[data-stat="SO"]',
    'away_plate_appearances': 'tfoot td[data-stat="PA"]',
    'away_batting_average': 'tfoot td[data-stat="batting_avg"]',
    'away_on_base_percentage': 'tfoot td[data-stat="onbase_perc"]',
    'away_slugging_percentage': 'tfoot td[data-stat="slugging_perc"]',
    'away_on_base_plus': 'tfoot td[data-stat="onbase_plus_slugging"]',
    'away_pitches': 'tfoot td[data-stat="pitches"]',
    'away_strikes': 'tfoot td[data-stat="strikes_total"]',
    'away_win_probability_for_offensive_player':
    'tfoot td[data-stat="wpa_bat"]',
    'away_average_leverage_index': 'tfoot td[data-stat="leverage_index_avg"]',
    'away_win_probability_added': 'tfoot td[data-stat="wpa_bat_pos"]',
    'away_win_probability_subtracted': 'tfoot td[data-stat="wpa_bat_neg"]',
    'away_base_out_runs_added': 'tfoot td[data-stat="re24_bat"]',
    'away_putouts': 'tfoot td[data-stat="PO"]',
    'away_assists': 'tfoot td[data-stat="A"]',
    'away_innings_pitched': 'tfoot td[data-stat="IP"]',
    'away_home_runs': 'tfoot td[data-stat="HR"]',
    'away_strikes_by_contact': 'tfoot td[data-stat="strikes_contact"]',
    'away_strikes_swinging': 'tfoot td[data-stat="strikes_swinging"]',
    'away_strikes_looking': 'tfoot td[data-stat="strikes_looking"]',
    'away_grounded_balls': 'tfoot td[data-stat="inplay_gb_total"]',
    'away_fly_balls': 'tfoot td[data-stat="inplay_fb_total"]',
    'away_line_drives': 'tfoot td[data-stat="inplay_ld"]',
    'away_unknown_bat_type': 'tfoot td[data-stat="inplay_unk"]',
    'away_game_score': 'tfoot td[data-stat="game_score"]',
    'away_inherited_runners': 'tfoot td[data-stat="inherited_runners"]',
    'away_inherited_score': 'tfoot td[data-stat="inherited_score"]',
    'away_win_probability_by_pitcher': 'tfoot td[data-stat="wpa_def"]',
    'away_average_leverage_index': 'tfoot td[data-stat="leverage_index_avg"]',
    'away_base_out_runs_saved': 'tfoot td[data-stat="re24_def"]',
    'home_at_bats': 'tfoot td[data-stat="AB"]',
    'home_runs': 'tfoot td[data-stat="R"]',
    'home_hits': 'tfoot td[data-stat="H"]',
    'home_rbi': 'tfoot td[data-stat="RBI"]',
    'home_earned_runs': 'tfoot td[data-stat="earned_run_avg"]',
    'home_bases_on_balls': 'tfoot td[data-stat="BB"]',
    'home_strikeouts': 'tfoot td[data-stat="SO"]',
    'home_plate_appearances': 'tfoot td[data-stat="PA"]',
    'home_batting_average': 'tfoot td[data-stat="batting_avg"]',
    'home_on_base_percentage': 'tfoot td[data-stat="onbase_perc"]',
    'home_slugging_percentage': 'tfoot td[data-stat="slugging_perc"]',
    'home_on_base_plus': 'tfoot td[data-stat="onbase_plus_slugging"]',
    'home_pitches': 'tfoot td[data-stat="pitches"]',
    'home_strikes': 'tfoot td[data-stat="strikes_total"]',
    'home_win_probability_for_offensive_player':
    'tfoot td[data-stat="wpa_bat"]',
    'home_average_leverage_index': 'tfoot td[data-stat="leverage_index_avg"]',
    'home_win_probability_added': 'tfoot td[data-stat="wpa_bat_pos"]',
    'home_win_probability_subtracted': 'tfoot td[data-stat="wpa_bat_neg"]',
    'home_base_out_runs_added': 'tfoot td[data-stat="re24_bat"]',
    'home_putouts': 'tfoot td[data-stat="PO"]',
    'home_assists': 'tfoot td[data-stat="A"]',
    'home_innings_pitched': 'tfoot td[data-stat="IP"]',
    'home_home_runs': 'tfoot td[data-stat="HR"]',
    'home_strikes_by_contact': 'tfoot td[data-stat="strikes_contact"]',
    'home_strikes_swinging': 'tfoot td[data-stat="strikes_swinging"]',
    'home_strikes_looking': 'tfoot td[data-stat="strikes_looking"]',
    'home_grounded_balls': 'tfoot td[data-stat="inplay_gb_total"]',
    'home_fly_balls': 'tfoot td[data-stat="inplay_fb_total"]',
    'home_line_drives': 'tfoot td[data-stat="inplay_ld"]',
    'home_unknown_bat_type': 'tfoot td[data-stat="inplay_unk"]',
    'home_game_score': 'tfoot td[data-stat="game_score"]',
    'home_inherited_runners': 'tfoot td[data-stat="inherited_runners"]',
    'home_inherited_score': 'tfoot td[data-stat="inherited_score"]',
    'home_win_probability_by_pitcher': 'tfoot td[data-stat="wpa_def"]',
    'home_average_leverage_index': 'tfoot td[data-stat="leverage_index_avg"]',
    'home_base_out_runs_saved': 'tfoot td[data-stat="re24_def"]'
}

BOXSCORE_ELEMENT_INDEX = {
    'date': 0,
    'time': 1,
    'attendance': 2,
    'venue': 3,
    'duration': 4,
    'time_of_day': 5,
    'away_at_bats': 0,
    'away_runs': 0,
    'away_hits': 0,
    'away_rbi': 0,
    'away_earned_runs': 1,
    'away_bases_on_balls': 0,
    'away_strikeouts': 0,
    'away_plate_appearances': 0,
    'away_batting_average': 0,
    'away_on_base_percentage': 0,
    'away_slugging_percentage': 0,
    'away_on_base_plus': 0,
    'away_pitches': 1,
    'away_strikes': 0,
    'away_win_probability_for_offensive_player': 0,
    'away_average_leverage_index': 1,
    'away_win_probability_added': 0,
    'away_win_probability_subtracted': 0,
    'away_base_out_runs_added': 0,
    'away_putouts': 0,
    'away_assists': 0,
    'away_innings_pitched': 0,
    'away_home_runs': 0,
    'away_strikes_by_contact': 1,
    'away_strikes_swinging': 1,
    'away_strikes_looking': 1,
    'away_grounded_balls': 1,
    'away_fly_balls': 1,
    'away_line_drives': 1,
    'away_unknown_bat_type': 1,
    'away_game_score': 0,
    'away_inherited_runners': 0,
    'away_inherited_score': 0,
    'away_win_probability_by_pitcher': 0,
    'away_base_out_runs_saved': 0,
    'home_at_bats': 1,
    'home_runs': 1,
    'home_hits': 1,
    'home_rbi': 1,
    'home_earned_runs': 0,
    'home_bases_on_balls': 1,
    'home_strikeouts': 1,
    'home_plate_appearances': 1,
    'home_batting_average': 1,
    'home_on_base_percentage': 1,
    'home_slugging_percentage': 1,
    'home_on_base_plus': 1,
    'home_pitches': 0,
    'home_strikes': 1,
    'home_win_probability_for_offensive_player': 1,
    'home_average_leverage_index': 0,
    'home_win_probability_added': 1,
    'home_win_probability_subtracted': 1,
    'home_base_out_runs_added': 1,
    'home_putouts': 1,
    'home_assists': 1,
    'home_innings_pitched': 1,
    'home_home_runs': 1,
    'home_strikes_by_contact': 0,
    'home_strikes_swinging': 0,
    'home_strikes_looking': 0,
    'home_grounded_balls': 0,
    'home_fly_balls': 0,
    'home_line_drives': 0,
    'home_unknown_bat_type': 0,
    'home_game_score': 1,
    'home_inherited_runners': 1,
    'home_inherited_score': 1,
    'home_win_probability_by_pitcher': 1,
    'home_base_out_runs_saved': 1
}

DOUBLE_HEADER_INDICES = {
    'time': 'start time',
    'attendance': 'attendance',
    'venue': 'venue',
    'duration': 'game duration'
}

STANDINGS_URL = ('https://www.baseball-reference.com/leagues/MLB/'
                 '%s-standings.shtml')
TEAM_STATS_URL = 'https://www.baseball-reference.com/leagues/MLB/%s.shtml'

SCHEDULE_URL = ('https://www.baseball-reference.com/teams/%s/'
                '%s-schedule-scores.shtml')

BOXSCORE_URL = 'https://www.baseball-reference.com/boxes/%s.shtml'

BOXSCORES_URL = ('https://www.baseball-reference.com/boxes/'
                 '?year=%s&month=%s&day=%s')

NIGHT = 'Night'
DAY = 'Day'
