This commit is contained in:
eric
2026-05-20 21:13:19 -05:00
parent aaf786b292
commit d28e64f4ef
21 changed files with 1580 additions and 85 deletions

View File

@@ -7,6 +7,31 @@ import re
from typing import Any
def norm_stream_key(key: str) -> str:
k = (key or "").strip()
if not k:
return ""
if k.lower().startswith(("rtmp://", "rtmps://")):
parts = k.rstrip("/").split("/")
k = parts[-1] if parts else k
return k.strip().lower()
def validate_youtube_keys(keys: list[str]) -> tuple[bool, str]:
cleaned = [str(x).strip() for x in keys if str(x).strip()]
if not cleaned:
return False, "至少需要一个有效的 YouTube 串流密钥"
seen: set[str] = set()
for key in cleaned:
nk = norm_stream_key(key)
if not nk:
continue
if nk in seen:
return False, "同一配置内不能重复使用相同的 YouTube 串流密钥"
seen.add(nk)
return True, ""
def parse_youtube_ini(content: str) -> dict[str, Any]:
if not (content or "").strip():
return {