From 11b06be9b18ec9ecf78b747daf361dfde3868427 Mon Sep 17 00:00:00 2001 From: hajimi Date: Sun, 21 Jun 2026 12:21:48 +0800 Subject: [PATCH] test: cover semicolon jsonp in match live stream parser --- .../crawler/tests/test_match_live_stream.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docker/crawler/tests/test_match_live_stream.py b/docker/crawler/tests/test_match_live_stream.py index a7bca80..fa46c8a 100644 --- a/docker/crawler/tests/test_match_live_stream.py +++ b/docker/crawler/tests/test_match_live_stream.py @@ -33,6 +33,27 @@ class MatchLiveStreamTest(unittest.TestCase): self.assertEqual(parsed["play_url_flv"], "http://a/flv") self.assertEqual(parsed["play_url_hd_flv"], "http://a/hdflv") + def test_parse_json_ncctrials_detail_accepts_trailing_semicolon(self): + payload = { + "code": 200, + "msg": "ok", + "data": { + "stream": { + "flv": "http://b/flv", + "hdFlv": "http://b/hdflv", + "m3u8": "http://b/m3u8", + "hdM3u8": "http://b/hdm3u8", + } + }, + } + + parsed = parse_match_live_detail_html(f"detail({json.dumps(payload, ensure_ascii=False)});") + + self.assertEqual(parsed["play_url_m3u8"], "http://b/m3u8") + self.assertEqual(parsed["play_url_hd_m3u8"], "http://b/hdm3u8") + self.assertEqual(parsed["play_url_flv"], "http://b/flv") + self.assertEqual(parsed["play_url_hd_flv"], "http://b/hdflv") + def test_choose_next_fetch_at_uses_60s_for_empty_streams(self): self.assertEqual(choose_next_fetch_at(now_ts=1000, has_existing_stream=False), 1060)