Files
gitlab-instance-0a899031_d2…/web2_youtube_preflight.py

21 lines
764 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""YouTube 开播前网络预检(参照 sh2 network_preflightWindows 版仅检 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再开始直播。"
)