mattdodge / yahoofantasy

A Python SDK for the Yahoo! Fantasy Sports API
59 stars 16 forks source link

is 2023 supported for the yahoo fantasy NBA yet? #63

Closed prestonlam53 closed 7 months ago

prestonlam53 commented 8 months ago

I'm trying to get the stats for our league in 2023, but I'm getting this error:

Traceback (most recent call last):
  File "yahoo_api_scripts/fantasy_downloads.py", line 99, in <module>
    export_to_excel(get_rosters_dataframe(), 'rosters')
  File "yahoo_api_scripts/fantasy_downloads.py", line 81, in get_rosters_dataframe
    leagues = ctx.get_leagues(game = 'nba', season = 2023)
  File "/Users/*****/Repositories/yahoo_fantasy/env/lib/python3.7/site-packages/yahoofantasy/context.py", line 114, in get_leagues
    game_id = get_game_id(game, season)
  File "/Users/*****/Repositories/yahoo_fantasy/env/lib/python3.7/site-packages/yahoofantasy/api/games.py", line 83, in get_game_id
    raise ValueError("{} is not a valid season for {}".format(season, game))
ValueError: 2023 is not a valid season for nba

This is the code I'm using - it works if I put in '2022' as the season, but returns the rosters from last year


def get_rosters_dataframe():

    df = pd.DataFrame(columns=['Team', 'Full_Name', 'First_Name', 'Last_Name'])
    ctx = Context()
    leagues = ctx.get_leagues(game = 'nba', season = 2023)
    print(leagues)

    league = next(l for l in leagues if l.id == "418.l.123183")
    for team in league.teams():
        players = team.players()
        for player in players:
            print(f"Team: {team}")
            print(f"Player: {player.name.first}")
            df.loc[len(df)] = [str(team), player.name.full, player.name.first, player.name.last]
    print(df.head(5))
    return df
mattdodge commented 7 months ago

2023 NBA support was added in version 1.4.2, be sure your library is updated to the latest version and it should work.

pip install -U yahoofantasy