72 lines
2.6 KiB
Python
72 lines
2.6 KiB
Python
#!/usr/bin/env python3
|
||
from pathlib import Path
|
||
|
||
p = Path(__file__).resolve().parents[1] / "frontend" / "src" / "components" / "YtAssignPanel.tsx"
|
||
lines = p.read_text(encoding="utf-8").splitlines(True)
|
||
|
||
start = end = None
|
||
for i, L in enumerate(lines):
|
||
if "直播地址列表 · {(selected.featured || []).length}" in L:
|
||
j = i
|
||
while j > 0 and "<section" not in lines[j]:
|
||
j -= 1
|
||
if start is None:
|
||
start = j
|
||
else:
|
||
end = j
|
||
break
|
||
|
||
assert start is not None and end is not None and end > start, (start, end)
|
||
print(f"removing lines {start+1}-{end}")
|
||
new_lines = lines[:start] + lines[end:]
|
||
text = "".join(new_lines)
|
||
|
||
repls = [
|
||
(
|
||
"即分配页的精选列表;FFmpeg 推流只从此列表选源(优先在播)。从普通池点 ★ 加入。",
|
||
"关「时间段排班」且开「自动推流」时:从此列表监听开播并推流(优先在播)。单路独占时只跑最先开播的频道。从普通池点 ★ 加入。",
|
||
),
|
||
("从左侧普通列表点星标加入精选", "从左侧普通列表点星标加入"),
|
||
(
|
||
'className="order-1 rounded-2xl border border-amber-500/20 bg-amber-500/5 p-4 lg:col-span-2 xl:order-1 xl:col-span-1"',
|
||
'className="order-1 rounded-2xl border border-amber-500/20 bg-amber-500/5 p-4 lg:order-1"',
|
||
),
|
||
(
|
||
"时间段自动选源与「全频道填充」不会选用它们,避免与已指定的手动直播撞同一路流。",
|
||
"时间段自动选源不会选用它们,避免与已指定的手动直播撞同一路流。",
|
||
),
|
||
]
|
||
for a, b in repls:
|
||
if a not in text:
|
||
print("WARN missing:", a[:40])
|
||
else:
|
||
text = text.replace(a, b, 1)
|
||
|
||
# Drop unused slot helpers / Clock if safe
|
||
# Keep functions but remove slotIds memo to avoid lint — remove if unused
|
||
if "slotIds" in text and "const slotIds" in text:
|
||
# remove slotIds useMemo block
|
||
import re
|
||
|
||
text2, n = re.subn(
|
||
r"\n const slotIds = useMemo\(\n \(\) => new Set\(\(selected\?\.slots \|\| \[\]\)\.map\(\(s\) => String\(s\.pool_url_id\)\)\),\n \[selected\]\n \);\n",
|
||
"\n",
|
||
text,
|
||
count=1,
|
||
)
|
||
if n:
|
||
text = text2
|
||
print("removed slotIds")
|
||
|
||
# Remove Clock from imports if unused
|
||
if "Clock" in text and text.count("Clock") == 1:
|
||
text = text.replace(" Clock,\n", "")
|
||
print("removed Clock import")
|
||
elif "Clock" in text:
|
||
print("Clock still referenced", text.count("Clock"))
|
||
|
||
p.write_text(text, encoding="utf-8")
|
||
print("done", len(lines), "->", len(text.splitlines()))
|
||
assert "时间段列表(轮播)" not in text
|
||
assert text.count("直播地址列表 ·") == 1
|