From a9281f27c7e92b9bee9f2a4bdf2f4c41576e4044 Mon Sep 17 00:00:00 2001 From: hajimi Date: Sun, 21 Jun 2026 12:29:36 +0800 Subject: [PATCH] fix: surface match live stream partial failures --- docker/crawler/match_live_stream.py | 2 +- docker/crawler/tests/test_match_live_stream.py | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/docker/crawler/match_live_stream.py b/docker/crawler/match_live_stream.py index 02dbca3..c108a0a 100644 --- a/docker/crawler/match_live_stream.py +++ b/docker/crawler/match_live_stream.py @@ -245,7 +245,7 @@ def run(db_config: Dict[str, Any]) -> Dict[str, Any]: candidate_count = len(rows) return { - "success": True, + "success": failed_count == 0, "candidate_count": candidate_count, "saved_count": success_count, "count": success_count, diff --git a/docker/crawler/tests/test_match_live_stream.py b/docker/crawler/tests/test_match_live_stream.py index fa46c8a..f8fc824 100644 --- a/docker/crawler/tests/test_match_live_stream.py +++ b/docker/crawler/tests/test_match_live_stream.py @@ -8,7 +8,7 @@ ROOT = Path(__file__).resolve().parents[1] if str(ROOT) not in sys.path: sys.path.insert(0, str(ROOT)) -from match_live_stream import choose_next_fetch_at, parse_match_live_detail_html +from match_live_stream import _build_detail_url, choose_next_fetch_at, parse_match_live_detail_html class MatchLiveStreamTest(unittest.TestCase): @@ -54,6 +54,17 @@ class MatchLiveStreamTest(unittest.TestCase): self.assertEqual(parsed["play_url_flv"], "http://b/flv") self.assertEqual(parsed["play_url_hd_flv"], "http://b/hdflv") + def test_build_detail_url_derives_room_id_from_source_url(self): + detail_url = _build_detail_url( + "https://yyzb1.tv/room/7988511?scheduleId=undefined", + now_ts=123456, + ) + + self.assertEqual( + detail_url, + "https://json.ncctrials.com/room/7988511/detail.json?v=123456", + ) + 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)