outside-edge / python-espncricinfo

Python wrapper for the ESPNCricInfo JSON API
MIT License
144 stars 65 forks source link

[BUG] Get KeyError: 'props' when trying to run Summary() #44

Closed johncoxon closed 3 years ago

johncoxon commented 3 years ago

When I run the following code, I get the traceback below.

>>> from espncricinfo.summary import Summary
>>> s = Summary()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/John/opt/anaconda3/lib/python3.7/site-packages/espncricinfo/summary.py", line 12, in __init__
    self.match_ids = self._match_ids()
  File "/Users/John/opt/anaconda3/lib/python3.7/site-packages/espncricinfo/summary.py", line 30, in _match_ids
    matches = [x['id'] for x in self.summary_json()['props']['pageProps']['data']['content']['leagueEvents'][0]['matchEvents']]
KeyError: 'props'

I'm not certain what I'm doing wrong here, can someone help me out?

BoredCyborg commented 3 years ago

I've created a pull request which (hopefully) should fix this issue. There may still be a NoScorecardError that needs to be handled. https://github.com/dwillis/python-espncricinfo/pull/45

Edit: the error is caused because it is getting upcoming matches, idk if there's a way to get past or only live matches

adityas21420 commented 3 years ago

Accessing Summary.match_ids gives this error.

Traceback (most recent call last): File "C:\Users\DELL PC\Desktop\github\cricket app\python-espncricinfo\script.py", line 2, in <module> s = Summary() File "C:\Users\DELL PC\Desktop\github\cricket app\python-espncricinfo\espncricinfo\summary.py", line 12, in __init__ self.match_ids = self._match_ids() File "C:\Users\DELL PC\Desktop\github\cricket app\python-espncricinfo\espncricinfo\summary.py", line 30, in _match_ids matches = [x['id'] for x in self.summary_json()['props']['pageProps']['data']['content']['leagueEvents'][0]['matchEvents']] KeyError: 'content'

I don't know how to proceed from here on, can someone help me out?