[object Object]

← back to Allnewsdaily

Fix live detection through residential proxy: anchor on live marker, not videoDetails proximity

acde7bd0f90d2d653b8cc310473955fad92ba647 · 2026-09-11 13:42:58 -0700 · Steve Abrams

YouTube serves a different ytInitialPlayerResponse layout to the proxy egress IP
than to Mac2's residential IP — the primary "isLive":true can sit ~370KB before
the "videoDetails" key, so the old /"videoDetails":\{[^}]*"isLive":true/ regex
matched 0/20 live channels through the proxy. Align detectLive with LIVE_MARKER
(hlsManifestUrl | isLive:true | isLiveNow:true). Verified no false positives on
non-live channels (Fox/MSNBC/BBC carry zero isLive:true through the proxy). TK-11340

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KdYQbarNfqKNkgQLQffDS4

Files touched

Diff

commit acde7bd0f90d2d653b8cc310473955fad92ba647
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Fri Sep 11 13:42:58 2026 -0700

    Fix live detection through residential proxy: anchor on live marker, not videoDetails proximity
    
    YouTube serves a different ytInitialPlayerResponse layout to the proxy egress IP
    than to Mac2's residential IP — the primary "isLive":true can sit ~370KB before
    the "videoDetails" key, so the old /"videoDetails":\{[^}]*"isLive":true/ regex
    matched 0/20 live channels through the proxy. Align detectLive with LIVE_MARKER
    (hlsManifestUrl | isLive:true | isLiveNow:true). Verified no false positives on
    non-live channels (Fox/MSNBC/BBC carry zero isLive:true through the proxy). TK-11340
    
    Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
    Claude-Session: https://claude.ai/code/session_01KdYQbarNfqKNkgQLQffDS4
---
 scripts/check-live.js | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/scripts/check-live.js b/scripts/check-live.js
index 3482b16..3367816 100644
--- a/scripts/check-live.js
+++ b/scripts/check-live.js
@@ -108,17 +108,19 @@ function fetchHtml(url, timeoutMs = 10000) {
 
 function detectLive(html) {
   // Marker 1 — hls manifest is present only when actively streaming
-  if (/"hlsManifestUrl":\s*"https:\/\/manifest\.googlevideo\.com/.test(html)) {
-    const m = html.match(/"videoId":\s*"([A-Za-z0-9_-]{11})"/);
-    return { isLive: true, videoId: m ? m[1] : null };
-  }
-  // Marker 2 — isLive:true inside videoDetails
-  if (/"videoDetails":\s*\{[^}]*"isLive":true/.test(html)) {
-    const m = html.match(/"videoId":\s*"([A-Za-z0-9_-]{11})"/);
-    return { isLive: true, videoId: m ? m[1] : null };
-  }
-  // Marker 3 — livestream microformat
-  if (/"liveBroadcastDetails":\s*\{[^}]*"isLiveNow":true/.test(html)) {
+  // Anchor on the live SIGNAL itself, not its position relative to "videoDetails".
+  // YouTube serves different ytInitialPlayerResponse layouts to different egress IPs
+  // (residential Mac2 vs the residential/ISP proxy prod now uses) — through the proxy the
+  // primary "isLive":true can sit ~370 KB *before* the "videoDetails" key, so the old
+  // proximity regex /"videoDetails":\{[^}]*"isLive":true/ missed every live channel and
+  // reported 0/20 live. These three markers match LIVE_MARKER exactly, so any marker that
+  // early-aborts the download is re-confirmed here. Verified no false positive: non-live
+  // channels (Fox/MSNBC/BBC) carry zero "isLive":true through the proxy (TK-11340).
+  if (
+    /"hlsManifestUrl":\s*"https:\/\/manifest\.googlevideo\.com/.test(html) ||
+    /"isLive":true/.test(html) ||
+    /"isLiveNow":true/.test(html)
+  ) {
     const m = html.match(/"videoId":\s*"([A-Za-z0-9_-]{11})"/);
     return { isLive: true, videoId: m ? m[1] : null };
   }

← 07451f1 Add approve ungate readiness launcher and verify error paths  ·  back to Allnewsdaily  ·  check-live: direct-first / residential-proxy-fallback for re ba93d26 →