ParsaD23 / MotoGP-API

MotoGP Api: Library that reads the results of the MotoGP, 500cc, Moto2 and Moto3 classes from a website.
MIT License
25 stars 1 forks source link

getSessionResult not working for MotoGP category #2

Closed thomaslprr closed 3 years ago

thomaslprr commented 3 years ago

Hi Parsa,

I try to do this : List<RiderSession> gridByRaceNumber = data.getSessionResults(Category.MotoGP, 2015, "FRA", Session.GRID); or this List<RiderSession> gridByRaceNumber = data.getSessionResults(Category.MotoGP, 2015, 3, Session.RACE); but it doesn't work.

I just found the origin of the problem but not the solution. The problem is there when the category is MotoGP, do you have any idea of the solution? If the category is Moto2 or Moto3 there is no problem.

The error log :

com.github.parsad23.motogpapi.exceptions.DataNotAvailableException: The requested session or data does not exist or is not available
    at com.github.parsad23.motogpapi.reader.URLGenerator.getSessionResultsURL(URLGenerator.java:80)
    at com.github.parsad23.motogpapi.reader.SessionResultsReader.getJSONObjectResults(SessionResultsReader.java:25)
    at com.github.parsad23.motogpapi.reader.SessionResultsReader.getSessionResults(SessionResultsReader.java:17)
    at com.github.parsad23.motogpapi.reader.MotoGPData.getSessionResults(MotoGPData.java:45)
    at testsetstsetmain.main.main(main.java:19)

If it can be helpful I make search and find that in URLGenerator.java :

try{
            races = JsonParser.parseString(JsonReader.readJsonFromUrl(url, referer, base_url)).getAsJsonArray();
        } catch (IOException e){
            throw new DataNotAvailableException("Unable to read the JSONArray containing the races: empty String returned...");
 }

races is an empty array and the URL is https://mssproxy.motorsportstats.com/web/3.0.0/seasons/2015-motogp/races/

Thanks a lot in advance, Respectfully Thomas

thomaslprr commented 3 years ago

Ok now I found that nothing is working when the category is MotoGP, do you know why ? (RidersStanding, RidersSession, etc)

ParsaD23 commented 3 years ago

Hi Thomas,

Thanks for reporting the issue. I released a new version of the API and it should now work correctly. The problem was caused by some changes in the website, more specifically in the URLs for the requests. Don't forget to leave a star if you find this repository useful!

Thanks, Best regards Parsa Dahesh