joeyagreco / leeger

Instant stats for any fantasy football league.
https://pypi.org/project/leeger
MIT License
61 stars 17 forks source link

[LEAGUE LOADER]: IndexError: list index out of range in __buildWeeks #26

Closed lhersman closed 10 months ago

lhersman commented 2 years ago

League Loader

ESPN

Summary

Finally got it to run (thanks!). Ran on first league, no problems at all. Tried it out on 2nd ESPN league and got a IndexError: list index out of range error. Full stack trace is attached.

Let me know if you need any more info, this is really cool!

League Info

No response

Error Logs

Traceback (most recent call last): File "C:\Users...\AppData\Local\Programs\Python\Python310\Lib\site-packages\leeger\league_loader\ESPN_High_School.py", line 10, in league: League = espnLeagueLoader.loadLeague() File "C:\Users...\AppData\Local\Programs\Python\Python310\lib\site-packages\leeger\league_loader\ESPNLeagueLoader.py", line 51, in loadLeague return self.buildLeague(espnLeagueYears) File "C:\Users...\AppData\Local\Programs\Python\Python310\lib\site-packages\leeger\league_loader\ESPNLeagueLoader.py", line 59, in buildLeague years.append(self.buildYear(espnLeague)) File "C:\Users...\AppData\Local\Programs\Python\Python310\lib\site-packages\leeger\league_loader\ESPNLeagueLoader.py", line 74, in buildYear weeks = self.buildWeeks(espnLeague) File "C:\Users...\AppData\Local\Programs\Python\Python310\lib\site-packages\leeger\league_loader\ESPNLeagueLoader.py", line 88, in __buildWeeks if espnTeam.team_id in espnTeamIDsWithMatchups or espnTeam.outcomes[i] == self.ESPN_BYE_OUTCOME: IndexError: list index out of range

joeyagreco commented 2 years ago

Thanks for opening an issue!

This seems to possibly be a bug with how the ESPN API is outputting game outcomes in its response.

We assume the list of game outcomes is at least the length of the total games in a season but there may be something I am missing/not understanding here.

By far the easiest way to debug and fix this issue is to step through it with a debugger on my local machine to spot what's going on. This is how I coded this to begin with (with ESPN leagues I am in).

With Sleeper, this would be as simple as sending your league ID, but ESPN requires the "S2" and "SWID" for private leagues.

If this is a public league, could you just post the league ID here so I can take a look.

If it is a private league, would you be willing to email me (joeyagreco@gmail.com) your "S2" and "SWID" cookies you are using (along with your league ID) so I could debug this locally?

If you're not comfortable with that we could perhaps hop on a call so you could share screen and we could go over it together (without you having to share your cookies with me).

lhersman commented 2 years ago

Thanks for opening an issue!

This seems to possibly be a bug with how the ESPN API is outputting game outcomes in its response.

We assume the list of game outcomes is at least the length of the total games in a season but there may be something I am missing/not understanding here.

By far the easiest way to debug and fix this issue is to step through it with a debugger on my local machine to spot what's going on. This is how I coded this to begin with (with ESPN leagues I am in).

With Sleeper, this would be as simple as sending your league ID, but ESPN requires the "S2" and "SWID" for private leagues.

If this is a public league, could you just post the league ID here so I can take a look.

If it is a private league, would you be willing to email me (joeyagreco@gmail.com) your "S2" and "SWID" cookies you are using (along with your league ID) so I could debug this locally?

If you're not comfortable with that we could perhaps hop on a call so you could share screen and we could go over it together (without you having to share your cookies with me).

We can try out a screen share if that's not too difficult. Got a discord or something?

joeyagreco commented 2 years ago

I do, e-mail me your username and we can set up a call.

lhersman commented 2 years ago

I do, e-mail me your username and we can set up a call.

sent

joeyagreco commented 2 years ago

This issue is due to lack of support for multi-week matchups. Will update when this is added.

joeyagreco commented 2 years ago

This will be fixed with this issue

joeyagreco commented 2 years ago

