Skip to content

Conversation

@shsiddhant
Copy link

Bug Summary

JSONDecodeError is raised while creating instances of classes:

  1. Match
  2. Player
  3. Summary

When manually opened in a web browser, the match url, json url, and new json url, all return Access Denied messages.

Reproduction

Run bug.py

from espncricinfo.match import Match
from espncricinfo.player import Player
from espncricinfo.series import Series
from espncricinfo.summary import Summary
from json import JSONDecodeError

try:
    print("Trying: match = Match('1490425')")
    match = Match('1490425')
    print("Match description:", match.description)
except JSONDecodeError as e:
    print("JSONDecodeError:", e)
try:
    print("Trying: player = Player('883405')")
    player = Player('883405')
    print("Player Name:", player.name)
except JSONDecodeError as e:
    print("JSONDecodeError:", e)
try:
    print("Trying: series = Series('1478193')")
    series = Series('1478193')
    print("Series Name:", series.short_name)
except JSONDecodeError as e:
    print("JSONDecodeError:", e)
try:
    print("Trying: summary = Summary()")
    summary = Summary()
    print("List of match ids in summary:", summary.match_ids)
except JSONDecodeError as e:
    print("JSONDecodeError:", e)

Output (before fix)

$ python bug.py
Trying: match = Match('1490425')
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Trying: player = Player('883405')
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Trying: series = Series('1478193')
Series Name: ICC Women's World Cup
Trying: summary = Summary()
JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Tests (before fix)

$ python tests.py

...
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

----------------------------------------------------------------------
Ran 3 tests in 1.818s

FAILED (errors=3)

Fix Summary

  1. Match class: updated self.match_url, and self.json_url to working endpoints.
  2. Player class: comment out references to new_json_url (no known working endpoint).
  3. All classes: updated headers to prevent 403 errors, since updated URLs weren't sufficient to prevent errors.

Output (after fix)

$ python bug.py
Trying: match = Match('1490425')
Match description: ICC Women's World Cup, 13th Match: India Women v Australia Women at Visakhapatnam, Oct 12, 2025
Trying: player = Player('883405')
Player Name: Jemimah Rodrigues
Trying: series = Series('1478193')
Series Name: ICC Women's World Cup
Trying: summary = Summary()
List of match ids in summary: ['1495282', '1495283', '1495284', '1492407', '1492408', '1492392', '1492400', '1492406', '1492393', '1492391', '1492390', '1492395', '1492394', '1492396', '1492397', '1492399', '1492401', '1492398', '1492405', '1492403', '1492402', '1492404', '1506415', '1490429', '1503467', '1506416', '1503468']

Tests (after fix)

$ python tests.py                                  
...
----------------------------------------------------------------------
Ran 3 tests in 11.116s

OK

Tests

New pytest tests added in tests_new.py.

Addition changes

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 this pull request may close these issues.

1 participant