's'
This commit is contained in:
@@ -10,6 +10,8 @@ import time
|
||||
from pathlib import Path
|
||||
from typing import Any, Callable, Awaitable
|
||||
|
||||
from web2_youtube_ini import parse_youtube_ini, serialize_youtube_ini
|
||||
|
||||
# 与 web2_client_overview 一致的去重键
|
||||
def _norm_douyin_url(url: str) -> str:
|
||||
u = (url or "").strip()
|
||||
@@ -380,8 +382,23 @@ def write_url_config_for_channel(config_dir: Path, channel_id: str, content: str
|
||||
|
||||
def write_youtube_ini_single_key(config_dir: Path, key: str) -> None:
|
||||
"""写入单路 youtube.ini([youtube] key=)。"""
|
||||
lines = ["[youtube]", f"key = {key.strip()}", ""]
|
||||
(config_dir / "youtube.ini").write_text("\n".join(lines), encoding="utf-8")
|
||||
config_dir = Path(config_dir)
|
||||
ini = config_dir / "youtube.ini"
|
||||
options: dict[str, str] = {}
|
||||
header = ""
|
||||
if ini.exists():
|
||||
try:
|
||||
parsed = parse_youtube_ini(ini.read_text(encoding="utf-8-sig"))
|
||||
raw_options = parsed.get("options")
|
||||
if isinstance(raw_options, dict):
|
||||
options = {str(k): str(v) for k, v in raw_options.items()}
|
||||
raw_header = parsed.get("header")
|
||||
if isinstance(raw_header, str):
|
||||
header = raw_header
|
||||
except Exception:
|
||||
options = {}
|
||||
header = ""
|
||||
ini.write_text(serialize_youtube_ini([key.strip()], 0, options, header), encoding="utf-8")
|
||||
|
||||
|
||||
def sync_channel_to_legacy_files(config_dir: Path, channel_id: str) -> tuple[bool, str]:
|
||||
|
||||
Reference in New Issue
Block a user