@lhersman The latest version of this project now supports multi-week matchup calculations. I have yet to add support to the ESPN league loader due to lack of access to a league that has multi-week matchups.

If you would like to set up a call where we can work through your league and making multi-week matchups work with it just reach out here or at the email in my profile and we can add that.

lhersman commented 1 year ago

Hey @joeyagreco I just saw this a year later so sorry! A friend asked me for fantasy history and suddenly remembered. Looks like my league with multi-week matches still doesn't work, did you need my league ID to finish this? If its been too long I totally get it. Hope all is well!

Exception from ESPN league: `Traceback (most recent call last): File "C:\Python38\Lib\site-packages\leeger\league_loader\ESPN_High_School.py", line 19, in league: League = espnLeagueLoader.loadLeague() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Luke\AppData\Roaming\Python\Python311\site-packages\leeger\league_loader\ESPNLeagueLoader.py", line 87, in loadLeague league = self.buildLeague(espnLeagueYears) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Luke\AppData\Roaming\Python\Python311\site-packages\leeger\league_loader\ESPNLeagueLoader.py", line 100, in buildLeague years.append(self.buildYear(espnLeague)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Luke\AppData\Roaming\Python\Python311\site-packages\leeger\league_loader\ESPNLeagueLoader.py", line 120, in buildYear weeks = self.__buildWeeks(espnLeague) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Luke\AppData\Roaming\Python\Python311\site-packages\leeger\league_loader\ESPNLeagueLoader.py", line 146, in buildWeeks or espnTeam.outcomes[i] == self.ESPN_BYE_OUTCOME


IndexError: list index out of range`
lhersman commented 1 year ago

FYI just tried it on my sleeper league as well and got: 2023-09-28 11:28:33 WARNING Unknown value for PlayoffRoundType: 'None'. leeger.exception.LeagueLoaderException.LeagueLoaderException: PlayoffRoundType 'None' is not supported.

Seems releated?

Full log: Traceback (most recent call last): File "C:\Python38\Lib\site-packages\leeger\league_loader\Sleeper_TXM.py", line 8, in <module> league: League = sleeperLeagueLoader.loadLeague() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Luke\AppData\Roaming\Python\Python311\site-packages\leeger\league_loader\SleeperLeagueLoader.py", line 121, in loadLeague league = self.__buildLeague(sleeperLeagues) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Luke\AppData\Roaming\Python\Python311\site-packages\leeger\league_loader\SleeperLeagueLoader.py", line 136, in __buildLeague years.append(self.__buildYear(sleeperLeague)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Luke\AppData\Roaming\Python\Python311\site-packages\leeger\league_loader\SleeperLeagueLoader.py", line 147, in __buildYear weeks = self.__buildWeeks(sleeperLeague) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Luke\AppData\Roaming\Python\Python311\site-packages\leeger\league_loader\SleeperLeagueLoader.py", line 234, in __buildWeeks numberOfPlayoffWeeks = self.__calculate_number_of_playoff_weeks( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Luke\AppData\Roaming\Python\Python311\site-packages\leeger\league_loader\SleeperLeagueLoader.py", line 401, in __calculate_number_of_playoff_weeks raise LeagueLoaderException( leeger.exception.LeagueLoaderException.LeagueLoaderException: PlayoffRoundType 'None' is not supported.

joeyagreco commented 1 year ago

Hi there @lhersman !

What version of Leeger are you running?

run python -m pip show leeger

You should be on version 2.5.5

If you are not on that version, run python -m pip install leeger --upgrade

If you are on the latest version and are still getting errors, please send them here.

lhersman commented 1 year ago

@joeyagreco, yes, on 2.5.5. The exceptions listed above are the full error logs from running it on 2.5.5. Let me know if you need more!

joeyagreco commented 1 year ago

@lhersman Could you send your Sleeper league ID/year and script please?

lhersman commented 1 year ago

@lhersman Could you send your Sleeper league ID/year and script please?

No problem, sent email. Script should have the IDs and years listed