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

Issue with fotmob_get_season_stats( ) #201

Closed
mcavs opened this issue Oct 28, 2022 · 18 comments · Fixed by #203
Closed

Issue with fotmob_get_season_stats( ) #201

mcavs opened this issue Oct 28, 2022 · 18 comments · Fixed by #203
Assignees
Labels
bug Something isn't working

Comments

@mcavs
Copy link

mcavs commented Oct 28, 2022

I received the following error to call the season stats by using fotmob_get_season_stats( ). How can I solve this?

> epl_team_xg_2021 <- fotmob_get_season_stats(
+   country = "ENG",
+   league_name = "Premier League",
+   season_name = "2020/2021",
+   stat_name = "Expected goals",
+   team_or_player = "team"
+ )

Error: lexical error: invalid char in json text.
                                       NA
                     (right here) ------^
@JaseZiv
Copy link
Owner

JaseZiv commented Oct 29, 2022

Tagging @tonyelhabr here as this does appear to be an issue.

I have recreated it locally using version 0.6.1.4000 and can confirm the error is occurring.

@JaseZiv JaseZiv added the bug Something isn't working label Oct 29, 2022
@tonyelhabr
Copy link
Collaborator

i'll take a look at it tomorrow

@tonyelhabr
Copy link
Collaborator

i'll take a look at it tomorrow

Ah, this is quite involved. Seems that they have changed the way that they store the data.

@mcavs
Copy link
Author

mcavs commented Nov 1, 2022

@tonyelhabr is this error solved? Because I still received the same error...

@tonyelhabr
Copy link
Collaborator

Ah yes it's broken again. fotmob changes their website very frequently. as you can see, there was no failed test for line 188 in test-fotmob.R when the PR merged (that test has essentially the same code as yours)

@JaseZiv JaseZiv reopened this Nov 1, 2022
@tonyelhabr
Copy link
Collaborator

@mcavs can you try it again? i just tried the function call and it worked.

for some context: i was debugging the issue last night and saw some big changes that Fotmob implemented on the backend (different format for build id, parameters in the query component of the URL), but I came back to it this morning and no longer saw the same changes

@mcavs
Copy link
Author

mcavs commented Nov 2, 2022

@tonyelhabr it works now. Thanks for your interest!

@mcavs mcavs closed this as completed Nov 2, 2022
@cjones46
Copy link

cjones46 commented Nov 2, 2022

@tonyelhabr I'm still receiving the lexical error running the exact same command. I've updated the worldfootballR package and restarted R. Any suggestions?

@tonyelhabr
Copy link
Collaborator

@cjones46

  1. what version of {jsonlite} do you have? (you can use packageVersion("jsonlite"))
  2. do you see something like this in your inspector mode when you go to Premier League > Stats > Players 2022/2023 > Top Scorer (See All button). specifically, i'm interested in seeing the GET request for premier-league-players.json

image

@cjones46
Copy link

cjones46 commented Nov 2, 2022

@tonyelhabr Thanks so much for the quick and helpful reply!

Appears I have the latest version of jsonlite; see output below.

> packageVersion("jsonlite")
[1] ‘1.8.0’
> update.packages("jsonlite")
> packageVersion("jsonlite")
[1] ‘1.8.0’
> epl_team_xg_2021 <- fotmob_get_season_stats(country = "ENG", league_name = "Premier League", season_name = "2020/2021", stat_name = "Expected goals",team_or_player = "team")
Error: lexical error: invalid char in json text.
                                       NA
                     (right here) ------^

I believe the below screenshot illustrates that the get request for premier-league-players.json is working.

image

@tonyelhabr
Copy link
Collaborator

@cjones46 thanks for the package version printout and the screenshot! can you try to update your jsonlite version to the development version using remotes::install_github("jeroen/jsonlite")? i have version 1.8.2.

i thought that the new internal .fromJSON() function I wrote would work for when the user has a jsonlite version below 1.8.1, but that may not be the case. (See here for the notification about an internal change to jsonlite::fromJSON().)

Depending on whether or not updating your package version resolves the issue, we may need to add a minimum version requirement to the DESCRIPTION file.

@cjones46
Copy link

cjones46 commented Nov 2, 2022

@tonyelhabr Updated the package, verified that my version is > 1.8.1, but still getting the same error unfortunately.

> packageVersion("jsonlite")
[1] ‘1.8.3’
> epl_team_xg_2021 <- fotmob_get_season_stats(country = "ENG", league_name = "Premier League", season_name = "2020/2021", stat_name = "Expected goals",team_or_player = "team")
Error: lexical error: invalid char in json text.
                                       NA
                     (right here) ------^

@tonyelhabr
Copy link
Collaborator

@cjones46 hmm ok i'll look into this more this evening

@tonyelhabr
Copy link
Collaborator

@cjones46 I realized that I forgot to ask what version of the {worldfootballR} package you have. Do you have at least 0.6.1.5000?

@cjones46
Copy link

cjones46 commented Nov 4, 2022

@tonyelhabr

Doesn't appear that I do; I ran update.packages() on it at the beginning of this conversation and thought that meant I had the latest version, but it doesn't seem to have given me a version 0.6.1.5000. How do I obtain that version?

> packageVersion("worldfootballR")
[1] ‘0.6.1’
> update.packages("worldfootballR")
> packageVersion("worldfootballR")
[1] ‘0.6.1’

@tonyelhabr
Copy link
Collaborator

Try remotes::install_github("JaseZiv/worldfootballR")

@cjones46
Copy link

cjones46 commented Nov 4, 2022

@tonyelhabr

That worked! Thank you so so much for your help and for the great work you guys do to keep up this wonderful package!

@tonyelhabr
Copy link
Collaborator

@tonyelhabr

That worked! Thank you so so much for your help and for the great work you guys do to keep up this wonderful package!

awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants