mattdodge / yahoofantasy

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

CLI dump matchups for NFL 2022 season yields "ValueError: 2022 is not a valid season for nfl" #27

Closed oconnorac closed 1 year ago

oconnorac commented 1 year ago

I entered the following commands using the CLI:

yahofantasy dump matchups

I then entered nfl and 2022, and received the following error:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/bin/yahoofantasy", line 8, in <module>
    sys.exit(yahoofantasy())
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1654, in invoke
    super().invoke(ctx)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/yahoofantasy/cli/dump.py", line 23, in dump
    leagues = yf_context.get_leagues(game, season)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/yahoofantasy/context.py", line 106, in get_leagues
    game_id = get_game_id(game, season)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/yahoofantasy/api/games.py", line 79, in get_game_id
    raise ValueError(
ValueError: 2022 is not a valid season for nfl

Recommended fix: pull the Yahoo! Fantasy 2022 NFL game codes and add it to line 50 as:

games['nfl']['2022'] = <yahoo game_code here>

https://github.com/mattdodge/yahoofantasy/blob/f8c0b5f8f650e5b093ad2742562190ca99c7da90/yahoofantasy/api/games.py#L50

mattdodge commented 1 year ago

Fixed in version 1.2.3, thanks for pointing that out!

To upgrade:

pip install -U yahoofantasy
oconnorac commented 1 year ago

You're awesome, thank you! Would've found the game_code myself but the Yahoo! Fantasy API has been so difficult to work with, hence using your wrapper for it. Great work!