Spaces:
Running
Running
James McCool commited on
Commit ·
7feab37
1
Parent(s): b68a706
Adding support to send NCAA FSR IDs into the draft guide staging sheet.
Browse files
app.py
CHANGED
|
@@ -50,6 +50,74 @@ projections_options = ['Aggregate', 'Kickers', 'Defenses']
|
|
| 50 |
projections_replacements = ['aggregate', 'kickers', 'defenses']
|
| 51 |
data_update_options = ['Betting Model', 'DFS', 'DVP', 'Strength of Sched', 'Air Yards', 'FAAB']
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
def grab_sr_fa(headers: dict) -> pd.DataFrame:
|
| 55 |
sr_fas = "https://api.sportradar.com/nfl/official/trial/v7/en/league/free_agents.json"
|
|
@@ -643,6 +711,19 @@ with tab3:
|
|
| 643 |
st.write("Updated Freedman Season Long NFL SR IDs")
|
| 644 |
|
| 645 |
st.success("SR IDs updated successfully")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 646 |
|
| 647 |
with tab4:
|
| 648 |
st.info("We will add this functionality as soon as we have the endpoints to make it work!")
|
|
|
|
| 50 |
projections_replacements = ['aggregate', 'kickers', 'defenses']
|
| 51 |
data_update_options = ['Betting Model', 'DFS', 'DVP', 'Strength of Sched', 'Air Yards', 'FAAB']
|
| 52 |
|
| 53 |
+
def grab_sr_ncaaf_ids(headers: dict) -> pd.DataFrame:
|
| 54 |
+
url = "https://api.sportradar.com/ncaafb/trial/v7/en/league/hierarchy.json"
|
| 55 |
+
response = requests.get(url, headers=headers)
|
| 56 |
+
data = response.json()
|
| 57 |
+
print(data['divisions'][0]['conferences'])
|
| 58 |
+
|
| 59 |
+
team_ids = []
|
| 60 |
+
player_fa_ids = []
|
| 61 |
+
player_sr_ids = []
|
| 62 |
+
player_first_names = []
|
| 63 |
+
player_prefer_first_name = []
|
| 64 |
+
player_last_name = []
|
| 65 |
+
player_name_suffix = []
|
| 66 |
+
player_position = []
|
| 67 |
+
player_team = []
|
| 68 |
+
|
| 69 |
+
row_data = []
|
| 70 |
+
|
| 71 |
+
for division in data['divisions']:
|
| 72 |
+
for conference in division['conferences']:
|
| 73 |
+
print(conference['name'])
|
| 74 |
+
try:
|
| 75 |
+
for team in conference['teams']:
|
| 76 |
+
team_ids.append(team['id'])
|
| 77 |
+
|
| 78 |
+
player_fa_ids.append(999999)
|
| 79 |
+
player_sr_ids.append(team['id'])
|
| 80 |
+
player_first_names.append(team['market'])
|
| 81 |
+
player_prefer_first_name.append('-')
|
| 82 |
+
player_last_name.append(team['name'])
|
| 83 |
+
player_name_suffix.append('-')
|
| 84 |
+
player_position.append('DST')
|
| 85 |
+
player_team.append(team['alias'])
|
| 86 |
+
|
| 87 |
+
row_data.append([
|
| 88 |
+
999999, team['id'], team['market'], '-', team['name'], '-', 'DST', team['alias']
|
| 89 |
+
])
|
| 90 |
+
except:
|
| 91 |
+
pass
|
| 92 |
+
|
| 93 |
+
for team_id in team_ids:
|
| 94 |
+
|
| 95 |
+
sr_injuries = f"https://api.sportradar.com/ncaafb/trial/v7/en/teams/{team_id}/full_roster.json"
|
| 96 |
+
response = requests.get(sr_injuries, headers=headers)
|
| 97 |
+
data = response.json()
|
| 98 |
+
|
| 99 |
+
team_name = data['alias']
|
| 100 |
+
|
| 101 |
+
print(team_name + ' - ' + team_id)
|
| 102 |
+
try:
|
| 103 |
+
for player in data['players']:
|
| 104 |
+
player_fa_ids.append(999999)
|
| 105 |
+
player_sr_ids.append(player['id'])
|
| 106 |
+
player_first_names.append(player['first_name'])
|
| 107 |
+
player_prefer_first_name.append('-')
|
| 108 |
+
player_last_name.append(player['last_name'])
|
| 109 |
+
player_name_suffix.append('-')
|
| 110 |
+
player_position.append(player['position'])
|
| 111 |
+
player_team.append(team_name)
|
| 112 |
+
|
| 113 |
+
row_data.append([
|
| 114 |
+
999999, player['id'], player['first_name'], '-', player['last_name'], '-', player['position'], team_name
|
| 115 |
+
])
|
| 116 |
+
except:
|
| 117 |
+
print(f"Error processing team: {team_name} - {team_id}")
|
| 118 |
+
continue
|
| 119 |
+
|
| 120 |
+
return pd.DataFrame(row_data, columns=['FA_ID', 'SR_ID', 'First_Name', 'Prefer_First_Name', 'Last_Name', 'Name_Suffix', 'Position', 'Team'])
|
| 121 |
|
| 122 |
def grab_sr_fa(headers: dict) -> pd.DataFrame:
|
| 123 |
sr_fas = "https://api.sportradar.com/nfl/official/trial/v7/en/league/free_agents.json"
|
|
|
|
| 711 |
st.write("Updated Freedman Season Long NFL SR IDs")
|
| 712 |
|
| 713 |
st.success("SR IDs updated successfully")
|
| 714 |
+
|
| 715 |
+
with col2:
|
| 716 |
+
st.info("Update NCAAF SR IDs")
|
| 717 |
+
if st.button("Update NCAAF SR IDs", key='ncaaf_sr_ids'):
|
| 718 |
+
ncaaf_df = grab_sr_ncaaf_ids(sr_headers)
|
| 719 |
+
st.write("NCAAF SR IDs collected")
|
| 720 |
+
st.write(ncaaf_df)
|
| 721 |
+
|
| 722 |
+
sh = gc.open_by_url('https://docs.google.com/spreadsheets/d/1Rc0oCOHRG8J0MsN_BYXcLZ5NPTG8FxJd2Om5HkuYpeo/edit?gid=246741171#gid=246741171')
|
| 723 |
+
worksheet = sh.worksheet('SR_IDs')
|
| 724 |
+
worksheet.batch_clear(['A:H'])
|
| 725 |
+
worksheet.update([ncaaf_df.columns.values.tolist()] + ncaaf_df.values.tolist())
|
| 726 |
+
st.write("Updated NCAAF SR IDs in Draft Guide Staging")
|
| 727 |
|
| 728 |
with tab4:
|
| 729 |
st.info("We will add this functionality as soon as we have the endpoints to make it work!")
|