fix(m0): a player that does not come back spoils its window instead of ending the stage

When loading the page again did not bring a player back, keep_room still
moved the missing player back to the start, the page script threw and the
stage stopped at the first window. Now a failed reload (or a refused
navigation) is recorded as "the video did not play again", only a playing
video is moved back (and the script checks the player exists), so the
window is measured as it is, not counted, and tried again up to the limit
before the stage goes on. The reload waits RELOAD_S for the video.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-11 02:04:59 +09:00
parent 6d0b3d5bec
commit 357f36afcc
2 changed files with 71 additions and 13 deletions

View File

@@ -48,6 +48,7 @@ ROUNDS = ("busy", "busy_cap95", "busy_cap95_2", "busy_2")
# this many times in all; one spoilt by a lower quality or frame rate is not (a busy GPU can cause that).
ATTEMPTS = 3
REPLAY_S = 30 # pressing play on a stopped player, before the page is loaded again
RELOAD_S = 120 # the page loaded again, until its video plays
# --------------------------------------------------------------------------
@@ -268,11 +269,15 @@ class VideoPage:
out.update(quality=snap.get("quality"), width=snap.get("width"), height=snap.get("height"))
return out
def reload(self) -> dict:
"""Load the watch page again (its counters go with it) and get the video going as at the start."""
self.cdp.call("Page.navigate", {"url": self.url})
def reload(self) -> bool:
"""Load the watch page again (its counters go with it) and get the video going as at the start.
False when it did not play again; the window is then measured as it is and not counted."""
try:
self.cdp.call("Page.navigate", {"url": self.url})
except RuntimeError:
return False
time.sleep(SETTLE_S)
return self.start(self.quality)
return bool(self.start(self.quality, timeout=RELOAD_S)["started"])
def keep_room(self, min_left: float = MIN_LEFT_S) -> list[str]:
"""Before a window: get a stopped, broken or reloaded player going again (pressing play first,
@@ -282,18 +287,21 @@ class VideoPage:
snap = self.snapshot()
if snap.get("error"):
did.append(f"the player showed an error: {_short(snap.get('error_text'))}")
if snap.get("lost") or snap.get("error"):
did.append("loaded the page again")
self.reload()
elif snap.get("paused") or snap.get("ended") or snap.get("ad_now") or not snap.get("height"):
reload = bool(snap.get("lost") or snap.get("error"))
if not reload and (snap.get("paused") or snap.get("ended") or snap.get("ad_now") or not snap.get("height")):
did.append("pressed play")
if not self.start(self.quality, timeout=REPLAY_S)["started"]:
did.append("loaded the page again")
self.reload()
reload = not self.start(self.quality, timeout=REPLAY_S)["started"]
if reload:
did.append("loaded the page again")
if not self.reload():
did.append("the video did not play again")
if did:
snap = self.snapshot()
if (snap.get("duration") or 0) - (snap.get("time") or 0) < min_left:
self.cdp.evaluate("(() => { document.getElementById('movie_player').seekTo(5, true); return true; })()")
# Only a playing video is moved back; a missing player is left to the window, which then does
# not count and is tried again.
if not snap.get("lost") and snap.get("duration") and snap["duration"] - (snap.get("time") or 0) < min_left:
self.cdp.evaluate("(() => { const p = document.getElementById('movie_player'); "
"if (p && p.seekTo) p.seekTo(5, true); return true; })()")
time.sleep(SETTLE_S)
self.cdp.evaluate(_INSTALL)
return did