Tighten http/youtubei live probes, classify Studio encoder_lost vs waiting, and keep dy/dylive public live counts aligned via edge assign_lives. Co-authored-by: Cursor <cursoragent@cursor.com>
44 lines
1.5 KiB
Python
44 lines
1.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
from __future__ import annotations
|
|
|
|
import time
|
|
|
|
from app import youtube_neko
|
|
|
|
|
|
def test_studio_live_control_url() -> None:
|
|
assert "UC123456789012345678" in youtube_neko.studio_live_control_url("UC123456789012345678")
|
|
assert youtube_neko.studio_live_control_url("UC123456789012345678").endswith("/livestreaming")
|
|
assert "studio.youtube.com" in youtube_neko.studio_live_control_url("")
|
|
|
|
|
|
def test_wait_group_ready_for_live_prefers_ops_telemetry() -> None:
|
|
youtube_neko._studio_events.clear() # noqa: SLF001
|
|
youtube_neko._studio_latest_by_ref.clear() # noqa: SLF001
|
|
now = time.time()
|
|
youtube_neko.ingest_studio_telemetry(
|
|
{
|
|
"neko_ref": "ops-2",
|
|
"neko_instance_id": "ops-2",
|
|
"url": "https://studio.youtube.com/channel/UCabcdefghijklmnopqr/livestreaming",
|
|
"live_status": "waiting",
|
|
"received_at": now,
|
|
"signals": {"path": "/livestreaming", "pending_go_live": True},
|
|
}
|
|
)
|
|
group = {
|
|
"id": "g1",
|
|
"neko_open_prefer": "remote",
|
|
"ops_neko_open_url": "https://dy.nomadro.cn/ops-neko/2/",
|
|
"ops_neko_slot": 2,
|
|
"neko_instance_id": 8,
|
|
"youtube_channel_id": "UCabcdefghijklmnopqr",
|
|
}
|
|
out = youtube_neko.wait_group_ready_for_live(
|
|
group, timeout_sec=3.0, settle_sec=0.5, strict=True
|
|
)
|
|
assert out.get("ok") is True
|
|
assert out.get("neko_kind") == "ops"
|
|
assert out.get("ops_slot") == 2
|
|
assert out.get("live_studio") is True
|