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

JSON Parsing Error due to malformed URL on Windows #50

Open
PrestonHager opened this issue Apr 8, 2024 · 0 comments
Open

JSON Parsing Error due to malformed URL on Windows #50

PrestonHager opened this issue Apr 8, 2024 · 0 comments

Comments

@PrestonHager
Copy link
Contributor

Running the ingestor on any non POSIX/Unix platform results in a malformed URL and inability to parse the returned JSON. The specific error I get is as follows:

Traceback (most recent call last):
  File "C:\Users\prest\OneDrive\Documents\Projects\openf1\ingestor\ingest_history.py", line 196, in <module>
    cli()
  File "c:\Users\prest\OneDrive\Documents\Projects\openf1\.venv\Lib\site-packages\click\core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\prest\OneDrive\Documents\Projects\openf1\.venv\Lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "c:\Users\prest\OneDrive\Documents\Projects\openf1\.venv\Lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\prest\OneDrive\Documents\Projects\openf1\.venv\Lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\prest\OneDrive\Documents\Projects\openf1\.venv\Lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\prest\OneDrive\Documents\Projects\openf1\ingestor\ingest_history.py", line 178, in ingest_session
    asyncio.run(_ingest_session(*args, **kwargs))
  File "C:\Python312\Lib\asyncio\runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\asyncio\base_events.py", line 685, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\prest\OneDrive\Documents\Projects\openf1\ingestor\ingest_history.py", line 149, in _ingest_session
    session_path = get_session_path(year=year, meeting_key=meeting_key, session_key=session_key)  
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
  File "C:\Users\prest\OneDrive\Documents\Projects\openf1\ingestor\ingest_history.py", line 85, in get_session_path
    for meeting in _get_schedule(year)['Meetings']:
                   ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\prest\OneDrive\Documents\Projects\openf1\ingestor\ingest_history.py", line 30, in _get_schedule
    return json.loads(requests.get(url).content)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

After some debug printing, I discovered that the URL it was trying to get was https://livetiming.formula1.com/static\2023/Index.json. The backslash is because the script uses os.path.join to join the parts of the URL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant