cwendt94 / espn-api

ESPN Fantasy API! (Football, Basketball)
MIT License
659 stars 213 forks source link

Issue with Add full owner info to team commit #518

Closed dtcarls closed 11 months ago

dtcarls commented 11 months ago

Sport

Football

Summary

Some leagues have teams without owners so league class cannot be loaded.

Logs/Data

Example public league: https://fantasy.espn.com/football/league/schedule?leagueId=1085961346

vscode ➜ /workspaces/espn-api (master) $ python
Python 3.8.17 (default, Jun  6 2023, 23:43:56) 
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> import os
>>> sys.path.insert(1, os.path.abspath('.'))
>>> 
>>> from espn_api.football import League
>>> LEAGUE_ID = 1085961346
>>> LEAGUE_YEAR = 2023
>>> 
>>> league = League(league_id=LEAGUE_ID, year=LEAGUE_YEAR)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/workspaces/espn-api/espn_api/football/league.py", line 33, in __init__
    self.fetch_league()
  File "/workspaces/espn-api/espn_api/football/league.py", line 36, in fetch_league
    self._fetch_league()
  File "/workspaces/espn-api/espn_api/football/league.py", line 43, in _fetch_league
    self._fetch_teams(data)
  File "/workspaces/espn-api/espn_api/football/league.py", line 48, in _fetch_teams
    super()._fetch_teams(data, TeamClass=Team)
  File "/workspaces/espn-api/espn_api/base_league.py", line 62, in _fetch_teams
    owners = [member for member in members if member.get('id') == team.get('owners', [''])[0]]
  File "/workspaces/espn-api/espn_api/base_league.py", line 62, in <listcomp>
    owners = [member for member in members if member.get('id') == team.get('owners', [''])[0]]
IndexError: list index out of range
dtcarls commented 11 months ago

For those that may need a fix earlier, you can roll back to espn_api 0.33.0

cwendt94 commented 11 months ago

fixed in v0.34.1