Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get player details of players whose names contain an apostrophe (only NBA tested) #10

Open
ntsirakis opened this issue Feb 13, 2020 · 2 comments

Comments

@ntsirakis
Copy link

Example: league.player_details("De'Aaron Fox") throws the following:

  File "[trunc]/yahoo_fantasy_api/yhandler.py", line 176, in get_player_raw
    return self.get("league/{}/{}".format(league_id, player_stat_uri))
  File [trunc]/yahoo_fantasy_api/yhandler.py", line 25, in get
    raise RuntimeError(response.content)
RuntimeError: b'<?xml version="1.0" encoding="UTF-8"?>\n<error xml:lang="en-us" yahoo:uri="http://fantasysports.yahooapis.com/fantasy/v2/league/395.l.36985/players;search=D&amp;#39;Angelo%20Russell/stats?format=json" xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" xmlns="http://www.yahooapis.com/v1/base.rng">\n <description>invalid param search (was modified by yiv_get_stripped )</description>\n <detail/>\n</error>'

Removing the apostrophe (league.player_details("DeAaron Fox")) throws the following:

  File "[trunc]/yahoo_fantasy_api/league.py", line 455, in player_details
    for category in player['0']['player']:
TypeError: list indices must be integers or slices, not str

Funnily enough you can get the data by removing the entire chunk before the apostrophe, so in this case, league.player_details("Aaron Fox")

Version: 1.8.1. Briefly checked commits since then and didn't see anything that would fix this.

@spilchen
Copy link
Owner

It kind of seems like a limitation with the yahoo REST API we're using. I was not able to pass in a name with an apostrophe, even after doing URL encoding (i.e. %20).

In 2.0.1, when the search does not find any players, I now return an empty list rather than the TypeError exception you were seeing.

@ntsirakis
Copy link
Author

ntsirakis commented Feb 16, 2020

Fair enough, that's a shame. I'll continue with the workaround I have now. Thanks for checking anyway!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants