Skip to content

Commit

Permalink
fix: Properly autodetect JSON format after it got broken in 1.7.0
Browse files Browse the repository at this point in the history
See issue #94.
  • Loading branch information
tkarabela committed May 25, 2024
1 parent cc1da8e commit ece4927
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pysubs2/formats/jsonformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class JSONFormat(FormatBase):
@classmethod
def guess_format(cls, text: str) -> Optional[str]:
"""See :meth:`pysubs2.formats.FormatBase.guess_format()`"""
if text.startswith("{\"") and "\"info:\"" in text:
if text.startswith("{\"") and "\"info\":" in text:
return "json"
else:
return None
Expand Down
2 changes: 2 additions & 0 deletions tests/formats/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ def test_write_read() -> None:
json_text = subs.to_string("json")

subs2 = SSAFile.from_string(json_text, "json")
subs3 = SSAFile.from_string(json_text)

assert subs2.equals(subs)
assert subs3.equals(subs)


def test_read_unsupported_json_issue_85() -> None:
Expand Down

0 comments on commit ece4927

Please sign in to comment.