fix: TikTok 文案只用标题模板原文,取样最短 1 分钟
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
4c8eafacb3
commit
21f74cb85c
@ -225,8 +225,8 @@ def init_db() -> None:
|
||||
enabled INTEGER NOT NULL DEFAULT 1,
|
||||
daily_min INTEGER NOT NULL DEFAULT 9,
|
||||
daily_max INTEGER NOT NULL DEFAULT 9,
|
||||
title_template TEXT NOT NULL DEFAULT '{anchor} #fyp',
|
||||
description_template TEXT NOT NULL DEFAULT '{anchor}\n{url}',
|
||||
title_template TEXT NOT NULL DEFAULT '',
|
||||
description_template TEXT NOT NULL DEFAULT '',
|
||||
privacy_level TEXT NOT NULL DEFAULT 'SELF_ONLY',
|
||||
last_assigned_at REAL NOT NULL DEFAULT 0,
|
||||
oauth_ok INTEGER NOT NULL DEFAULT -1,
|
||||
@ -412,7 +412,7 @@ def _seed_defaults(conn: sqlite3.Connection) -> None:
|
||||
],
|
||||
# TikTok pipeline (fully isolated from Shorts)
|
||||
"tiktok_enabled": False,
|
||||
"tiktok_clip_sec": 15,
|
||||
"tiktok_clip_sec": 60,
|
||||
"tiktok_trigger": "tagged",
|
||||
"tiktok_tag": "shorts",
|
||||
"tiktok_dedupe_room_day": True,
|
||||
|
||||
@ -286,8 +286,8 @@ class TikTokSessionBody(BaseModel):
|
||||
class TikTokChannelCreate(BaseModel):
|
||||
name: str = "TikTok 账号"
|
||||
enabled: bool = True
|
||||
title_template: str = "{anchor} #fyp"
|
||||
description_template: str = "{anchor}\n{url}"
|
||||
title_template: str = ""
|
||||
description_template: str = ""
|
||||
privacy_level: str = "PUBLIC_TO_EVERYONE"
|
||||
note: str = ""
|
||||
|
||||
|
||||
@ -50,8 +50,8 @@ def create_tiktok_channel(
|
||||
enabled: bool = True,
|
||||
daily_min: int = TIKTOK_DAILY_FORCE,
|
||||
daily_max: int = TIKTOK_DAILY_FORCE,
|
||||
title_template: str = "{anchor} #fyp",
|
||||
description_template: str = "{anchor}\n{url}",
|
||||
title_template: str = "",
|
||||
description_template: str = "",
|
||||
privacy_level: str = "SELF_ONLY",
|
||||
note: str = "",
|
||||
) -> dict[str, Any]:
|
||||
|
||||
@ -208,7 +208,7 @@ class TikTokPipeline:
|
||||
"sampled": self.sampled,
|
||||
"quota_gap": tiktok_db.tiktok_total_quota_gap(),
|
||||
"last_error": self.last_error,
|
||||
"clip_sec": int(cfg.get("tiktok_clip_sec") or 15),
|
||||
"clip_sec": max(60, int(cfg.get("tiktok_clip_sec") or 60)),
|
||||
"douyin_live_count": len(db.list_live_douyin_rooms_for_shorts(limit=400)),
|
||||
"board": board,
|
||||
"oauth_issues": oauth_issues,
|
||||
@ -375,7 +375,8 @@ class TikTokPipeline:
|
||||
finished_at=time.time(),
|
||||
)
|
||||
return
|
||||
sec = max(5, int(cfg.get("tiktok_clip_sec") or 15))
|
||||
# TikTok 素材最少录 1 分钟
|
||||
sec = max(60, int(cfg.get("tiktok_clip_sec") or 60))
|
||||
outcome = await record_clip(job_id=f"tiktok_{jid[:8]}", stream_url=stream, seconds=sec)
|
||||
if not outcome.get("ok"):
|
||||
tiktok_db.update_tiktok_job(
|
||||
@ -430,18 +431,14 @@ class TikTokPipeline:
|
||||
if not tiktok_session.channel_has_session(channel):
|
||||
tiktok_db.update_tiktok_job(jid, status="scheduled", error="账号未配置 Cookie")
|
||||
return
|
||||
title_tpl = str(channel.get("title_template") or "{anchor} #fyp")
|
||||
desc_tpl = str(channel.get("description_template") or "")
|
||||
anchor = str(fresh.get("anchor_name") or fresh.get("room_id") or "live")
|
||||
url = str(fresh.get("source_url") or "")
|
||||
title = title_tpl.replace("{anchor}", anchor).replace("{url}", url)
|
||||
desc = desc_tpl.replace("{anchor}", anchor).replace("{url}", url)
|
||||
# 文案只用账号「标题模板」原文,绝不自动拼直播间名/链接
|
||||
title = str(channel.get("title_template") or "").strip()
|
||||
if not tiktok_db.touch_tiktok_upload_lease(jid):
|
||||
return
|
||||
result = await upload_tiktok_mp4(
|
||||
file_path=clip,
|
||||
title=title,
|
||||
description=desc,
|
||||
description="",
|
||||
privacy_level=str(channel.get("privacy_level") or "PUBLIC_TO_EVERYONE"),
|
||||
channel_pk=str(channel["id"]),
|
||||
)
|
||||
|
||||
@ -129,9 +129,8 @@ async def upload_tiktok_mp4(
|
||||
_ = (description, client_key, client_secret, refresh_token, access_token, token_expires_at)
|
||||
if not channel_pk:
|
||||
raise ValueError("缺少 channel_pk")
|
||||
caption = (title or "").strip()
|
||||
if description.strip() and description.strip() not in caption:
|
||||
caption = f"{caption}\n{description.strip()}"[:2200]
|
||||
# 只用 title;不再把 description 拼进文案(避免带上直播间名)
|
||||
caption = (title or "").strip()[:2200]
|
||||
try:
|
||||
return await asyncio.wait_for(
|
||||
asyncio.to_thread(
|
||||
|
||||
@ -93,8 +93,7 @@ export default function TikTokPage() {
|
||||
const [editId, setEditId] = useState("");
|
||||
const [formName, setFormName] = useState("TikTok 账号");
|
||||
const [formPrivacy, setFormPrivacy] = useState("PUBLIC_TO_EVERYONE");
|
||||
const [formTitle, setFormTitle] = useState("{anchor} #fyp");
|
||||
const [formDesc, setFormDesc] = useState("{anchor}\n{url}");
|
||||
const [formTitle, setFormTitle] = useState("");
|
||||
|
||||
const [sessionChannelId, setSessionChannelId] = useState("");
|
||||
const [sessionChannelName, setSessionChannelName] = useState("");
|
||||
@ -152,8 +151,7 @@ export default function TikTokPage() {
|
||||
setEditId("");
|
||||
setFormName("TikTok 账号");
|
||||
setFormPrivacy("PUBLIC_TO_EVERYONE");
|
||||
setFormTitle("{anchor} #fyp");
|
||||
setFormDesc("{anchor}\n{url}");
|
||||
setFormTitle("");
|
||||
setShowForm(true);
|
||||
setShowSessionForm(false);
|
||||
};
|
||||
@ -241,7 +239,7 @@ export default function TikTokPage() {
|
||||
name: formName,
|
||||
privacy_level: formPrivacy,
|
||||
title_template: formTitle,
|
||||
description_template: formDesc,
|
||||
description_template: "",
|
||||
}),
|
||||
});
|
||||
toast.push("账号已添加,请粘贴 Cookie", "ok");
|
||||
@ -261,7 +259,7 @@ export default function TikTokPage() {
|
||||
name: formName,
|
||||
privacy_level: formPrivacy,
|
||||
title_template: formTitle,
|
||||
description_template: formDesc,
|
||||
description_template: "",
|
||||
}),
|
||||
});
|
||||
toast.push("已保存", "ok");
|
||||
@ -337,8 +335,7 @@ export default function TikTokPage() {
|
||||
setEditId(ch.id);
|
||||
setFormName(ch.name || "TikTok 账号");
|
||||
setFormPrivacy(ch.privacy_level || "PUBLIC_TO_EVERYONE");
|
||||
setFormTitle(ch.title_template || "{anchor} #fyp");
|
||||
setFormDesc(ch.description_template || "{anchor}\n{url}");
|
||||
setFormTitle(ch.title_template || "");
|
||||
setShowForm(true);
|
||||
};
|
||||
|
||||
@ -581,9 +578,13 @@ export default function TikTokPage() {
|
||||
<input
|
||||
value={formTitle}
|
||||
onChange={(e) => setFormTitle(e.target.value)}
|
||||
placeholder="例如 street food(原文案上传,不会带直播间名)"
|
||||
className="mt-1 w-full rounded-lg border border-white/10 bg-black/40 px-3 py-2 text-sm"
|
||||
/>
|
||||
</label>
|
||||
<p className="text-[11px] text-slate-500 sm:col-span-2">
|
||||
发到 TikTok 的文案就是这里写的原文,不会自动加直播间名字或链接。
|
||||
</p>
|
||||
</div>
|
||||
<div className="mt-3 flex gap-2">
|
||||
<button
|
||||
|
||||
Loading…
Reference in New Issue
Block a user