rozzac90 / pinnacle

Python Wrapper for Pinnacle Sports API
MIT License
52 stars 26 forks source link

Error decoding json when there's no updates on "get_odds" #21

Open ArielCarvalho opened 4 years ago

ArielCarvalho commented 4 years ago

This error happens when there's no updates on the odds:

  File "/usr/local/lib/python3.7/site-packages/pinnacle/endpoints/marketdata.py", line 117, in get_odds
    response.json(), resources.OddsDetails, date_time_sent, datetime.datetime.utcnow()
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 866, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/lib/python3.7/json/__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.7/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.7/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)

debugging it I got this:

> https://api.pinnacle.com/v1/odds - 200
>response: <Response [200]>
>response.content: b''
>response.text: 
>response.headers: {'Date': 'Mon, 12 Aug 2019 22:21:36 GMT', 'Content-Length': '0', 'Connection': 'keep-alive'; expires=Tue, 11-Aug-20 22:21:36 GMT; path=/; domain=.pinnacle.com; HttpOnly', 'Cache-Control': 'no-cache', 'Pragma': 'no-cache', 'Expires': '-1', 'X-Powered-By': 'ASP.NET, ARR/3.0, ASP.NET', 'Expect-CT': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"', 'Server': 'cloudflare'}

Last time I checked you can use a league with no odds for it to get that response. At the time I used this league id on the odds api call: 1891 I've already seen two issues with problems with the return pinnacle sends (I believe they were related with not being in a region allowed), not sure why it doesn't just return a json with the message though.