21 lines
764 B
Python
21 lines
764 B
Python
"""YouTube 开播前网络预检(参照 sh2 network_preflight,Windows 版仅检 Google 可达)。"""
|
||
|
||
from __future__ import annotations
|
||
|
||
import httpx
|
||
|
||
from web2_network import CONNECT_TIMEOUT, GOOGLE_CHECK_URL, READ_TIMEOUT, _latency_get
|
||
|
||
|
||
async def youtube_start_preflight_message() -> str | None:
|
||
timeout = httpx.Timeout(READ_TIMEOUT, connect=CONNECT_TIMEOUT)
|
||
async with httpx.AsyncClient(timeout=timeout, follow_redirects=True) as client:
|
||
ok, _, err = await _latency_get(client, GOOGLE_CHECK_URL)
|
||
if ok:
|
||
return None
|
||
detail = err or "timeout"
|
||
return (
|
||
f"Google 出口不可达({detail}),YouTube 推流可能失败。"
|
||
"请先在「网络」页检测并配置代理/TUN,再开始直播。"
|
||
)
|