';s'
This commit is contained in:
parent
8552f56617
commit
151ac3218f
@ -41,6 +41,22 @@ def _youtube_bitrate_triplet(kbps: int) -> tuple[str, str, str]:
|
||||
return f"{n}k", f"{n}k", f"{n * 2}k"
|
||||
|
||||
|
||||
def _load_simple_env_file(path: str) -> dict[str, str]:
|
||||
out: dict[str, str] = {}
|
||||
if not os.path.isfile(path):
|
||||
return out
|
||||
with open(path, "r", encoding="utf-8-sig", errors="ignore") as fh:
|
||||
for line in fh:
|
||||
line = line.strip()
|
||||
if not line or line.startswith("#") or "=" not in line:
|
||||
continue
|
||||
k, _, v = line.partition("=")
|
||||
key = k.strip()
|
||||
if key.startswith("#"):
|
||||
continue
|
||||
out[key] = v.strip().strip('"').strip("'")
|
||||
return out
|
||||
|
||||
def _ffmpeg_stats_period_seconds(default: int = 5) -> str:
|
||||
raw = os.environ.get("LIVE_FFMPEG_STATS_PERIOD") or os.environ.get("YOUTUBE_FFMPEG_STATS_PERIOD") or str(default)
|
||||
try:
|
||||
@ -324,6 +340,10 @@ def _ffmpeg_env_with_push_proxy(
|
||||
use_proxychains: bool = False,
|
||||
) -> dict[str, str]:
|
||||
env = os.environ.copy()
|
||||
pm2 = _live_pm2_name()
|
||||
if pm2:
|
||||
env["LIVE_PM2_PROCESS_NAME"] = pm2
|
||||
env["PM2_SERVICE_NAME"] = pm2
|
||||
for key in _PROXY_ENV_KEYS:
|
||||
env.pop(key, None)
|
||||
|
||||
@ -375,6 +395,36 @@ def _proxychains_proxy_line(push_proxy: str) -> str | None:
|
||||
return " ".join(parts)
|
||||
|
||||
|
||||
def _looks_like_youtube_output_rejected(line_lower: str) -> bool:
|
||||
if not any(
|
||||
marker in line_lower
|
||||
for marker in (
|
||||
"rtmps://a.rtmps.youtube.com/live2/",
|
||||
"rtmp://a.rtmp.youtube.com/live2/",
|
||||
"youtube.com/live2/",
|
||||
)
|
||||
):
|
||||
return False
|
||||
if not any(
|
||||
marker in line_lower
|
||||
for marker in ("error opening output", "error opening output file", "error opening output files")
|
||||
):
|
||||
return False
|
||||
return any(
|
||||
marker in line_lower
|
||||
for marker in (
|
||||
"input/output error",
|
||||
"io error: end of file",
|
||||
"error in the pull function",
|
||||
"tls @",
|
||||
"401",
|
||||
"403",
|
||||
"unauthorized",
|
||||
"forbidden",
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def _proxychains_config_for_push(push_proxy: str) -> str | None:
|
||||
explicit = (
|
||||
os.environ.get("YOUTUBE_PROXYCHAINS_CONF")
|
||||
@ -552,6 +602,7 @@ def start_douyin_youtube_ffplay(
|
||||
|
||||
# ====================== 读取 YouTube 配置 ======================
|
||||
config_file = _resolve_youtube_push_config_file(config_file)
|
||||
_config_dir = os.path.dirname(os.path.abspath(config_file))
|
||||
rtmps_base = os.environ.get("YOUTUBE_RTMPS_BASE", "rtmps://a.rtmps.youtube.com/live2/")
|
||||
rtmp_base = os.environ.get("YOUTUBE_RTMP_BASE", "rtmp://a.rtmp.youtube.com/live2/")
|
||||
use_rtmps = True
|
||||
@ -612,6 +663,11 @@ def start_douyin_youtube_ffplay(
|
||||
print(f"[WARN] {ffmpeg_note}")
|
||||
if ffmpeg_bin != "ffmpeg":
|
||||
print(f"[INFO] YouTube push ffmpeg: {ffmpeg_bin}")
|
||||
if not _ffmpeg_supports_stats_period(ffmpeg_bin):
|
||||
print(
|
||||
f"[WARN] {_ffmpeg_display_name(ffmpeg_bin)} 不支持 -stats_period;"
|
||||
"建议执行 scripts/linux/upgrade_ffmpeg_newer.sh 以获得稳定 speed 指标"
|
||||
)
|
||||
|
||||
MAX_RETRY_DELAY = 90
|
||||
INITIAL_RETRY_DELAY = 3
|
||||
@ -629,6 +685,9 @@ def start_douyin_youtube_ffplay(
|
||||
"access denied",
|
||||
"server returned 403",
|
||||
"client disconnected",
|
||||
"error opening output file",
|
||||
"error opening output files",
|
||||
"error opening output",
|
||||
]
|
||||
# 瞬时错误:结束当前 ffmpeg 进程后由外层循环退避重连
|
||||
TRANSIENT_KEYWORDS = [
|
||||
@ -658,30 +717,13 @@ def start_douyin_youtube_ffplay(
|
||||
print(f"[INFO] {rec_info} 开始推流到 YouTube: {stream_title}")
|
||||
|
||||
# ====================== 视频编码:hardware.env(ARM)→ NVENC → libx264 ======================
|
||||
def _load_simple_env(path: str) -> dict[str, str]:
|
||||
out: dict[str, str] = {}
|
||||
if not os.path.isfile(path):
|
||||
return out
|
||||
with open(path, "r", encoding="utf-8-sig", errors="ignore") as fh:
|
||||
for line in fh:
|
||||
line = line.strip()
|
||||
if not line or line.startswith("#") or "=" not in line:
|
||||
continue
|
||||
k, _, v = line.partition("=")
|
||||
key = k.strip()
|
||||
if key.startswith("#"):
|
||||
continue
|
||||
out[key] = v.strip().strip('"').strip("'")
|
||||
return out
|
||||
|
||||
_hw_env = _load_simple_env_file(os.path.join(_config_dir, "hardware.env"))
|
||||
codec_v = "libx264"
|
||||
video_args = [
|
||||
"-preset", "ultrafast", "-tune", "zerolatency", "-profile:v", "high", "-level", "4.0",
|
||||
"-b:v", b_v, "-minrate", b_v, "-maxrate", maxrate, "-bufsize", bufsize,
|
||||
]
|
||||
|
||||
_config_dir = os.path.dirname(os.path.abspath(config_file))
|
||||
_hw_env = _load_simple_env(os.path.join(_config_dir, "hardware.env"))
|
||||
_want_enc = (_hw_env.get("LIVE_VIDEO_ENCODER") or "").strip()
|
||||
_hw_enc_active = False
|
||||
_encoders_blob = ""
|
||||
@ -924,14 +966,14 @@ def start_douyin_youtube_ffplay(
|
||||
proc = None
|
||||
stderr_q = None
|
||||
reader_t = None
|
||||
retry_delay = INITIAL_RETRY_DELAY
|
||||
retry_delay = 0
|
||||
|
||||
try:
|
||||
while True:
|
||||
try:
|
||||
if retry_delay > INITIAL_RETRY_DELAY:
|
||||
if retry_delay > 0:
|
||||
print(f"[WARN] 防风控等待 {retry_delay}s 后重新连接抖音源...")
|
||||
time.sleep(retry_delay)
|
||||
time.sleep(retry_delay)
|
||||
|
||||
cleanup_proc(proc)
|
||||
stderr_q = queue.Queue()
|
||||
@ -999,7 +1041,7 @@ def start_douyin_youtube_ffplay(
|
||||
if is_progress_line:
|
||||
last_ffmpeg_log_time = now_ts
|
||||
|
||||
if any(kw in line_lower for kw in TERMINAL_KEYWORDS):
|
||||
if any(kw in line_lower for kw in TERMINAL_KEYWORDS) or _looks_like_youtube_output_rejected(line_lower):
|
||||
print("[ERROR] 判定直播结束或平台明确拒绝,停止推流")
|
||||
cleanup_proc(proc)
|
||||
raise StreamEnded()
|
||||
@ -1016,7 +1058,7 @@ def start_douyin_youtube_ffplay(
|
||||
time_advanced = media_time is not None and media_time > last_progress_time + 0.01
|
||||
if frame_advanced or time_advanced:
|
||||
last_frame_time = time.time()
|
||||
retry_delay = INITIAL_RETRY_DELAY
|
||||
retry_delay = 0
|
||||
if frame is not None:
|
||||
last_progress_frame = frame
|
||||
if media_time is not None:
|
||||
|
||||
@ -72,6 +72,27 @@ def _source_title_from_url_lines(url_lines: str) -> str:
|
||||
return ""
|
||||
|
||||
|
||||
def _log_indicates_active_relay(recent_log: str) -> bool:
|
||||
text = (recent_log or "").lower()
|
||||
if "frame=" in text and "speed=" in text:
|
||||
return True
|
||||
return bool(_RECORDING_TITLE_RE.search(recent_log or "")) or bool(_LIVE_TITLE_RE.search(recent_log or ""))
|
||||
|
||||
|
||||
def _title_from_waiting_log_only(recent_log: str) -> str:
|
||||
lines = [line.strip() for line in (recent_log or "").splitlines() if line.strip()]
|
||||
for line in reversed(lines[-240:]):
|
||||
if _ERROR_CONTEXT_RE.search(line):
|
||||
continue
|
||||
match = _WAIT_TITLE_RE.search(line) or _STATUS_TITLE_RE.search(line)
|
||||
if not match:
|
||||
continue
|
||||
title = _clean_source_title(match.group(1))
|
||||
if title:
|
||||
return title
|
||||
return ""
|
||||
|
||||
|
||||
def _source_title_from_log(recent_log: str) -> str:
|
||||
lines = [line.strip() for line in (recent_log or "").splitlines() if line.strip()]
|
||||
tail = lines[-240:]
|
||||
@ -175,6 +196,19 @@ def extract_douyin_source_meta(url_lines: str = "", recent_log: str = "") -> dic
|
||||
source_url = ""
|
||||
title = ""
|
||||
|
||||
if (
|
||||
len(entries) > 1
|
||||
and title
|
||||
and not _log_indicates_active_relay(recent_log)
|
||||
and title == _title_from_waiting_log_only(recent_log)
|
||||
):
|
||||
pinned = entries[0]
|
||||
room_id = pinned["room_id"]
|
||||
source_url = pinned["source_url"]
|
||||
title = pinned.get("source_title", "") or title
|
||||
source_ambiguous = True
|
||||
source_current = False
|
||||
|
||||
display = title or (f"抖音直播间 {room_id}" if room_id else "")
|
||||
return {
|
||||
"source_title": title,
|
||||
|
||||
@ -199,5 +199,6 @@ def summarize_process_activity(
|
||||
"ffmpeg_speed": latest_progress.get("speed"),
|
||||
"ffmpeg_progress_stalled": progress_stalled,
|
||||
"ffmpeg_speed_low": speed_low,
|
||||
"is_pushing": business_status in {"streaming", "relay_slow"},
|
||||
"is_pushing": business_status in {"streaming", "relay_slow"}
|
||||
or (business_status == "source_stalled" and bool(pids)),
|
||||
}
|
||||
|
||||
80
d2ypp2/src/recorder_config.py
Normal file
80
d2ypp2/src/recorder_config.py
Normal file
@ -0,0 +1,80 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import configparser
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
SHARED_RECORDER_SECTIONS = frozenset(
|
||||
{"Cookie", "录制设置", "推送配置", "Authorization", "账号密码"}
|
||||
)
|
||||
|
||||
|
||||
def _read_ini_tolerant(path: Path, encoding: str) -> configparser.RawConfigParser:
|
||||
"""Parse ini files even when duplicate keys exist (keep first occurrence)."""
|
||||
parser = configparser.RawConfigParser()
|
||||
if not path.is_file():
|
||||
return parser
|
||||
section: str | None = None
|
||||
seen: dict[str, set[str]] = {}
|
||||
for raw_line in path.read_text(encoding=encoding, errors="ignore").splitlines():
|
||||
line = raw_line.strip()
|
||||
if not line or line.startswith("#") or line.startswith(";"):
|
||||
continue
|
||||
if line.startswith("[") and line.endswith("]"):
|
||||
section = line[1:-1].strip()
|
||||
seen.setdefault(section, set())
|
||||
continue
|
||||
if section is None or "=" not in line:
|
||||
continue
|
||||
key, _, value = line.partition("=")
|
||||
key = key.strip()
|
||||
if key in seen[section]:
|
||||
continue
|
||||
seen[section].add(key)
|
||||
if not parser.has_section(section):
|
||||
parser.add_section(section)
|
||||
parser.set(section, key, value.strip())
|
||||
return parser
|
||||
|
||||
|
||||
def shared_recorder_config_path(base_dir: str | Path) -> Path:
|
||||
return Path(base_dir) / "config" / "config.ini"
|
||||
|
||||
|
||||
def read_recorder_setting(
|
||||
*,
|
||||
base_dir: str | Path,
|
||||
lane_config_file: str | Path,
|
||||
section: str,
|
||||
option: str,
|
||||
default: Any = "",
|
||||
encoding: str = "utf-8-sig",
|
||||
) -> Any:
|
||||
"""Read recorder settings from lane config, then fall back to shared config.ini."""
|
||||
lane_path = Path(lane_config_file)
|
||||
lane_parser = configparser.RawConfigParser()
|
||||
if lane_path.is_file():
|
||||
lane_parser = _read_ini_tolerant(lane_path, encoding)
|
||||
if lane_parser.has_section(section) and lane_parser.has_option(section, option):
|
||||
value = lane_parser.get(section, option)
|
||||
if str(value).strip():
|
||||
return value
|
||||
|
||||
shared_path = shared_recorder_config_path(base_dir)
|
||||
if shared_path.is_file() and shared_path.resolve() != lane_path.resolve():
|
||||
shared_parser = _read_ini_tolerant(shared_path, encoding)
|
||||
if shared_parser.has_section(section) and shared_parser.has_option(section, option):
|
||||
return shared_parser.get(section, option)
|
||||
return default
|
||||
|
||||
|
||||
def recorder_config_target_path(
|
||||
*,
|
||||
base_dir: str | Path,
|
||||
lane_config_file: str | Path,
|
||||
section: str,
|
||||
) -> Path:
|
||||
"""Lane files own [youtube]; shared/global sections belong in config.ini."""
|
||||
if section in SHARED_RECORDER_SECTIONS:
|
||||
return shared_recorder_config_path(base_dir)
|
||||
return Path(lane_config_file)
|
||||
@ -19,7 +19,7 @@ import uuid
|
||||
from operator import itemgetter
|
||||
import urllib.parse
|
||||
import urllib.error
|
||||
from typing import List, Optional, Union
|
||||
from typing import Any, List, Optional, Union
|
||||
import httpx
|
||||
import ssl
|
||||
import re
|
||||
@ -67,7 +67,18 @@ async def get_play_url_list(m3u8: str, proxy: OptionalStr = None, header: Option
|
||||
return play_url_list
|
||||
|
||||
|
||||
async def get_douyin_web_stream_data(url: str, proxy_addr: OptionalStr = None, cookies: OptionalStr = None):
|
||||
_PARSE_WEB = "web"
|
||||
_PARSE_HTML = "html"
|
||||
_PARSE_APP = "app"
|
||||
|
||||
|
||||
async def get_douyin_web_stream_data(
|
||||
url: str,
|
||||
proxy_addr: OptionalStr = None,
|
||||
cookies: OptionalStr = None,
|
||||
*,
|
||||
_tried: frozenset[str] = frozenset(),
|
||||
):
|
||||
headers = {
|
||||
'cookie': 'ttwid=1%7C2iDIYVmjzMcpZ20fcaFde0VghXAA3NaNXE_SLR68IyE%7C1761045455'
|
||||
'%7Cab35197d5cfb21df6cbb2fa7ef1c9262206b062c315b9d04da746d0b37dfbc7d',
|
||||
@ -78,6 +89,7 @@ async def get_douyin_web_stream_data(url: str, proxy_addr: OptionalStr = None, c
|
||||
if cookies:
|
||||
headers['cookie'] = cookies
|
||||
|
||||
room_data: dict[str, Any] = {'anchor_name': ""}
|
||||
try:
|
||||
web_rid = url.split('?')[0].split('live.douyin.com/')[-1]
|
||||
params = {
|
||||
@ -138,13 +150,27 @@ async def get_douyin_web_stream_data(url: str, proxy_addr: OptionalStr = None, c
|
||||
room_data['stream_url']['hls_pull_url_map'] = {**origin_m3u8, **hls_pull_url_map}
|
||||
room_data['stream_url']['flv_pull_url'] = {**origin_flv, **flv_pull_url}
|
||||
except Exception as e:
|
||||
print(f"Douyin web API failed for {url}, trying HTML parser: {e}")
|
||||
if _PARSE_HTML not in _tried:
|
||||
return await get_douyin_stream_data(
|
||||
url=url,
|
||||
proxy_addr=proxy_addr,
|
||||
cookies=cookies,
|
||||
_tried=_tried | {_PARSE_WEB},
|
||||
)
|
||||
print(f"Error message: {e} Error line: {e.__traceback__.tb_lineno}")
|
||||
room_data = {'anchor_name': ""}
|
||||
return room_data
|
||||
|
||||
|
||||
@trace_error_decorator
|
||||
async def get_douyin_app_stream_data(url: str, proxy_addr: OptionalStr = None, cookies: OptionalStr = None) -> dict:
|
||||
async def get_douyin_app_stream_data(
|
||||
url: str,
|
||||
proxy_addr: OptionalStr = None,
|
||||
cookies: OptionalStr = None,
|
||||
*,
|
||||
_tried: frozenset[str] = frozenset(),
|
||||
) -> dict:
|
||||
headers = {
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
|
||||
'Chrome/141.0.0.0 Safari/537.36 Edg/141.0.0.0',
|
||||
@ -184,7 +210,18 @@ async def get_douyin_app_stream_data(url: str, proxy_addr: OptionalStr = None, c
|
||||
try:
|
||||
web_rid = url.split('?')[0].split('live.douyin.com/')
|
||||
if len(web_rid) > 1:
|
||||
return await get_douyin_web_stream_data(url, proxy_addr, cookies)
|
||||
if _PARSE_WEB not in _tried:
|
||||
return await get_douyin_web_stream_data(
|
||||
url, proxy_addr, cookies, _tried=_tried | {_PARSE_APP}
|
||||
)
|
||||
if _PARSE_HTML not in _tried:
|
||||
return await get_douyin_stream_data(
|
||||
url=url,
|
||||
proxy_addr=proxy_addr,
|
||||
cookies=cookies,
|
||||
_tried=_tried | {_PARSE_APP},
|
||||
)
|
||||
return {'anchor_name': ""}
|
||||
else:
|
||||
try:
|
||||
data = await get_sec_user_id(url, proxy_addr=proxy_addr)
|
||||
@ -229,7 +266,13 @@ async def get_douyin_app_stream_data(url: str, proxy_addr: OptionalStr = None, c
|
||||
|
||||
|
||||
@trace_error_decorator
|
||||
async def get_douyin_stream_data(url: str, proxy_addr: OptionalStr = None, cookies: OptionalStr = None) -> dict:
|
||||
async def get_douyin_stream_data(
|
||||
url: str,
|
||||
proxy_addr: OptionalStr = None,
|
||||
cookies: OptionalStr = None,
|
||||
*,
|
||||
_tried: frozenset[str] = frozenset(),
|
||||
) -> dict:
|
||||
headers = {
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0',
|
||||
'Accept-Language': 'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
|
||||
@ -245,10 +288,18 @@ async def get_douyin_stream_data(url: str, proxy_addr: OptionalStr = None, cooki
|
||||
match_json_str = re.search(r'(\{\\"state\\":.*?)]\\n"]\)', html_str)
|
||||
if not match_json_str:
|
||||
match_json_str = re.search(r'(\{\\"common\\":.*?)]\\n"]\)</script><div hidden', html_str)
|
||||
if not match_json_str:
|
||||
raise ValueError("douyin HTML state blob not found")
|
||||
json_str = match_json_str.group(1)
|
||||
cleaned_string = json_str.replace('\\', '').replace(r'u0026', r'&')
|
||||
room_store = re.search('"roomStore":(.*?),"linkmicStore"', cleaned_string, re.DOTALL).group(1)
|
||||
anchor_name = re.search('"nickname":"(.*?)","avatar_thumb', room_store, re.DOTALL).group(1)
|
||||
room_store_match = re.search('"roomStore":(.*?),"linkmicStore"', cleaned_string, re.DOTALL)
|
||||
if not room_store_match:
|
||||
raise ValueError("douyin HTML roomStore not found")
|
||||
room_store = room_store_match.group(1)
|
||||
anchor_match = re.search('"nickname":"(.*?)","avatar_thumb', room_store, re.DOTALL)
|
||||
if not anchor_match:
|
||||
raise ValueError("douyin HTML anchor nickname not found")
|
||||
anchor_name = anchor_match.group(1)
|
||||
room_store = room_store.split(',"has_commerce_goods"')[0] + '}}}'
|
||||
json_data = json.loads(room_store)['roomInfo']['room']
|
||||
json_data['anchor_name'] = anchor_name
|
||||
@ -281,7 +332,14 @@ async def get_douyin_stream_data(url: str, proxy_addr: OptionalStr = None, cooki
|
||||
|
||||
except Exception as e:
|
||||
print(f"First data retrieval failed: {url} Preparing to switch parsing methods due to {e}")
|
||||
return await get_douyin_app_stream_data(url=url, proxy_addr=proxy_addr, cookies=cookies)
|
||||
if _PARSE_APP not in _tried:
|
||||
return await get_douyin_app_stream_data(
|
||||
url=url,
|
||||
proxy_addr=proxy_addr,
|
||||
cookies=cookies,
|
||||
_tried=_tried | {_PARSE_HTML},
|
||||
)
|
||||
return {'anchor_name': ""}
|
||||
|
||||
|
||||
@trace_error_decorator
|
||||
|
||||
@ -101,6 +101,27 @@ def _ffmpeg_cmdline_markers(process_name: str, project_root: Path | None) -> lis
|
||||
str(config_dir / f"URL_config.{safe}.ini"),
|
||||
}
|
||||
)
|
||||
ini_path = config_dir / f"youtube.{safe}.ini"
|
||||
if ini_path.is_file():
|
||||
try:
|
||||
text = ini_path.read_text(encoding="utf-8", errors="replace")
|
||||
except OSError:
|
||||
text = ""
|
||||
for line in text.splitlines():
|
||||
match = re.match(r"^\s*key\s*=\s*(.+)$", line, flags=re.IGNORECASE)
|
||||
if not match:
|
||||
continue
|
||||
value = match.group(1).strip().split("#", 1)[0].strip()
|
||||
if not value:
|
||||
continue
|
||||
if "live2/" in value:
|
||||
stream_key = value.rsplit("live2/", 1)[-1].strip("/")
|
||||
else:
|
||||
stream_key = value
|
||||
if stream_key:
|
||||
markers.add(stream_key)
|
||||
markers.add(f"live2/{stream_key}")
|
||||
break
|
||||
return [m for m in markers if m]
|
||||
|
||||
|
||||
@ -414,6 +435,7 @@ class LocalProcessRegistry:
|
||||
"process_status": status,
|
||||
"out_path": out_path,
|
||||
"err_path": err_path,
|
||||
"pid": pid if status == "online" else 0,
|
||||
}
|
||||
|
||||
def status_table_text(self) -> str:
|
||||
@ -974,7 +996,17 @@ class WebProcessBackend:
|
||||
names.append(name)
|
||||
|
||||
if not self._use_pm2:
|
||||
return {name: self._local.describe_status(name) for name in names}
|
||||
runtime = await self._proc_runtime_items()
|
||||
out: dict[str, dict[str, Any]] = {}
|
||||
for name in names:
|
||||
info = self._local.describe_status(name)
|
||||
runtime_info = runtime.get(name)
|
||||
if runtime_info:
|
||||
info = dict(info)
|
||||
info["process_status"] = "online"
|
||||
info["pid"] = int(runtime_info.get("pid") or info.get("pid") or 0)
|
||||
out[name] = info
|
||||
return out
|
||||
|
||||
jlist = await self._pm2_jlist_index()
|
||||
runtime = await self._proc_runtime_items()
|
||||
@ -1054,6 +1086,8 @@ class WebProcessBackend:
|
||||
if cached and now - cached[0] <= self._ffmpeg_pid_cache_ttl:
|
||||
return list(cached[1])
|
||||
result = await asyncio.to_thread(_linux_ffmpeg_pids_for_process_tree, pid, root_pgid=pgid)
|
||||
if not result:
|
||||
result = await asyncio.to_thread(_linux_ffmpeg_pids_for_stack, process, self.base_dir)
|
||||
self._ffmpeg_pid_cache[cache_key] = (now, list(result))
|
||||
return result
|
||||
|
||||
|
||||
@ -28,22 +28,61 @@ def _as_int(value: Any) -> int | None:
|
||||
return None if parsed is None else max(0, int(parsed))
|
||||
|
||||
|
||||
_IDLE_MARKERS = (
|
||||
"等待直播",
|
||||
"waiting",
|
||||
"获取失败",
|
||||
"douyin web api failed",
|
||||
"无录制任务",
|
||||
"网址内容获取失败",
|
||||
"没有正在监测的直播",
|
||||
)
|
||||
|
||||
|
||||
def _line_implies_relay_idle(line: str) -> bool:
|
||||
lower = line.lower()
|
||||
if "frame=" in lower and "speed=" in lower:
|
||||
return False
|
||||
return any(marker in lower for marker in _IDLE_MARKERS) or "error" in lower or "failed" in lower
|
||||
|
||||
|
||||
def _latest_ffmpeg_stats_line(text: str, *, lookback: int = 12) -> str:
|
||||
lines = [line.strip() for line in str(text or "").splitlines() if line.strip()]
|
||||
if not lines:
|
||||
return ""
|
||||
tail = lines[-lookback:]
|
||||
stats_idx = -1
|
||||
stats_line = ""
|
||||
for idx in range(len(tail) - 1, -1, -1):
|
||||
line = tail[idx]
|
||||
lower = line.lower()
|
||||
if "frame=" in lower and "speed=" in lower:
|
||||
stats_idx = idx
|
||||
stats_line = line
|
||||
break
|
||||
if stats_idx < 0:
|
||||
return ""
|
||||
if any(_line_implies_relay_idle(line) for line in tail[stats_idx + 1 :]):
|
||||
return ""
|
||||
return stats_line
|
||||
|
||||
|
||||
def parse_ffmpeg_metrics(*texts: str) -> dict[str, Any]:
|
||||
raw = "\n".join(str(item or "") for item in texts)
|
||||
tail = raw[-16000:]
|
||||
metrics: dict[str, Any] = {}
|
||||
for match in _FFMPEG_KV_RE.finditer(tail):
|
||||
key = match.group("key").lower()
|
||||
value = match.group("value")
|
||||
if key in {"frame", "drop", "dup"}:
|
||||
metrics[key] = _as_int(value)
|
||||
elif key in {"fps", "speed", "bitrate"}:
|
||||
metrics[key] = _as_float(value)
|
||||
time_match = None
|
||||
for time_match in _TIME_RE.finditer(tail):
|
||||
pass
|
||||
if time_match:
|
||||
metrics["encoded_time"] = time_match.group("value")
|
||||
stats_line = _latest_ffmpeg_stats_line(tail)
|
||||
if stats_line:
|
||||
for match in _FFMPEG_KV_RE.finditer(stats_line):
|
||||
key = match.group("key").lower()
|
||||
value = match.group("value")
|
||||
if key in {"frame", "drop", "dup"}:
|
||||
metrics[key] = _as_int(value)
|
||||
elif key in {"fps", "speed", "bitrate"}:
|
||||
metrics[key] = _as_float(value)
|
||||
time_match = _TIME_RE.search(stats_line)
|
||||
if time_match:
|
||||
metrics["encoded_time"] = time_match.group("value")
|
||||
lower = tail.lower()
|
||||
metrics["error_count"] = sum(
|
||||
lower.count(token)
|
||||
@ -201,7 +240,7 @@ def build_youtube_quality_guard_report(
|
||||
"lanes": lanes,
|
||||
"recommendations": recommendations[:10],
|
||||
"ffmpeg_profile": {
|
||||
"target": "1080p30/RTMPS/AAC/stable input copy when possible",
|
||||
"target": "720p30 H.264 CBR / RTMPS / AAC 128k / hardware encoder when available",
|
||||
"guardrails": [
|
||||
"保持 FFmpeg speed 接近 1.00x",
|
||||
"长直播优先稳定码率与低错误率,而不是频繁重启",
|
||||
|
||||
@ -10,12 +10,12 @@ def normalize_youtube_video_save_type(raw_value: str, process_name: str) -> str:
|
||||
low_process = (process_name or "").strip().lower()
|
||||
force_youtube_push = low_process.startswith("youtube") or low_process.startswith("douyin_youtube")
|
||||
|
||||
if force_youtube_push:
|
||||
return "YOUTUBE"
|
||||
if normalized in YOUTUBE_PUSH_SAVE_TYPES:
|
||||
return "YOUTUBE"
|
||||
if normalized in LOCAL_RECORD_SAVE_TYPES:
|
||||
return normalized
|
||||
if force_youtube_push:
|
||||
return "YOUTUBE"
|
||||
return "TS"
|
||||
|
||||
|
||||
|
||||
@ -104,5 +104,27 @@ class DouyinSourceDisplayTests(unittest.TestCase):
|
||||
self.assertFalse(meta["source_current"])
|
||||
|
||||
|
||||
def test_pins_ambiguous_waiting_probe_title_to_first_configured_room(self) -> None:
|
||||
meta = extract_douyin_source_meta(
|
||||
"\n".join(
|
||||
[
|
||||
"https://live.douyin.com/11111111, 主播: 第一个主播",
|
||||
"https://live.douyin.com/22222222, 主播: 第二个主播",
|
||||
]
|
||||
),
|
||||
"\n".join(
|
||||
[
|
||||
"序号2 第二个主播 等待直播...",
|
||||
"序号1 第一个主播 等待直播...",
|
||||
]
|
||||
),
|
||||
)
|
||||
|
||||
self.assertEqual(meta["source_title"], "第一个主播")
|
||||
self.assertEqual(meta["source_room_id"], "11111111")
|
||||
self.assertTrue(meta["source_ambiguous"])
|
||||
self.assertFalse(meta["source_current"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
40
d2ypp2/tests/test_ffmpeg_metrics.py
Normal file
40
d2ypp2/tests/test_ffmpeg_metrics.py
Normal file
@ -0,0 +1,40 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import unittest
|
||||
|
||||
from src.youtube_quality_guard import parse_ffmpeg_metrics
|
||||
|
||||
|
||||
class FfmpegMetricsFrontendParityTests(unittest.TestCase):
|
||||
def test_uses_recent_stats_line_when_last_line_is_idle(self) -> None:
|
||||
metrics = parse_ffmpeg_metrics(
|
||||
"\n".join(
|
||||
[
|
||||
"序号2 第二个主播 等待直播...",
|
||||
"[FFmpeg] frame=9440 fps=30 bitrate=4186.4kbits/s speed=1.00x time=00:05:14.63",
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
self.assertEqual(metrics.get("fps"), 30.0)
|
||||
self.assertEqual(metrics.get("speed"), 1.0)
|
||||
self.assertEqual(metrics.get("bitrate"), 4186.4)
|
||||
self.assertEqual(metrics.get("frame"), 9440)
|
||||
|
||||
def test_ignores_stale_stats_after_waiting_lines(self) -> None:
|
||||
metrics = parse_ffmpeg_metrics(
|
||||
"\n".join(
|
||||
[
|
||||
"[FFmpeg] frame=9440 fps=30 bitrate=4186.4kbits/s speed=1.00x time=00:05:14.63",
|
||||
"序号2 第二个主播 等待直播...",
|
||||
"Douyin web API failed for https://live.douyin.com/141410319583",
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
self.assertNotIn("bitrate", metrics)
|
||||
self.assertNotIn("fps", metrics)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@ -128,7 +128,7 @@ class ProcessRuntimeStatusTests(unittest.TestCase):
|
||||
ffmpeg_pids=[1234],
|
||||
)
|
||||
self.assertEqual(state["business_status"], "source_stalled")
|
||||
self.assertFalse(state["is_pushing"])
|
||||
self.assertTrue(state["is_pushing"])
|
||||
self.assertTrue(state["ffmpeg_progress_stalled"])
|
||||
|
||||
def test_summarize_process_activity_marks_relay_slow_when_speed_stays_low(self) -> None:
|
||||
|
||||
56
d2ypp2/tests/test_recorder_config.py
Normal file
56
d2ypp2/tests/test_recorder_config.py
Normal file
@ -0,0 +1,56 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import configparser
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from src.recorder_config import read_recorder_setting
|
||||
|
||||
|
||||
class RecorderConfigTests(unittest.TestCase):
|
||||
def test_read_recorder_setting_falls_back_to_shared_cookie(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
config_dir = root / "config"
|
||||
config_dir.mkdir()
|
||||
shared = config_dir / "config.ini"
|
||||
lane = config_dir / "youtube.youtube2__ch_test.ini"
|
||||
shared.write_text(
|
||||
"\ufeff[Cookie]\n抖音cookie = shared-cookie-value\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
lane.write_text(
|
||||
"\ufeff[youtube]\nkey = test\n\n[Cookie]\n抖音cookie = \n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
value = read_recorder_setting(
|
||||
base_dir=root,
|
||||
lane_config_file=lane,
|
||||
section="Cookie",
|
||||
option="抖音cookie",
|
||||
default="",
|
||||
)
|
||||
self.assertEqual(value, "shared-cookie-value")
|
||||
|
||||
def test_lane_cookie_overrides_shared(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
config_dir = root / "config"
|
||||
config_dir.mkdir()
|
||||
shared = config_dir / "config.ini"
|
||||
lane = config_dir / "youtube.youtube2__ch_test.ini"
|
||||
shared.write_text("\ufeff[Cookie]\n抖音cookie = shared\n", encoding="utf-8")
|
||||
lane.write_text("\ufeff[Cookie]\n抖音cookie = lane\n", encoding="utf-8")
|
||||
value = read_recorder_setting(
|
||||
base_dir=root,
|
||||
lane_config_file=lane,
|
||||
section="Cookie",
|
||||
option="抖音cookie",
|
||||
default="",
|
||||
)
|
||||
self.assertEqual(value, "lane")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@ -8,6 +8,7 @@ from unittest.mock import AsyncMock, patch
|
||||
|
||||
from src.web_process_backend import (
|
||||
WebProcessBackend,
|
||||
_ffmpeg_cmdline_markers,
|
||||
_ffmpeg_pid_matches_process,
|
||||
build_pm2_start_command,
|
||||
pm2_process_entry_needs_recreate,
|
||||
@ -255,6 +256,32 @@ class WebProcessBackendTests(unittest.TestCase):
|
||||
self.assertEqual(text, "boom")
|
||||
set_desired.assert_not_awaited()
|
||||
|
||||
def test_local_process_infos_merges_runtime_scan_when_registry_missing_pid(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
base = Path(tmp)
|
||||
backend = WebProcessBackend(base, base / ".pm2" / "logs")
|
||||
backend._use_pm2 = False
|
||||
backend.ensure_mode = AsyncMock()
|
||||
with patch.object(
|
||||
backend,
|
||||
"_proc_runtime_items",
|
||||
AsyncMock(return_value={"youtube2__lane1": {"pid": 5151}}),
|
||||
):
|
||||
infos = asyncio.run(backend.process_infos(["youtube2__lane1"]))
|
||||
self.assertEqual(infos["youtube2__lane1"]["process_status"], "online")
|
||||
self.assertEqual(infos["youtube2__lane1"]["pid"], 5151)
|
||||
|
||||
def test_local_describe_status_includes_pid_for_online_process(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
base = Path(tmp)
|
||||
backend = WebProcessBackend(base, base / ".pm2" / "logs")
|
||||
registry = backend._local
|
||||
registry._write_state({"processes": {"youtube": {"pid": 4242, "script": "youtube.py"}}})
|
||||
with patch.object(registry, "_pid_alive", return_value=True):
|
||||
info = registry.describe_status("youtube")
|
||||
self.assertEqual(info["process_status"], "online")
|
||||
self.assertEqual(info["pid"], 4242)
|
||||
|
||||
def test_live_ffmpeg_pids_uses_process_tree_of_target_process(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
base_dir = Path(tmp)
|
||||
@ -271,6 +298,39 @@ class WebProcessBackendTests(unittest.TestCase):
|
||||
self.assertEqual(pids, [9876])
|
||||
finder.assert_called_once_with(4321, root_pgid=6789)
|
||||
|
||||
def test_live_ffmpeg_pids_falls_back_to_stack_markers_when_tree_empty(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
base_dir = Path(tmp)
|
||||
backend = WebProcessBackend(base_dir, base_dir / ".pm2" / "logs")
|
||||
backend.ensure_mode = AsyncMock()
|
||||
backend.process_infos = AsyncMock( # type: ignore[method-assign]
|
||||
return_value={"youtube2__lane1": {"pid": 4321, "process_status": "online"}}
|
||||
)
|
||||
|
||||
with patch("src.web_process_backend.os.getpgid", return_value=6789):
|
||||
with patch("src.web_process_backend._linux_ffmpeg_pids_for_process_tree", return_value=[]):
|
||||
with patch(
|
||||
"src.web_process_backend._linux_ffmpeg_pids_for_stack",
|
||||
return_value=[5555],
|
||||
) as stack_finder:
|
||||
pids = asyncio.run(backend.live_ffmpeg_pids("youtube2__lane1"))
|
||||
|
||||
self.assertEqual(pids, [5555])
|
||||
stack_finder.assert_called_once_with("youtube2__lane1", base_dir)
|
||||
|
||||
def test_ffmpeg_cmdline_markers_include_stream_key_suffix(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
base = Path(tmp)
|
||||
ini = base / "config" / "youtube.youtube2__lane1.ini"
|
||||
ini.parent.mkdir(parents=True, exist_ok=True)
|
||||
ini.write_text(
|
||||
"[youtube]\nkey = rtmps://a.rtmps.youtube.com/live2/test-stream-key\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
markers = _ffmpeg_cmdline_markers("youtube2__lane1", base)
|
||||
self.assertIn("live2/test-stream-key", markers)
|
||||
self.assertIn("test-stream-key", markers)
|
||||
|
||||
def test_ffmpeg_pid_matches_process_uses_exact_inherited_env_name(self) -> None:
|
||||
env_map = {
|
||||
"LIVE_PM2_PROCESS_NAME": "youtube2__lane1",
|
||||
|
||||
@ -85,7 +85,7 @@ class YoutubePushConfigTests(unittest.TestCase):
|
||||
|
||||
self.assertEqual(parsed["stream_key"], "bom-key")
|
||||
self.assertEqual(parsed["b_v"], "5500k")
|
||||
self.assertEqual(parsed["maxrate"], "6600k")
|
||||
self.assertEqual(parsed["maxrate"], "5500k")
|
||||
self.assertEqual(parsed["bufsize"], "11000k")
|
||||
self.assertTrue(parsed["fast_audio"])
|
||||
|
||||
|
||||
@ -17,6 +17,19 @@ class YoutubeQualityGuardTests(unittest.TestCase):
|
||||
self.assertEqual(metrics["drop"], 1)
|
||||
self.assertEqual(metrics["encoded_time"], "00:00:40.00")
|
||||
|
||||
def test_parse_ffmpeg_metrics_ignores_stale_bitrate_before_waiting_lines(self) -> None:
|
||||
metrics = parse_ffmpeg_metrics(
|
||||
"\n".join(
|
||||
[
|
||||
"[FFmpeg] frame=9440 fps=30 bitrate=4186.4kbits/s speed=1.00x time=00:05:14.63",
|
||||
"序号2 第二个主播 等待直播...",
|
||||
"Douyin web API failed for https://live.douyin.com/141410319583",
|
||||
]
|
||||
)
|
||||
)
|
||||
self.assertNotIn("bitrate", metrics)
|
||||
self.assertNotIn("speed", metrics)
|
||||
|
||||
def test_quality_report_flags_inactive_lane_and_missing_studio_samples(self) -> None:
|
||||
report = build_youtube_quality_guard_report(
|
||||
[
|
||||
|
||||
@ -10,9 +10,9 @@ class YoutubeRuntimeTests(unittest.TestCase):
|
||||
self.assertEqual(normalize_youtube_video_save_type("ts", "youtube"), "YOUTUBE")
|
||||
self.assertEqual(normalize_youtube_video_save_type("", "youtube2__lane1"), "YOUTUBE")
|
||||
|
||||
def test_explicit_local_record_format_is_preserved(self) -> None:
|
||||
self.assertEqual(normalize_youtube_video_save_type("mp4", "youtube"), "MP4")
|
||||
self.assertEqual(normalize_youtube_video_save_type("mkv", "douyin_youtube"), "MKV")
|
||||
def test_youtube_process_forces_push_even_with_local_format(self) -> None:
|
||||
self.assertEqual(normalize_youtube_video_save_type("mp4", "youtube"), "YOUTUBE")
|
||||
self.assertEqual(normalize_youtube_video_save_type("mkv", "douyin_youtube"), "YOUTUBE")
|
||||
|
||||
def test_non_youtube_process_falls_back_to_ts(self) -> None:
|
||||
self.assertEqual(normalize_youtube_video_save_type("ts", "tiktok"), "TS")
|
||||
@ -28,7 +28,7 @@ class YoutubeRuntimeTests(unittest.TestCase):
|
||||
cfg.write_text("[youtube]\nkey = abc\n", encoding="utf-8")
|
||||
settings = _load_youtube_push_settings(str(cfg))
|
||||
self.assertEqual(settings["b_v"], "4000k")
|
||||
self.assertEqual(settings["maxrate"], "4500k")
|
||||
self.assertEqual(settings["maxrate"], "4000k")
|
||||
self.assertEqual(settings["bufsize"], "8000k")
|
||||
self.assertTrue(settings["fast_audio"])
|
||||
|
||||
|
||||
25
d2ypp2/tools/_check_host04_errors.py
Normal file
25
d2ypp2/tools/_check_host04_errors.py
Normal file
@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env python3
|
||||
import paramiko
|
||||
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect("10.88.0.4", username="eric", password="4669805", timeout=20)
|
||||
B = "/home/eric/d2ypp2-src"
|
||||
|
||||
|
||||
def run(cmd: str) -> str:
|
||||
_, o, e = c.exec_command(f"export LC_ALL=C.UTF-8; {cmd}", timeout=90, get_pty=True)
|
||||
return (o.read() + e.read()).decode("utf-8", "replace")
|
||||
|
||||
|
||||
for label, cmd in [
|
||||
("proxychains_nameerror", f"grep -h '_proxychains_config_for_push' {B}/.pm2/logs/youtube2__*-err.log 2>/dev/null | tail -5 || echo none"),
|
||||
("duplicate_option", f"grep -h 'DuplicateOptionError' {B}/.pm2/logs/youtube2__*-err.log 2>/dev/null | tail -3 || echo none"),
|
||||
("outer_exception", f"grep -h '外层异常' {B}/.pm2/logs/youtube2__*-out.log 2>/dev/null | tail -5 || echo none"),
|
||||
("ffmpeg", "pgrep -af 'ffmpeg.*rtmps' | grep -v pgrep | head -3"),
|
||||
("recent_out", f"tail -8 {B}/.pm2/logs/youtube2__ch_mpwri36r_z5lm2-out.log 2>/dev/null"),
|
||||
]:
|
||||
print(f"=== {label} ===")
|
||||
print(run(cmd)[:1500])
|
||||
print()
|
||||
c.close()
|
||||
40
d2ypp2/tools/_check_host04_lanes.py
Normal file
40
d2ypp2/tools/_check_host04_lanes.py
Normal file
@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env python3
|
||||
import json
|
||||
import paramiko
|
||||
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect("10.88.0.4", username="eric", password="4669805", timeout=20)
|
||||
B = "/home/eric/d2ypp2-src"
|
||||
|
||||
|
||||
def run(cmd: str, timeout: int = 90) -> str:
|
||||
_, o, e = c.exec_command(f"export LC_ALL=C.UTF-8; {cmd}", timeout=timeout, get_pty=True)
|
||||
return (o.read() + e.read()).decode("utf-8", "replace")
|
||||
|
||||
|
||||
raw = run("curl -sS -m 12 'http://127.0.0.1:8001/process_monitor?family=youtube'")
|
||||
entries = json.loads(raw).get("entries", [])
|
||||
print("=== all youtube lanes ===")
|
||||
for row in entries:
|
||||
pm2 = row.get("pm2", "")
|
||||
if not pm2.startswith("youtube"):
|
||||
continue
|
||||
print(
|
||||
pm2,
|
||||
row.get("business_status"),
|
||||
f"pushing={row.get('is_pushing')}",
|
||||
f"speed={row.get('ffmpeg_speed')}",
|
||||
repr((row.get("source_display") or "")[:50]),
|
||||
)
|
||||
|
||||
print("\n=== ffmpeg ===")
|
||||
print(run("pgrep -af ffmpeg | grep -v pgrep | head -6"))
|
||||
|
||||
print("\n=== live profile lines ===")
|
||||
print(run(f"grep -h 'YouTube Live profile' {B}/.pm2/logs/youtube2__*-out.log 2>/dev/null | tail -6"))
|
||||
|
||||
print("\n=== recent errors ===")
|
||||
print(run(f"grep -hE '外层异常|NameError|DuplicateOption' {B}/.pm2/logs/youtube2__*-err.log 2>/dev/null | tail -5 || echo none"))
|
||||
|
||||
c.close()
|
||||
42
d2ypp2/tools/_check_host04_now.py
Normal file
42
d2ypp2/tools/_check_host04_now.py
Normal file
@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env python3
|
||||
import json
|
||||
import paramiko
|
||||
|
||||
HOST, USER, PASS, BASE = "10.88.0.4", "eric", "4669805", "/home/eric/d2ypp2-src"
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(HOST, username=USER, password=PASS, timeout=20)
|
||||
|
||||
|
||||
def run(cmd: str) -> str:
|
||||
_, o, e = c.exec_command(f"export LC_ALL=C.UTF-8; {cmd}", timeout=90, get_pty=True)
|
||||
return (o.read() + e.read()).decode("utf-8", "replace")
|
||||
|
||||
|
||||
checks = {
|
||||
"health": run("curl -sf -m 8 http://127.0.0.1:8001/health"),
|
||||
"copy_fn": run(f"grep -c _resolve_stream_copy_plan {BASE}/douyin_youtube_ffplay.py 2>/dev/null || echo 0").strip(),
|
||||
"key_guard": run(f"grep -c _looks_like_youtube_output_rejected {BASE}/douyin_youtube_ffplay.py").strip(),
|
||||
"relay": run(f"grep -c relay_strategy {BASE}/config/hardware-profile.json 2>/dev/null || echo 0").strip(),
|
||||
"ffmpeg": run("pgrep -af 'ffmpeg.*rtmps' | grep -v pgrep | head -3"),
|
||||
"profile": run(f"grep -h 'YouTube Live profile' {BASE}/.pm2/logs/youtube2__*-out.log 2>/dev/null | tail -4"),
|
||||
"speed": run(f"grep -h 'speed=' {BASE}/.pm2/logs/youtube2__*-out.log 2>/dev/null | tail -4"),
|
||||
"qg": run(
|
||||
"curl -sS -m 12 http://127.0.0.1:8001/hub/youtube/quality_guard | "
|
||||
"python3 -c \"import sys,json; d=json.load(sys.stdin); print(d.get('ffmpeg_profile',{}).get('target','?'))\""
|
||||
).strip(),
|
||||
}
|
||||
print(json.dumps(checks, ensure_ascii=False, indent=2))
|
||||
raw = run("curl -sS -m 12 'http://127.0.0.1:8001/process_monitor?family=youtube'")
|
||||
for row in json.loads(raw).get("entries", []):
|
||||
pm2 = row.get("pm2", "")
|
||||
if pm2.startswith("youtube2"):
|
||||
print(pm2, row.get("business_status"), row.get("is_pushing"), row.get("ffmpeg_speed"))
|
||||
|
||||
ok = (
|
||||
checks["copy_fn"] in {"0", ""}
|
||||
and checks["relay"] in {"0", ""}
|
||||
and "libx264" in (checks["ffmpeg"] + checks["profile"])
|
||||
)
|
||||
print("REGRESSION:", "PASS" if ok else "PARTIAL")
|
||||
c.close()
|
||||
26
d2ypp2/tools/_diag_host04_console.py
Normal file
26
d2ypp2/tools/_diag_host04_console.py
Normal file
@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env python3
|
||||
import paramiko
|
||||
|
||||
HOST, USER, PASS, BASE = "10.88.0.4", "eric", "4669805", "/home/eric/d2ypp2-src"
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(HOST, username=USER, password=PASS, timeout=20)
|
||||
|
||||
|
||||
def run(cmd: str, timeout: int = 120) -> str:
|
||||
_, o, e = c.exec_command(cmd, timeout=timeout, get_pty=True)
|
||||
return (o.read() + e.read()).decode("utf-8", "replace")
|
||||
|
||||
|
||||
for cmd in [
|
||||
"systemctl is-active live-console.service",
|
||||
"systemctl status live-console.service --no-pager -n 30",
|
||||
"journalctl -u live-console.service -n 50 --no-pager",
|
||||
f"cd {BASE} && . .venv/bin/activate && python -m py_compile web.py douyin_youtube_ffplay.py youtube.py",
|
||||
f"grep relay_strategy {BASE}/config/hardware-profile.json 2>/dev/null || echo no_relay",
|
||||
]:
|
||||
print("===", cmd[:100])
|
||||
print(run(cmd)[:4000])
|
||||
print()
|
||||
|
||||
c.close()
|
||||
55
d2ypp2/tools/_remote_cleanup_relay.py
Normal file
55
d2ypp2/tools/_remote_cleanup_relay.py
Normal file
@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env python3
|
||||
import glob
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
base = sys.argv[1]
|
||||
|
||||
def patch_ini() -> int:
|
||||
removed = 0
|
||||
for path in sorted(glob.glob(f"{base}/config/youtube.youtube2__*.ini")):
|
||||
lines_out = []
|
||||
for line in Path(path).read_text(encoding="utf-8-sig").splitlines():
|
||||
key = line.split("=", 1)[0].strip().lower()
|
||||
if key in {"video_mode", "bitrate"}:
|
||||
removed += 1
|
||||
continue
|
||||
lines_out.append(line)
|
||||
Path(path).write_text("\n".join(lines_out).rstrip() + "\n", encoding="utf-8")
|
||||
return removed
|
||||
|
||||
|
||||
def patch_profile() -> bool:
|
||||
p = Path(f"{base}/config/hardware-profile.json")
|
||||
if not p.is_file():
|
||||
return False
|
||||
data = json.loads(p.read_text(encoding="utf-8"))
|
||||
if isinstance(data, dict) and "relay_strategy" in data:
|
||||
data.pop("relay_strategy", None)
|
||||
p.write_text(json.dumps(data, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def patch_env() -> int:
|
||||
p = Path(f"{base}/config/hardware.env")
|
||||
if not p.is_file():
|
||||
return 0
|
||||
kept = []
|
||||
removed = 0
|
||||
for line in p.read_text(encoding="utf-8-sig").splitlines():
|
||||
key = line.split("=", 1)[0].strip()
|
||||
if key.startswith("LIVE_RELAY_"):
|
||||
removed += 1
|
||||
continue
|
||||
kept.append(line)
|
||||
p.write_text("\n".join(kept).rstrip() + "\n", encoding="utf-8")
|
||||
return removed
|
||||
|
||||
|
||||
text = Path(f"{base}/douyin_youtube_ffplay.py").read_text(encoding="utf-8", errors="ignore")
|
||||
print("ini_removed", patch_ini())
|
||||
print("relay_strategy_removed", patch_profile())
|
||||
print("relay_env_removed", patch_env())
|
||||
print("has_stream_copy_fn", "_resolve_stream_copy_plan" in text)
|
||||
28
d2ypp2/tools/_remote_douyin_diag2.py
Normal file
28
d2ypp2/tools/_remote_douyin_diag2.py
Normal file
@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env python3
|
||||
import paramiko
|
||||
|
||||
HOST, USER, PASS, BASE = "10.88.0.4", "eric", "4669805", "/home/eric/d2ypp2-src"
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(HOST, username=USER, password=PASS, timeout=20)
|
||||
|
||||
|
||||
def run(cmd: str, timeout: int = 120) -> str:
|
||||
_, o, e = c.exec_command(f"export LC_ALL=C.UTF-8; {cmd}", timeout=timeout, get_pty=True)
|
||||
return (o.read() + e.read()).decode("utf-8", "replace")
|
||||
|
||||
|
||||
cmds = [
|
||||
f"head -30 {BASE}/config/youtube.youtube2__ch_mpwri36r_z5lm2.ini",
|
||||
f"grep -i douyin {BASE}/config/config.ini 2>/dev/null | head -3 || echo no_douyin_cookie",
|
||||
f"grep -E 'push_proxy|proxy' {BASE}/config/youtube.youtube2__ch_mpwri36r_z5lm2.ini | head -5",
|
||||
f"cd {BASE} && . .venv/bin/activate && python tools/test_douyin_fetch.py https://live.douyin.com/29155980665 2>&1",
|
||||
f"grep -c 'def _proxychains_config_for_push' {BASE}/douyin_youtube_ffplay.py",
|
||||
f"grep -c 'Douyin web API failed' {BASE}/src/spider.py || echo 0",
|
||||
]
|
||||
for cmd in cmds:
|
||||
print("===", cmd[:100])
|
||||
print(run(cmd)[:2500])
|
||||
print()
|
||||
|
||||
c.close()
|
||||
58
d2ypp2/tools/apply_host04_like_05.py
Normal file
58
d2ypp2/tools/apply_host04_like_05.py
Normal file
@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Upload and run remote_patch_host04.py on 10.88.0.4, restart shellcrash, verify."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
import paramiko
|
||||
|
||||
HOST, USER, PASS = "10.88.0.4", "eric", "4669805"
|
||||
LOCAL = Path(__file__).resolve().parent / "remote_patch_host04.py"
|
||||
REMOTE = "/tmp/remote_patch_host04.py"
|
||||
|
||||
|
||||
def run(c: paramiko.SSHClient, cmd: str, timeout: int = 120) -> str:
|
||||
_, o, e = c.exec_command(cmd, timeout=timeout, get_pty=True)
|
||||
return (o.read() + e.read()).decode("utf-8", "replace")
|
||||
|
||||
|
||||
def main() -> int:
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(HOST, username=USER, password=PASS, timeout=20)
|
||||
|
||||
sftp = c.open_sftp()
|
||||
sftp.put(str(LOCAL), REMOTE)
|
||||
sftp.close()
|
||||
|
||||
print("=== apply patch ===")
|
||||
print(run(c, f"python3 {REMOTE}"))
|
||||
|
||||
print("\n=== restart shellcrash ===")
|
||||
print(run(c, f"echo '{PASS}' | sudo -S -p '' systemctl restart shellcrash && sleep 2 && systemctl is-active shellcrash"))
|
||||
|
||||
verify = (
|
||||
"curl -sS -m 8 -x socks5://127.0.0.1:7890 https://www.gstatic.com/generate_204 "
|
||||
"-w 'gstatic=%{http_code} t=%{time_total}\\n' -o /dev/null; "
|
||||
"curl -sS -m 10 -x socks5://127.0.0.1:7890 https://a.rtmps.youtube.com/ "
|
||||
"-w 'yt_rtmps_t=%{time_total}\\n' -o /dev/null 2>&1 | tail -1; "
|
||||
"python3 -c \"import urllib.request,json;print(json.load(urllib.request.urlopen('http://127.0.0.1:9999/proxies',timeout=5))['proxies']['\\U0001f680 \\u8282\\u70b9\\u9009\\u62e9']['now'])\""
|
||||
)
|
||||
print("\n=== verify proxy ===")
|
||||
print(run(c, verify))
|
||||
|
||||
print("\n=== config snapshot ===")
|
||||
print(run(c, "grep -H 'video_mode\\|bitrate\\|fast_audio' /home/eric/d2ypp2-src/config/youtube.youtube2__*.ini | head -10"))
|
||||
print(run(c, "cat /home/eric/d2ypp2-src/config/hardware.env"))
|
||||
print(run(c, "grep SHELLCRASH /home/eric/d2ypp2-src/config/system-stack.env"))
|
||||
|
||||
print("\n=== active ffmpeg (restart lanes from UI if needed) ===")
|
||||
print(run(c, "pgrep -af 'ffmpeg.*rtmps' || echo none"))
|
||||
|
||||
c.close()
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
97
d2ypp2/tools/check_host04_deep.py
Normal file
97
d2ypp2/tools/check_host04_deep.py
Normal file
@ -0,0 +1,97 @@
|
||||
#!/usr/bin/env python3
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
|
||||
import paramiko
|
||||
|
||||
HOST, USER, PASS = "10.88.0.4", "eric", "4669805"
|
||||
BASE = "/home/eric/d2ypp2-src"
|
||||
|
||||
|
||||
def run(cmd: str, timeout: int = 90) -> str:
|
||||
client = paramiko.SSHClient()
|
||||
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
client.connect(HOST, username=USER, password=PASS, timeout=20)
|
||||
_, stdout, stderr = client.exec_command(f"export LC_ALL=C.UTF-8; {cmd}", timeout=timeout)
|
||||
out = (stdout.read() + stderr.read()).decode("utf-8", "replace")
|
||||
client.close()
|
||||
return out.strip()
|
||||
|
||||
|
||||
def curl_json(path: str) -> tuple[int, object | str]:
|
||||
raw = run(f"curl -sS -m 12 -w '\\n__HTTP__%{{http_code}}' 'http://127.0.0.1:8001{path}'")
|
||||
if "__HTTP__" not in raw:
|
||||
return 0, raw
|
||||
body, code_s = raw.rsplit("__HTTP__", 1)
|
||||
code = int(code_s.strip() or "0")
|
||||
body = body.strip()
|
||||
if not body:
|
||||
return code, ""
|
||||
try:
|
||||
return code, json.loads(body)
|
||||
except json.JSONDecodeError:
|
||||
return code, body[:2000]
|
||||
|
||||
|
||||
def main() -> int:
|
||||
print("=== host ===")
|
||||
print(run("hostname"))
|
||||
|
||||
print("\n=== is_pushing fix on disk ===")
|
||||
print(run(f"grep -n 'is_pushing' {BASE}/src/process_runtime_status.py | tail -2"))
|
||||
|
||||
print("\n=== uvicorn ===")
|
||||
print(run("pgrep -af 'uvicorn web:app' | head -2"))
|
||||
|
||||
print("\n=== ffmpeg pushing ===")
|
||||
print(run("pgrep -af 'ffmpeg.*rtmps' | grep -v pgrep | head -3"))
|
||||
|
||||
code, data = curl_json("/process_monitor?family=youtube")
|
||||
print(f"\n=== process_monitor http={code} ===")
|
||||
if isinstance(data, dict):
|
||||
rows = data.get("rows") or []
|
||||
print("row_count", len(rows))
|
||||
for row in rows:
|
||||
print(
|
||||
f" {row.get('pm2')}: business={row.get('business_status')} "
|
||||
f"pushing={row.get('is_pushing')} label={row.get('label')} "
|
||||
f"display={row.get('source_display') or row.get('source_title') or '-'}"
|
||||
)
|
||||
else:
|
||||
print(data)
|
||||
|
||||
code, data = curl_json("/hub/youtube_pro_channels")
|
||||
print(f"\n=== pro_channels http={code} ===")
|
||||
if isinstance(data, dict):
|
||||
for ch in (data.get("channels") or [])[:8]:
|
||||
print(f" name={ch.get('name')} pm2={ch.get('pm2Name')}")
|
||||
else:
|
||||
print(data)
|
||||
|
||||
print("\n=== served page bundle ===")
|
||||
print(run("curl -sS -m 8 http://127.0.0.1/ | grep -o 'page-[a-z0-9]*\\.js' | head -3"))
|
||||
|
||||
print("\n=== bundle contains new UI strings ===")
|
||||
print(
|
||||
run(
|
||||
"python3 -c \"from pathlib import Path; import glob; "
|
||||
f"files=glob.glob('{BASE}/web-console/out/_next/static/chunks/app/page-*.js'); "
|
||||
"text=Path(files[0]).read_text('utf-8', errors='replace') if files else ''; "
|
||||
"needles=['当前转播线路','抖音源','Pro relay status']; "
|
||||
"[print(n, n in text) for n in needles]; "
|
||||
"print('file', files[0] if files else 'none', 'size', len(text))\""
|
||||
)
|
||||
)
|
||||
|
||||
print("\n=== lane logs (last 2 lines each) ===")
|
||||
print(run(f"for f in {BASE}/.pm2/logs/youtube2__*-out.log; do echo ---$f---; tail -n 2 $f; done"))
|
||||
|
||||
print("\n=== restart web if python module stale? ===")
|
||||
print(run(f"stat -c '%y' {BASE}/src/process_runtime_status.py; ps -o lstart= -p $(pgrep -f 'uvicorn web:app' | head -1) 2>/dev/null"))
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
103
d2ypp2/tools/check_host04_now.py
Normal file
103
d2ypp2/tools/check_host04_now.py
Normal file
@ -0,0 +1,103 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Quick remote check for 10.88.0.4 deployment and YouTube Pro status."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import sys
|
||||
|
||||
import paramiko
|
||||
|
||||
HOST, USER, PASS = "10.88.0.4", "eric", "4669805"
|
||||
BASE = "/home/eric/d2ypp2-src"
|
||||
|
||||
|
||||
def run(cmd: str, timeout: int = 60) -> str:
|
||||
client = paramiko.SSHClient()
|
||||
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
client.connect(HOST, username=USER, password=PASS, timeout=20)
|
||||
_, stdout, stderr = client.exec_command(f"export LC_ALL=C.UTF-8; {cmd}", timeout=timeout)
|
||||
out = (stdout.read() + stderr.read()).decode("utf-8", "replace")
|
||||
client.close()
|
||||
return out
|
||||
|
||||
|
||||
def main() -> int:
|
||||
checks: list[tuple[str, str]] = [
|
||||
("hostname", "hostname"),
|
||||
("health", "curl -sf -m 5 http://127.0.0.1:8001/health; echo"),
|
||||
(
|
||||
"web_root",
|
||||
"curl -sS -m 8 -o /dev/null -w 'http_code=%{http_code} size=%{size_download}' http://127.0.0.1/; echo",
|
||||
),
|
||||
(
|
||||
"console_built",
|
||||
"curl -sf -m 8 http://127.0.0.1:8001/server_info | python3 -c \"import sys,json; d=json.load(sys.stdin); print('console_built=', d.get('console_built'))\"",
|
||||
),
|
||||
(
|
||||
"ui_helpers",
|
||||
f"grep -n 'proLanePrimaryTitle\\|proLaneStatusLabel' {BASE}/web-console/components/live-product/LiveYoutubeUnmannedView.tsx | head -5",
|
||||
),
|
||||
(
|
||||
"backend_is_pushing",
|
||||
f"grep -n 'is_pushing' {BASE}/src/process_runtime_status.py | tail -2",
|
||||
),
|
||||
(
|
||||
"backend_ambiguous",
|
||||
f"grep -n '_log_indicates_active_relay' {BASE}/src/douyin_source_display.py | head -2",
|
||||
),
|
||||
(
|
||||
"web_out_mtime",
|
||||
f"ls -la {BASE}/web-console/out/index.html {BASE}/web-console/out/_next/static/chunks/app/page-*.js 2>/dev/null | tail -3",
|
||||
),
|
||||
("uvicorn", "pgrep -af 'uvicorn web:app' | head -2"),
|
||||
("youtube_procs", "pgrep -af 'youtube.py' | grep -v grep | head -8"),
|
||||
("ffmpeg", "pgrep -af 'ffmpeg.*rtmps' | head -3"),
|
||||
(
|
||||
"process_monitor",
|
||||
"""curl -sf -m 8 'http://127.0.0.1:8001/process_monitor?family=youtube' | python3 - <<'PY'
|
||||
import json,sys
|
||||
rows=json.load(sys.stdin).get('rows') or []
|
||||
for r in rows[:8]:
|
||||
print(
|
||||
f"{r.get('pm2')}: business={r.get('business_status')} pushing={r.get('is_pushing')} "
|
||||
f"display={r.get('source_display') or r.get('source_title') or '-'} label={r.get('label')}"
|
||||
)
|
||||
if not rows:
|
||||
print('no youtube rows')
|
||||
PY""",
|
||||
),
|
||||
(
|
||||
"pro_channels",
|
||||
"""curl -sf -m 8 'http://127.0.0.1:8001/hub/youtube_pro_channels' | python3 - <<'PY'
|
||||
import json,sys
|
||||
data=json.load(sys.stdin)
|
||||
channels=data.get('channels') or []
|
||||
print('channel_count=', len(channels))
|
||||
for ch in channels[:8]:
|
||||
print(f" id={ch.get('id')} name={ch.get('name')} pm2={ch.get('pm2Name')}")
|
||||
PY""",
|
||||
),
|
||||
(
|
||||
"recent_youtube_log",
|
||||
f"tail -n 8 {BASE}/.pm2/logs/youtube2__ch_mp9mm36r_2wn0r-out.log 2>/dev/null || "
|
||||
f"ls -1 {BASE}/.pm2/logs/*youtube*out.log 2>/dev/null | head -5",
|
||||
),
|
||||
(
|
||||
"js_bundle_has_fix",
|
||||
f"grep -l 'proLanePrimaryTitle\\|推流中' {BASE}/web-console/out/_next/static/chunks/app/page-*.js 2>/dev/null | head -1 | xargs -I{{}} sh -c 'echo bundle={{}}; grep -o proLanePrimaryTitle {{}} | head -1 || echo minified_no_symbol'",
|
||||
),
|
||||
]
|
||||
|
||||
for title, cmd in checks:
|
||||
print(f"\n=== {title} ===")
|
||||
try:
|
||||
text = run(cmd)
|
||||
print(text[:3000] if text else "(empty)")
|
||||
except Exception as exc:
|
||||
print(f"ERR: {exc}")
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
159
d2ypp2/tools/cleanup_relay_remote.py
Normal file
159
d2ypp2/tools/cleanup_relay_remote.py
Normal file
@ -0,0 +1,159 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Remove Cursor relay/copy artifacts from remote hosts and sync clean push code."""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import glob
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import paramiko
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
LOCAL_PUSH = ROOT / "douyin_youtube_ffplay.py"
|
||||
LOCAL_PROBE = ROOT / "scripts" / "hardware_probe.py"
|
||||
|
||||
|
||||
def run(ssh: paramiko.SSHClient, cmd: str, timeout: int = 120) -> str:
|
||||
_, stdout, stderr = ssh.exec_command(cmd, timeout=timeout, get_pty=True)
|
||||
out = (stdout.read() + stderr.read()).decode("utf-8", "replace")
|
||||
return out.strip()
|
||||
|
||||
|
||||
def sftp_put(sftp: paramiko.SFTPClient, local: Path, remote: str) -> None:
|
||||
sftp.put(str(local), remote)
|
||||
print(f"[ok] uploaded {local.name} -> {remote}")
|
||||
|
||||
|
||||
def patch_ini_files(base: str) -> int:
|
||||
removed = 0
|
||||
for path in sorted(glob.glob(f"{base}/config/youtube.youtube2__*.ini")):
|
||||
lines_out: list[str] = []
|
||||
for line in Path(path).read_text(encoding="utf-8-sig").splitlines():
|
||||
key = line.split("=", 1)[0].strip().lower()
|
||||
if key in {"video_mode", "bitrate"}:
|
||||
removed += 1
|
||||
continue
|
||||
lines_out.append(line)
|
||||
Path(path).write_text("\n".join(lines_out).rstrip() + "\n", encoding="utf-8")
|
||||
return removed
|
||||
|
||||
|
||||
def patch_hardware_profile(base: str) -> bool:
|
||||
profile_path = Path(f"{base}/config/hardware-profile.json")
|
||||
if not profile_path.is_file():
|
||||
return False
|
||||
data = json.loads(profile_path.read_text(encoding="utf-8"))
|
||||
if isinstance(data, dict) and "relay_strategy" in data:
|
||||
data.pop("relay_strategy", None)
|
||||
profile_path.write_text(json.dumps(data, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def cleanup_hardware_env(base: str) -> int:
|
||||
env_path = Path(f"{base}/config/hardware.env")
|
||||
if not env_path.is_file():
|
||||
return 0
|
||||
kept: list[str] = []
|
||||
removed = 0
|
||||
for line in env_path.read_text(encoding="utf-8-sig").splitlines():
|
||||
key = line.split("=", 1)[0].strip()
|
||||
if key.startswith("LIVE_RELAY_"):
|
||||
removed += 1
|
||||
continue
|
||||
kept.append(line)
|
||||
env_path.write_text("\n".join(kept).rstrip() + "\n", encoding="utf-8")
|
||||
return removed
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("host")
|
||||
parser.add_argument("--user", default="eric")
|
||||
parser.add_argument("--password", default=os.environ.get("LIVE_DEPLOY_PASS", "4669805"))
|
||||
parser.add_argument("--base", required=True, help="Remote repo base path")
|
||||
parser.add_argument("--restart", action="store_true")
|
||||
args = parser.parse_args()
|
||||
|
||||
if not LOCAL_PUSH.is_file():
|
||||
print(f"missing {LOCAL_PUSH}", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
ssh = paramiko.SSHClient()
|
||||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
ssh.connect(args.host, username=args.user, password=args.password, timeout=20)
|
||||
sftp = ssh.open_sftp()
|
||||
|
||||
remote_push = f"{args.base}/douyin_youtube_ffplay.py"
|
||||
remote_probe = f"{args.base}/scripts/hardware_probe.py"
|
||||
sftp_put(sftp, LOCAL_PUSH, remote_push)
|
||||
if LOCAL_PROBE.is_file():
|
||||
sftp_put(sftp, LOCAL_PROBE, remote_probe)
|
||||
sftp.close()
|
||||
|
||||
# Run cleanup on remote via inline python (paths are on remote)
|
||||
cleanup_py = f"""
|
||||
import glob, json
|
||||
from pathlib import Path
|
||||
base = {args.base!r}
|
||||
|
||||
def patch_ini():
|
||||
removed = 0
|
||||
for path in sorted(glob.glob(f"{{base}}/config/youtube.youtube2__*.ini")):
|
||||
lines_out = []
|
||||
for line in Path(path).read_text(encoding='utf-8-sig').splitlines():
|
||||
key = line.split('=', 1)[0].strip().lower()
|
||||
if key in {{'video_mode', 'bitrate'}}:
|
||||
removed += 1
|
||||
continue
|
||||
lines_out.append(line)
|
||||
Path(path).write_text('\\n'.join(lines_out).rstrip() + '\\n', encoding='utf-8')
|
||||
return removed
|
||||
|
||||
def patch_profile():
|
||||
p = Path(f"{{base}}/config/hardware-profile.json")
|
||||
if not p.is_file():
|
||||
return False
|
||||
data = json.loads(p.read_text(encoding='utf-8'))
|
||||
if isinstance(data, dict) and 'relay_strategy' in data:
|
||||
data.pop('relay_strategy', None)
|
||||
p.write_text(json.dumps(data, indent=2, ensure_ascii=False) + '\\n', encoding='utf-8')
|
||||
return True
|
||||
return False
|
||||
|
||||
def patch_env():
|
||||
p = Path(f"{{base}}/config/hardware.env")
|
||||
if not p.is_file():
|
||||
return 0
|
||||
kept = []
|
||||
removed = 0
|
||||
for line in p.read_text(encoding='utf-8-sig').splitlines():
|
||||
key = line.split('=', 1)[0].strip()
|
||||
if key.startswith('LIVE_RELAY_'):
|
||||
removed += 1
|
||||
continue
|
||||
kept.append(line)
|
||||
p.write_text('\\n'.join(kept).rstrip() + '\\n', encoding='utf-8')
|
||||
return removed
|
||||
|
||||
print('ini_removed', patch_ini())
|
||||
print('relay_strategy_removed', patch_profile())
|
||||
print('relay_env_removed', patch_env())
|
||||
has_copy_fn = '_resolve_stream_copy_plan' in Path(f"{{base}}/douyin_youtube_ffplay.py").read_text(encoding='utf-8', errors='ignore')
|
||||
print('has_stream_copy_fn', has_copy_fn)
|
||||
"""
|
||||
print(run(ssh, f"python3 -c {json.dumps(cleanup_py)}"))
|
||||
|
||||
if args.restart:
|
||||
print(run(ssh, f"cd {args.base} && pm2 restart youtube2__ch_mpwri36r_z5lm2 youtube2__ch_mpyvqkc0_gj63k 2>/dev/null || true"))
|
||||
print(run(ssh, f"grep -hE 'LIVE_VIDEO_ENCODER|YouTube Live profile|stream copy|libx264' {args.base}/.pm2/logs/youtube2__*-out.log 2>/dev/null | tail -8"))
|
||||
|
||||
ssh.close()
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
32
d2ypp2/tools/compare_04_05_speed.py
Normal file
32
d2ypp2/tools/compare_04_05_speed.py
Normal file
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python3
|
||||
import paramiko
|
||||
|
||||
def run(host, user, pw, cmd, timeout=60):
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(host, username=user, password=pw, timeout=15)
|
||||
_, o, e = c.exec_command(cmd, timeout=timeout, get_pty=True)
|
||||
out = (o.read() + e.read()).decode("utf-8", "replace")
|
||||
c.close()
|
||||
return out
|
||||
|
||||
HOSTS = [("10.88.0.4", "eric", "4669805"), ("10.88.0.5", "eric", "4669805")]
|
||||
|
||||
for host, user, pw in HOSTS:
|
||||
print(f"\n{'#'*70}\n# {host}\n{'#'*70}")
|
||||
cmds = [
|
||||
("live_speed", "for pid in $(pgrep -f 'ffmpeg.*rtmps'); do echo PID=$pid; ps -p $pid -o %cpu,%mem,etime,cmd --no-headers | head -c 200; echo; timeout 3 tail -c 8000 /proc/$pid/fd/2 2>/dev/null | tr '\\r' '\\n' | grep speed= | tail -3; done"),
|
||||
("proxychains", "pgrep -af proxychains; ps aux | grep proxychains | grep -v grep"),
|
||||
("top_mem", "ps aux --sort=-%mem | head -15"),
|
||||
("top_cpu", "ps aux --sort=-%cpu | head -15"),
|
||||
("services", "systemctl is-active live-console shellcrash 2>/dev/null; docker ps --format '{{.Names}} {{.Status}}' 2>/dev/null | wc -l"),
|
||||
("yt_proxy_test", "time curl -sS -m 15 -x socks5://127.0.0.1:7890 -o /dev/null -w 'yt_socks=%{http_code} spd=%{speed_download} time=%{time_total}\\n' https://a.rtmps.youtube.com/ 2>&1; time curl -sS -m 10 -o /dev/null -w 'douyin_pull=%{http_code} spd=%{speed_download} time=%{time_total}\\n' -H 'User-Agent: Mozilla/5.0' -H 'Referer: https://live.douyin.com/' 'http://pull-flv-l26.douyincdn.com/' 2>&1 | head -3"),
|
||||
("wg", "ip -br a | grep -E 'wgeasy|wg0|enp'; wg show wgeasy 2>/dev/null | head -5"),
|
||||
("lane_logs_mode", "grep -hE 'proxychains|push_proxy|stream copy|transcode|1080|1088|720' /home/eric/d2ypp2-src/.pm2/logs/youtube2__*-out.log 2>/dev/null | tail -12"),
|
||||
]
|
||||
for label, cmd in cmds:
|
||||
print(f"\n--- {label} ---")
|
||||
try:
|
||||
print(run(host, user, pw, cmd)[:5000].encode("ascii", "backslashreplace").decode())
|
||||
except Exception as ex:
|
||||
print(ex)
|
||||
56
d2ypp2/tools/compare_hosts.py
Normal file
56
d2ypp2/tools/compare_hosts.py
Normal file
@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Compare live streaming hosts on the same LAN."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
|
||||
import paramiko
|
||||
|
||||
HOSTS = [
|
||||
("10.88.0.4", "eric", "4669805"),
|
||||
("10.88.0.5", "eric", "4669805"),
|
||||
]
|
||||
|
||||
|
||||
def run(host: str, user: str, password: str, cmd: str, timeout: int = 45) -> str:
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(host, username=user, password=password, timeout=15)
|
||||
try:
|
||||
_, o, e = c.exec_command(cmd, timeout=timeout, get_pty=True)
|
||||
return (o.read() + e.read()).decode("utf-8", "replace")
|
||||
finally:
|
||||
c.close()
|
||||
|
||||
|
||||
def safe(text: str, limit: int = 6000) -> str:
|
||||
return text.encode("ascii", "backslashreplace").decode()[:limit]
|
||||
|
||||
|
||||
def main() -> None:
|
||||
cmds = [
|
||||
"hostname; uptime; free -h | head -2; nproc; uname -m",
|
||||
"curl -sS -m 8 http://127.0.0.1:8001/health 2>/dev/null || echo health_fail",
|
||||
"curl -sS -m 12 'http://127.0.0.1:8001/process_monitor?family=youtube&light=1' 2>/dev/null | head -c 5000",
|
||||
"pgrep -af 'ffmpeg.*rtmps' || echo NO_FFMPEG",
|
||||
"ps aux | grep 'd2ypp2.*/youtube.py' | grep -v grep || echo NO_YOUTUBE",
|
||||
"grep -E 'stream copy|transcode|speed=|Douyin web data fetch|YouTube Live profile' $(ls -t /home/eric/d2ypp2-src/.pm2/logs/youtube2__ch_*-out.log 2>/dev/null | head -2) 2>/dev/null | tail -8 || true",
|
||||
"test -f /home/eric/d2ypp2-src/douyin_youtube_ffplay.py && grep -c '_resolve_stream_copy_plan' /home/eric/d2ypp2-src/douyin_youtube_ffplay.py || echo NO_COPY_FIX",
|
||||
"grep -H 'video_mode\\|fast_audio' /home/eric/d2ypp2-src/config/youtube.youtube2__ch_*.ini 2>/dev/null | head -6",
|
||||
"curl -sS -m 5 -x socks5://127.0.0.1:7890 https://www.gstatic.com/generate_204 -w 'proxy7890=%{http_code}\\n' -o /dev/null 2>/dev/null; curl -sS -m 5 -x http://127.0.0.1:7894 https://www.gstatic.com/generate_204 -w 'proxy7894=%{http_code}\\n' -o /dev/null 2>/dev/null",
|
||||
"systemctl is-active shellcrash live-console 2>/dev/null; ss -tlnp 2>/dev/null | grep -E ':7890|:7894|:8001' || true",
|
||||
"ls -d /home/eric/d2ypp2* 2>/dev/null | head -5",
|
||||
]
|
||||
for host, user, password in HOSTS:
|
||||
print(f"\n{'#' * 70}\n# HOST {host}\n{'#' * 70}")
|
||||
for cmd in cmds:
|
||||
print(f"\n--- {cmd[:72]} ---")
|
||||
try:
|
||||
out = run(host, user, password, cmd)
|
||||
print(safe(out))
|
||||
except Exception as exc:
|
||||
print(f"ERROR: {exc}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
33
d2ypp2/tools/compare_hosts2.py
Normal file
33
d2ypp2/tools/compare_hosts2.py
Normal file
@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env python3
|
||||
import paramiko
|
||||
|
||||
HOSTS = [("10.88.0.4", "eric", "4669805"), ("10.88.0.5", "eric", "4669805")]
|
||||
|
||||
def run(host, user, pw, cmd, timeout=40):
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(host, username=user, password=pw, timeout=15)
|
||||
try:
|
||||
_, o, e = c.exec_command(cmd, timeout=timeout, get_pty=True)
|
||||
return (o.read() + e.read()).decode('utf-8', 'replace')
|
||||
finally:
|
||||
c.close()
|
||||
|
||||
cmds = [
|
||||
"lscpu | grep 'Model name'",
|
||||
"ps aux | grep youtube.py | grep -v grep",
|
||||
"ls -la /home/eric/d2ypp2/youtube.py /home/eric/d2ypp2-src/youtube.py 2>&1",
|
||||
"grep -r LIVE_PM2 /home/eric/d2ypp2-src/.pm2/logs/*.log 2>/dev/null | tail -1; ls /home/eric/d2ypp2/.pm2/logs/youtube2__ch_*-out.log 2>/dev/null | head -3",
|
||||
"cd /home/eric/d2ypp2 2>/dev/null || cd /home/eric/d2ypp2-src; pwd; .venv/bin/python -c \"import asyncio; from src.spider import get_douyin_app_stream_data; print('test')\" 2>&1 | head -3",
|
||||
"curl -sS -m 8 'http://127.0.0.1:8001/restart?process=youtube2__ch_mpwri36r_z5lm2' 2>/dev/null | head -c 300",
|
||||
"sleep 3; ps aux | grep youtube.py | grep -v grep | head -3",
|
||||
]
|
||||
|
||||
for host, user, pw in HOSTS:
|
||||
print('\n' + '='*20, host, '='*20)
|
||||
for cmd in cmds:
|
||||
print('\n--', cmd[:65])
|
||||
try:
|
||||
print(run(host, user, pw, cmd).encode('ascii','backslashreplace').decode()[:3500])
|
||||
except Exception as ex:
|
||||
print('ERR', ex)
|
||||
24
d2ypp2/tools/compare_hosts3.py
Normal file
24
d2ypp2/tools/compare_hosts3.py
Normal file
@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env python3
|
||||
import paramiko
|
||||
|
||||
def q(host, cmd, timeout=30):
|
||||
c=paramiko.SSHClient(); c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(host,username='eric',password='4669805',timeout=15)
|
||||
_,o,e=c.exec_command(cmd,timeout=timeout,get_pty=True)
|
||||
out=(o.read()+e.read()).decode('utf-8','replace')
|
||||
c.close(); return out
|
||||
|
||||
for host in ['10.88.0.4','10.88.0.5']:
|
||||
print('\n===',host,'===')
|
||||
for cmd in [
|
||||
'ls -la /opt/live/d2ypp/youtube.py /opt/live/d2ypp/douyin_youtube_ffplay.py 2>&1',
|
||||
'systemctl list-units --type=service --state=running 2>/dev/null | grep -Ei \"live|youtube|d2ypp\" || true',
|
||||
'cat /home/eric/d2ypp2-src/config/system-stack.env 2>/dev/null | grep -E \"^PORT=|^BASE|^REPO\" || true',
|
||||
'cat /opt/live/d2ypp/config/system-stack.env 2>/dev/null | grep -E \"^PORT=\" || true',
|
||||
'docker ps --format \"{{.Names}} {{.Status}}\" 2>/dev/null | wc -l',
|
||||
'free -h | grep -E \"Mem|Swap\"',
|
||||
'curl -sS -m 10 http://127.0.0.1:8001/stack/summary 2>/dev/null | head -c 2000',
|
||||
'ls /home/eric/d2ypp2-src/.pm2/pids/*.pid 2>/dev/null | wc -l; cat /home/eric/d2ypp2-src/.pm2/pids/*.pid 2>/dev/null | head -5',
|
||||
]:
|
||||
print('--',cmd[:60])
|
||||
print(q(host,cmd).encode('ascii','backslashreplace').decode()[:2500])
|
||||
21
d2ypp2/tools/compare_proxy_shellcrash.py
Normal file
21
d2ypp2/tools/compare_proxy_shellcrash.py
Normal file
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env python3
|
||||
import paramiko
|
||||
|
||||
CMDS = [
|
||||
"systemctl status shellcrash --no-pager 2>/dev/null | head -12",
|
||||
"tail -20 /tmp/ShellCrash/ShellCrash.log 2>/dev/null || tail -20 /var/log/shellcrash.log 2>/dev/null || echo no_log",
|
||||
"grep -E 'mode|proxy|mixed|tun|socks' /tmp/ShellCrash/config.yaml 2>/dev/null | head -20",
|
||||
"curl -sS -m 5 http://127.0.0.1:9090/proxies 2>/dev/null | head -c 500 || echo no_clash_api",
|
||||
"neko_count=$(docker ps 2>/dev/null | grep -c neko || echo 0); echo neko_containers=$neko_count; docker ps --format '{{.Names}} {{.Status}}' 2>/dev/null | grep neko",
|
||||
]
|
||||
|
||||
for host, pw in [("10.88.0.4", "4669805"), ("10.88.0.5", "4669805")]:
|
||||
print(f"\n{'='*50}\n{host}\n{'='*50}")
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(host, username="eric", password=pw, timeout=15)
|
||||
for cmd in CMDS:
|
||||
print(f"\n> {cmd[:70]}")
|
||||
_, o, e = c.exec_command(cmd, timeout=25, get_pty=True)
|
||||
print((o.read() + e.read()).decode()[:1200].encode("ascii", "backslashreplace").decode())
|
||||
c.close()
|
||||
87
d2ypp2/tools/compare_three_hosts_speed.py
Normal file
87
d2ypp2/tools/compare_three_hosts_speed.py
Normal file
@ -0,0 +1,87 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Compare streaming speed/config across 10.88.0.3/.4/.5."""
|
||||
from __future__ import annotations
|
||||
|
||||
import paramiko
|
||||
|
||||
HOSTS = [
|
||||
("10.88.0.3", "eric", "Xiao4669805"),
|
||||
("10.88.0.4", "eric", "4669805"),
|
||||
("10.88.0.5", "eric", "4669805"),
|
||||
]
|
||||
|
||||
CMDS = [
|
||||
("identity", "hostname; uname -m; nproc; free -h | grep Mem; uptime"),
|
||||
(
|
||||
"ffmpeg",
|
||||
"ffmpeg -hide_banner -version 2>&1 | head -3; which ffmpeg; ls -la $(which ffmpeg) 2>/dev/null",
|
||||
),
|
||||
("hw_profile", "cat /home/eric/d2ypp2-src/config/hardware-profile.json 2>/dev/null | head -c 2500"),
|
||||
("hardware_env", "cat /home/eric/d2ypp2-src/config/hardware.env 2>/dev/null"),
|
||||
("pm2", "PM2_HOME=/home/eric/d2ypp2-src/.pm2 pm2 list 2>/dev/null | head -25"),
|
||||
("ffmpeg_ps", "ps aux | grep -E 'ffmpeg.*rtmps' | grep -v grep"),
|
||||
(
|
||||
"speed_proc",
|
||||
r"""for pid in $(pgrep -f 'ffmpeg.*rtmps://a.rtmps.youtube.com' 2>/dev/null); do
|
||||
echo PID=$pid
|
||||
timeout 2 cat /proc/$pid/fd/2 2>/dev/null | tr '\r' '\n' | grep -E 'speed=|stream copy|transcode|YouTube Live profile' | tail -5
|
||||
done""",
|
||||
),
|
||||
("speed_api", "curl -sS -m 12 'http://127.0.0.1:8001/process_monitor?family=youtube' 2>/dev/null | head -c 4000"),
|
||||
(
|
||||
"youtube_ini",
|
||||
"grep -H 'video_mode\\|fast_audio\\|bitrate' /home/eric/d2ypp2-src/config/youtube.youtube2__*.ini 2>/dev/null | head -20",
|
||||
),
|
||||
(
|
||||
"code_hash",
|
||||
"md5sum /home/eric/d2ypp2-src/douyin_youtube_ffplay.py /home/eric/d2ypp2-src/youtube.py 2>/dev/null",
|
||||
),
|
||||
("load", "top -bn1 | head -5; echo ffmpeg_count=$(pgrep -cf ffmpeg)"),
|
||||
(
|
||||
"proxy",
|
||||
"curl -sS -m 5 -x socks5://127.0.0.1:7890 https://www.gstatic.com/generate_204 -w 'socks=%{http_code} time=%{time_total}\n' -o /dev/null 2>&1; "
|
||||
"curl -sS -m 5 -x http://127.0.0.1:7894 https://www.gstatic.com/generate_204 -w 'http=%{http_code} time=%{time_total}\n' -o /dev/null 2>&1",
|
||||
),
|
||||
(
|
||||
"recent_log",
|
||||
"grep -hE 'speed=|stream copy|transcode|YouTube Live profile|hardware relay' /home/eric/d2ypp2-src/.pm2/logs/youtube2__*-out.log 2>/dev/null | tail -10",
|
||||
),
|
||||
(
|
||||
"ffplay_re",
|
||||
"grep -n '\\-re' /home/eric/d2ypp2-src/douyin_youtube_ffplay.py | head -8",
|
||||
),
|
||||
(
|
||||
"static_ffmpeg",
|
||||
"file $(which ffmpeg); ldd $(which ffmpeg) 2>&1 | head -3",
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
def q(host: str, user: str, pw: str, cmd: str, timeout: int = 45) -> str:
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(host, username=user, password=pw, timeout=15)
|
||||
_, o, e = c.exec_command(cmd, timeout=timeout, get_pty=True)
|
||||
out = (o.read() + e.read()).decode("utf-8", "replace")
|
||||
c.close()
|
||||
return out
|
||||
|
||||
|
||||
def main() -> int:
|
||||
for host, user, pw in HOSTS:
|
||||
print(f"\n{'=' * 60}\nHOST {host}\n{'=' * 60}")
|
||||
try:
|
||||
for label, cmd in CMDS:
|
||||
print(f"\n--- {label} ---")
|
||||
try:
|
||||
out = q(host, user, pw, cmd)
|
||||
print(out[:4000].encode("ascii", "backslashreplace").decode())
|
||||
except Exception as exc:
|
||||
print(f"CMD_ERR: {exc}")
|
||||
except Exception as exc:
|
||||
print(f"CONNECT_FAIL: {exc}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
97
d2ypp2/tools/deploy_relay_fix.py
Normal file
97
d2ypp2/tools/deploy_relay_fix.py
Normal file
@ -0,0 +1,97 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Deploy relay fix, auto-tune hardware profile, and restart Pro lanes."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
import paramiko
|
||||
|
||||
HOST, USER, PASS = "10.88.0.4", "eric", "4669805"
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
REMOTE_BASE = "/home/eric/d2ypp2-src"
|
||||
LANES = ["youtube2__ch_mpwri36r_z5lm2", "youtube2__ch_mpyvqkc0_gj63k"]
|
||||
UPLOADS = {
|
||||
ROOT / "douyin_youtube_ffplay.py": f"{REMOTE_BASE}/douyin_youtube_ffplay.py",
|
||||
ROOT / "scripts" / "hardware_probe.py": f"{REMOTE_BASE}/scripts/hardware_probe.py",
|
||||
ROOT / "config" / "hardware.env.example": f"{REMOTE_BASE}/config/hardware.env.example",
|
||||
ROOT / "youtube.py": f"{REMOTE_BASE}/youtube.py",
|
||||
ROOT / "src" / "spider.py": f"{REMOTE_BASE}/src/spider.py",
|
||||
ROOT / "src" / "recorder_config.py": f"{REMOTE_BASE}/src/recorder_config.py",
|
||||
}
|
||||
|
||||
|
||||
def run(c: paramiko.SSHClient, cmd: str, timeout: int = 90) -> str:
|
||||
_, o, e = c.exec_command(cmd, timeout=timeout, get_pty=True)
|
||||
return (o.read() + e.read()).decode("utf-8", "replace")
|
||||
|
||||
|
||||
def main() -> int:
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(HOST, username=USER, password=PASS, timeout=20)
|
||||
sftp = c.open_sftp()
|
||||
for local, remote in UPLOADS.items():
|
||||
sftp.put(str(local), remote)
|
||||
print(f"uploaded {remote}")
|
||||
sftp.close()
|
||||
|
||||
print(
|
||||
run(
|
||||
c,
|
||||
f"echo '{PASS}' | sudo -S -p '' chown -R eric:eric {REMOTE_BASE}/config && "
|
||||
f"chmod -R u+rwX {REMOTE_BASE}/config && echo perms_ok",
|
||||
timeout=30,
|
||||
)
|
||||
)
|
||||
probe_raw = run(
|
||||
c,
|
||||
f"cd {REMOTE_BASE} && . .venv/bin/activate && "
|
||||
"python scripts/hardware_probe.py --write --apply-youtube-defaults",
|
||||
timeout=120,
|
||||
)
|
||||
print(probe_raw[:3500])
|
||||
print("\n=== hardware.env ===")
|
||||
print(run(c, f"grep LIVE_RELAY {REMOTE_BASE}/config/hardware.env 2>/dev/null || true"))
|
||||
print("\n=== lane ini ===")
|
||||
print(
|
||||
run(
|
||||
c,
|
||||
f"grep -H 'video_mode\\|fast_audio\\|bitrate' {REMOTE_BASE}/config/youtube.youtube2__ch_*.ini 2>/dev/null | head -10",
|
||||
)[:1500]
|
||||
)
|
||||
|
||||
for lane in LANES:
|
||||
print(run(c, f"curl -sS -m 60 'http://127.0.0.1:8001/restart?process={lane}'")[:220])
|
||||
time.sleep(4)
|
||||
|
||||
print("waiting 50s...")
|
||||
time.sleep(50)
|
||||
print(run(c, "pgrep -af 'ffmpeg.*rtmps' || echo none")[:4000])
|
||||
for lane in LANES:
|
||||
print(f"\n=== {lane} log ===")
|
||||
print(
|
||||
run(
|
||||
c,
|
||||
f"grep -E 'hardware relay|stream copy|YouTube Live profile|speed=' "
|
||||
f"{REMOTE_BASE}/.pm2/logs/{lane}-out.log | tail -6",
|
||||
)[:1200]
|
||||
)
|
||||
raw = run(c, "curl -sS -m 15 'http://127.0.0.1:8001/process_monitor?family=youtube&light=1'")
|
||||
try:
|
||||
data = json.loads(raw)
|
||||
for entry in data.get("entries", []):
|
||||
if entry.get("pm2") in LANES:
|
||||
print(
|
||||
f"{entry['pm2']}: {entry.get('business_status')} "
|
||||
f"speed={entry.get('ffmpeg_speed')} room={entry.get('source_room_id')}"
|
||||
)
|
||||
except json.JSONDecodeError:
|
||||
print(raw[:1500])
|
||||
c.close()
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
170
d2ypp2/tools/deploy_test_host04.py
Normal file
170
d2ypp2/tools/deploy_test_host04.py
Normal file
@ -0,0 +1,170 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Deploy current repo source to 10.88.0.4 for integration test, then verify clean regression."""
|
||||
from __future__ import annotations
|
||||
|
||||
import io
|
||||
import json
|
||||
import posixpath
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
import paramiko
|
||||
|
||||
HOST, USER, PASS = "10.88.0.4", "eric", "4669805"
|
||||
BASE = "/home/eric/d2ypp2-src"
|
||||
REPO = Path(__file__).resolve().parent.parent
|
||||
OUT = REPO / "web-console" / "out"
|
||||
|
||||
# Core files changed in this fix cycle — sync from local repo as source of truth.
|
||||
SYNC_FILES = [
|
||||
"douyin_youtube_ffplay.py",
|
||||
"youtube.py",
|
||||
"web.py",
|
||||
"scripts/hardware_probe.py",
|
||||
"src/youtube_runtime.py",
|
||||
"src/youtube_quality_guard.py",
|
||||
"src/process_runtime_status.py",
|
||||
"src/douyin_source_display.py",
|
||||
"src/web_process_backend.py",
|
||||
"src/spider.py",
|
||||
"web-console/lib/ffmpegMetrics.ts",
|
||||
"web-console/lib/youtubeConfigUtils.ts",
|
||||
"web-console/components/live-product/LiveYoutubeUnmannedView.tsx",
|
||||
"web-console/components/live-product/LiveProcessLiveLogCard.tsx",
|
||||
]
|
||||
|
||||
|
||||
def run(ssh: paramiko.SSHClient, cmd: str, timeout: int = 180) -> str:
|
||||
_, stdout, stderr = ssh.exec_command(f"export LC_ALL=C.UTF-8; {cmd}", timeout=timeout, get_pty=True)
|
||||
return (stdout.read() + stderr.read()).decode("utf-8", "replace").strip()
|
||||
|
||||
|
||||
def mkdir_p(sftp: paramiko.SFTPClient, remote_dir: str) -> None:
|
||||
remote_dir = remote_dir.replace("\\", "/").rstrip("/")
|
||||
parts = [p for p in remote_dir.split("/") if p]
|
||||
cur = ""
|
||||
for part in parts:
|
||||
cur = f"{cur}/{part}" if cur else f"/{part}"
|
||||
try:
|
||||
sftp.stat(cur)
|
||||
except OSError:
|
||||
sftp.mkdir(cur)
|
||||
|
||||
|
||||
def put_file(sftp: paramiko.SFTPClient, local: Path, remote: str) -> None:
|
||||
mkdir_p(sftp, posixpath.dirname(remote))
|
||||
if local.suffix.lower() in {".py", ".ts", ".tsx", ".sh"}:
|
||||
sftp.putfo(io.BytesIO(local.read_bytes().replace(b"\r\n", b"\n")), remote)
|
||||
else:
|
||||
sftp.put(str(local), remote)
|
||||
|
||||
|
||||
def put_tree(sftp: paramiko.SFTPClient, local_dir: Path, remote_dir: str) -> int:
|
||||
count = 0
|
||||
for path in sorted(local_dir.rglob("*")):
|
||||
if not path.is_file():
|
||||
continue
|
||||
rel = path.relative_to(local_dir).as_posix()
|
||||
remote = posixpath.join(remote_dir, rel)
|
||||
mkdir_p(sftp, posixpath.dirname(remote))
|
||||
sftp.put(str(path), remote)
|
||||
count += 1
|
||||
return count
|
||||
|
||||
|
||||
def lane_names(ssh: paramiko.SSHClient) -> list[str]:
|
||||
raw = run(ssh, f"ls {BASE}/config/youtube.youtube2__*.ini 2>/dev/null")
|
||||
names: list[str] = []
|
||||
for line in raw.splitlines():
|
||||
name = line.rsplit("/", 1)[-1]
|
||||
if name.startswith("youtube.") and name.endswith(".ini"):
|
||||
names.append(name[len("youtube.") : -len(".ini")])
|
||||
return sorted(names)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
if not (OUT / "index.html").is_file():
|
||||
raise SystemExit("missing web-console/out — run: cd web-console && npm run build")
|
||||
|
||||
ssh = paramiko.SSHClient()
|
||||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
ssh.connect(HOST, username=USER, password=PASS, timeout=25)
|
||||
sftp = ssh.open_sftp()
|
||||
|
||||
print("=== [1/5] upload repo source files ===")
|
||||
for rel in SYNC_FILES:
|
||||
local = REPO / rel
|
||||
if not local.is_file():
|
||||
print(f"[skip] missing {rel}")
|
||||
continue
|
||||
remote = f"{BASE}/{rel.replace(chr(92), '/')}"
|
||||
put_file(sftp, local, remote)
|
||||
print(f"[ok] {rel}")
|
||||
|
||||
print("\n=== [2/5] upload web-console/out ===")
|
||||
uploaded = put_tree(sftp, OUT, f"{BASE}/web-console/out")
|
||||
print(f"[ok] uploaded {uploaded} static files")
|
||||
|
||||
cleanup_py = (REPO / "tools" / "_remote_cleanup_relay.py").read_text(encoding="utf-8")
|
||||
with sftp.open("/tmp/_remote_cleanup_relay.py", "w") as fh:
|
||||
fh.write(cleanup_py)
|
||||
sftp.close()
|
||||
|
||||
print("\n=== [3/5] cleanup relay/copy artifacts on remote ===")
|
||||
print(run(ssh, f"python3 /tmp/_remote_cleanup_relay.py {BASE}"))
|
||||
|
||||
print("\n=== [4/5] restart live-console + youtube lanes ===")
|
||||
print(run(ssh, f"echo '{PASS}' | sudo -S -p '' systemctl restart live-console.service", timeout=90))
|
||||
print(run(ssh, "sleep 5; curl -sf -m 8 http://127.0.0.1:8001/health && echo health_ok"))
|
||||
for proc in lane_names(ssh):
|
||||
out = run(
|
||||
ssh,
|
||||
"curl -sS -m 60 -X POST 'http://127.0.0.1:8001/restart' "
|
||||
"-H 'Content-Type: application/json' "
|
||||
f"-d '{json.dumps({'process': proc})}'",
|
||||
)
|
||||
print(f"restart {proc}: {out[:220]}")
|
||||
time.sleep(12)
|
||||
|
||||
print("\n=== [5/5] regression verify (remote == repo source) ===")
|
||||
checks = [
|
||||
("no_stream_copy_fn", f"grep -c _resolve_stream_copy_plan {BASE}/douyin_youtube_ffplay.py || echo 0"),
|
||||
("has_key_reject_guard", f"grep -c _looks_like_youtube_output_rejected {BASE}/douyin_youtube_ffplay.py"),
|
||||
("force_youtube_push", f"grep -A2 'force_youtube_push' {BASE}/src/youtube_runtime.py | head -4"),
|
||||
("no_relay_strategy", f"grep relay_strategy {BASE}/config/hardware-profile.json 2>/dev/null || echo clean"),
|
||||
("no_video_mode_ini", f"grep -H video_mode {BASE}/config/youtube.youtube2__*.ini 2>/dev/null | head -3 || echo clean"),
|
||||
("ffmpeg_cmd", "pgrep -af 'ffmpeg.*rtmps' | grep -v pgrep | head -2"),
|
||||
("push_profile_log", f"grep -hE 'YouTube Live profile|stream copy|libx264' {BASE}/.pm2/logs/youtube2__*-out.log 2>/dev/null | tail -6"),
|
||||
("quality_guard_profile", "curl -sS -m 12 http://127.0.0.1:8001/hub/youtube/quality_guard | python3 -c \"import sys,json;d=json.load(sys.stdin);print(d.get('ffmpeg_profile',{}).get('target','?'))\""),
|
||||
("process_monitor", "curl -sS -m 12 'http://127.0.0.1:8001/process_monitor?family=youtube'"),
|
||||
]
|
||||
monitor_rows: list[dict] = []
|
||||
for label, cmd in checks:
|
||||
out = run(ssh, cmd)
|
||||
print(f"\n--- {label} ---\n{out[:1200]}")
|
||||
if label == "process_monitor":
|
||||
try:
|
||||
monitor_rows = json.loads(out).get("entries") or []
|
||||
except json.JSONDecodeError:
|
||||
pass
|
||||
|
||||
print("\n=== summary ===")
|
||||
copy_fn = run(ssh, f"grep -c _resolve_stream_copy_plan {BASE}/douyin_youtube_ffplay.py || true").strip()
|
||||
relay = run(ssh, f"grep -c relay_strategy {BASE}/config/hardware-profile.json 2>/dev/null || echo 0").strip()
|
||||
ffmpeg = run(ssh, "pgrep -af 'ffmpeg.*rtmps' | grep -v pgrep | head -1")
|
||||
ok = copy_fn in {"0", ""} and relay in {"0", ""} and "libx264" in ffmpeg
|
||||
print(f"stream_copy_removed={copy_fn in {'0', ''}}")
|
||||
print(f"relay_strategy_removed={relay in {'0', ''}}")
|
||||
print(f"libx264_push={'libx264' in ffmpeg}")
|
||||
for row in monitor_rows[:8]:
|
||||
print(
|
||||
f" {row.get('pm2')}: {row.get('business_status')} pushing={row.get('is_pushing')} "
|
||||
f"speed={row.get('ffmpeg_speed')}"
|
||||
)
|
||||
print(f"\n回归源码: {'PASS' if ok else 'CHECK LOGS'} — remote {BASE} synced from local repo")
|
||||
ssh.close()
|
||||
return 0 if ok else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
40
d2ypp2/tools/diag_host04_ffmpeg_match.py
Normal file
40
d2ypp2/tools/diag_host04_ffmpeg_match.py
Normal file
@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env python3
|
||||
import paramiko
|
||||
|
||||
HOST, USER, PASS = "10.88.0.4", "eric", "4669805"
|
||||
BASE = "/home/eric/d2ypp2-src"
|
||||
|
||||
REMOTE_PY = f"""
|
||||
import os, json
|
||||
from pathlib import Path
|
||||
os.chdir('{BASE}')
|
||||
import sys
|
||||
sys.path.insert(0, '{BASE}')
|
||||
from src.web_process_backend import (
|
||||
_linux_ffmpeg_pids_for_process_tree,
|
||||
_linux_ffmpeg_pids_for_stack,
|
||||
_ffmpeg_cmdline_markers,
|
||||
_ffmpeg_pid_matches_process,
|
||||
_read_proc_env_value,
|
||||
)
|
||||
|
||||
ff = [int(x) for x in os.popen("pgrep -f 'ffmpeg.*rtmps'").read().split() if x.strip().isdigit()]
|
||||
print('ffmpeg_pids', ff)
|
||||
for pid in ff[:3]:
|
||||
cmd = (Path('/proc')/str(pid)/'cmdline').read_bytes().replace(b'\\0', b' ').decode('utf-8','replace')[:300]
|
||||
print('cmd', pid, cmd)
|
||||
for proc in ['youtube2__ch_mpwri36r_z5lm2','youtube2__ch_mpyvqkc0_gj63k']:
|
||||
print(' env_match', proc, _ffmpeg_pid_matches_process(pid, proc))
|
||||
print(' markers', _ffmpeg_cmdline_markers(proc, Path('{BASE}'))[:4])
|
||||
|
||||
for proc in ['youtube2__ch_mpwri36r_z5lm2','youtube2__ch_mpyvqkc0_gj63k']:
|
||||
ypid = [x for x in os.popen(f"pgrep -f 'youtube.py'").read().split() if x.strip().isdigit()]
|
||||
print('proc', proc, 'youtube_pids', ypid[:4])
|
||||
stack = _linux_ffmpeg_pids_for_stack(proc, Path('{BASE}'))
|
||||
print(' stack_match', stack)
|
||||
"""
|
||||
|
||||
c = paramiko.SSHClient(); c.set_missing_host_key_policy(paramiko.AutoAddPolicy()); c.connect(HOST, username=USER, password=PASS, timeout=20)
|
||||
_, o, e = c.exec_command(f"cd {BASE} && .venv/bin/python - <<'PY'\n{REMOTE_PY}\nPY", timeout=90)
|
||||
print((o.read()+e.read()).decode('utf-8','replace'))
|
||||
c.close()
|
||||
36
d2ypp2/tools/diag_host04_live_ffmpeg_pids.py
Normal file
36
d2ypp2/tools/diag_host04_live_ffmpeg_pids.py
Normal file
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python3
|
||||
import asyncio
|
||||
import json
|
||||
import paramiko
|
||||
|
||||
HOST, USER, PASS = "10.88.0.4", "eric", "4669805"
|
||||
BASE = "/home/eric/d2ypp2-src"
|
||||
PY = f"""
|
||||
import asyncio, json, os
|
||||
os.chdir('{BASE}')
|
||||
import sys
|
||||
sys.path.insert(0, '{BASE}')
|
||||
from pathlib import Path
|
||||
from src.web_process_backend import WebProcessBackend
|
||||
|
||||
async def main():
|
||||
backend = WebProcessBackend(Path('{BASE}'), Path('{BASE}/.pm2/logs'))
|
||||
await backend.ensure_mode()
|
||||
for proc in ['youtube2__ch_mpwri36r_z5lm2','youtube2__ch_mpyvqkc0_gj63k']:
|
||||
info = (await backend.process_infos([proc])).get(proc) or {{}}
|
||||
pids = await backend.live_ffmpeg_pids(proc, info)
|
||||
print(proc, 'status=', info.get('process_status'), 'pid=', info.get('pid'), 'ffmpeg_pids=', pids)
|
||||
|
||||
asyncio.run(main())
|
||||
"""
|
||||
|
||||
c = paramiko.SSHClient(); c.set_missing_host_key_policy(paramiko.AutoAddPolicy()); c.connect(HOST,username=USER,password=PASS,timeout=20)
|
||||
_, o, e = c.exec_command(f"cd {BASE} && .venv/bin/python - <<'PY'\n{PY}\nPY", timeout=90)
|
||||
print((o.read()+e.read()).decode('utf-8','replace'))
|
||||
raw = (o.read()+e.read()).decode('utf-8','replace')
|
||||
c.close()
|
||||
|
||||
c = paramiko.SSHClient(); c.set_missing_host_key_policy(paramiko.AutoAddPolicy()); c.connect(HOST,username=USER,password=PASS,timeout=20)
|
||||
_, o, e = c.exec_command(f"curl -sS -m 12 'http://127.0.0.1:8001/process_monitor?family=youtube&light=0'", timeout=90)
|
||||
print((o.read()+e.read()).decode('utf-8','replace')[:3000])
|
||||
c.close()
|
||||
33
d2ypp2/tools/diag_host4_speed.py
Normal file
33
d2ypp2/tools/diag_host4_speed.py
Normal file
@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env python3
|
||||
import paramiko
|
||||
|
||||
HOST, USER, PASS = "10.88.0.4", "eric", "4669805"
|
||||
|
||||
CMDS = [
|
||||
("mem_detail", "free -h; swapon --show; cat /proc/meminfo | grep -E 'MemTotal|MemAvailable|Swap'"),
|
||||
("cpu", "lscpu | grep -E 'Model name|CPU\\(s\\)|MHz'"),
|
||||
("deploy_path", "ls -la /home/eric/d2ypp2-src/ /opt/live/d2ypp/ 2>&1 | head -20"),
|
||||
("hw_files", "ls -la /home/eric/d2ypp2-src/config/hardware* 2>&1; cat /home/eric/d2ypp2-src/config/hardware-profile.json 2>/dev/null"),
|
||||
("hw_env", "cat /home/eric/d2ypp2-src/config/hardware.env 2>/dev/null"),
|
||||
("pm2_full", "PM2_HOME=/home/eric/d2ypp2-src/.pm2 pm2 list 2>/dev/null"),
|
||||
("ffmpeg_cmd", "ps auxww | grep -E 'ffmpeg.*rtmps' | grep -v grep"),
|
||||
("stream_mode", "grep -hE 'stream copy|transcode|YouTube Live profile|hardware relay|video_mode' /home/eric/d2ypp2-src/.pm2/logs/youtube2__*-out.log 2>/dev/null | tail -15"),
|
||||
("speed_lines", "grep -h 'speed=' /home/eric/d2ypp2-src/.pm2/logs/youtube2__*-out.log 2>/dev/null | tail -20"),
|
||||
("ini_all", "grep -H '' /home/eric/d2ypp2-src/config/youtube*.ini 2>/dev/null | head -40"),
|
||||
("quality", "curl -sS -m 15 http://127.0.0.1:8001/youtube/quality_guard 2>/dev/null | head -c 5000"),
|
||||
("process_mon", "curl -sS -m 15 'http://127.0.0.1:8001/process_monitor?family=youtube' 2>/dev/null"),
|
||||
("compare_ffmpeg", "which -a ffmpeg; /usr/bin/ffmpeg -version 2>&1 | head -1; /usr/local/bin/ffmpeg -version 2>&1 | head -1"),
|
||||
("docker_neko", "docker ps --format '{{.Names}} {{.Status}}' 2>/dev/null | head -15"),
|
||||
("load_per_cpu", "mpstat -P ALL 1 1 2>/dev/null || top -bn1 | head -8"),
|
||||
("oom", "dmesg 2>/dev/null | grep -iE 'oom|killed process' | tail -5; journalctl -k --no-pager 2>/dev/null | grep -i oom | tail -3"),
|
||||
]
|
||||
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(HOST, username=USER, password=PASS, timeout=15)
|
||||
for label, cmd in CMDS:
|
||||
print(f"\n=== {label} ===")
|
||||
_, o, e = c.exec_command(cmd, timeout=60, get_pty=True)
|
||||
out = (o.read() + e.read()).decode("utf-8", "replace")
|
||||
print(out[:6000].encode("ascii", "backslashreplace").decode())
|
||||
c.close()
|
||||
26
d2ypp2/tools/diag_lane_status_mismatch.py
Normal file
26
d2ypp2/tools/diag_lane_status_mismatch.py
Normal file
@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env python3
|
||||
import json
|
||||
import paramiko
|
||||
|
||||
HOST, USER, PASS = "10.88.0.4", "eric", "4669805"
|
||||
|
||||
CMDS = [
|
||||
"cat /home/eric/d2ypp2-src/.process_runner/state.json 2>/dev/null",
|
||||
"ps auxww | grep 'd2ypp2-src/youtube.py' | grep -v grep",
|
||||
"for pid in $(pgrep -f 'ffmpeg.*rtmps'); do echo FFMPEG=$pid PPID=$(ps -o ppid= -p $pid | tr -d ' ') PGID=$(ps -o pgid= -p $pid | tr -d ' '); ps -p $pid -o user,cmd --no-headers | head -c 120; echo; done",
|
||||
"curl -sS -m 10 'http://127.0.0.1:8001/process_monitor?family=youtube' | python3 -m json.tool",
|
||||
"ls -la /home/eric/d2ypp2-src/.pm2/logs/youtube2__*-out.log 2>/dev/null | tail -5",
|
||||
"tail -3 /home/eric/d2ypp2-src/.pm2/logs/youtube2__ch_mpwri36r_z5lm2-out.log 2>/dev/null",
|
||||
"tail -3 /home/eric/d2ypp2-src/.pm2/logs/youtube2__ch_mpyvqkc0_gj63k-out.log 2>/dev/null",
|
||||
"grep -h 'speed=' /home/eric/d2ypp2-src/.pm2/logs/youtube2__ch_mpwri36r_z5lm2-out.log 2>/dev/null | tail -2",
|
||||
"grep -h 'speed=' /home/eric/d2ypp2-src/.pm2/logs/youtube2__ch_mpyvqkc0_gj63k-out.log 2>/dev/null | tail -2",
|
||||
]
|
||||
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(HOST, username=USER, password=PASS, timeout=15)
|
||||
for cmd in CMDS:
|
||||
print(f"\n=== {cmd[:90]} ===")
|
||||
_, o, e = c.exec_command(cmd, timeout=40, get_pty=True)
|
||||
print((o.read() + e.read()).decode()[:5000].encode("ascii", "backslashreplace").decode())
|
||||
c.close()
|
||||
22
d2ypp2/tools/find_deploy_paths.py
Normal file
22
d2ypp2/tools/find_deploy_paths.py
Normal file
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python3
|
||||
import paramiko
|
||||
|
||||
def q(host, pw, cmd):
|
||||
c = paramiko.SSHClient(); c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(host, username='eric', password=pw, timeout=15)
|
||||
_, o, e = c.exec_command(cmd, timeout=60, get_pty=True)
|
||||
r = (o.read()+e.read()).decode('utf-8','replace'); c.close(); return r
|
||||
|
||||
pw = '4669805'
|
||||
for host in ['10.88.0.4', '10.88.0.5']:
|
||||
print('\n===', host, '===')
|
||||
for cmd in [
|
||||
'find /home/eric /opt/live -maxdepth 4 -name d2ypp2-src -type d 2>/dev/null',
|
||||
'find /home/eric /opt/live -maxdepth 5 -name hardware.env 2>/dev/null',
|
||||
'find /home/eric /opt/live -maxdepth 5 -name system-stack.env 2>/dev/null',
|
||||
'ps auxww | grep "ffmpeg.*rtmps" | grep -v grep | head -1 | grep -oE "scale=[^ ]+|libx264|copy|video_mode" || ps auxww | grep ffmpeg | grep rtmps | grep -v grep | head -c 300',
|
||||
"curl -sS -m 5 'http://127.0.0.1:9999/proxies' 2>/dev/null | python3 -c \"import sys,json;d=json.load(sys.stdin);p=d.get('proxies',{});g=p.get('\\U0001f680 \\u8282\u70b9\u9009\u62e9') or p.get('GLOBAL') or {};print('selected=',g.get('now'));print('all=',list(p.keys())[:8])\" 2>/dev/null || echo no_clash_api",
|
||||
'grep -r SHELLCRASH_NEKO_PROXY_NODE /home/eric /opt/live/config 2>/dev/null | head -5',
|
||||
]:
|
||||
print('>', cmd[:75])
|
||||
print(q(host, pw, cmd)[:1200].encode('ascii','backslashreplace').decode())
|
||||
46
d2ypp2/tools/fix_host04_caddy.py
Normal file
46
d2ypp2/tools/fix_host04_caddy.py
Normal file
@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env python3
|
||||
from __future__ import annotations
|
||||
|
||||
import time
|
||||
|
||||
import paramiko
|
||||
|
||||
HOST, USER, PASS = "10.88.0.4", "eric", "4669805"
|
||||
BASE = "/home/eric/d2ypp2-src"
|
||||
|
||||
|
||||
def run(cmd: str, timeout: int = 180, sudo: bool = False) -> str:
|
||||
client = paramiko.SSHClient()
|
||||
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
client.connect(HOST, username=USER, password=PASS, timeout=20)
|
||||
_, stdout, stderr = client.exec_command(f"export LC_ALL=C.UTF-8; {cmd}", timeout=timeout, get_pty=bool(sudo))
|
||||
if sudo:
|
||||
stdout.channel.send(f"{PASS}\n")
|
||||
out = (stdout.read() + stderr.read()).decode("utf-8", "replace")
|
||||
client.close()
|
||||
return out.strip()
|
||||
|
||||
|
||||
def main() -> int:
|
||||
print("=== disk index bundle ===")
|
||||
print(run(f"grep -o 'page-[a-z0-9]*\\.js' {BASE}/web-console/out/index.html | head -1"))
|
||||
|
||||
print("\n=== served bundle before edge reinstall ===")
|
||||
print(run("curl -sS -m 8 http://127.0.0.1/ | grep -o 'page-[a-z0-9]*\\.js' | head -1"))
|
||||
|
||||
print("\n=== caddy root hints ===")
|
||||
print(run(f"grep -R 'web-console/out' {BASE}/live-platform /etc/caddy 2>/dev/null | head -15"))
|
||||
|
||||
print("\n=== reinstall live edge ===")
|
||||
print(run(f"sudo -S -p '' bash {BASE}/scripts/linux/reinstall_live_edge.sh", sudo=True))
|
||||
|
||||
time.sleep(8)
|
||||
print("\n=== served bundle after edge reinstall ===")
|
||||
print(run("curl -sS -m 8 http://127.0.0.1/ | grep -o 'page-[a-z0-9]*\\.js' | head -1"))
|
||||
print(run("curl -sS -m 8 -o /dev/null -w 'http_code=%{http_code}' http://127.0.0.1/; echo"))
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
112
d2ypp2/tools/fix_host04_frontend.py
Normal file
112
d2ypp2/tools/fix_host04_frontend.py
Normal file
@ -0,0 +1,112 @@
|
||||
#!/usr/bin/env python3
|
||||
from __future__ import annotations
|
||||
|
||||
import io
|
||||
import json
|
||||
import posixpath
|
||||
from pathlib import Path
|
||||
|
||||
import paramiko
|
||||
|
||||
HOST, USER, PASS = "10.88.0.4", "eric", "4669805"
|
||||
BASE = "/home/eric/d2ypp2-src"
|
||||
REPO = Path(__file__).resolve().parent.parent
|
||||
OUT = REPO / "web-console" / "out"
|
||||
|
||||
|
||||
def run(ssh: paramiko.SSHClient, cmd: str, timeout: int = 120) -> str:
|
||||
_, stdout, stderr = ssh.exec_command(f"export LC_ALL=C.UTF-8; {cmd}", timeout=timeout)
|
||||
return (stdout.read() + stderr.read()).decode("utf-8", "replace").strip()
|
||||
|
||||
|
||||
def mkdir_p(sftp: paramiko.SFTPClient, remote_dir: str) -> None:
|
||||
remote_dir = remote_dir.replace("\\", "/").rstrip("/")
|
||||
parts = [p for p in remote_dir.split("/") if p]
|
||||
cur = ""
|
||||
for part in parts:
|
||||
cur = f"{cur}/{part}" if cur else f"/{part}"
|
||||
try:
|
||||
sftp.stat(cur)
|
||||
except OSError:
|
||||
sftp.mkdir(cur)
|
||||
|
||||
|
||||
def put_tree(sftp: paramiko.SFTPClient, local_dir: Path, remote_dir: str) -> int:
|
||||
count = 0
|
||||
for path in sorted(local_dir.rglob("*")):
|
||||
if not path.is_file():
|
||||
continue
|
||||
rel = path.relative_to(local_dir).as_posix()
|
||||
remote = posixpath.join(remote_dir, rel)
|
||||
mkdir_p(sftp, posixpath.dirname(remote))
|
||||
sftp.put(str(path), remote)
|
||||
count += 1
|
||||
return count
|
||||
|
||||
|
||||
def main() -> int:
|
||||
if not (OUT / "index.html").is_file():
|
||||
raise SystemExit("missing local web-console/out; run pnpm build first")
|
||||
|
||||
local_page = next(OUT.glob("_next/static/chunks/app/page-*.js"), None)
|
||||
local_index = (OUT / "index.html").read_text(encoding="utf-8", errors="replace")
|
||||
print("local page bundle:", local_page.name if local_page else "missing")
|
||||
|
||||
client = paramiko.SSHClient()
|
||||
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
client.connect(HOST, username=USER, password=PASS, timeout=20)
|
||||
sftp = client.open_sftp()
|
||||
|
||||
print("uploading web-console/out ...")
|
||||
uploaded = put_tree(sftp, OUT, f"{BASE}/web-console/out")
|
||||
print(f"uploaded {uploaded} files")
|
||||
|
||||
backend_files = [
|
||||
"src/process_runtime_status.py",
|
||||
"src/douyin_source_display.py",
|
||||
"src/youtube_quality_guard.py",
|
||||
"web-console/components/live-product/LiveYoutubeUnmannedView.tsx",
|
||||
"web-console/components/live-product/LiveProcessLiveLogCard.tsx",
|
||||
"web-console/lib/ffmpegMetrics.ts",
|
||||
"web-console/lib/youtubeConfigUtils.ts",
|
||||
]
|
||||
for rel in backend_files:
|
||||
local = REPO / rel
|
||||
remote = f"{BASE}/{rel.replace(chr(92), '/')}"
|
||||
mkdir_p(sftp, posixpath.dirname(remote))
|
||||
if local.suffix.lower() in {".py", ".ts", ".tsx"}:
|
||||
sftp.putfo(io.BytesIO(local.read_bytes().replace(b"\r\n", b"\n")), remote)
|
||||
else:
|
||||
sftp.put(str(local), remote)
|
||||
sftp.close()
|
||||
|
||||
print(run(client, f"grep -o 'page-[a-z0-9]*\\.js' {BASE}/web-console/out/index.html | head -1"))
|
||||
print(run(client, f"wc -c {BASE}/web-console/out/_next/static/chunks/app/page-*.js"))
|
||||
|
||||
print("restarting live-console ...")
|
||||
print(run(client, f"echo '{PASS}' | sudo -S -p '' systemctl restart live-console.service", timeout=60))
|
||||
print(run(client, "sleep 4; curl -sf -m 8 http://127.0.0.1:8001/health; echo"))
|
||||
|
||||
raw = run(client, "curl -sS -m 12 'http://127.0.0.1:8001/process_monitor?family=youtube'")
|
||||
try:
|
||||
data = json.loads(raw)
|
||||
entries = data.get("entries") or []
|
||||
print(f"process_monitor entries={len(entries)}")
|
||||
for row in entries:
|
||||
print(
|
||||
f" {row.get('pm2')}: business={row.get('business_status')} pushing={row.get('is_pushing')} "
|
||||
f"label={row.get('label')} display={row.get('source_display') or row.get('source_title') or '-'}"
|
||||
)
|
||||
except json.JSONDecodeError:
|
||||
print("process_monitor raw:", raw[:1500])
|
||||
|
||||
served = run(client, "curl -sS -m 8 http://127.0.0.1/ | grep -o 'page-[a-z0-9]*\\.js' | head -1")
|
||||
print("served page bundle:", served)
|
||||
print("local index references page-9ff3a078ec6e16cb.js:", "page-9ff3a078ec6e16cb.js" in local_index)
|
||||
|
||||
client.close()
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
75
d2ypp2/tools/hotfix_host04_ffmpeg_pids.py
Normal file
75
d2ypp2/tools/hotfix_host04_ffmpeg_pids.py
Normal file
@ -0,0 +1,75 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Deploy ffmpeg PID matching fix to 10.88.0.4."""
|
||||
from __future__ import annotations
|
||||
|
||||
import io
|
||||
import json
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
import paramiko
|
||||
|
||||
HOST, USER, PASS = "10.88.0.4", "eric", "4669805"
|
||||
BASE = "/home/eric/d2ypp2-src"
|
||||
REPO = Path(__file__).resolve().parent.parent
|
||||
FILES = [
|
||||
REPO / "src" / "web_process_backend.py",
|
||||
REPO / "douyin_youtube_ffplay.py",
|
||||
]
|
||||
|
||||
|
||||
def put(sftp: paramiko.SFTPClient, local: Path, remote: str) -> None:
|
||||
sftp.putfo(io.BytesIO(local.read_bytes().replace(b"\r\n", b"\n")), remote)
|
||||
|
||||
|
||||
def ssh_run(client: paramiko.SSHClient, cmd: str, sudo: bool = False) -> str:
|
||||
_, stdout, stderr = client.exec_command(f"export LC_ALL=C.UTF-8; {cmd}", timeout=180, get_pty=sudo)
|
||||
if sudo:
|
||||
stdout.channel.send(f"{PASS}\n")
|
||||
return (stdout.read() + stderr.read()).decode("utf-8", "replace").strip()
|
||||
|
||||
|
||||
def main() -> int:
|
||||
client = paramiko.SSHClient()
|
||||
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
client.connect(HOST, username=USER, password=PASS, timeout=20)
|
||||
sftp = client.open_sftp()
|
||||
for local in FILES:
|
||||
remote = f"{BASE}/{local.relative_to(REPO).as_posix()}"
|
||||
put(sftp, local, remote)
|
||||
print("uploaded", remote)
|
||||
sftp.close()
|
||||
|
||||
print(ssh_run(client, "sudo -S -p '' systemctl restart live-console.service", sudo=True))
|
||||
for _ in range(15):
|
||||
if '"status":"ok"' in ssh_run(client, "curl -sf -m 4 http://127.0.0.1:8001/health; echo"):
|
||||
print("health ok")
|
||||
break
|
||||
time.sleep(2)
|
||||
|
||||
for proc in ("youtube2__ch_mpwri36r_z5lm2", "youtube2__ch_mpyvqkc0_gj63k"):
|
||||
print(proc, ssh_run(
|
||||
client,
|
||||
"curl -sS -m 60 -X POST 'http://127.0.0.1:8001/restart' "
|
||||
"-H 'Content-Type: application/json' "
|
||||
f"-d '{{\"process\":\"{proc}\"}}'",
|
||||
)[:300])
|
||||
|
||||
print("waiting for ffmpeg ...")
|
||||
time.sleep(20)
|
||||
print(ssh_run(client, "pgrep -af 'ffmpeg.*rtmps' | grep -v pgrep"))
|
||||
raw = ssh_run(client, "curl -sS -m 12 'http://127.0.0.1:8001/process_monitor?family=youtube'")
|
||||
data = json.loads(raw)
|
||||
for row in data.get("entries") or []:
|
||||
if str(row.get("pm2", "")).startswith("youtube2__"):
|
||||
line = (
|
||||
f"{row.get('pm2')} business={row.get('business_status')} "
|
||||
f"pushing={row.get('is_pushing')} label={row.get('label')}"
|
||||
)
|
||||
print(line.encode("utf-8", "replace").decode("utf-8", "replace"))
|
||||
client.close()
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
71
d2ypp2/tools/hotfix_host04_proxychains.py
Normal file
71
d2ypp2/tools/hotfix_host04_proxychains.py
Normal file
@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env python3
|
||||
from __future__ import annotations
|
||||
|
||||
import io
|
||||
import json
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
import paramiko
|
||||
|
||||
HOST, USER, PASS, BASE = "10.88.0.4", "eric", "4669805", "/home/eric/d2ypp2-src"
|
||||
REPO = Path(__file__).resolve().parent.parent
|
||||
FILES = ["douyin_youtube_ffplay.py", "src/recorder_config.py", "youtube.py", "src/spider.py"]
|
||||
|
||||
|
||||
def run(ssh: paramiko.SSHClient, cmd: str, timeout: int = 120) -> str:
|
||||
_, o, e = ssh.exec_command(f"export LC_ALL=C.UTF-8; {cmd}", timeout=timeout, get_pty=True)
|
||||
return (o.read() + e.read()).decode("utf-8", "replace")
|
||||
|
||||
|
||||
def lane_names(ssh: paramiko.SSHClient) -> list[str]:
|
||||
raw = run(ssh, f"ls {BASE}/config/youtube.youtube2__*.ini 2>/dev/null")
|
||||
out: list[str] = []
|
||||
for line in raw.splitlines():
|
||||
name = line.rsplit("/", 1)[-1]
|
||||
if name.startswith("youtube.") and name.endswith(".ini"):
|
||||
out.append(name[len("youtube.") : -len(".ini")])
|
||||
return sorted(out)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
ssh = paramiko.SSHClient()
|
||||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
ssh.connect(HOST, username=USER, password=PASS, timeout=20)
|
||||
sftp = ssh.open_sftp()
|
||||
for rel in FILES:
|
||||
local = REPO / rel
|
||||
remote = f"{BASE}/{rel.replace(chr(92), '/')}"
|
||||
sftp.putfo(io.BytesIO(local.read_bytes().replace(b"\r\n", b"\n")), remote)
|
||||
print(f"[ok] {rel}")
|
||||
sftp.close()
|
||||
|
||||
print(run(ssh, f"python3 -m py_compile {BASE}/douyin_youtube_ffplay.py {BASE}/src/recorder_config.py {BASE}/youtube.py"))
|
||||
print("fn count:", run(ssh, f"grep -c 'def _proxychains_config_for_push' {BASE}/douyin_youtube_ffplay.py").strip())
|
||||
|
||||
for proc in lane_names(ssh):
|
||||
out = run(
|
||||
ssh,
|
||||
"curl -sS -m 60 -X POST 'http://127.0.0.1:8001/restart' "
|
||||
"-H 'Content-Type: application/json' "
|
||||
f"-d '{json.dumps({'process': proc})}'",
|
||||
)
|
||||
print(f"restart {proc}: {out[:200]}")
|
||||
time.sleep(18)
|
||||
|
||||
print("\nffmpeg:", run(ssh, "pgrep -af 'ffmpeg.*rtmps' | grep -v pgrep | head -2"))
|
||||
print(
|
||||
"proxychains err:",
|
||||
run(ssh, f"grep -h '_proxychains_config_for_push' {BASE}/.pm2/logs/youtube2__*-err.log 2>/dev/null | tail -3 || echo none"),
|
||||
)
|
||||
print(
|
||||
"duplicate err:",
|
||||
run(ssh, f"grep -h 'DuplicateOptionError' {BASE}/.pm2/logs/youtube2__*-err.log 2>/dev/null | tail -3 || echo none"),
|
||||
)
|
||||
print("profile:", run(ssh, f"grep -h 'YouTube Live profile' {BASE}/.pm2/logs/youtube2__*-out.log 2>/dev/null | tail -4"))
|
||||
ssh.close()
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
36
d2ypp2/tools/inspect_host04_caddy.py
Normal file
36
d2ypp2/tools/inspect_host04_caddy.py
Normal file
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python3
|
||||
from __future__ import annotations
|
||||
|
||||
import paramiko
|
||||
|
||||
HOST, USER, PASS = "10.88.0.4", "eric", "4669805"
|
||||
|
||||
|
||||
def run(cmd: str, timeout: int = 90) -> str:
|
||||
client = paramiko.SSHClient()
|
||||
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
client.connect(HOST, username=USER, password=PASS, timeout=20)
|
||||
_, stdout, stderr = client.exec_command(f"export LC_ALL=C.UTF-8; {cmd}", timeout=timeout)
|
||||
out = (stdout.read() + stderr.read()).decode("utf-8", "replace")
|
||||
client.close()
|
||||
return out.strip()
|
||||
|
||||
|
||||
def main() -> int:
|
||||
cmds = [
|
||||
"cat /opt/live/generated/Caddyfile",
|
||||
"grep -R 'root\\|file_server\\|web-console' /opt/live/generated/Caddyfile /home/eric/d2ypp2-src/live-platform 2>/dev/null | head -30",
|
||||
"ls -la /opt/live/d2ypp/web-console/out/index.html 2>/dev/null || echo no_opt_live_out",
|
||||
"grep -o 'page-[a-z0-9]*\\.js' /opt/live/d2ypp/web-console/out/index.html 2>/dev/null | head -1",
|
||||
"grep -o 'page-[a-z0-9]*\\.js' /home/eric/d2ypp2-src/web-console/out/index.html | head -1",
|
||||
"readlink -f /opt/live/d2ypp 2>/dev/null || true",
|
||||
"systemctl cat live-console.service | head -40",
|
||||
]
|
||||
for cmd in cmds:
|
||||
print(f"\n=== {cmd} ===")
|
||||
print(run(cmd)[:4000])
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
15
d2ypp2/tools/live_speed_now.py
Normal file
15
d2ypp2/tools/live_speed_now.py
Normal file
@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env python3
|
||||
import paramiko
|
||||
|
||||
for host, pw in [("10.88.0.4", "4669805"), ("10.88.0.5", "4669805")]:
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(host, username="eric", password=pw, timeout=15)
|
||||
cmd = (
|
||||
"for pid in $(pgrep -f 'ffmpeg.*rtmps'); do echo PID=$pid; "
|
||||
"timeout 2 cat /proc/$pid/fd/2 2>/dev/null | tr '\\r' '\\n' | grep speed= | tail -2; done"
|
||||
)
|
||||
print(f"=== {host} ===")
|
||||
_, o, e = c.exec_command(cmd, timeout=20, get_pty=True)
|
||||
print((o.read() + e.read()).decode()[:800])
|
||||
c.close()
|
||||
22
d2ypp2/tools/poll_host04_push.py
Normal file
22
d2ypp2/tools/poll_host04_push.py
Normal file
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python3
|
||||
import json
|
||||
import time
|
||||
|
||||
import paramiko
|
||||
|
||||
HOST, USER, PASS = "10.88.0.4", "eric", "4669805"
|
||||
|
||||
def run(cmd):
|
||||
c=paramiko.SSHClient(); c.set_missing_host_key_policy(paramiko.AutoAddPolicy()); c.connect(HOST,username=USER,password=PASS,timeout=20)
|
||||
_,o,e=c.exec_command('export LC_ALL=C.UTF-8; '+cmd,timeout=90)
|
||||
out=(o.read()+e.read()).decode('utf-8','replace'); c.close(); return out
|
||||
|
||||
for i in range(6):
|
||||
print(f'--- poll {i+1} ---')
|
||||
print(run("pgrep -af 'ffmpeg.*rtmps' | grep -v pgrep"))
|
||||
raw=run("curl -sS -m 12 'http://127.0.0.1:8001/process_monitor?family=youtube'")
|
||||
d=json.loads(raw)
|
||||
for row in d.get('entries') or []:
|
||||
if str(row.get('pm2','')).startswith('youtube2__'):
|
||||
print(row['pm2'], row.get('business_status'), row.get('is_pushing'), row.get('source_display'), row.get('label'))
|
||||
time.sleep(5)
|
||||
32
d2ypp2/tools/proxy_check_three.py
Normal file
32
d2ypp2/tools/proxy_check_three.py
Normal file
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python3
|
||||
import paramiko
|
||||
|
||||
HOSTS = [
|
||||
("10.88.0.3", "Xiao4669805"),
|
||||
("10.88.0.4", "4669805"),
|
||||
("10.88.0.5", "4669805"),
|
||||
]
|
||||
|
||||
CMDS = [
|
||||
"ss -tlnp | grep -E '7890|7894|7891' || true",
|
||||
"curl -sS -m 8 -x socks5://127.0.0.1:7890 https://www.gstatic.com/generate_204 -w 'gstatic_socks=%{http_code} t=%{time_total}\n' -o /dev/null",
|
||||
"curl -sS -m 12 -x socks5://127.0.0.1:7890 https://a.rtmps.youtube.com/ -w 'yt_socks=%{http_code} t=%{time_total}\n' -o /dev/null",
|
||||
"pgrep -cf 'ffmpeg.*rtmps'; pgrep -cf neko; free -h | grep -E 'Mem|Swap'",
|
||||
]
|
||||
|
||||
|
||||
def q(host: str, pw: str, cmd: str) -> str:
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(host, username="eric", password=pw, timeout=15)
|
||||
_, o, e = c.exec_command(cmd, timeout=45, get_pty=True)
|
||||
out = (o.read() + e.read()).decode("utf-8", "replace")
|
||||
c.close()
|
||||
return out
|
||||
|
||||
|
||||
for host, pw in HOSTS:
|
||||
print(f"\nHOST {host}")
|
||||
for cmd in CMDS:
|
||||
print(f" > {cmd}")
|
||||
print(q(host, pw, cmd).encode("ascii", "backslashreplace").decode()[:900])
|
||||
15
d2ypp2/tools/quick_host5.py
Normal file
15
d2ypp2/tools/quick_host5.py
Normal file
@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env python3
|
||||
import paramiko
|
||||
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect("10.88.0.5", username="eric", password="4669805", timeout=15)
|
||||
for cmd in [
|
||||
"lscpu | grep 'Model name'",
|
||||
"grep -h speed= /home/eric/d2ypp2-src/.pm2/logs/youtube2__*-out.log 2>/dev/null | tail -6",
|
||||
"ps auxww | grep 'ffmpeg.*rtmps' | grep -v grep | head -1 | cut -c1-220",
|
||||
]:
|
||||
print(">", cmd)
|
||||
_, o, e = c.exec_command(cmd, timeout=30, get_pty=True)
|
||||
print((o.read() + e.read()).decode()[:600])
|
||||
c.close()
|
||||
22
d2ypp2/tools/read_host05_config.py
Normal file
22
d2ypp2/tools/read_host05_config.py
Normal file
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python3
|
||||
import paramiko
|
||||
|
||||
def q(host, pw, cmd):
|
||||
c = paramiko.SSHClient(); c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(host, username='eric', password=pw, timeout=15)
|
||||
_, o, e = c.exec_command(cmd, timeout=60, get_pty=True)
|
||||
r = (o.read()+e.read()).decode('utf-8','replace'); c.close(); return r
|
||||
|
||||
pw='4669805'
|
||||
host='10.88.0.5'
|
||||
cmds=[
|
||||
'cat /opt/live/d2ypp/config/hardware.env 2>/dev/null',
|
||||
'cat /opt/live/d2ypp/config/hardware-profile.json 2>/dev/null | head -c 2000',
|
||||
'grep -H "video_mode\\|fast_audio\\|bitrate" /opt/live/d2ypp/config/youtube.youtube2__*.ini 2>/dev/null | head -30',
|
||||
'cat /opt/live/d2ypp/config/system-stack.env 2>/dev/null | grep -E SHELLCRASH|YOUTUBE|PUSH|RELAY|PROXY',
|
||||
'ls /opt/live/d2ypp/config/youtube.youtube2__*.ini 2>/dev/null',
|
||||
'md5sum /opt/live/d2ypp/douyin_youtube_ffplay.py /home/eric/d2ypp2-src/douyin_youtube_ffplay.py 2>/dev/null',
|
||||
]
|
||||
for cmd in cmds:
|
||||
print('>',cmd)
|
||||
print(q(host,pw,cmd)[:2500].encode('ascii','backslashreplace').decode())
|
||||
19
d2ypp2/tools/read_lane_ini_both.py
Normal file
19
d2ypp2/tools/read_lane_ini_both.py
Normal file
@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env python3
|
||||
import paramiko
|
||||
|
||||
def q(host, pw, cmd):
|
||||
c = paramiko.SSHClient(); c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(host, username='eric', password=pw, timeout=15)
|
||||
_, o, e = c.exec_command(cmd, timeout=60, get_pty=True)
|
||||
return (o.read()+e.read()).decode('utf-8','replace')
|
||||
|
||||
pw='4669805'
|
||||
for host, base in [('10.88.0.5','/opt/live/d2ypp'), ('10.88.0.4','/home/eric/d2ypp2-src')]:
|
||||
print('\n===', host, '===')
|
||||
for cmd in [
|
||||
f'cat {base}/config/youtube.youtube2__ch_mp9mm36r_2wn0r.ini 2>/dev/null || ls {base}/config/youtube.youtube2__*.ini | head -1 | xargs cat 2>/dev/null',
|
||||
f"grep -E 'SHELLCRASH|YOUTUBE|PUSH|RELAY|PROXY' {base}/config/system-stack.env 2>/dev/null",
|
||||
f'grep relay_strategy {base}/config/hardware-profile.json 2>/dev/null -A12 | head -15',
|
||||
]:
|
||||
print('>', cmd[:90])
|
||||
print(q(host,pw,cmd)[:2000].encode('ascii','backslashreplace').decode())
|
||||
56
d2ypp2/tools/remote_diag.py
Normal file
56
d2ypp2/tools/remote_diag.py
Normal file
@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Quick remote diagnostics for live streaming host."""
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
|
||||
import paramiko
|
||||
|
||||
HOST = sys.argv[1] if len(sys.argv) > 1 else "10.88.0.4"
|
||||
USER = sys.argv[2] if len(sys.argv) > 2 else "eric"
|
||||
PASS = sys.argv[3] if len(sys.argv) > 3 else "4669805"
|
||||
|
||||
COMMANDS = [
|
||||
"hostname; uptime; free -h | head -3",
|
||||
"which pm2; PM2_HOME=/etc/.pm2 pm2 list 2>/dev/null; PM2_HOME=$HOME/.pm2 pm2 list 2>/dev/null",
|
||||
"ps aux | grep -E 'ffmpeg|youtube|douyin|ffplay' | grep -v grep | head -40",
|
||||
"ss -tlnp 2>/dev/null | head -40",
|
||||
"systemctl is-active live-console shellcrash 2>/dev/null; docker ps --format '{{.Names}} {{.Status}}' 2>/dev/null | head -20",
|
||||
"find /opt /home/eric -maxdepth 4 -name 'd2ypp*' -type d 2>/dev/null | head -10",
|
||||
"for p in 8001 8000 9200 9201 7890 7894; do curl -sS -m 3 -o /dev/null -w \"port=$p code=%{http_code}\\n\" http://127.0.0.1:$p/ 2>/dev/null; done",
|
||||
"curl -sS -m 8 http://127.0.0.1:8001/api/process-monitor 2>/dev/null | head -c 5000",
|
||||
"curl -sS -m 8 http://127.0.0.1:8001/process-monitor 2>/dev/null | head -c 5000",
|
||||
"ls -la /etc/.pm2/logs/ 2>/dev/null | tail -20",
|
||||
"tail -30 /etc/.pm2/logs/*youtube*out*.log 2>/dev/null | tail -80",
|
||||
"tail -30 /etc/.pm2/logs/*youtube*error*.log 2>/dev/null | tail -80",
|
||||
"wg show 2>/dev/null | head -30",
|
||||
"curl -sS -m 5 -x http://127.0.0.1:7894 https://www.gstatic.com/generate_204 -w 'proxy7894=%{http_code}\\n' -o /dev/null 2>/dev/null",
|
||||
"for pid in $(pgrep -f 'ffmpeg.*rtmps://a.rtmps.youtube.com'); do echo PID=$pid; timeout 3 cat /proc/$pid/fd/2 2>/dev/null | tail -3; done",
|
||||
"curl -sS -m 10 http://127.0.0.1:8001/api/process-monitor/list 2>/dev/null | head -c 10000",
|
||||
"curl -sS -m 10 http://127.0.0.1:8001/hub/youtube/quality 2>/dev/null | head -c 10000",
|
||||
"grep -r speed= /home/eric/d2ypp2-src/logs/ /var/log/ 2>/dev/null | tail -15",
|
||||
"ls -la /root/.pm2/logs/ 2>/dev/null; ls -la /home/eric/d2ypp2-src/logs/ 2>/dev/null | tail -15",
|
||||
"grep fast_audio /home/eric/d2ypp2-src/config/youtube*.ini 2>/dev/null",
|
||||
"head -80 /home/eric/d2ypp2-src/douyin_youtube_ffplay.py 2>/dev/null | tail -5; grep -n fast_audio /home/eric/d2ypp2-src/douyin_youtube_ffplay.py 2>/dev/null | head -5",
|
||||
]
|
||||
|
||||
|
||||
def main() -> int:
|
||||
client = paramiko.SSHClient()
|
||||
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
client.connect(HOST, username=USER, password=PASS, timeout=20)
|
||||
for cmd in COMMANDS:
|
||||
print(f"\n{'='*20} {cmd[:72]} {'='*20}")
|
||||
_, stdout, stderr = client.exec_command(cmd, timeout=60)
|
||||
out = stdout.read().decode("utf-8", "replace")
|
||||
err = stderr.read().decode("utf-8", "replace")
|
||||
if out.strip():
|
||||
print(out[:12000])
|
||||
if err.strip():
|
||||
print("STDERR:", err[:2000])
|
||||
client.close()
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
67
d2ypp2/tools/remote_douyin_diag.py
Normal file
67
d2ypp2/tools/remote_douyin_diag.py
Normal file
@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Diagnose Douyin fetch failures on remote host."""
|
||||
from __future__ import annotations
|
||||
|
||||
import configparser
|
||||
import concurrent.futures
|
||||
import paramiko
|
||||
|
||||
HOST, USER, PASS = "10.88.0.4", "eric", "4669805"
|
||||
REMOTE = "/home/eric/d2ypp2-src"
|
||||
|
||||
|
||||
def run(c: paramiko.SSHClient, cmd: str, timeout: int = 90) -> str:
|
||||
_, o, e = c.exec_command(cmd, timeout=timeout, get_pty=True)
|
||||
return (o.read() + e.read()).decode("utf-8", "replace")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(HOST, username=USER, password=PASS, timeout=20)
|
||||
sftp = c.open_sftp()
|
||||
sftp.put("tools/test_douyin_fetch.py", f"{REMOTE}/tools/test_douyin_fetch.py")
|
||||
sftp.close()
|
||||
|
||||
remote_py = f"""
|
||||
import asyncio, configparser
|
||||
from pathlib import Path
|
||||
from src.spider import get_douyin_web_stream_data
|
||||
|
||||
cfg = configparser.RawConfigParser()
|
||||
cfg.read('{REMOTE}/config/config.ini', encoding='utf-8-sig')
|
||||
dy_cookie = cfg.get('Cookie', '抖音cookie', fallback='')
|
||||
|
||||
async def one(url, cookies):
|
||||
data = await get_douyin_web_stream_data(url, proxy_addr=None, cookies=cookies)
|
||||
return url, bool(data.get('anchor_name')), data.get('status')
|
||||
|
||||
async def main():
|
||||
url = 'https://live.douyin.com/29155980665'
|
||||
for label, cookies in [('builtin', ''), ('config', dy_cookie)]:
|
||||
data = await get_douyin_web_stream_data(url, cookies=cookies or None)
|
||||
print(label, 'anchor=', data.get('anchor_name',''), 'status=', data.get('status'), 'stream=', bool(data.get('stream_url')))
|
||||
urls = [
|
||||
'https://live.douyin.com/29155980665',
|
||||
'https://live.douyin.com/52546370369',
|
||||
'https://live.douyin.com/70746445716',
|
||||
'https://live.douyin.com/53684233877',
|
||||
'https://live.douyin.com/49924415687',
|
||||
]
|
||||
tasks = [one(u, dy_cookie) for u in urls]
|
||||
results = await asyncio.gather(*tasks, return_exceptions=True)
|
||||
for item in results:
|
||||
print('burst', item)
|
||||
|
||||
asyncio.run(main())
|
||||
"""
|
||||
cmd = (
|
||||
f"cd {REMOTE} && . .venv/bin/activate && PYTHONPATH={REMOTE} python - <<'PY'\n"
|
||||
f"{remote_py}\nPY"
|
||||
)
|
||||
print(run(c, cmd, timeout=120))
|
||||
c.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
43
d2ypp2/tools/remote_fix_now.py
Normal file
43
d2ypp2/tools/remote_fix_now.py
Normal file
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python3
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import paramiko
|
||||
|
||||
HOST, USER, PASS = "10.88.0.4", "eric", "4669805"
|
||||
|
||||
|
||||
def run(c, cmd, timeout=60):
|
||||
_, o, e = c.exec_command(cmd, timeout=timeout, get_pty=True)
|
||||
return (o.read() + e.read()).decode("utf-8", "replace")
|
||||
|
||||
|
||||
def main():
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(HOST, username=USER, password=PASS, timeout=20)
|
||||
cmds = [
|
||||
"curl -sS -m 15 'http://127.0.0.1:8001/process_monitor?family=youtube'",
|
||||
"pgrep -af 'ffmpeg.*rtmps' || echo NO_FFMPEG",
|
||||
"ps aux | grep 'd2ypp2-src/youtube.py' | grep -v grep",
|
||||
"head -3 /home/eric/d2ypp2-src/config/URL_config.youtube2__ch_mpwri36r_z5lm2.ini",
|
||||
"head -3 /home/eric/d2ypp2-src/config/URL_config.youtube2__ch_mpyvqkc0_gj63k.ini",
|
||||
"grep -E 'stream copy|transcode|speed=|并发|YouTube Live profile' /home/eric/d2ypp2-src/.pm2/logs/youtube2__ch_mpwri36r_z5lm2-out.log | tail -12",
|
||||
"grep -E 'stream copy|transcode|speed=|并发|YouTube Live profile' /home/eric/d2ypp2-src/.pm2/logs/youtube2__ch_mpyvqkc0_gj63k-out.log | tail -12",
|
||||
"tail -20 /home/eric/d2ypp2-src/.pm2/logs/youtube2__ch_mpwri36r_z5lm2-out.log",
|
||||
"tail -20 /home/eric/d2ypp2-src/.pm2/logs/youtube2__ch_mpyvqkc0_gj63k-out.log",
|
||||
"md5sum /home/eric/d2ypp2-src/douyin_youtube_ffplay.py | head -1",
|
||||
"grep -c '_use_stream_copy' /home/eric/d2ypp2-src/douyin_youtube_ffplay.py || true",
|
||||
]
|
||||
for cmd in cmds:
|
||||
print(f"\n=== {cmd[:75]} ===")
|
||||
out = run(c, cmd)
|
||||
try:
|
||||
print(out.encode("ascii", "backslashreplace").decode()[:8000])
|
||||
except Exception:
|
||||
print(out[:8000])
|
||||
c.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
36
d2ypp2/tools/remote_hw_check.py
Normal file
36
d2ypp2/tools/remote_hw_check.py
Normal file
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python3
|
||||
from __future__ import annotations
|
||||
|
||||
import paramiko
|
||||
|
||||
HOST, USER, PASS = "10.88.0.4", "eric", "4669805"
|
||||
|
||||
|
||||
def run(c, cmd):
|
||||
_, o, e = c.exec_command(cmd, timeout=45, get_pty=True)
|
||||
return (o.read() + e.read()).decode("utf-8", "replace").strip()
|
||||
|
||||
|
||||
def main() -> None:
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(HOST, username=USER, password=PASS, timeout=20)
|
||||
cmds = [
|
||||
"cat /home/eric/d2ypp2-src/config/hardware.env 2>/dev/null || echo NO_HW_ENV",
|
||||
"ls -la /dev/dri/ 2>/dev/null; ls /dev/mpp_service 2>/dev/null; nvidia-smi 2>/dev/null | head -8",
|
||||
"ffmpeg -hide_banner -encoders 2>/dev/null | grep -E '264|265|vaapi|nvenc|rkmpp|v4l2'",
|
||||
"top -bn1 | head -20",
|
||||
"ps -o pid,pcpu,pmem,etime,cmd -p $(pgrep -f 'ffmpeg.*rtmps://a.rtmps.youtube.com' | tr '\\n' ',') 2>/dev/null",
|
||||
"grep -E 'NVENC|VAAPI|libx264|hardware|Encoder|fast_audio' /home/eric/d2ypp2-src/logs/*.log 2>/dev/null | tail -30",
|
||||
f"echo '{PASS}' | sudo -S -p '' journalctl -u 'youtube2__ch_*' --no-pager -n 5 2>/dev/null | tail -20",
|
||||
"systemctl list-units 'youtube*' --all --no-pager 2>/dev/null | head -15",
|
||||
"ls -la /home/eric/d2ypp2-src/logs/ 2>/dev/null",
|
||||
"find /home/eric/d2ypp2-src -name '*.log' -mmin -120 2>/dev/null | head -20",
|
||||
]
|
||||
for cmd in cmds:
|
||||
print(f"\n=== {cmd[:70]} ===\n{run(c, cmd)[:5000]}")
|
||||
c.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
15
d2ypp2/tools/remote_lane2_check.py
Normal file
15
d2ypp2/tools/remote_lane2_check.py
Normal file
@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env python3
|
||||
import paramiko
|
||||
c=paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect('10.88.0.4',username='eric',password='4669805',timeout=15)
|
||||
cmds=[
|
||||
"grep -n '29155980665\\|654138586813' /home/eric/d2ypp2-src/config/URL_config.youtube2__ch_mpwri36r_z5lm2.ini /home/eric/d2ypp2-src/config/URL_config.youtube2__ch_mpyvqkc0_gj63k.ini 2>/dev/null",
|
||||
"tail -15 /home/eric/d2ypp2-src/.pm2/logs/youtube2__ch_mpyvqkc0_gj63k-out.log",
|
||||
"curl -sS -m 8 'http://127.0.0.1:8001/restart?process=youtube2__ch_mpyvqkc0_gj63k'",
|
||||
]
|
||||
for cmd in cmds:
|
||||
print('===',cmd)
|
||||
_,o,e=c.exec_command(cmd,timeout=30)
|
||||
print(o.read().decode('utf-8','replace')[:3000])
|
||||
c.close()
|
||||
116
d2ypp2/tools/remote_patch_host04.py
Normal file
116
d2ypp2/tools/remote_patch_host04.py
Normal file
@ -0,0 +1,116 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Remote patch script - run on 10.88.0.4."""
|
||||
from __future__ import annotations
|
||||
|
||||
import glob
|
||||
import json
|
||||
import os
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
from pathlib import Path
|
||||
|
||||
BASE = "/home/eric/d2ypp2-src"
|
||||
TUIC3 = "5d723acc-singbox_tuic3"
|
||||
|
||||
HARDWARE_ENV = """LIVE_HW_DECODER=vaapi
|
||||
LIVE_HDMI_PLAYER=mpv-drm
|
||||
LIVE_BROWSER_HWACCEL=auto
|
||||
LIVE_STABILITY_MODE=balanced
|
||||
# LIVE_VIDEO_ENCODER= # optional: h264_v4l2m2m / h264_rkmpp when ffmpeg supports it
|
||||
"""
|
||||
|
||||
STACK_PATCH = {
|
||||
"SHELLCRASH_NEKO_PROXY_NODE": TUIC3,
|
||||
"SHELLCRASH_ATTACH_WHEN_DIRECT_OK": "1",
|
||||
"SHELLCRASH_ATTACH_NEKO": "auto",
|
||||
"SHELLCRASH_ATTACH_FFMPEG": "auto",
|
||||
"NEKO_BROWSER_PROXY": "http://host.docker.internal:7894",
|
||||
}
|
||||
|
||||
|
||||
def patch_ini_files() -> None:
|
||||
removed = 0
|
||||
for path in sorted(glob.glob(f"{BASE}/config/youtube.youtube2__*.ini")):
|
||||
lines_out = []
|
||||
for line in Path(path).read_text(encoding="utf-8-sig").splitlines():
|
||||
key = line.split("=", 1)[0].strip().lower()
|
||||
if key in {"video_mode", "bitrate"}:
|
||||
removed += 1
|
||||
continue
|
||||
lines_out.append(line)
|
||||
Path(path).write_text("\n".join(lines_out).rstrip() + "\n", encoding="utf-8")
|
||||
print(f"[ok] lane ini cleaned, removed {removed} copy/bitrate lines")
|
||||
|
||||
|
||||
def patch_hardware_profile() -> None:
|
||||
profile_path = Path(f"{BASE}/config/hardware-profile.json")
|
||||
if not profile_path.is_file():
|
||||
print("[skip] no hardware-profile.json")
|
||||
return
|
||||
data = json.loads(profile_path.read_text(encoding="utf-8"))
|
||||
if isinstance(data, dict) and "relay_strategy" in data:
|
||||
data.pop("relay_strategy", None)
|
||||
profile_path.write_text(json.dumps(data, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
|
||||
print("[ok] removed relay_strategy from hardware-profile.json")
|
||||
else:
|
||||
print("[skip] relay_strategy not present")
|
||||
|
||||
|
||||
def patch_system_stack() -> None:
|
||||
stack_path = Path(f"{BASE}/config/system-stack.env")
|
||||
lines = stack_path.read_text(encoding="utf-8-sig").splitlines() if stack_path.is_file() else []
|
||||
kv: dict[str, str] = {}
|
||||
for line in lines:
|
||||
if not line.strip() or line.strip().startswith("#") or "=" not in line:
|
||||
continue
|
||||
k, _, v = line.partition("=")
|
||||
kv[k.strip()] = v
|
||||
kv.update(STACK_PATCH)
|
||||
out_lines: list[str] = []
|
||||
seen: set[str] = set()
|
||||
for line in lines:
|
||||
if "=" not in line or line.strip().startswith("#"):
|
||||
out_lines.append(line)
|
||||
continue
|
||||
k = line.split("=", 1)[0].strip()
|
||||
if k in STACK_PATCH:
|
||||
if k not in seen:
|
||||
out_lines.append(f"{k}={STACK_PATCH[k]}")
|
||||
seen.add(k)
|
||||
continue
|
||||
out_lines.append(line)
|
||||
seen.add(k)
|
||||
for k, v in STACK_PATCH.items():
|
||||
if k not in seen:
|
||||
out_lines.append(f"{k}={v}")
|
||||
stack_path.write_text("\n".join(out_lines).rstrip() + "\n", encoding="utf-8")
|
||||
print("[ok] system-stack.env patched")
|
||||
|
||||
|
||||
def select_shellcrash_node() -> None:
|
||||
for group in ("🚀 节点选择", "dialer"):
|
||||
try:
|
||||
req = urllib.request.Request(
|
||||
f"http://127.0.0.1:9999/proxies/{urllib.parse.quote(group)}",
|
||||
data=json.dumps({"name": TUIC3}).encode(),
|
||||
headers={"Content-Type": "application/json"},
|
||||
method="PUT",
|
||||
)
|
||||
with urllib.request.urlopen(req, timeout=8) as resp:
|
||||
print(f"[ok] shellcrash {group} -> {TUIC3} ({resp.status})")
|
||||
except Exception as exc:
|
||||
print(f"[warn] shellcrash {group}: {exc}")
|
||||
|
||||
|
||||
def main() -> int:
|
||||
Path(f"{BASE}/config/hardware.env").write_text(HARDWARE_ENV, encoding="utf-8")
|
||||
print("[ok] hardware.env")
|
||||
patch_ini_files()
|
||||
patch_hardware_profile()
|
||||
patch_system_stack()
|
||||
select_shellcrash_node()
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
36
d2ypp2/tools/remote_pm2_logs.py
Normal file
36
d2ypp2/tools/remote_pm2_logs.py
Normal file
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python3
|
||||
from __future__ import annotations
|
||||
|
||||
import paramiko
|
||||
|
||||
HOST, USER, PASS = "10.88.0.4", "eric", "4669805"
|
||||
|
||||
|
||||
def run(c, cmd):
|
||||
_, o, e = c.exec_command(cmd, timeout=60, get_pty=True)
|
||||
return (o.read() + e.read()).decode("utf-8", "replace")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(HOST, username=USER, password=PASS, timeout=20)
|
||||
cmds = [
|
||||
"PM2_HOME=/home/eric/d2ypp2-src/.pm2 pm2 list 2>/dev/null",
|
||||
"tail -40 /home/eric/d2ypp2-src/.pm2/logs/youtube2__ch_mpwri36r_z5lm2-out.log",
|
||||
"tail -40 /home/eric/d2ypp2-src/.pm2/logs/youtube2__ch_mpyvqkc0_gj63k-out.log",
|
||||
"grep -E 'NVENC|VAAPI|libx264|fast_audio|Encoder|hardware|使用' /home/eric/d2ypp2-src/.pm2/logs/youtube2__ch_*-out.log | tail -30",
|
||||
"pgrep -af 'ffmpeg.*rtmps' || echo NO_FFMPEG",
|
||||
"nvidia-smi -L 2>/dev/null; nvidia-smi --query-gpu=utilization.encoder,utilization.gpu --format=csv 2>/dev/null",
|
||||
"ffmpeg -hide_banner -loglevel error -vaapi_device /dev/dri/renderD128 -f lavfi -i testsrc2=size=128x128:rate=1 -vf format=nv12,hwupload -frames:v 1 -an -c:v h264_vaapi -f null - 2>&1; echo VAAPI_EXIT=$?",
|
||||
"ffmpeg -hide_banner -loglevel error -f lavfi -i testsrc2=size=128x128:rate=1 -frames:v 1 -an -c:v h264_nvenc -f null - 2>&1; echo NVENC_EXIT=$?",
|
||||
"uname -m; lscpu | grep -E 'Model name|CPU\\(s\\)|Thread'",
|
||||
]
|
||||
for cmd in cmds:
|
||||
print(f"\n=== {cmd[:72]} ===")
|
||||
print(run(c, cmd)[:8000])
|
||||
c.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
98
d2ypp2/tools/remote_probe_restart.py
Normal file
98
d2ypp2/tools/remote_probe_restart.py
Normal file
@ -0,0 +1,98 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Fix config perms, run hardware probe, restart Pro lanes on 10.88.0.4."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
import paramiko
|
||||
|
||||
HOST, USER, PASS = "10.88.0.4", "eric", "4669805"
|
||||
REMOTE = "/home/eric/d2ypp2-src"
|
||||
LANES = ["youtube2__ch_mpwri36r_z5lm2", "youtube2__ch_mpyvqkc0_gj63k"]
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
UPLOADS = {
|
||||
ROOT / "douyin_youtube_ffplay.py": f"{REMOTE}/douyin_youtube_ffplay.py",
|
||||
ROOT / "scripts" / "hardware_probe.py": f"{REMOTE}/scripts/hardware_probe.py",
|
||||
ROOT / "config" / "hardware.env.example": f"{REMOTE}/config/hardware.env.example",
|
||||
ROOT / "youtube.py": f"{REMOTE}/youtube.py",
|
||||
ROOT / "src" / "spider.py": f"{REMOTE}/src/spider.py",
|
||||
ROOT / "src" / "recorder_config.py": f"{REMOTE}/src/recorder_config.py",
|
||||
}
|
||||
|
||||
|
||||
def run(c: paramiko.SSHClient, cmd: str, timeout: int = 90) -> str:
|
||||
_, o, e = c.exec_command(cmd, timeout=timeout, get_pty=True)
|
||||
return (o.read() + e.read()).decode("utf-8", "replace")
|
||||
|
||||
|
||||
def main() -> int:
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(HOST, username=USER, password=PASS, timeout=20)
|
||||
sftp = c.open_sftp()
|
||||
for local, remote in UPLOADS.items():
|
||||
sftp.put(str(local), remote)
|
||||
print(f"uploaded {remote}")
|
||||
sftp.close()
|
||||
|
||||
print(
|
||||
run(
|
||||
c,
|
||||
f"echo '{PASS}' | sudo -S -p '' chown -R eric:eric {REMOTE}/config && "
|
||||
f"chmod -R u+rwX {REMOTE}/config && echo perms_ok",
|
||||
timeout=30,
|
||||
)
|
||||
)
|
||||
probe_out = run(
|
||||
c,
|
||||
f"cd {REMOTE} && . .venv/bin/activate && "
|
||||
"python scripts/hardware_probe.py --write --apply-youtube-defaults",
|
||||
timeout=120,
|
||||
)
|
||||
try:
|
||||
profile = json.loads(probe_out.strip().splitlines()[-1])
|
||||
relay = profile.get("relay_strategy", {})
|
||||
print(f"relay_tier={relay.get('tier')} video_mode={relay.get('video_mode')} policy={relay.get('dual_lane_policy')}")
|
||||
applied = profile.get("youtube_defaults_applied") or []
|
||||
if applied:
|
||||
print(f"ini_updated={len(applied)}")
|
||||
except (json.JSONDecodeError, IndexError):
|
||||
print(probe_out[-2000:])
|
||||
|
||||
print("\n=== hardware.env ===")
|
||||
print(run(c, f"grep LIVE_RELAY {REMOTE}/config/hardware.env 2>/dev/null || echo MISSING"))
|
||||
|
||||
for lane in LANES:
|
||||
print(run(c, f"curl -sS -m 60 'http://127.0.0.1:8001/restart?process={lane}'")[:200])
|
||||
time.sleep(4)
|
||||
|
||||
print("waiting 50s...")
|
||||
time.sleep(50)
|
||||
print(run(c, "pgrep -af 'ffmpeg.*rtmps' || echo none")[:3000])
|
||||
raw = run(c, "curl -sS -m 15 'http://127.0.0.1:8001/process_monitor?family=youtube&light=1'")
|
||||
try:
|
||||
data = json.loads(raw)
|
||||
for entry in data.get("entries", []):
|
||||
if entry.get("pm2") in LANES:
|
||||
print(
|
||||
f"{entry['pm2']}: {entry.get('business_status')} "
|
||||
f"speed={entry.get('ffmpeg_speed')} room={entry.get('source_room_id')}"
|
||||
)
|
||||
except json.JSONDecodeError:
|
||||
print(raw[:1500])
|
||||
|
||||
for lane in LANES:
|
||||
log = run(
|
||||
c,
|
||||
f"grep -E 'hardware relay|stream copy|YouTube Live profile|speed=' "
|
||||
f"{REMOTE}/.pm2/logs/{lane}-out.log | tail -6",
|
||||
)
|
||||
print(f"\n=== {lane} ===\n{log[:1000]}")
|
||||
c.close()
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
81
d2ypp2/tools/remote_speed_check.py
Normal file
81
d2ypp2/tools/remote_speed_check.py
Normal file
@ -0,0 +1,81 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Live streaming speed check on remote host."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import sys
|
||||
|
||||
import paramiko
|
||||
|
||||
HOST = "10.88.0.4"
|
||||
USER = "eric"
|
||||
PASS = "4669805"
|
||||
|
||||
|
||||
def run(client: paramiko.SSHClient, cmd: str, timeout: int = 60) -> str:
|
||||
_, stdout, stderr = client.exec_command(cmd, timeout=timeout, get_pty=True)
|
||||
out = stdout.read().decode("utf-8", "replace")
|
||||
err = stderr.read().decode("utf-8", "replace")
|
||||
return (out + err).strip()
|
||||
|
||||
|
||||
def main() -> int:
|
||||
client = paramiko.SSHClient()
|
||||
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
client.connect(HOST, username=USER, password=PASS, timeout=20)
|
||||
|
||||
print("=== process_monitor ===")
|
||||
raw = run(client, "curl -sS -m 15 'http://127.0.0.1:8001/process_monitor?family=youtube'")
|
||||
try:
|
||||
data = json.loads(raw)
|
||||
for entry in data.get("entries", []):
|
||||
print(
|
||||
f"{entry.get('pm2')}: status={entry.get('process_status')} "
|
||||
f"biz={entry.get('business_status')} speed={entry.get('ffmpeg_speed')} "
|
||||
f"speed_low={entry.get('ffmpeg_speed_low')} pids={entry.get('ffmpeg_pids')}"
|
||||
)
|
||||
note = entry.get("business_note") or ""
|
||||
if note:
|
||||
print(f" note: {note}")
|
||||
except json.JSONDecodeError:
|
||||
print(raw[:3000])
|
||||
|
||||
print("\n=== quality_guard ===")
|
||||
raw = run(client, "curl -sS -m 15 'http://127.0.0.1:8001/youtube/quality_guard'")
|
||||
try:
|
||||
q = json.loads(raw)
|
||||
print(json.dumps(q, ensure_ascii=False, indent=2)[:6000])
|
||||
except json.JSONDecodeError:
|
||||
print(raw[:3000])
|
||||
|
||||
print("\n=== ffmpeg speed (sudo tail stderr) ===")
|
||||
print(
|
||||
run(
|
||||
client,
|
||||
f"echo '{PASS}' | sudo -S -p '' bash -lc "
|
||||
"\"for pid in $(pgrep -f 'ffmpeg.*rtmps://a.rtmps.youtube.com'); do "
|
||||
"echo PID=$pid; timeout 2 tail -c 4000 /proc/$pid/fd/2 2>/dev/null | tr '\\r' '\\n' | grep speed= | tail -2; done\"",
|
||||
timeout=30,
|
||||
)
|
||||
)
|
||||
|
||||
print("\n=== youtube processes ===")
|
||||
print(run(client, "ps aux | grep 'd2ypp2-src/youtube.py' | grep -v grep"))
|
||||
|
||||
print("\n=== active youtube configs fast_audio ===")
|
||||
print(
|
||||
run(
|
||||
client,
|
||||
"grep -H 'fast_audio\\|bitrate' /home/eric/d2ypp2-src/config/youtube.youtube2__*.ini 2>/dev/null",
|
||||
)
|
||||
)
|
||||
|
||||
print("\n=== system load / mem ===")
|
||||
print(run(client, "uptime; free -h | head -2; nproc"))
|
||||
|
||||
client.close()
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
40
d2ypp2/tools/remote_wait_speed.py
Normal file
40
d2ypp2/tools/remote_wait_speed.py
Normal file
@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env python3
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import time
|
||||
|
||||
import paramiko
|
||||
|
||||
HOST, USER, PASS = "10.88.0.4", "eric", "4669805"
|
||||
LANES = ["youtube2__ch_mpwri36r_z5lm2", "youtube2__ch_mpyvqkc0_gj63k"]
|
||||
|
||||
|
||||
def run(c, cmd, timeout=60):
|
||||
_, o, e = c.exec_command(cmd, timeout=timeout, get_pty=True)
|
||||
return (o.read() + e.read()).decode("utf-8", "replace")
|
||||
|
||||
|
||||
def main():
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(HOST, username=USER, password=PASS, timeout=20)
|
||||
print("waiting 45s for stable push...")
|
||||
time.sleep(45)
|
||||
print(run(c, "pgrep -af 'ffmpeg.*rtmps' || echo none"))
|
||||
for lane in LANES:
|
||||
print(f"\n=== {lane} log tail ===")
|
||||
print(run(c, f"grep -E 'speed=|stream copy|并发推流|FFmpeg]' /home/eric/d2ypp2-src/.pm2/logs/{lane}-out.log | tail -8"))
|
||||
raw = run(c, "curl -sS -m 15 'http://127.0.0.1:8001/process_monitor?family=youtube&light=1'")
|
||||
data = json.loads(raw)
|
||||
for entry in data.get("entries", []):
|
||||
if entry.get("pm2") in LANES:
|
||||
print(
|
||||
f"\n{entry['pm2']}: {entry.get('business_status')} "
|
||||
f"speed={entry.get('ffmpeg_speed')} low={entry.get('ffmpeg_speed_low')}"
|
||||
)
|
||||
c.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
67
d2ypp2/tools/restart_host04_lanes.py
Normal file
67
d2ypp2/tools/restart_host04_lanes.py
Normal file
@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env python3
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
|
||||
import paramiko
|
||||
|
||||
HOST, USER, PASS = "10.88.0.4", "eric", "4669805"
|
||||
BASE = "/home/eric/d2ypp2-src"
|
||||
|
||||
|
||||
def run(cmd: str, timeout: int = 120) -> str:
|
||||
client = paramiko.SSHClient()
|
||||
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
client.connect(HOST, username=USER, password=PASS, timeout=20)
|
||||
_, stdout, stderr = client.exec_command(f"export LC_ALL=C.UTF-8; {cmd}", timeout=timeout)
|
||||
out = (stdout.read() + stderr.read()).decode("utf-8", "replace")
|
||||
client.close()
|
||||
return out.strip()
|
||||
|
||||
|
||||
def main() -> int:
|
||||
print("=== process runner state ===")
|
||||
raw = run(f"cat {BASE}/.process_runner/state.json 2>/dev/null || echo '{{}}'")
|
||||
try:
|
||||
state = json.loads(raw)
|
||||
for name, row in sorted(state.items()):
|
||||
if "youtube" not in name:
|
||||
continue
|
||||
print(name, "pid=", row.get("pid"), "status=", row.get("status"), "script=", row.get("script"))
|
||||
except json.JSONDecodeError:
|
||||
print(raw[:2000])
|
||||
|
||||
print("\n=== running youtube/ffmpeg ===")
|
||||
print(run("pgrep -af 'youtube.py|ffmpeg.*rtmps' | grep -v pgrep || echo none"))
|
||||
|
||||
print("\n=== try restart pro lanes via api ===")
|
||||
for proc in ("youtube2__ch_mpwri36r_z5lm2", "youtube2__ch_mpyvqkc0_gj63k"):
|
||||
out = run(
|
||||
"curl -sS -m 60 -X POST 'http://127.0.0.1:8001/restart' "
|
||||
"-H 'Content-Type: application/json' "
|
||||
f"-d '{{\"process\":\"{proc}\"}}'"
|
||||
)
|
||||
print(proc, out[:800])
|
||||
|
||||
print("\n=== after start ===")
|
||||
print(run("sleep 8; pgrep -af 'youtube.py' | grep -v pgrep"))
|
||||
print(run("pgrep -af 'ffmpeg.*rtmps' | grep -v pgrep"))
|
||||
raw = run("curl -sS -m 12 'http://127.0.0.1:8001/process_monitor?family=youtube'")
|
||||
try:
|
||||
data = json.loads(raw)
|
||||
for row in data.get("entries") or []:
|
||||
print(
|
||||
row.get("pm2"),
|
||||
row.get("business_status"),
|
||||
row.get("is_pushing"),
|
||||
row.get("label"),
|
||||
row.get("source_display"),
|
||||
)
|
||||
except json.JSONDecodeError:
|
||||
print(raw[:2000])
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
36
d2ypp2/tools/restart_lanes_host04.py
Normal file
36
d2ypp2/tools/restart_lanes_host04.py
Normal file
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Restart Pro lanes on .4 and verify transcode profile."""
|
||||
import sys
|
||||
import time
|
||||
|
||||
import paramiko
|
||||
|
||||
HOST, USER, PASS = "10.88.0.4", "eric", "4669805"
|
||||
LANES = [
|
||||
"youtube2__ch_mpwri36r_z5lm2",
|
||||
"youtube2__ch_mpyvqkc0_gj63k",
|
||||
]
|
||||
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(HOST, username=USER, password=PASS, timeout=15)
|
||||
|
||||
|
||||
def run(cmd: str, timeout: int = 90) -> str:
|
||||
_, o, e = c.exec_command(cmd, timeout=timeout, get_pty=True)
|
||||
return (o.read() + e.read()).decode("utf-8", "replace")
|
||||
|
||||
|
||||
for lane in LANES:
|
||||
print(f"\n=== start {lane} ===")
|
||||
print(run(f"curl -sS -m 30 'http://127.0.0.1:8001/start?process={lane}'")[:500])
|
||||
|
||||
print("\n=== wait 15s ===")
|
||||
time.sleep(15)
|
||||
|
||||
print(run("pgrep -af 'ffmpeg.*rtmps' | head -2"))
|
||||
print(run("grep -hE 'stream copy|transcode|YouTube Live profile|hardware relay' /home/eric/d2ypp2-src/.pm2/logs/youtube2__*-out.log 2>/dev/null | tail -8"))
|
||||
print(run("grep -h 'speed=' /home/eric/d2ypp2-src/.pm2/logs/youtube2__*-out.log 2>/dev/null | tail -4"))
|
||||
print(run("curl -sS -m 10 'http://127.0.0.1:8001/process_monitor?family=youtube' | python3 -m json.tool | head -60"))
|
||||
|
||||
c.close()
|
||||
61
d2ypp2/tools/restart_youtube_lanes.py
Normal file
61
d2ypp2/tools/restart_youtube_lanes.py
Normal file
@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Restart YouTube lanes via control plane API after relay/copy cleanup."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import time
|
||||
|
||||
import paramiko
|
||||
|
||||
TARGETS = [
|
||||
("10.88.0.4", "/home/eric/d2ypp2-src"),
|
||||
("10.88.0.5", "/opt/live/d2ypp"),
|
||||
]
|
||||
|
||||
|
||||
def run(ssh: paramiko.SSHClient, cmd: str, timeout: int = 120) -> str:
|
||||
_, stdout, stderr = ssh.exec_command(cmd, timeout=timeout, get_pty=True)
|
||||
return (stdout.read() + stderr.read()).decode("utf-8", "replace").strip()
|
||||
|
||||
|
||||
def lane_names(ssh: paramiko.SSHClient, base: str) -> list[str]:
|
||||
raw = run(ssh, f"ls {base}/config/youtube.youtube2__*.ini 2>/dev/null")
|
||||
names: list[str] = []
|
||||
for line in raw.splitlines():
|
||||
name = line.rsplit("/", 1)[-1]
|
||||
if name.startswith("youtube.") and name.endswith(".ini"):
|
||||
names.append(name[len("youtube.") : -len(".ini")])
|
||||
return sorted(names)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
for host, base in TARGETS:
|
||||
ssh = paramiko.SSHClient()
|
||||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
ssh.connect(host, username="eric", password="4669805", timeout=20)
|
||||
print(f"=== {host} {base} ===")
|
||||
print("before:", run(ssh, "pgrep -af 'ffmpeg.*rtmps' | grep -v pgrep | head -3"))
|
||||
for proc in lane_names(ssh, base):
|
||||
out = run(
|
||||
ssh,
|
||||
"curl -sS -m 60 -X POST 'http://127.0.0.1:8001/restart' "
|
||||
"-H 'Content-Type: application/json' "
|
||||
f"-d '{{\"process\":\"{proc}\"}}'",
|
||||
)
|
||||
print(f"restart {proc}: {out[:300]}")
|
||||
time.sleep(10)
|
||||
print("after:", run(ssh, "pgrep -af 'ffmpeg.*rtmps' | grep -v pgrep | head -3"))
|
||||
print(
|
||||
run(
|
||||
ssh,
|
||||
f"grep -hE 'YouTube Live profile|stream copy|libx264|LIVE_VIDEO_ENCODER' "
|
||||
f"{base}/.pm2/logs/youtube2__*-out.log 2>/dev/null | tail -8",
|
||||
)
|
||||
)
|
||||
ssh.close()
|
||||
print()
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
55
d2ypp2/tools/sync_host04_from_05.py
Normal file
55
d2ypp2/tools/sync_host04_from_05.py
Normal file
@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Compare and sync relay/proxy config from 10.88.0.5 -> 10.88.0.4."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import paramiko
|
||||
|
||||
HOSTS = {
|
||||
"10.88.0.4": ("eric", "4669805"),
|
||||
"10.88.0.5": ("eric", "4669805"),
|
||||
}
|
||||
|
||||
COMPARE_CMDS = [
|
||||
("hardware_env", "cat /home/eric/d2ypp2-src/config/hardware.env 2>/dev/null"),
|
||||
("hw_profile", "cat /home/eric/d2ypp2-src/config/hardware-profile.json 2>/dev/null"),
|
||||
("system_stack", "grep -E 'YOUTUBE|PUSH|PROXY|SHELL|RELAY|PM2|FFMPEG' /home/eric/d2ypp2-src/config/system-stack.env 2>/dev/null | head -40"),
|
||||
("proxychains_yt", "cat /home/eric/d2ypp2-src/config/proxychains-youtube.conf 2>/dev/null"),
|
||||
("youtube_ini_glob", "grep -H 'video_mode\\|fast_audio\\|bitrate\\|push_proxy\\|rtmps' /home/eric/d2ypp2-src/config/youtube.youtube2__*.ini 2>/dev/null"),
|
||||
("shellcrash_proxy", "grep -A30 'proxy-groups:' /tmp/ShellCrash/config.yaml 2>/dev/null | head -35"),
|
||||
("shellcrash_selected", "grep -E '^(mode|mixed-port|socks-port|external-controller)' /tmp/ShellCrash/config.yaml 2>/dev/null"),
|
||||
("ffmpeg_bin", "which ffmpeg; ffmpeg -version 2>&1 | head -1"),
|
||||
("pm2_mode", "which pm2 2>/dev/null; PM2_HOME=/home/eric/d2ypp2-src/.pm2 pm2 list 2>/dev/null | head -8"),
|
||||
("state_json", "cat /home/eric/d2ypp2-src/.process_runner/state.json 2>/dev/null"),
|
||||
("ffplay_push_proxy", "grep -n 'push_proxy\\|proxychains\\|YOUTUBE_PUSH' /home/eric/d2ypp2-src/douyin_youtube_ffplay.py 2>/dev/null | head -15"),
|
||||
]
|
||||
|
||||
|
||||
def run(host: str, user: str, pw: str, cmd: str, timeout: int = 45) -> str:
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(host, username=user, password=pw, timeout=15)
|
||||
_, o, e = c.exec_command(cmd, timeout=timeout, get_pty=True)
|
||||
out = (o.read() + e.read()).decode("utf-8", "replace")
|
||||
c.close()
|
||||
return out
|
||||
|
||||
|
||||
def main() -> int:
|
||||
data: dict[str, dict[str, str]] = {}
|
||||
for host, (user, pw) in HOSTS.items():
|
||||
data[host] = {}
|
||||
print(f"\n{'#' * 60}\n# {host}\n{'#' * 60}")
|
||||
for label, cmd in COMPARE_CMDS:
|
||||
try:
|
||||
out = run(host, user, pw, cmd)
|
||||
data[host][label] = out
|
||||
print(f"\n--- {label} ---")
|
||||
print(out[:3500].encode("ascii", "backslashreplace").decode())
|
||||
except Exception as exc:
|
||||
print(f"ERR {label}: {exc}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
35
d2ypp2/tools/test_douyin_fetch.py
Normal file
35
d2ypp2/tools/test_douyin_fetch.py
Normal file
@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Test Douyin fetch paths on remote or local."""
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
if str(ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from src.spider import get_douyin_stream_data, get_douyin_web_stream_data
|
||||
|
||||
|
||||
async def main() -> None:
|
||||
url = sys.argv[1] if len(sys.argv) > 1 else "https://live.douyin.com/29155980665"
|
||||
proxy = sys.argv[2] if len(sys.argv) > 2 else ""
|
||||
cookie_arg = sys.argv[3] if len(sys.argv) > 3 else "__default__"
|
||||
proxy_addr = proxy or None
|
||||
cookies = None if cookie_arg == "__default__" else cookie_arg
|
||||
for name, fn in (
|
||||
("web", get_douyin_web_stream_data),
|
||||
("html", get_douyin_stream_data),
|
||||
):
|
||||
data = await fn(url, proxy_addr=proxy_addr, cookies=cookies)
|
||||
anchor = str(data.get("anchor_name") or "")
|
||||
print(
|
||||
f"{name}: anchor={anchor[:30] or '-'} status={data.get('status')} "
|
||||
f"stream={bool(data.get('stream_url'))}"
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
9
d2ypp2/tools/tmp_lane2_grep.py
Normal file
9
d2ypp2/tools/tmp_lane2_grep.py
Normal file
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
import paramiko
|
||||
c=paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect('10.88.0.4',username='eric',password='4669805',timeout=15)
|
||||
cmd=r"""grep -E 'stream copy|ffprobe|probe|transcode|不可用|YouTube Live profile' /home/eric/d2ypp2-src/.pm2/logs/youtube2__ch_mpyvqkc0_gj63k-out.log | tail -25"""
|
||||
_,o,_=c.exec_command(cmd,timeout=30)
|
||||
print(o.read().decode('utf-8','replace').encode('ascii','backslashreplace').decode())
|
||||
c.close()
|
||||
79
d2ypp2/tools/verify_deploy_host04.py
Normal file
79
d2ypp2/tools/verify_deploy_host04.py
Normal file
@ -0,0 +1,79 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Post-deploy verify on 10.88.0.4."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import sys
|
||||
|
||||
import paramiko
|
||||
|
||||
HOST, USER, PASS, BASE = "10.88.0.4", "eric", "4669805", "/home/eric/d2ypp2-src"
|
||||
OUT_PATH = sys.argv[1] if len(sys.argv) > 1 else None
|
||||
|
||||
|
||||
def emit(text: str) -> None:
|
||||
if OUT_PATH:
|
||||
with open(OUT_PATH, "a", encoding="utf-8") as fh:
|
||||
fh.write(text + "\n")
|
||||
else:
|
||||
sys.stdout.buffer.write((text + "\n").encode("utf-8", errors="replace"))
|
||||
|
||||
|
||||
def run(ssh: paramiko.SSHClient, cmd: str, timeout: int = 90) -> str:
|
||||
_, o, e = ssh.exec_command(f"export LC_ALL=C.UTF-8; {cmd}", timeout=timeout, get_pty=True)
|
||||
return (o.read() + e.read()).decode("utf-8", "replace")
|
||||
|
||||
|
||||
def main() -> int:
|
||||
if OUT_PATH:
|
||||
open(OUT_PATH, "w", encoding="utf-8").close()
|
||||
|
||||
ssh = paramiko.SSHClient()
|
||||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
ssh.connect(HOST, username=USER, password=PASS, timeout=20)
|
||||
|
||||
checks = {
|
||||
"health": run(ssh, "curl -sf -m 8 http://127.0.0.1:8001/health || echo DOWN"),
|
||||
"hide_relay_snapshot": run(
|
||||
ssh, f"grep -c 'HIDE_YOUTUBE_RELAY_SNAPSHOT = true' {BASE}/web-console/components/live-product/LiveYoutubeUnmannedView.tsx"
|
||||
).strip(),
|
||||
"hide_event_hub": run(
|
||||
ssh, f"grep -c 'HIDE_YOUTUBE_LIVE_EVENT_HUB = true' {BASE}/web-console/components/live-product/LiveYoutubeUnmannedView.tsx"
|
||||
).strip(),
|
||||
"static_chunk": run(
|
||||
ssh, f"ls {BASE}/web-console/out/_next/static/chunks/904-*.js 2>/dev/null | tail -1"
|
||||
).strip(),
|
||||
"proxychains_fn": run(
|
||||
ssh, f"grep -c 'def _proxychains_config_for_push' {BASE}/douyin_youtube_ffplay.py"
|
||||
).strip(),
|
||||
"ffmpeg": run(ssh, "pgrep -af 'ffmpeg.*rtmps' | grep -v pgrep | head -2"),
|
||||
}
|
||||
emit("=== deploy verify ===")
|
||||
for key, value in checks.items():
|
||||
emit(f"{key}: {value[:500]}")
|
||||
|
||||
raw = run(ssh, "curl -sS -m 12 'http://127.0.0.1:8001/process_monitor?family=youtube'")
|
||||
emit("\n=== lanes ===")
|
||||
try:
|
||||
for row in json.loads(raw).get("entries", []):
|
||||
pm2 = row.get("pm2", "")
|
||||
if pm2.startswith("youtube"):
|
||||
emit(
|
||||
f"{pm2}: {row.get('business_status')} pushing={row.get('is_pushing')} speed={row.get('ffmpeg_speed')}"
|
||||
)
|
||||
except json.JSONDecodeError:
|
||||
emit(f"process_monitor failed: {raw[:300]}")
|
||||
|
||||
ok = (
|
||||
"ok" in checks["health"]
|
||||
and checks["hide_relay_snapshot"] == "1"
|
||||
and checks["hide_event_hub"] == "1"
|
||||
and checks["proxychains_fn"] == "1"
|
||||
)
|
||||
emit(f"\nDEPLOY_TEST: {'PASS' if ok else 'PARTIAL'}")
|
||||
ssh.close()
|
||||
return 0 if ok else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
20
d2ypp2/tools/verify_host04.py
Normal file
20
d2ypp2/tools/verify_host04.py
Normal file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env python3
|
||||
import paramiko, sys
|
||||
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect("10.88.0.4", username="eric", password="4669805", timeout=15)
|
||||
cmds = [
|
||||
"grep -H 'video_mode\\|bitrate' /home/eric/d2ypp2-src/config/youtube.youtube2__*.ini 2>/dev/null | head -15 || echo no_copy_lines",
|
||||
"grep relay_strategy /home/eric/d2ypp2-src/config/hardware-profile.json || echo no_relay_strategy",
|
||||
"curl -sS -m 8 -x socks5://127.0.0.1:7890 https://www.gstatic.com/generate_204 -w 'gstatic=%{http_code} t=%{time_total}\n' -o /dev/null",
|
||||
"curl -sS -m 10 -x socks5://127.0.0.1:7890 https://a.rtmps.youtube.com/ -w 'yt_t=%{time_total}\n' -o /dev/null 2>&1 | tail -1",
|
||||
"pgrep -af 'ffmpeg.*rtmps' || echo no_ffmpeg",
|
||||
"grep -hE 'stream copy|transcode|YouTube Live profile' /home/eric/d2ypp2-src/.pm2/logs/youtube2__*-out.log 2>/dev/null | tail -4",
|
||||
]
|
||||
for cmd in cmds:
|
||||
_, o, e = c.exec_command(cmd, timeout=45, get_pty=True)
|
||||
out = (o.read() + e.read()).decode("utf-8", "replace")
|
||||
sys.stdout.buffer.write(f"\n> {cmd[:70]}\n".encode())
|
||||
sys.stdout.buffer.write(out.encode("utf-8", "replace"))
|
||||
c.close()
|
||||
72
d2ypp2/tools/verify_host04_after_fix.py
Normal file
72
d2ypp2/tools/verify_host04_after_fix.py
Normal file
@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env python3
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import time
|
||||
|
||||
import paramiko
|
||||
|
||||
HOST, USER, PASS = "10.88.0.4", "eric", "4669805"
|
||||
BASE = "/home/eric/d2ypp2-src"
|
||||
|
||||
|
||||
def run(cmd: str, timeout: int = 90) -> str:
|
||||
client = paramiko.SSHClient()
|
||||
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
client.connect(HOST, username=USER, password=PASS, timeout=20)
|
||||
_, stdout, stderr = client.exec_command(f"export LC_ALL=C.UTF-8; {cmd}", timeout=timeout)
|
||||
out = (stdout.read() + stderr.read()).decode("utf-8", "replace")
|
||||
client.close()
|
||||
return out.strip()
|
||||
|
||||
|
||||
def main() -> int:
|
||||
for attempt in range(1, 21):
|
||||
health = run("curl -sf -m 4 http://127.0.0.1:8001/health; echo")
|
||||
if '"status":"ok"' in health or '"status": "ok"' in health:
|
||||
print(f"health ok (attempt {attempt})")
|
||||
break
|
||||
print(f"waiting health attempt {attempt}: {health[:120]}")
|
||||
time.sleep(2)
|
||||
else:
|
||||
print("health failed")
|
||||
print(run(f"echo {PASS!r} | sudo -S -p '' systemctl status live-console.service --no-pager"))
|
||||
|
||||
raw = run("curl -sS -m 12 'http://127.0.0.1:8001/process_monitor?family=youtube'")
|
||||
print("\n=== process_monitor ===")
|
||||
try:
|
||||
data = json.loads(raw)
|
||||
entries = data.get("entries") or []
|
||||
print("entries", len(entries))
|
||||
for row in entries:
|
||||
print(
|
||||
f" {row.get('pm2')}: business={row.get('business_status')} pushing={row.get('is_pushing')} "
|
||||
f"label={row.get('label')} display={row.get('source_display') or row.get('source_title') or '-'}"
|
||||
)
|
||||
except json.JSONDecodeError:
|
||||
print(raw[:2500])
|
||||
|
||||
print("\n=== served bundle ===")
|
||||
print(run("curl -sS -m 8 http://127.0.0.1/ | grep -o 'page-[a-z0-9]*\\.js' | head -1"))
|
||||
|
||||
print("\n=== chunk string hits ===")
|
||||
print(
|
||||
run(
|
||||
"python3 -c \"from pathlib import Path; import glob; "
|
||||
f"hits=[]; "
|
||||
f"files=glob.glob('{BASE}/web-console/out/_next/static/chunks/**/*.js', recursive=True); "
|
||||
"needles=['Douyin','Current relay lane','Pro relay status','Waiting source','Pushing']; "
|
||||
"exec('for p in files:\\n t=Path(p).read_text(\\\"utf-8\\\",errors=\\\"replace\\\")\\n for n in needles:\\n if n in t: hits.append((n,p))'); "
|
||||
"[print(h) for h in hits[:12]]; print('files',len(files))\""
|
||||
)
|
||||
)
|
||||
|
||||
print("\n=== ffmpeg / youtube ===")
|
||||
print(run("pgrep -af 'ffmpeg.*rtmps' | grep -v pgrep | wc -l"))
|
||||
print(run("pgrep -af 'youtube.py' | grep -v pgrep"))
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
79
d2ypp2/tools/verify_host04_regression.py
Normal file
79
d2ypp2/tools/verify_host04_regression.py
Normal file
@ -0,0 +1,79 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Finish host04 deploy: restart lanes and verify regression."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import time
|
||||
|
||||
import paramiko
|
||||
|
||||
HOST, USER, PASS, BASE = "10.88.0.4", "eric", "4669805", "/home/eric/d2ypp2-src"
|
||||
|
||||
|
||||
def run(ssh: paramiko.SSHClient, cmd: str, timeout: int = 120) -> str:
|
||||
_, o, e = ssh.exec_command(f"export LC_ALL=C.UTF-8; {cmd}", timeout=timeout, get_pty=True)
|
||||
return (o.read() + e.read()).decode("utf-8", "replace")
|
||||
|
||||
|
||||
def lane_names(ssh: paramiko.SSHClient) -> list[str]:
|
||||
raw = run(ssh, f"ls {BASE}/config/youtube.youtube2__*.ini 2>/dev/null")
|
||||
out: list[str] = []
|
||||
for line in raw.splitlines():
|
||||
name = line.rsplit("/", 1)[-1]
|
||||
if name.startswith("youtube.") and name.endswith(".ini"):
|
||||
out.append(name[len("youtube.") : -len(".ini")])
|
||||
return sorted(out)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
ssh = paramiko.SSHClient()
|
||||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
ssh.connect(HOST, username=USER, password=PASS, timeout=20)
|
||||
|
||||
print("health:", run(ssh, "curl -sf -m 8 http://127.0.0.1:8001/health && echo OK"))
|
||||
for proc in lane_names(ssh):
|
||||
out = run(
|
||||
ssh,
|
||||
"curl -sS -m 60 -X POST 'http://127.0.0.1:8001/restart' "
|
||||
"-H 'Content-Type: application/json' "
|
||||
f"-d '{json.dumps({'process': proc})}'",
|
||||
)
|
||||
print(f"restart {proc}: {out[:240]}")
|
||||
time.sleep(30)
|
||||
|
||||
copy_fn = run(ssh, f"grep -c _resolve_stream_copy_plan {BASE}/douyin_youtube_ffplay.py 2>/dev/null || echo 0").strip()
|
||||
relay = run(ssh, f"grep -c relay_strategy {BASE}/config/hardware-profile.json 2>/dev/null || echo 0").strip()
|
||||
ffmpeg = run(ssh, "pgrep -af 'ffmpeg.*rtmps' | grep -v pgrep | head -2")
|
||||
profile = run(
|
||||
ssh,
|
||||
"grep -hE 'YouTube Live profile|stream copy|libx264' "
|
||||
f"{BASE}/.pm2/logs/youtube2__*-out.log 2>/dev/null | tail -8",
|
||||
)
|
||||
qg = run(
|
||||
ssh,
|
||||
"curl -sS -m 12 http://127.0.0.1:8001/hub/youtube/quality_guard | "
|
||||
"python3 -c \"import sys,json; d=json.load(sys.stdin); print(d.get('ffmpeg_profile',{}).get('target','?'))\"",
|
||||
)
|
||||
raw = run(ssh, "curl -sS -m 12 'http://127.0.0.1:8001/process_monitor?family=youtube'")
|
||||
print("\n--- ffmpeg processes ---\n", ffmpeg)
|
||||
print("\n--- push profile log ---\n", profile)
|
||||
print("\n--- quality guard target ---\n", qg)
|
||||
try:
|
||||
rows = json.loads(raw).get("entries") or []
|
||||
print("\n--- process_monitor ---")
|
||||
for row in rows:
|
||||
print(
|
||||
f" {row.get('pm2')}: {row.get('business_status')} pushing={row.get('is_pushing')} "
|
||||
f"speed={row.get('ffmpeg_speed')} display={row.get('source_display') or '-'}"
|
||||
)
|
||||
except json.JSONDecodeError:
|
||||
print("process_monitor raw:", raw[:800])
|
||||
|
||||
ok = copy_fn in {"0", ""} and relay in {"0", ""} and ("libx264" in ffmpeg or "H.264 libx264" in profile)
|
||||
print(f"\n回归源码: {'PASS' if ok else 'PARTIAL'} (copy_fn={copy_fn}, relay={relay}, libx264={'yes' if 'libx264' in ffmpeg else 'no'})")
|
||||
ssh.close()
|
||||
return 0 if ok else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
@ -4,6 +4,12 @@ import { AlertTriangle, ExternalLink, Pause, Play, RefreshCw } from "lucide-reac
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
|
||||
import { formatPollBadge } from "@/lib/adaptivePoll";
|
||||
import {
|
||||
formatBitrateLabel,
|
||||
formatFfmpegMetricValue,
|
||||
formatFfmpegStatsBrief,
|
||||
mergeFfmpegMetrics,
|
||||
} from "@/lib/ffmpegMetrics";
|
||||
import {
|
||||
douyinSourceDisplayFrom,
|
||||
extractDouyinCurrentRoomFromLog,
|
||||
@ -22,6 +28,11 @@ type StatusPayload = {
|
||||
ffmpeg_pids?: number[];
|
||||
log_age_seconds?: number | null;
|
||||
is_pushing?: boolean;
|
||||
ffmpeg_speed?: number | null;
|
||||
ffmpeg_frame?: number | null;
|
||||
ffmpeg_time_seconds?: number | null;
|
||||
ffmpeg_speed_low?: boolean;
|
||||
ffmpeg_progress_stalled?: boolean;
|
||||
source_title?: string;
|
||||
source_room_id?: string;
|
||||
source_url?: string;
|
||||
@ -53,6 +64,8 @@ type MonitorRowHint = {
|
||||
ffmpeg_active?: boolean;
|
||||
ffmpeg_speed?: number | null;
|
||||
ffmpeg_frame?: number | null;
|
||||
ffmpeg_speed_low?: boolean;
|
||||
ffmpeg_progress_stalled?: boolean;
|
||||
is_pushing?: boolean;
|
||||
};
|
||||
|
||||
@ -69,6 +82,8 @@ type Props = {
|
||||
refreshToken?: number;
|
||||
/** process_monitor 行:补全 light status 缺失的 FFmpeg 指标 */
|
||||
monitorRow?: MonitorRowHint;
|
||||
/** Pro 线路名:推流中时固定显示频道名 */
|
||||
preferredTitle?: string;
|
||||
};
|
||||
|
||||
function businessLine(t: TFn, raw: string | undefined, note: string | undefined): string {
|
||||
@ -92,7 +107,8 @@ function businessLine(t: TFn, raw: string | undefined, note: string | undefined)
|
||||
return t("暂无业务状态", "No business-state hint yet");
|
||||
}
|
||||
|
||||
function businessShortLine(t: TFn, raw: string | undefined): string {
|
||||
function businessShortLine(t: TFn, raw: string | undefined, pushing = false): string {
|
||||
if (pushing) return t("推流中", "Pushing");
|
||||
const s = (raw || "").toLowerCase();
|
||||
if (s === "streaming") return t("推流中", "Pushing");
|
||||
if (s === "relay_slow") return t("低速", "Slow");
|
||||
@ -137,6 +153,7 @@ export function LiveProcessLiveLogCard({
|
||||
pollMs = 1000,
|
||||
refreshToken = 0,
|
||||
monitorRow,
|
||||
preferredTitle,
|
||||
}: Props) {
|
||||
const [processStatus, setProcessStatus] = useState<string>("");
|
||||
const [recentLog, setRecentLog] = useState("");
|
||||
@ -152,13 +169,18 @@ export function LiveProcessLiveLogCard({
|
||||
const [sourceAmbiguous, setSourceAmbiguous] = useState(false);
|
||||
const [sourceCurrent, setSourceCurrent] = useState(false);
|
||||
const [isPushing, setIsPushing] = useState(false);
|
||||
const [statusFfmpegSpeed, setStatusFfmpegSpeed] = useState<number | null>(null);
|
||||
const [statusFfmpegFrame, setStatusFfmpegFrame] = useState<number | null>(null);
|
||||
const [statusFfmpegTime, setStatusFfmpegTime] = useState<number | null>(null);
|
||||
const [statusSpeedLow, setStatusSpeedLow] = useState(false);
|
||||
const [statusProgressStalled, setStatusProgressStalled] = useState(false);
|
||||
const [paused, setPaused] = useState(false);
|
||||
const [liveSince, setLiveSince] = useState<number | null>(null);
|
||||
const [nowTick, setNowTick] = useState(0);
|
||||
const [pageVisible, setPageVisible] = useState(true);
|
||||
const outRef = useRef<HTMLPreElement>(null);
|
||||
const errRef = useRef<HTMLPreElement>(null);
|
||||
const prevOnlineRef = useRef(false);
|
||||
const prevPushingRef = useRef(false);
|
||||
const pullInFlightRef = useRef(false);
|
||||
const pullQueuedRef = useRef(false);
|
||||
const currentProcRef = useRef(currentProc);
|
||||
@ -173,9 +195,25 @@ export function LiveProcessLiveLogCard({
|
||||
isPushing ||
|
||||
!!monitorRow?.is_pushing ||
|
||||
["streaming", "relay_slow"].includes(businessStatus.trim().toLowerCase());
|
||||
const monitorSpeed =
|
||||
typeof monitorRow?.ffmpeg_speed === "number" ? monitorRow.ffmpeg_speed.toFixed(2) : null;
|
||||
const monitorFrame = typeof monitorRow?.ffmpeg_frame === "number" ? String(monitorRow.ffmpeg_frame) : null;
|
||||
const liveMetrics = mergeFfmpegMetrics(
|
||||
{
|
||||
ffmpeg_speed: statusFfmpegSpeed ?? monitorRow?.ffmpeg_speed,
|
||||
ffmpeg_frame: statusFfmpegFrame ?? monitorRow?.ffmpeg_frame,
|
||||
ffmpeg_active: monitorRow?.ffmpeg_active,
|
||||
is_pushing: pushingNow,
|
||||
ffmpeg_speed_low: statusSpeedLow || monitorRow?.ffmpeg_speed_low,
|
||||
ffmpeg_progress_stalled: statusProgressStalled || monitorRow?.ffmpeg_progress_stalled,
|
||||
},
|
||||
undefined,
|
||||
`${recentLog}\n${recentError}`,
|
||||
);
|
||||
const encodedDurationLabel =
|
||||
typeof statusFfmpegTime === "number" && statusFfmpegTime > 0
|
||||
? fmtDuration(Math.max(0, Math.floor(statusFfmpegTime)))
|
||||
: null;
|
||||
const liveStatsText = formatFfmpegStatsBrief(liveMetrics, {
|
||||
live: pushingNow || onlineNow || !!monitorRow?.ffmpeg_active,
|
||||
});
|
||||
const ffmpegWorkerLabel = ffmpegPids.length
|
||||
? ffmpegPids.join(", ")
|
||||
: pushingNow || monitorRow?.ffmpeg_active
|
||||
@ -207,7 +245,12 @@ export function LiveProcessLiveLogCard({
|
||||
(suppressAmbiguousBackend ? "" : sourceDisplay) ||
|
||||
(suppressAmbiguousBackend ? "" : sourceTitle) ||
|
||||
localSourceLabel ||
|
||||
preferredTitle?.trim() ||
|
||||
(primaryRoomId ? `抖音直播间 ${primaryRoomId}` : "");
|
||||
const douyinSourceSubtitle =
|
||||
preferredTitle?.trim() && primarySourceLabel && preferredTitle.trim() !== primarySourceLabel
|
||||
? preferredTitle.trim()
|
||||
: "";
|
||||
const youtubeKeyRejected = businessStatus.trim().toLowerCase() === "youtube_key_rejected";
|
||||
|
||||
const pull = useCallback(async () => {
|
||||
@ -239,14 +282,22 @@ export function LiveProcessLiveLogCard({
|
||||
setSourceAmbiguous(!!data.source_ambiguous);
|
||||
setSourceCurrent(!!data.source_current);
|
||||
setIsPushing(!!data.is_pushing);
|
||||
const online = /^(online|running)$/i.test(ps);
|
||||
if (online && !prevOnlineRef.current) {
|
||||
setStatusFfmpegSpeed(typeof data.ffmpeg_speed === "number" ? data.ffmpeg_speed : null);
|
||||
setStatusFfmpegFrame(typeof data.ffmpeg_frame === "number" ? data.ffmpeg_frame : null);
|
||||
setStatusFfmpegTime(typeof data.ffmpeg_time_seconds === "number" ? data.ffmpeg_time_seconds : null);
|
||||
setStatusSpeedLow(!!data.ffmpeg_speed_low);
|
||||
setStatusProgressStalled(!!data.ffmpeg_progress_stalled);
|
||||
const pushing = !!(
|
||||
data.is_pushing ||
|
||||
["streaming", "relay_slow"].includes((data.business_status || "").trim().toLowerCase())
|
||||
);
|
||||
if (pushing && !prevPushingRef.current) {
|
||||
setLiveSince(Date.now());
|
||||
}
|
||||
if (!online) {
|
||||
if (!pushing) {
|
||||
setLiveSince(null);
|
||||
}
|
||||
prevOnlineRef.current = online;
|
||||
prevPushingRef.current = pushing;
|
||||
} catch {
|
||||
if (requestId !== requestSeqRef.current || targetProc !== currentProcRef.current.trim()) return;
|
||||
setProcessStatus("error");
|
||||
@ -261,6 +312,12 @@ export function LiveProcessLiveLogCard({
|
||||
setSourceAmbiguous(false);
|
||||
setSourceCurrent(false);
|
||||
setIsPushing(false);
|
||||
setStatusFfmpegSpeed(null);
|
||||
setStatusFfmpegFrame(null);
|
||||
setStatusFfmpegTime(null);
|
||||
setStatusSpeedLow(false);
|
||||
setStatusProgressStalled(false);
|
||||
prevPushingRef.current = false;
|
||||
} finally {
|
||||
pullInFlightRef.current = false;
|
||||
if (pullQueuedRef.current) {
|
||||
@ -289,8 +346,13 @@ export function LiveProcessLiveLogCard({
|
||||
setSourceAmbiguous(false);
|
||||
setSourceCurrent(false);
|
||||
setIsPushing(false);
|
||||
setStatusFfmpegSpeed(null);
|
||||
setStatusFfmpegFrame(null);
|
||||
setStatusFfmpegTime(null);
|
||||
setStatusSpeedLow(false);
|
||||
setStatusProgressStalled(false);
|
||||
setLiveSince(null);
|
||||
prevOnlineRef.current = false;
|
||||
prevPushingRef.current = false;
|
||||
return;
|
||||
}
|
||||
setProcessStatus("");
|
||||
@ -307,8 +369,13 @@ export function LiveProcessLiveLogCard({
|
||||
setSourceAmbiguous(false);
|
||||
setSourceCurrent(false);
|
||||
setIsPushing(false);
|
||||
setStatusFfmpegSpeed(null);
|
||||
setStatusFfmpegFrame(null);
|
||||
setStatusFfmpegTime(null);
|
||||
setStatusSpeedLow(false);
|
||||
setStatusProgressStalled(false);
|
||||
setLiveSince(null);
|
||||
prevOnlineRef.current = false;
|
||||
prevPushingRef.current = false;
|
||||
void pull();
|
||||
}, [currentProc, pull]);
|
||||
|
||||
@ -433,34 +500,75 @@ export function LiveProcessLiveLogCard({
|
||||
className={`mt-2 inline-flex max-w-full rounded-full px-2.5 py-0.5 text-[11px] font-medium ring-1 ${businessBadgeClass(businessStatus)}`}
|
||||
title={businessLine(t, businessStatus, businessNote)}
|
||||
>
|
||||
{businessShortLine(t, businessStatus)}
|
||||
{businessShortLine(t, businessStatus, pushingNow)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="rounded-lg border border-white/[0.05] bg-black/20 p-3">
|
||||
<p className="text-[11px] text-zinc-500">{t("本次在线时长(估算)", "Online duration (est.)")}</p>
|
||||
<p className="text-[11px] text-zinc-500">
|
||||
{pushingNow ? t("推流时长(估算)", "Relay duration (est.)") : t("进程在线时长(估算)", "Process uptime (est.)")}
|
||||
</p>
|
||||
<p className="mt-2 font-mono text-sm font-semibold text-cyan-200/90">{durationLabel}</p>
|
||||
{encodedDurationLabel ? (
|
||||
<p className="mt-1 text-[10px] text-zinc-600">
|
||||
{t("已编码", "Encoded")} {encodedDurationLabel}
|
||||
</p>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="rounded-lg border border-white/[0.05] bg-black/20 p-3">
|
||||
<p className="text-[11px] text-zinc-500">{t("FFmpeg workers", "FFmpeg workers")}</p>
|
||||
<p className="mt-2 font-mono text-sm text-zinc-200">{ffmpegWorkerLabel}</p>
|
||||
{monitorSpeed || monitorFrame ? (
|
||||
<p className="mt-1 font-mono text-[10px] text-zinc-500">
|
||||
{monitorSpeed ? `speed ${monitorSpeed}x` : ""}
|
||||
{monitorSpeed && monitorFrame ? " · " : ""}
|
||||
{monitorFrame ? `frame ${monitorFrame}` : ""}
|
||||
</p>
|
||||
) : null}
|
||||
{logAgeSeconds != null ? (
|
||||
<p className="mt-1 text-[10px] text-zinc-600">
|
||||
{t("日志心跳", "Log heartbeat")} {fmtDuration(Math.max(0, Math.floor(logAgeSeconds)))}
|
||||
</p>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="rounded-lg border border-white/[0.05] bg-black/20 p-3 sm:col-span-2 xl:col-span-4">
|
||||
<p className="text-[11px] text-zinc-500">{t("实时转推指标", "Live relay metrics")}</p>
|
||||
<p
|
||||
className={`mt-2 font-mono text-sm ${
|
||||
liveMetrics.speedLow
|
||||
? "text-amber-200"
|
||||
: liveMetrics.progressStalled
|
||||
? "text-rose-200"
|
||||
: "text-cyan-100"
|
||||
}`}
|
||||
>
|
||||
{liveStatsText || t("等待 FFmpeg 上报 fps / speed / frame", "Waiting for FFmpeg fps / speed / frame")}
|
||||
</p>
|
||||
<div className="mt-2 grid gap-2 sm:grid-cols-4 font-mono text-[11px] text-zinc-400">
|
||||
<p>
|
||||
<span className="block text-zinc-600">fps</span>
|
||||
{formatFfmpegMetricValue(liveMetrics.fps)}
|
||||
</p>
|
||||
<p>
|
||||
<span className="block text-zinc-600">speed</span>
|
||||
{formatFfmpegMetricValue(liveMetrics.speed, "x")}
|
||||
</p>
|
||||
<p>
|
||||
<span className="block text-zinc-600">frame</span>
|
||||
{formatFfmpegMetricValue(liveMetrics.frame, "", 0)}
|
||||
</p>
|
||||
<p>
|
||||
<span className="block text-zinc-600">{t("码率", "Bitrate")}</span>
|
||||
{formatBitrateLabel(liveMetrics.bitrate) ?? "—"}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{primarySourceLabel ? (
|
||||
<div className="rounded-lg border border-white/[0.05] bg-black/20 px-3 py-2.5">
|
||||
<p className="text-[11px] text-zinc-500">{t("当前转播源", "Current relay source")}</p>
|
||||
<p className="text-[11px] text-zinc-500">
|
||||
{pushingNow && preferredTitle?.trim()
|
||||
? t("当前转播线路", "Current relay lane")
|
||||
: t("当前转播源", "Current relay source")}
|
||||
</p>
|
||||
<p className="mt-1 text-sm font-medium text-zinc-200">{primarySourceLabel}</p>
|
||||
{douyinSourceSubtitle ? (
|
||||
<p className="mt-1 text-xs text-zinc-500">
|
||||
{t("抖音源", "Douyin")}: {douyinSourceSubtitle}
|
||||
</p>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
{showKeyRow ? (
|
||||
|
||||
@ -46,6 +46,13 @@ import {
|
||||
urlConfigPollMs,
|
||||
} from "@/lib/adaptivePoll";
|
||||
import { normalizeBrowserReachableHttpUrl } from "@/lib/panelUrls";
|
||||
import {
|
||||
formatBitrateLabel,
|
||||
formatFfmpegMetricValue,
|
||||
formatFfmpegStatsBrief,
|
||||
mergeFfmpegMetrics,
|
||||
type FfmpegMetrics,
|
||||
} from "@/lib/ffmpegMetrics";
|
||||
|
||||
type ProcessEntry = { pm2: string; script: string; label: string };
|
||||
|
||||
@ -171,6 +178,12 @@ const PRO_PM2_RESERVED = new Set(["douyin_youtube", "tiktok", "obs", "web"]);
|
||||
/** UI 暂时隐藏「多频道 Pro」切换(DOM 与逻辑保留,改 false 即可恢复) */
|
||||
const HIDE_YOUTUBE_MULTI_PRO_TOGGLE = false;
|
||||
|
||||
/** UI 隐藏顶部「转播实况」概览卡(状态、指标网格、打开源站等) */
|
||||
const HIDE_YOUTUBE_RELAY_SNAPSHOT = true;
|
||||
|
||||
/** UI 隐藏「直播事件中枢」板块 */
|
||||
const HIDE_YOUTUBE_LIVE_EVENT_HUB = true;
|
||||
|
||||
type ProLaneDraft = {
|
||||
name: string;
|
||||
streamKey: string;
|
||||
@ -197,7 +210,35 @@ function laneDraftsFromChannels(channels: YoutubeProChannel[]): Record<string, P
|
||||
|
||||
function isLivePushingRow(row?: LiveProcRow): boolean {
|
||||
const business = (row?.business_status || "").trim().toLowerCase();
|
||||
return !!row?.is_pushing || business === "streaming" || business === "relay_slow";
|
||||
return (
|
||||
!!row?.is_pushing ||
|
||||
business === "streaming" ||
|
||||
business === "relay_slow" ||
|
||||
(business === "source_stalled" && !!row?.ffmpeg_active)
|
||||
);
|
||||
}
|
||||
|
||||
function proLaneStatusLabel(row: LiveProcRow | undefined, t: TFn): string {
|
||||
if (isLivePushingRow(row)) return t("推流中", "Pushing");
|
||||
return businessStatusLabel(row, t);
|
||||
}
|
||||
|
||||
function proLanePrimaryTitle(
|
||||
laneName: string,
|
||||
row?: LiveProcRow,
|
||||
urlLines = "",
|
||||
qualityLane?: YoutubeQualityLane,
|
||||
): string {
|
||||
const fromQuality = (qualityLane?.source_display || qualityLane?.source_title || "").trim();
|
||||
if (fromQuality) return fromQuality;
|
||||
return douyinSourceDisplayFor(row, urlLines) || laneName.trim();
|
||||
}
|
||||
|
||||
function proLaneDouyinSubtitle(row?: LiveProcRow, urlLines = "", laneName = ""): string {
|
||||
const source = douyinSourceDisplayFor(row, urlLines).trim();
|
||||
const lane = laneName.trim();
|
||||
if (isLivePushingRow(row) && lane && source && lane !== source) return lane;
|
||||
return "";
|
||||
}
|
||||
|
||||
function douyinSourceDisplayFor(row?: LiveProcRow, urlLines = "", logText = ""): string {
|
||||
@ -522,6 +563,66 @@ function metricText(value: number | undefined, suffix = ""): string {
|
||||
return `${value.toFixed(value >= 100 ? 0 : 2).replace(/\.00$/, "")}${suffix}`;
|
||||
}
|
||||
|
||||
function laneStatusEmoji(row?: LiveProcRow): string {
|
||||
const business = (row?.business_status || "").trim().toLowerCase();
|
||||
if (business === "streaming") return "🟢";
|
||||
if (business === "relay_slow") return "🟡";
|
||||
if (business === "source_stalled") return "🟠";
|
||||
if (business === "youtube_key_rejected" || business === "error") return "🔴";
|
||||
if (business === "source_live") return "🔵";
|
||||
if (business === "waiting_source") return "⚪";
|
||||
return "⚫";
|
||||
}
|
||||
|
||||
function speedToneClass(speed?: number, speedLow?: boolean, progressStalled?: boolean): string {
|
||||
if (progressStalled) return "text-rose-300";
|
||||
if (speedLow || (typeof speed === "number" && speed > 0 && speed < 0.95)) return "text-amber-200";
|
||||
if (typeof speed === "number" && speed >= 0.95) return "text-emerald-200";
|
||||
return "text-cyan-100";
|
||||
}
|
||||
|
||||
function MetricPulseCard({
|
||||
label,
|
||||
value,
|
||||
helper,
|
||||
warn = false,
|
||||
accent = "cyan",
|
||||
}: {
|
||||
label: string;
|
||||
value: string;
|
||||
helper: string;
|
||||
warn?: boolean;
|
||||
accent?: "cyan" | "emerald" | "amber" | "violet";
|
||||
}) {
|
||||
const ring =
|
||||
accent === "emerald"
|
||||
? "from-emerald-500/20 via-transparent to-cyan-500/10"
|
||||
: accent === "amber"
|
||||
? "from-amber-500/20 via-transparent to-rose-500/10"
|
||||
: accent === "violet"
|
||||
? "from-violet-500/20 via-transparent to-cyan-500/10"
|
||||
: "from-cyan-500/20 via-transparent to-violet-500/10";
|
||||
return (
|
||||
<div className="group relative overflow-hidden rounded-xl border border-white/[0.06] bg-black/25 p-3 min-w-0 transition hover:border-white/12">
|
||||
<div className={`pointer-events-none absolute inset-0 bg-gradient-to-br ${ring} opacity-70`} />
|
||||
<div className="relative">
|
||||
<p className="text-[11px] text-zinc-500">{label}</p>
|
||||
<p className={`mt-1 text-xl font-semibold tracking-tight ${warn ? "text-amber-200" : "text-white"}`}>
|
||||
<span className={warn ? "inline-flex animate-pulse" : ""}>{value}</span>
|
||||
</p>
|
||||
<p className="mt-1 text-[10px] text-zinc-600">{helper}</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function qualityLaneMetrics(
|
||||
row: LiveProcRow | undefined,
|
||||
qualityLane: YoutubeQualityLane | undefined,
|
||||
): FfmpegMetrics & { speedLow?: boolean; progressStalled?: boolean; live: boolean } {
|
||||
return mergeFfmpegMetrics(row, qualityLane?.metrics, "");
|
||||
}
|
||||
|
||||
function nonCommentUrlLinesOf(text: string): string[] {
|
||||
return text
|
||||
.split(/\r?\n/)
|
||||
@ -949,7 +1050,7 @@ export function LiveYoutubeUnmannedView({
|
||||
name: "线路 1",
|
||||
streamKey: "",
|
||||
urlLines: "",
|
||||
pm2Name: "youtube",
|
||||
pm2Name: defaultPm2NameForChannel(id),
|
||||
notes: "",
|
||||
},
|
||||
];
|
||||
@ -1928,10 +2029,19 @@ export function LiveYoutubeUnmannedView({
|
||||
if (ch && ch.id === active?.id) return proUrlDraft;
|
||||
return (ch?.urlLines ?? "").trim() || proUrlDraft;
|
||||
}, [active?.id, channels, mode, proUrlDraft, runtimeLogProc, singleUrlDraft]);
|
||||
const overviewSource = douyinSourceDisplayFor(overviewRow, monitorUrlDraft);
|
||||
const overviewChannel =
|
||||
mode === "pro" ? channels.find((channel) => resolveChannelPm2(channel) === runtimeLogProc) : null;
|
||||
const overviewLaneIndex = overviewChannel ? channels.findIndex((channel) => channel.id === overviewChannel.id) : -1;
|
||||
const overviewLaneName = overviewChannel
|
||||
? cleanLaneName(overviewChannel.name, overviewLaneIndex >= 0 ? overviewLaneIndex : 0)
|
||||
: "";
|
||||
const overviewSource = proLanePrimaryTitle(overviewLaneName, overviewRow, monitorUrlDraft);
|
||||
const overviewDouyinSubtitle = proLaneDouyinSubtitle(overviewRow, monitorUrlDraft, overviewLaneName);
|
||||
const overviewStatusLabel = proLaneStatusLabel(overviewRow, t);
|
||||
const overviewSourceUrl = douyinSourceUrlFor(overviewRow, monitorUrlDraft);
|
||||
const overviewQualityLane = qualityGuard?.lanes?.find((lane) => lane.process === runtimeLogProc);
|
||||
const overviewQualityMetrics = overviewQualityLane?.metrics;
|
||||
const overviewLiveMetrics = qualityLaneMetrics(overviewRow, overviewQualityLane);
|
||||
const overviewQualityScore = overviewQualityLane?.score ?? null;
|
||||
const overviewPushingLanes =
|
||||
mode === "pro"
|
||||
@ -1939,23 +2049,11 @@ export function LiveYoutubeUnmannedView({
|
||||
: overviewPushing
|
||||
? 1
|
||||
: 0;
|
||||
const overviewFfmpegSpeed =
|
||||
typeof overviewRow?.ffmpeg_speed === "number"
|
||||
? overviewRow.ffmpeg_speed.toFixed(2)
|
||||
: typeof overviewQualityMetrics?.speed === "number"
|
||||
? overviewQualityMetrics.speed.toFixed(2)
|
||||
: null;
|
||||
const overviewFfmpegFrame =
|
||||
typeof overviewRow?.ffmpeg_frame === "number"
|
||||
? String(overviewRow.ffmpeg_frame)
|
||||
: typeof overviewQualityMetrics?.frame === "number"
|
||||
? String(overviewQualityMetrics.frame)
|
||||
: null;
|
||||
const overviewBitrate =
|
||||
typeof overviewQualityMetrics?.bitrate === "number"
|
||||
? `${Math.round(overviewQualityMetrics.bitrate)} kbps`
|
||||
: null;
|
||||
const overviewRelayDuration =
|
||||
const overviewFfmpegSpeed = formatFfmpegMetricValue(overviewLiveMetrics.speed, "x");
|
||||
const overviewFfmpegFrame = formatFfmpegMetricValue(overviewLiveMetrics.frame, "", 0);
|
||||
const overviewFfmpegFps = formatFfmpegMetricValue(overviewLiveMetrics.fps);
|
||||
const overviewBitrate = overviewLiveMetrics.live ? formatBitrateLabel(overviewLiveMetrics.bitrate) : null;
|
||||
const overviewEncodedDuration =
|
||||
typeof overviewRow?.ffmpeg_time_seconds === "number"
|
||||
? fmtDurationHuman(overviewRow.ffmpeg_time_seconds, t)
|
||||
: null;
|
||||
@ -2606,7 +2704,13 @@ export function LiveYoutubeUnmannedView({
|
||||
</div>
|
||||
<div className="divide-y divide-white/[0.06]">
|
||||
{qualityLanes.map((lane) => {
|
||||
const laneDisplay = (lane.source_display || lane.source_title || "").trim() || lane.label || lane.process || "-";
|
||||
const laneLabelName = (lane.label || "").replace(/^YouTube Pro\s*·\s*/i, "").trim();
|
||||
const laneRow = rowForPm2(String(lane.process || ""));
|
||||
const laneLiveMetrics = qualityLaneMetrics(laneRow, lane);
|
||||
const laneDisplay =
|
||||
(lane.source_display || lane.source_title || "").trim() || laneLabelName || lane.label || lane.process || "-";
|
||||
const laneDouyinSubtitle =
|
||||
lane.is_pushing && laneLabelName && laneDisplay !== laneLabelName ? laneLabelName : "";
|
||||
const laneTech = [lane.label, lane.process].filter(Boolean).join(" · ");
|
||||
return (
|
||||
<div key={lane.process || lane.label} className="grid gap-3 px-4 py-4 md:grid-cols-[minmax(0,1fr)_6rem_14rem]">
|
||||
@ -2620,6 +2724,9 @@ export function LiveYoutubeUnmannedView({
|
||||
{lane.rtmps ? "RTMPS" : t("非 RTMPS", "No RTMPS")}
|
||||
</span>
|
||||
</div>
|
||||
{laneDouyinSubtitle && laneDouyinSubtitle !== laneDisplay ? (
|
||||
<p className="mt-0.5 truncate text-xs text-zinc-500">{laneDouyinSubtitle}</p>
|
||||
) : null}
|
||||
<p className="mt-1 truncate text-xs text-zinc-600">{laneTech || "-"}</p>
|
||||
<div className="mt-2 flex flex-wrap gap-1.5">
|
||||
{(lane.issues || []).slice(0, 3).map((issue, idx) => (
|
||||
@ -2634,9 +2741,23 @@ export function LiveYoutubeUnmannedView({
|
||||
<p className={`mt-1 text-2xl font-semibold ${qualityScoreClass(lane.score)}`}>{lane.score ?? 0}</p>
|
||||
</div>
|
||||
<div className="grid grid-cols-3 gap-2 font-mono text-[11px] text-zinc-300">
|
||||
<p><span className="block text-zinc-600">fps</span>{metricText(lane.metrics?.fps)}</p>
|
||||
<p><span className="block text-zinc-600">speed</span>{metricText(lane.metrics?.speed, "x")}</p>
|
||||
<p><span className="block text-zinc-600">kbps</span>{metricText(lane.metrics?.bitrate)}</p>
|
||||
<p><span className="block text-zinc-600">fps</span>{formatFfmpegMetricValue(laneLiveMetrics.fps)}</p>
|
||||
<p>
|
||||
<span className="block text-zinc-600">speed</span>
|
||||
<span className={laneLiveMetrics.speedLow ? "text-amber-300" : ""}>
|
||||
{formatFfmpegMetricValue(laneLiveMetrics.speed, "x")}
|
||||
</span>
|
||||
</p>
|
||||
<p>
|
||||
<span className="block text-zinc-600">{t("码率", "Bitrate")}</span>
|
||||
{lane.is_pushing ? formatBitrateLabel(laneLiveMetrics.bitrate) ?? "—" : "—"}
|
||||
</p>
|
||||
<p>
|
||||
<span className="block text-zinc-600">frame</span>
|
||||
<span className={laneLiveMetrics.progressStalled ? "text-rose-300" : ""}>
|
||||
{formatFfmpegMetricValue(laneLiveMetrics.frame, "", 0)}
|
||||
</span>
|
||||
</p>
|
||||
<p><span className="block text-zinc-600">drop</span>{lane.metrics?.drop ?? "-"}</p>
|
||||
<p><span className="block text-zinc-600">urls</span>{lane.url_count ?? 0}</p>
|
||||
<p><span className="block text-zinc-600">err</span>{lane.metrics?.error_count ?? 0}</p>
|
||||
@ -2666,7 +2787,7 @@ export function LiveYoutubeUnmannedView({
|
||||
</div>
|
||||
<div className="rounded-xl border border-white/[0.06] bg-black/25 p-4">
|
||||
<h4 className="text-sm font-semibold text-white">FFmpeg</h4>
|
||||
<p className="mt-2 text-xs text-zinc-400">{qualityGuard?.ffmpeg_profile?.target || "1080p30 / RTMPS / AAC / stable relay"}</p>
|
||||
<p className="mt-2 text-xs text-zinc-400">{qualityGuard?.ffmpeg_profile?.target || "720p30 H.264 CBR / RTMPS / AAC 128k"}</p>
|
||||
<ul className="mt-3 space-y-1.5 text-xs text-zinc-500">
|
||||
{(qualityGuard?.ffmpeg_profile?.guardrails || []).slice(0, 4).map((item) => (
|
||||
<li key={item}>- {item}</li>
|
||||
@ -2697,17 +2818,17 @@ export function LiveYoutubeUnmannedView({
|
||||
<span
|
||||
className={`rounded-full px-2.5 py-0.5 text-[11px] font-medium ring-1 ${businessStatusBadgeClass(overviewRow)}`}
|
||||
>
|
||||
{businessStatusLabel(overviewRow, t)}
|
||||
{overviewStatusLabel}
|
||||
</span>
|
||||
{overviewPushing ? (
|
||||
<span className="rounded-full bg-emerald-500/15 px-2.5 py-0.5 text-[11px] text-emerald-100 ring-1 ring-emerald-500/25">
|
||||
{t("正在推流", "Pushing")}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
<p className="mt-1 truncate text-sm text-zinc-300">
|
||||
{overviewSource || t("未配置抖音直播源", "No Douyin source configured")}
|
||||
</p>
|
||||
{overviewDouyinSubtitle && overviewDouyinSubtitle !== overviewSource ? (
|
||||
<p className="mt-0.5 truncate text-xs text-zinc-500">
|
||||
{t("抖音源", "Douyin")}: {overviewDouyinSubtitle}
|
||||
</p>
|
||||
) : null}
|
||||
<p className="mt-1 font-mono text-[11px] text-zinc-600">
|
||||
{runtimeLogProc || "—"}
|
||||
{mode === "pro" && overviewPushingLanes > 0
|
||||
@ -2754,54 +2875,66 @@ export function LiveYoutubeUnmannedView({
|
||||
{[
|
||||
{
|
||||
label: t("FFmpeg 速度", "FFmpeg speed"),
|
||||
value: overviewFfmpegSpeed ? `${overviewFfmpegSpeed}x` : "—",
|
||||
warn: overviewRow?.ffmpeg_speed_low,
|
||||
helper: overviewRelayDuration || t("等待进程上报", "Waiting for metrics"),
|
||||
value: overviewFfmpegSpeed,
|
||||
warn: overviewLiveMetrics.speedLow,
|
||||
helper: overviewLiveMetrics.live
|
||||
? overviewEncodedDuration
|
||||
? `${t("已编码", "Encoded")} ${overviewEncodedDuration}`
|
||||
: t("实时倍速", "Realtime multiplier")
|
||||
: t("等待进程上报", "Waiting for metrics"),
|
||||
accent: overviewLiveMetrics.speedLow ? "amber" as const : "emerald" as const,
|
||||
},
|
||||
{
|
||||
label: t("实时 FPS", "Live FPS"),
|
||||
value: overviewFfmpegFps,
|
||||
warn: typeof overviewLiveMetrics.fps === "number" && overviewLiveMetrics.fps > 0 && overviewLiveMetrics.fps < 24,
|
||||
helper: overviewLiveMetrics.live ? t("FFmpeg 输出帧率", "FFmpeg output fps") : t("未推流", "Not pushing"),
|
||||
accent: "cyan" as const,
|
||||
},
|
||||
{
|
||||
label: t("编码帧", "Encoded frame"),
|
||||
value: overviewFfmpegFrame ?? "—",
|
||||
warn: overviewRow?.ffmpeg_progress_stalled,
|
||||
value: overviewFfmpegFrame,
|
||||
warn: overviewLiveMetrics.progressStalled,
|
||||
helper: overviewRow?.ffmpeg_active ? t("Worker 活跃", "Worker active") : t("无活跃 Worker", "No active worker"),
|
||||
accent: overviewLiveMetrics.progressStalled ? "amber" as const : "violet" as const,
|
||||
},
|
||||
{
|
||||
label: t("码率", "Bitrate"),
|
||||
value: overviewBitrate ?? "—",
|
||||
warn: false,
|
||||
helper: overviewQualityMetrics?.fps != null ? `${overviewQualityMetrics.fps} fps` : t("质量守护采样", "Quality guard"),
|
||||
helper: overviewLiveMetrics.live ? t("实时输出码率", "Live output bitrate") : t("停推后不显示", "Hidden when idle"),
|
||||
accent: "cyan" as const,
|
||||
},
|
||||
{
|
||||
label: t("质量分", "Quality score"),
|
||||
value: overviewQualityScore != null ? String(overviewQualityScore) : "—",
|
||||
warn: overviewQualityScore != null && overviewQualityScore < 55,
|
||||
helper: t("当前线路综合评估", "Current lane score"),
|
||||
accent: "violet" as const,
|
||||
},
|
||||
{
|
||||
label: t("活动场次", "Active events"),
|
||||
value: String(activeLiveEventCount),
|
||||
warn: false,
|
||||
helper: t("本地事件库", "Local event store"),
|
||||
accent: "cyan" as const,
|
||||
},
|
||||
{
|
||||
label: t("抖音地址", "Douyin URLs"),
|
||||
value: String(currentDouyinCount),
|
||||
warn: currentDouyinCount === 0,
|
||||
helper: `${currentUrlCount} ${t("条有效地址", "valid URLs")}`,
|
||||
accent: "cyan" as const,
|
||||
},
|
||||
{
|
||||
label: t("密钥尾码", "Key suffix"),
|
||||
value: keySuffixDisplay,
|
||||
warn: !keySuffixUi,
|
||||
helper: overviewKeyHelper,
|
||||
accent: "violet" as const,
|
||||
},
|
||||
].map(({ label, value, warn, helper }) => (
|
||||
<div key={label} className="rounded-xl border border-white/[0.06] bg-black/25 p-3 min-w-0">
|
||||
<p className="text-[11px] text-zinc-500">{label}</p>
|
||||
<p className={`mt-1 text-xl font-semibold tracking-tight ${warn ? "text-amber-200" : "text-white"}`}>
|
||||
{value}
|
||||
</p>
|
||||
<p className="mt-1 text-[10px] text-zinc-600">{helper}</p>
|
||||
</div>
|
||||
].map(({ label, value, warn, helper, accent }) => (
|
||||
<MetricPulseCard key={label} label={label} value={value} warn={warn} helper={helper} accent={accent} />
|
||||
))}
|
||||
</div>
|
||||
{overviewActiveEvent && overviewPushing ? (
|
||||
@ -2907,7 +3040,7 @@ export function LiveYoutubeUnmannedView({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{statusOverviewPanel}
|
||||
{!HIDE_YOUTUBE_RELAY_SNAPSHOT ? statusOverviewPanel : null}
|
||||
|
||||
{laneQuickLinks.length ? (
|
||||
<div className="space-y-2">
|
||||
@ -3069,9 +3202,14 @@ export function LiveYoutubeUnmannedView({
|
||||
const laneIndex = channels.findIndex((row) => row.id === c.id);
|
||||
const laneNeko = resolveNekoBrowserLink(nekoLinks, laneIndex).link;
|
||||
const laneName = cleanLaneName(c.name, laneIndex >= 0 ? laneIndex : 0);
|
||||
const laneDisplay = douyinSourceDisplayFor(row, laneUrlText);
|
||||
const speedText = typeof row?.ffmpeg_speed === "number" ? `speed ${row.ffmpeg_speed.toFixed(2)}x` : "";
|
||||
const frameText = typeof row?.ffmpeg_frame === "number" ? `frame ${row.ffmpeg_frame}` : "";
|
||||
const laneQuality = qualityGuard?.lanes?.find((lane) => lane.process === pm);
|
||||
const laneDisplay = proLanePrimaryTitle(laneName, row, laneUrlText, laneQuality);
|
||||
const laneDouyinSubtitle = proLaneDouyinSubtitle(row, laneUrlText, laneName);
|
||||
const laneStatusLabel = proLaneStatusLabel(row, t);
|
||||
const laneLiveMetrics = qualityLaneMetrics(row, laneQuality);
|
||||
const laneStatsText = formatFfmpegStatsBrief(laneLiveMetrics, {
|
||||
live: laneLiveMetrics.live || rowOnline || isLivePushingRow(row),
|
||||
});
|
||||
return (
|
||||
<div
|
||||
key={c.id}
|
||||
@ -3089,6 +3227,7 @@ export function LiveYoutubeUnmannedView({
|
||||
>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<span className="font-medium text-zinc-100">
|
||||
<span className="mr-1.5" aria-hidden>{laneStatusEmoji(row)}</span>
|
||||
{laneDisplay || t("未配置抖音直播源", "No Douyin source")}
|
||||
</span>
|
||||
<span
|
||||
@ -3096,7 +3235,7 @@ export function LiveYoutubeUnmannedView({
|
||||
businessStatusBadgeClass(row)
|
||||
}`}
|
||||
>
|
||||
{businessStatusLabel(row, t)}
|
||||
{laneStatusLabel}
|
||||
</span>
|
||||
{laneNeko ? (
|
||||
<span className="shrink-0 rounded-md bg-emerald-500/15 px-2 py-0.5 text-[10px] font-medium text-emerald-100 ring-1 ring-emerald-500/25">
|
||||
@ -3105,6 +3244,14 @@ export function LiveYoutubeUnmannedView({
|
||||
) : null}
|
||||
</div>
|
||||
<div className="mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 font-mono text-[10px] text-zinc-500">
|
||||
{laneDouyinSubtitle && laneDouyinSubtitle !== laneDisplay ? (
|
||||
<>
|
||||
<span className="truncate text-zinc-400" title={laneDouyinSubtitle}>
|
||||
{t("抖音源", "Douyin")} {laneDouyinSubtitle}
|
||||
</span>
|
||||
<span className="text-zinc-600">·</span>
|
||||
</>
|
||||
) : null}
|
||||
<span title={laneName}>
|
||||
{t("线路", "Lane")} {laneName}
|
||||
</span>
|
||||
@ -3124,19 +3271,17 @@ export function LiveYoutubeUnmannedView({
|
||||
<span>
|
||||
DY {douyinUrls.length}
|
||||
</span>
|
||||
{speedText ? (
|
||||
{laneStatsText ? (
|
||||
<>
|
||||
<span className="text-zinc-600">·</span>
|
||||
<span className={row?.ffmpeg_speed_low ? "text-amber-300" : "text-zinc-500"}>
|
||||
{speedText}
|
||||
</span>
|
||||
</>
|
||||
) : null}
|
||||
{frameText ? (
|
||||
<>
|
||||
<span className="text-zinc-600">·</span>
|
||||
<span className={row?.ffmpeg_progress_stalled ? "text-rose-300" : "text-zinc-500"}>
|
||||
{frameText}
|
||||
<span
|
||||
className={speedToneClass(
|
||||
laneLiveMetrics.speed,
|
||||
laneLiveMetrics.speedLow,
|
||||
laneLiveMetrics.progressStalled,
|
||||
)}
|
||||
>
|
||||
{laneStatsText}
|
||||
</span>
|
||||
</>
|
||||
) : null}
|
||||
@ -3237,11 +3382,12 @@ export function LiveYoutubeUnmannedView({
|
||||
pollMs={statusCardPollMs}
|
||||
refreshToken={activeViewRefreshToken}
|
||||
monitorRow={overviewRow ?? undefined}
|
||||
preferredTitle={mode === "pro" ? overviewLaneName : undefined}
|
||||
/>
|
||||
|
||||
{qualityGuardPanel}
|
||||
|
||||
{humanLiveEventPanel || liveEventPanel}
|
||||
{!HIDE_YOUTUBE_LIVE_EVENT_HUB ? humanLiveEventPanel || liveEventPanel : null}
|
||||
|
||||
<section className="rounded-2xl border border-white/[0.08] bg-zinc-950/50 ring-1 ring-white/[0.03]">
|
||||
<div className="border-b border-white/[0.06] px-6 py-4">
|
||||
|
||||
@ -102,12 +102,32 @@ export function extractDouyinSourceTitleFromLog(logText: string): string {
|
||||
}
|
||||
|
||||
export function douyinSourceDisplayFrom(urlIni: string, logText = ""): string {
|
||||
const title = extractDouyinSourceTitleFromUrlLines(urlIni) || extractDouyinSourceTitleFromLog(logText);
|
||||
const urlTitle = extractDouyinSourceTitleFromUrlLines(urlIni);
|
||||
const logTitle = extractDouyinSourceTitleFromLog(logText);
|
||||
const urlCount = extractDouyinLiveUrls(urlIni).length;
|
||||
const waitingOnly = extractDouyinSourceTitleFromWaitingLog(logText);
|
||||
const activeRelay = /frame=.*speed=/i.test(logText) || /(?:正在录制|录制中)\s*\d*\s*个?\s*[::]/i.test(logText);
|
||||
if (urlCount > 1 && logTitle && !activeRelay && logTitle === waitingOnly) {
|
||||
if (urlTitle) return urlTitle;
|
||||
}
|
||||
const title = urlTitle || logTitle;
|
||||
if (title) return title;
|
||||
const roomId = extractDouyinCurrentRoomFromLog(logText) || extractDouyinRoomHints(urlIni)[0] || "";
|
||||
return roomId ? `抖音直播间 ${roomId}` : "";
|
||||
}
|
||||
|
||||
function extractDouyinSourceTitleFromWaitingLog(logText: string): string {
|
||||
const lines = logText.split(/\r?\n/).map((line) => line.trim()).filter(Boolean).slice(-160);
|
||||
const waiting = /(?:序号\s*\d+\s*)?(.{1,80}?)\s*(?:等待直播|主播已下播|下播)/i;
|
||||
const errorContext = /(?:获取失败|错误|异常|error|failed|exception)/i;
|
||||
for (let i = lines.length - 1; i >= 0; i -= 1) {
|
||||
if (errorContext.test(lines[i])) continue;
|
||||
const title = cleanDouyinSourceTitle(lines[i].match(waiting)?.[1] || "");
|
||||
if (title) return title;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/** 从进程日志中解析「当前」抖音房间号(取文本中最后一次出现的 live.douyin.com/xxx) */
|
||||
export function extractDouyinCurrentRoomFromLog(logText: string): string | null {
|
||||
if (!logText) return null;
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{2195:function(n,e,u){Promise.resolve().then(u.bind(u,7340))},7340:function(n,e,u){"use strict";u.r(e),u.d(e,{default:function(){return t.Z}});var t=u(6348)}},function(n){n.O(0,[500,568,246,348,971,117,744],function(){return n(n.s=2195)}),_N_E=n.O()}]);
|
||||
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{2195:function(n,e,u){Promise.resolve().then(u.bind(u,7340))},7340:function(n,e,u){"use strict";u.r(e),u.d(e,{default:function(){return t.Z}});var t=u(8904)}},function(n){n.O(0,[500,568,246,904,971,117,744],function(){return n(n.s=2195)}),_N_E=n.O()}]);
|
||||
@ -1 +1 @@
|
||||
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[851],{8797:function(n,e,u){Promise.resolve().then(u.bind(u,316))},316:function(n,e,u){"use strict";u.r(e),u.d(e,{default:function(){return t.Z}});var t=u(6348)}},function(n){n.O(0,[500,568,246,348,971,117,744],function(){return n(n.s=8797)}),_N_E=n.O()}]);
|
||||
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[851],{8797:function(n,e,u){Promise.resolve().then(u.bind(u,316))},316:function(n,e,u){"use strict";u.r(e),u.d(e,{default:function(){return t.Z}});var t=u(8904)}},function(n){n.O(0,[500,568,246,904,971,117,744],function(){return n(n.s=8797)}),_N_E=n.O()}]);
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -2,6 +2,6 @@
|
||||
3:I[3946,["500","static/chunks/500-ea37cc8de90441f7.js","246","static/chunks/246-17569b8e78acf2ac.js","357","static/chunks/app/android/page-5f87422c86e34807.js"],"default",1]
|
||||
4:I[4707,[],""]
|
||||
5:I[6423,[],""]
|
||||
0:["BfhpIk8_9MUFzvnv8gp2T",[[["",{"children":["android",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",{"children":["android",{"children":["__PAGE__",{},[["$L1",["$","$L2",null,{"props":{"params":{},"searchParams":{}},"Component":"$3"}],null],null],null]},[null,["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children","android","children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined"}]],null]},[[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/267c3a238bcbe8cf.css","precedence":"next","crossOrigin":"$undefined"}]],["$","html",null,{"lang":"zh-CN","data-theme":"dark","suppressHydrationWarning":true,"children":["$","body",null,{"className":"__variable_1e4310 __variable_c3aa02 font-sans antialiased","children":[["$","div",null,{"className":"app-bg-layer","aria-hidden":true}],["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[]}]]}]}]],null],null],["$L6",null]]]]
|
||||
0:["LUR--1jFr5J8xPFAxV9C7",[[["",{"children":["android",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",{"children":["android",{"children":["__PAGE__",{},[["$L1",["$","$L2",null,{"props":{"params":{},"searchParams":{}},"Component":"$3"}],null],null],null]},[null,["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children","android","children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined"}]],null]},[[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/8082d3508f852f9a.css","precedence":"next","crossOrigin":"$undefined"}]],["$","html",null,{"lang":"zh-CN","data-theme":"dark","suppressHydrationWarning":true,"children":["$","body",null,{"className":"__variable_1e4310 __variable_c3aa02 font-sans antialiased","children":[["$","div",null,{"className":"app-bg-layer","aria-hidden":true}],["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[]}]]}]}]],null],null],["$L6",null]]]]
|
||||
6:[["$","meta","0",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","1",{"charSet":"utf-8"}],["$","title","2",{"children":"无人直播系统 · live.local"}],["$","meta","3",{"name":"description","content":"Linux ARM/x86 一键部署的无人直播控制台:YouTube 转播、TikTok HDMI、SRS、Neko 与系统服务"}],["$","link","4",{"rel":"icon","href":"/favicon.ico","type":"image/x-icon","sizes":"16x16"}]]
|
||||
1:null
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -2,6 +2,6 @@
|
||||
3:I[6367,["500","static/chunks/500-ea37cc8de90441f7.js","246","static/chunks/246-17569b8e78acf2ac.js","443","static/chunks/app/console/page-f5a0052a001f3016.js"],"default",1]
|
||||
4:I[4707,[],""]
|
||||
5:I[6423,[],""]
|
||||
0:["BfhpIk8_9MUFzvnv8gp2T",[[["",{"children":["console",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",{"children":["console",{"children":["__PAGE__",{},[["$L1",["$","$L2",null,{"props":{"params":{},"searchParams":{}},"Component":"$3"}],null],null],null]},[null,["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children","console","children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined"}]],null]},[[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/267c3a238bcbe8cf.css","precedence":"next","crossOrigin":"$undefined"}]],["$","html",null,{"lang":"zh-CN","data-theme":"dark","suppressHydrationWarning":true,"children":["$","body",null,{"className":"__variable_1e4310 __variable_c3aa02 font-sans antialiased","children":[["$","div",null,{"className":"app-bg-layer","aria-hidden":true}],["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[]}]]}]}]],null],null],["$L6",null]]]]
|
||||
0:["LUR--1jFr5J8xPFAxV9C7",[[["",{"children":["console",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",{"children":["console",{"children":["__PAGE__",{},[["$L1",["$","$L2",null,{"props":{"params":{},"searchParams":{}},"Component":"$3"}],null],null],null]},[null,["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children","console","children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined"}]],null]},[[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/8082d3508f852f9a.css","precedence":"next","crossOrigin":"$undefined"}]],["$","html",null,{"lang":"zh-CN","data-theme":"dark","suppressHydrationWarning":true,"children":["$","body",null,{"className":"__variable_1e4310 __variable_c3aa02 font-sans antialiased","children":[["$","div",null,{"className":"app-bg-layer","aria-hidden":true}],["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[]}]]}]}]],null],null],["$L6",null]]]]
|
||||
6:[["$","meta","0",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","1",{"charSet":"utf-8"}],["$","title","2",{"children":"无人直播系统 · live.local"}],["$","meta","3",{"name":"description","content":"Linux ARM/x86 一键部署的无人直播控制台:YouTube 转播、TikTok HDMI、SRS、Neko 与系统服务"}],["$","link","4",{"rel":"icon","href":"/favicon.ico","type":"image/x-icon","sizes":"16x16"}]]
|
||||
1:null
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -1,7 +1,7 @@
|
||||
2:I[9107,[],"ClientPageRoot"]
|
||||
3:I[7340,["500","static/chunks/500-ea37cc8de90441f7.js","568","static/chunks/568-00230e48c631a139.js","246","static/chunks/246-17569b8e78acf2ac.js","348","static/chunks/348-80f0852ea47d5112.js","931","static/chunks/app/page-9ff3a078ec6e16cb.js"],"default",1]
|
||||
3:I[7340,["500","static/chunks/500-ea37cc8de90441f7.js","568","static/chunks/568-00230e48c631a139.js","246","static/chunks/246-17569b8e78acf2ac.js","904","static/chunks/904-e2d4e288fe270492.js","931","static/chunks/app/page-5d458b26bf02fc41.js"],"default",1]
|
||||
4:I[4707,[],""]
|
||||
5:I[6423,[],""]
|
||||
0:["BfhpIk8_9MUFzvnv8gp2T",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],["",{"children":["__PAGE__",{},[["$L1",["$","$L2",null,{"props":{"params":{},"searchParams":{}},"Component":"$3"}],null],null],null]},[[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/267c3a238bcbe8cf.css","precedence":"next","crossOrigin":"$undefined"}]],["$","html",null,{"lang":"zh-CN","data-theme":"dark","suppressHydrationWarning":true,"children":["$","body",null,{"className":"__variable_1e4310 __variable_c3aa02 font-sans antialiased","children":[["$","div",null,{"className":"app-bg-layer","aria-hidden":true}],["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[]}]]}]}]],null],null],["$L6",null]]]]
|
||||
0:["LUR--1jFr5J8xPFAxV9C7",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],["",{"children":["__PAGE__",{},[["$L1",["$","$L2",null,{"props":{"params":{},"searchParams":{}},"Component":"$3"}],null],null],null]},[[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/8082d3508f852f9a.css","precedence":"next","crossOrigin":"$undefined"}]],["$","html",null,{"lang":"zh-CN","data-theme":"dark","suppressHydrationWarning":true,"children":["$","body",null,{"className":"__variable_1e4310 __variable_c3aa02 font-sans antialiased","children":[["$","div",null,{"className":"app-bg-layer","aria-hidden":true}],["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[]}]]}]}]],null],null],["$L6",null]]]]
|
||||
6:[["$","meta","0",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","1",{"charSet":"utf-8"}],["$","title","2",{"children":"无人直播系统 · live.local"}],["$","meta","3",{"name":"description","content":"Linux ARM/x86 一键部署的无人直播控制台:YouTube 转播、TikTok HDMI、SRS、Neko 与系统服务"}],["$","link","4",{"rel":"icon","href":"/favicon.ico","type":"image/x-icon","sizes":"16x16"}]]
|
||||
1:null
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -2,6 +2,6 @@
|
||||
3:I[3398,["500","static/chunks/500-ea37cc8de90441f7.js","246","static/chunks/246-17569b8e78acf2ac.js","6","static/chunks/app/shellcrash/page-0c73522b1d5c8dc1.js"],"default",1]
|
||||
4:I[4707,[],""]
|
||||
5:I[6423,[],""]
|
||||
0:["BfhpIk8_9MUFzvnv8gp2T",[[["",{"children":["shellcrash",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",{"children":["shellcrash",{"children":["__PAGE__",{},[["$L1",["$","$L2",null,{"props":{"params":{},"searchParams":{}},"Component":"$3"}],null],null],null]},[null,["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children","shellcrash","children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined"}]],null]},[[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/267c3a238bcbe8cf.css","precedence":"next","crossOrigin":"$undefined"}]],["$","html",null,{"lang":"zh-CN","data-theme":"dark","suppressHydrationWarning":true,"children":["$","body",null,{"className":"__variable_1e4310 __variable_c3aa02 font-sans antialiased","children":[["$","div",null,{"className":"app-bg-layer","aria-hidden":true}],["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[]}]]}]}]],null],null],["$L6",null]]]]
|
||||
0:["LUR--1jFr5J8xPFAxV9C7",[[["",{"children":["shellcrash",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",{"children":["shellcrash",{"children":["__PAGE__",{},[["$L1",["$","$L2",null,{"props":{"params":{},"searchParams":{}},"Component":"$3"}],null],null],null]},[null,["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children","shellcrash","children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined"}]],null]},[[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/8082d3508f852f9a.css","precedence":"next","crossOrigin":"$undefined"}]],["$","html",null,{"lang":"zh-CN","data-theme":"dark","suppressHydrationWarning":true,"children":["$","body",null,{"className":"__variable_1e4310 __variable_c3aa02 font-sans antialiased","children":[["$","div",null,{"className":"app-bg-layer","aria-hidden":true}],["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[]}]]}]}]],null],null],["$L6",null]]]]
|
||||
6:[["$","meta","0",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","1",{"charSet":"utf-8"}],["$","title","2",{"children":"无人直播系统 · live.local"}],["$","meta","3",{"name":"description","content":"Linux ARM/x86 一键部署的无人直播控制台:YouTube 转播、TikTok HDMI、SRS、Neko 与系统服务"}],["$","link","4",{"rel":"icon","href":"/favicon.ico","type":"image/x-icon","sizes":"16x16"}]]
|
||||
1:null
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -1,7 +1,7 @@
|
||||
2:I[9107,[],"ClientPageRoot"]
|
||||
3:I[316,["500","static/chunks/500-ea37cc8de90441f7.js","568","static/chunks/568-00230e48c631a139.js","246","static/chunks/246-17569b8e78acf2ac.js","348","static/chunks/348-80f0852ea47d5112.js","851","static/chunks/app/youtube-events/page-a88e6c919a0b42a9.js"],"default",1]
|
||||
3:I[316,["500","static/chunks/500-ea37cc8de90441f7.js","568","static/chunks/568-00230e48c631a139.js","246","static/chunks/246-17569b8e78acf2ac.js","904","static/chunks/904-e2d4e288fe270492.js","851","static/chunks/app/youtube-events/page-d361f3631be60b8a.js"],"default",1]
|
||||
4:I[4707,[],""]
|
||||
5:I[6423,[],""]
|
||||
0:["BfhpIk8_9MUFzvnv8gp2T",[[["",{"children":["youtube-events",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",{"children":["youtube-events",{"children":["__PAGE__",{},[["$L1",["$","$L2",null,{"props":{"params":{},"searchParams":{}},"Component":"$3"}],null],null],null]},[null,["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children","youtube-events","children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined"}]],null]},[[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/267c3a238bcbe8cf.css","precedence":"next","crossOrigin":"$undefined"}]],["$","html",null,{"lang":"zh-CN","data-theme":"dark","suppressHydrationWarning":true,"children":["$","body",null,{"className":"__variable_1e4310 __variable_c3aa02 font-sans antialiased","children":[["$","div",null,{"className":"app-bg-layer","aria-hidden":true}],["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[]}]]}]}]],null],null],["$L6",null]]]]
|
||||
0:["LUR--1jFr5J8xPFAxV9C7",[[["",{"children":["youtube-events",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",{"children":["youtube-events",{"children":["__PAGE__",{},[["$L1",["$","$L2",null,{"props":{"params":{},"searchParams":{}},"Component":"$3"}],null],null],null]},[null,["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children","youtube-events","children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined"}]],null]},[[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/8082d3508f852f9a.css","precedence":"next","crossOrigin":"$undefined"}]],["$","html",null,{"lang":"zh-CN","data-theme":"dark","suppressHydrationWarning":true,"children":["$","body",null,{"className":"__variable_1e4310 __variable_c3aa02 font-sans antialiased","children":[["$","div",null,{"className":"app-bg-layer","aria-hidden":true}],["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[]}]]}]}]],null],null],["$L6",null]]]]
|
||||
6:[["$","meta","0",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","1",{"charSet":"utf-8"}],["$","title","2",{"children":"无人直播系统 · live.local"}],["$","meta","3",{"name":"description","content":"Linux ARM/x86 一键部署的无人直播控制台:YouTube 转播、TikTok HDMI、SRS、Neko 与系统服务"}],["$","link","4",{"rel":"icon","href":"/favicon.ico","type":"image/x-icon","sizes":"16x16"}]]
|
||||
1:null
|
||||
|
||||
@ -2003,9 +2003,11 @@ async def status(
|
||||
recent_error = ""
|
||||
full_status = configured_hint
|
||||
else:
|
||||
status_log_lines = 80 if light and process_family(process) == "youtube" else MAX_LOG_LINES
|
||||
status_err_lines = 24 if light and process_family(process) == "youtube" else MAX_LOG_LINES
|
||||
recent_log, recent_error, ffmpeg_pids = await asyncio.gather(
|
||||
read_log_path_normalized(info.get("out_path"), MAX_LOG_LINES),
|
||||
read_log_path_normalized(info.get("err_path"), MAX_LOG_LINES),
|
||||
read_log_path_normalized(info.get("out_path"), status_log_lines),
|
||||
read_log_path_normalized(info.get("err_path"), status_err_lines),
|
||||
process_backend.live_ffmpeg_pids(process, info),
|
||||
)
|
||||
|
||||
|
||||
@ -42,6 +42,7 @@ from src.proxy import ProxyDetector
|
||||
from src.runtime_bootstrap import load_msg_push_exports
|
||||
from src.youtube_config_paths import resolve_youtube_style_config_paths
|
||||
from src.youtube_runtime import normalize_youtube_video_save_type
|
||||
from src.recorder_config import read_recorder_setting, recorder_config_target_path, SHARED_RECORDER_SECTIONS
|
||||
from src.utils import logger
|
||||
from src import utils
|
||||
from ffmpeg_install import (
|
||||
@ -1635,25 +1636,22 @@ def start_record(url_data: tuple, count_variable: int = -1) -> None:
|
||||
error_window.append(1)
|
||||
|
||||
else:
|
||||
try:
|
||||
from douyin_youtube_ffplay import start_douyin_youtube_ffplay
|
||||
from douyin_youtube_ffplay import start_douyin_youtube_ffplay
|
||||
|
||||
start_douyin_youtube_ffplay(
|
||||
title=title_in_name,
|
||||
anchor_name=anchor_name,
|
||||
real_url=real_url,
|
||||
rec_info=rec_info,
|
||||
record_name=record_name,
|
||||
recording=recording,
|
||||
recording_time_list=recording_time_list,
|
||||
running_list=running_list,
|
||||
clear_record_info=clear_record_info,
|
||||
color_obj=color_obj,
|
||||
config_file=config_file,
|
||||
record_url=record_url,
|
||||
)
|
||||
finally:
|
||||
clear_record_info(record_name, record_url)
|
||||
start_douyin_youtube_ffplay(
|
||||
title=title_in_name,
|
||||
anchor_name=anchor_name,
|
||||
real_url=real_url,
|
||||
rec_info=rec_info,
|
||||
record_name=record_name,
|
||||
recording=recording,
|
||||
recording_time_list=recording_time_list,
|
||||
running_list=running_list,
|
||||
clear_record_info=clear_record_info,
|
||||
color_obj=color_obj,
|
||||
config_file=config_file,
|
||||
record_url=record_url,
|
||||
)
|
||||
count_time = time.time()
|
||||
|
||||
|
||||
@ -1786,6 +1784,17 @@ utils.remove_duplicate_lines(url_config_file)
|
||||
|
||||
def read_config_value(config_parser: configparser.RawConfigParser, section: str, option: str, default_value: Any) \
|
||||
-> Any:
|
||||
if section in SHARED_RECORDER_SECTIONS:
|
||||
value = read_recorder_setting(
|
||||
base_dir=script_path,
|
||||
lane_config_file=config_file,
|
||||
section=section,
|
||||
option=option,
|
||||
default=default_value,
|
||||
encoding=text_encoding,
|
||||
)
|
||||
if str(value).strip():
|
||||
return value
|
||||
try:
|
||||
|
||||
config_parser.read(config_file, encoding=text_encoding)
|
||||
@ -1801,9 +1810,25 @@ def read_config_value(config_parser: configparser.RawConfigParser, section: str,
|
||||
config_parser.add_section('账号密码')
|
||||
return config_parser.get(section, option)
|
||||
except (configparser.NoSectionError, configparser.NoOptionError):
|
||||
target = recorder_config_target_path(
|
||||
base_dir=script_path,
|
||||
lane_config_file=config_file,
|
||||
section=section,
|
||||
)
|
||||
config_parser.set(section, option, str(default_value))
|
||||
with open(config_file, 'w', encoding=text_encoding) as f:
|
||||
with open(target, 'w', encoding=text_encoding) as f:
|
||||
config_parser.write(f)
|
||||
if section in SHARED_RECORDER_SECTIONS:
|
||||
shared_value = read_recorder_setting(
|
||||
base_dir=script_path,
|
||||
lane_config_file=config_file,
|
||||
section=section,
|
||||
option=option,
|
||||
default=default_value,
|
||||
encoding=text_encoding,
|
||||
)
|
||||
if str(shared_value).strip():
|
||||
return shared_value
|
||||
return default_value
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user