bgrnwd / mobfot

:soccer: An unofficial Python client for the FotMob API
https://bgrnwd.com/mobfot/
MIT License
29 stars 4 forks source link

[BUG] Parameters in get_league do not affect output #18

Open rbarman opened 2 months ago

rbarman commented 2 months ago

Is there an existing issue for this?

Current Behavior

The parameters in get_league do not affect the output.

All of the below calls return the same output. It returns all of the league's information. Changing the tab parameter does not do anything.

league_id = 47 # premier league
res = client.get_league(league_id )
matches_res = client.get_league(league_id ,tab='matches')
table_res = client.get_league(league_id, tab=' table')
# Changing the tab parameter does not change the output. Tried with all of the documented tab options (overview, table, matches, stats, transfers)

# confirm it returns same data
assert res == matches_res
assert res == table_res
assert matches_res == table_res

Expected Behavior

If we specify a parameter, then the output should return data only for that parameter.

client.get_league(league_id ,tab='matches') should only return data about the league's matches.

Steps To Reproduce

main.py

league_id = 47 # premier league
res = client.get_league(league_id )
matches_res = client.get_league(league_id ,tab='matches')
table_res = client.get_league(league_id, tab=' table')
# Changing the tab parameter does not change the output. Tried with all of the documented tab options (overview, table, matches, stats, transfers)

# confirm it returns same data
assert res == matches_res
assert res == table_res
assert matches_res == table_res

Steps:

python -m venv venv
.\venv\Scripts\activate
python main.py

Environment

- OS: Windows 11
- Python: 3.11.4
- pip: 23.1.2

Version

1.0.0

Anything else?

The root cause might be incorrect way of applying the tab parameter in the API url

get_league internally builds urls like these:

These urls all return the same data.

bgrnwd commented 2 months ago

Hey @rbarman thanks for submitting this bug. I will try to re-create it and get back to you.

bgrnwd commented 1 month ago

I was able to replicate this locally. My hunch is the API may have changed at some point. I'll push a fix in the next couple weeks.