roclark / sportsipy

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

FBRef roster pulls broken due to bad suffixes #654

Open safog111 opened 3 years ago

safog111 commented 3 years ago

Describe the bug Pulling the Roster for the larger premier league clubs doesn't work.

To Reproduce Sample code which causes an issue.

man_utd = Roster(sportsipy.fb.fb_utils.lookup_squad_id('Manchester United'))
# Returns empty
print(man_utd)

Expected behavior Expect to see all the players who play for Manchester United.

Screenshots

Desktop (please complete the following information):

Additional context After some debugging, I think the error might be caused by a bad / incorrect league-ids file. https://github.com/roclark/sportsipy/blob/master/sportsipy/fb/league_ids.py

We run a LEAGUE_IDS.get() here: https://github.com/roclark/sportsipy/blob/master/sportsipy/fb/roster.py#L1654

(As a side note, The input param seems to be a squad id rather than a league id. I assume the entries in LEAGUE_IDS.py are squad ids as well).

I went through and manually checked the tables on FBRef for the big four PL clubs and it looks like the postfix is common and should be 11160.

Adding something manual like

'19538871': '11160', # United
'822bd0ba': '11160', # City
'b8fd03ef': '11160', # Liverpool
'cff3d9bb': '11160', # Chelsea

works but isn't scalable. It seems like a league wide suffix should work, so maybe plumbing in a league-id into roster.py would be the right fix.