This commit is contained in:
root
2026-05-17 04:31:59 +00:00
parent 75a0ca4e31
commit 07aa02bca6
51 changed files with 1322 additions and 435 deletions

View File

@@ -4,6 +4,8 @@ import re
from pathlib import Path
from typing import Any, Iterable, Optional
from src.youtube_config_paths import resolve_youtube_style_config_paths
_SAFE_PM2_SEGMENT = re.compile(r"[^a-zA-Z0-9_.-]+")
_YOUTUBE_HEADER = re.compile(r"^\s*\[youtube\]\s*$", re.IGNORECASE)
_ANY_HEADER = re.compile(r"^\s*\[[^\]]+\]\s*$")
@@ -228,3 +230,25 @@ def ensure_youtube_pro_channel_runtime_files(
except OSError as exc:
return True, [f"{pm2}: failed to write config ({exc})"]
return True, []
def validate_youtube_runtime_files(
base_dir: Path,
config_dir: Path,
process: str,
channels: Iterable[dict[str, Any]],
) -> list[str]:
handled, errors = ensure_youtube_pro_channel_runtime_files(config_dir, process, channels)
if handled:
return errors
youtube_path_raw, url_path_raw = resolve_youtube_style_config_paths(base_dir, process)
youtube_text = _read_text_if_file(Path(youtube_path_raw)) or ""
url_text = _read_text_if_file(Path(url_path_raw)) or ""
fallback_errors: list[str] = []
if not _extract_stream_key(youtube_text):
fallback_errors.append(f"{process}: stream key missing")
if not _has_noncomment_url(url_text):
fallback_errors.append(f"{process}: source URL missing")
return fallback_errors