roclark / sportsipy

A free sports API written for python
MIT License
484 stars 188 forks source link

NFL Kicker URI Format #205

Open jtrueblood opened 5 years ago

jtrueblood commented 5 years ago

I noticed when making requests for Player information some of the NFL kickers seem to have a different format for their URI. A lot of current kickers follow the standard 8 character 'LlllFfNN' format. But some have a 10 character string.

In this example Mason Crosby this works fine and returns 'Field Goals - 30':

thisplayer = Player('CrosMa20') 
theyear = '2018'
print('Field Goals -', thisplayer(theyear).field_goals_made)

But for a player like Robbie Gould the page url is: https://www.pro-football-reference.com/players/G/gouldrob01.htm

And this returns an error - 'TypeError: 'NoneType' object is not subscriptable'

thisplayer = Player('gouldrob01') 
theyear = '2018'
print('Field Goals -', thisplayer(theyear).field_goals_made)

I can't quite identify why some kickers use this 10 character uri and the rest use the standard 8 character format. Seems like the format changed over at some point a few years ago. I'm not sure if this issue extends beyond place kickers.

Great work here! This is a fantastic resource and it gives me an excuse to learn some Python.

Thanks.

roclark commented 5 years ago

Hey @jtrueblood! Thanks for bringing this to my attention! I was unaware that some players had different formats for their Player ID. This is a puzzling one, as I'm not sure what the best way to resolve this would be, outside of updating the documentation to indicate the different formats an ID can take on. In general, the Player ID is either referenced from the player's unique page, or pulled programmatically through a team's roster, so there's flexibility with how it can be supplied, but I would like to address this scenario in case any user supplies what they believe is a valid ID when the website uses a different format. Perhaps a good way to resolve this would be to mention the 10-character format in the documentation, and also add a more useful error message which suggests the other format in case the user supplies an invalid one. Any thoughts on this?

Thanks again for writing this up! This is a very important clarification and I want to sort out a lot of the usage semantics prior to the official 1.0.0 release (which is very much TBD at this point).

jtrueblood commented 5 years ago

@roclark Thanks for replying so quickly. I'm sure revising the documentation would help others in the future. I think this issue may be more fundamental than just documentation though. In another example, when I just print out the whole team roster -- for instance the Falcons for this season...

team = Roster('ATL') for player in team.players: print(player.name, player.player_id)

Matt Bryant returns the longer form player_id (same as his profootball ref URI) and the name comes back as 'None'.

https://www.dropbox.com/s/caa8z97zesaxs3a/screen-shot.png?dl=0

And if you pass back that URI that is listed in the Roster response for Bryant, you get the error I mentioned above. So even calling the roster for the proper player_id doesn't seem to work either. It appears that the player data for players with this id format is inaccessible.

Thanks again for your work on this.

roclark commented 5 years ago

Hmm... this gets more puzzling... I will have to investigate why the Roster module isn't working either... it almost sounds like there would be invalid links on their site then? I will try and get down to the bottom of this, as I agree, this sounds more systemic than just the semantics of an ID. I will try and see where this is coming from and get a fix out if possible.

I really appreciate the detailed analysis here! This is greatly helpful and is something that's crucial to figure out!