Skip to content

Instantly share code, notes, and snippets.

@jchaskell
Created December 8, 2022 04:44
Show Gist options
  • Save jchaskell/a58d12f0b38d70ceaddd8b7922d0f5ad to your computer and use it in GitHub Desktop.
Save jchaskell/a58d12f0b38d70ceaddd8b7922d0f5ad to your computer and use it in GitHub Desktop.
Find free agents in fantasy football league who were drafted and for how much
import os
from espn_api.football import League
ESPN_S2 = os.getenv("ESPN_S2")
SWID = os.getenv("SWID")
LEAGUE_ID = os.getenv("LEAGUE_ID")
def get_drafted_players(league):
all_picks = league.draft
print(f"There were {len(all_picks)} picks in your draft")
return all_picks
def get_all_team_rosters(league):
all_players = []
for team in league.teams:
all_players += [player.name for player in team.roster]
return all_players
def main():
league = League(league_id=LEAGUE_ID, year=2022, espn_s2=ESPN_S2, swid=SWID)
drafted_players = get_drafted_players(league)
current_players = get_all_team_rosters(league)
# Check all drafted players and see if they are on a roster
for pick in drafted_players:
if pick.playerName not in current_players:
print(f"{pick.playerName} is available & drafted for {pick.bid_amount}")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment