Randomize TikTok clip length to 61–120s instead of fixed 60–90.
Live record and yt-long cascade both pick a random duration in the >1–2 minute range each job. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
960a268fa2
commit
e8bc7764b6
@ -24,13 +24,9 @@ def _clamp(v: int, lo: int, hi: int) -> int:
|
||||
|
||||
|
||||
def tiktok_cut_sec(cfg: dict[str, Any]) -> int:
|
||||
"""1–1.5 minutes."""
|
||||
try:
|
||||
base = int(cfg.get("tiktok_clip_sec") or 75)
|
||||
except Exception:
|
||||
base = 75
|
||||
base = _clamp(base, 60, 90)
|
||||
return random.randint(60, max(60, base)) if base > 60 else random.randint(60, 90)
|
||||
"""Random >1–2 minutes (61–120s). cfg kept for call-site compatibility."""
|
||||
_ = cfg
|
||||
return random.randint(61, 120)
|
||||
|
||||
|
||||
def shorts_cut_sec(cfg: dict[str, Any]) -> int:
|
||||
@ -254,7 +250,7 @@ async def cascade_from_yt_long(job: dict[str, Any], cfg: dict[str, Any] | None =
|
||||
clips_root = settings.clips_dir
|
||||
clips_root.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# ── TikTok (1–1.5 min) ─────────────────────────────────────────────
|
||||
# ── TikTok (>1–2 min random) ───────────────────────────────────────
|
||||
if bool(settings_map.get("tiktok_enabled", False)):
|
||||
try:
|
||||
if room_id and tiktok_db.has_tiktok_job_for_room_day(room_id, day):
|
||||
|
||||
@ -656,7 +656,8 @@ def _seed_defaults(conn: sqlite3.Connection) -> None:
|
||||
"ops_neko_public_base": "",
|
||||
# TikTok pipeline (fully isolated from Shorts)
|
||||
"tiktok_enabled": False,
|
||||
"tiktok_clip_sec": 75,
|
||||
# Upper bound for random TikTok clip length (actual: randint 61..tiktok_clip_sec, max 120)
|
||||
"tiktok_clip_sec": 120,
|
||||
"tiktok_trigger": "tagged",
|
||||
"tiktok_tag": "shorts",
|
||||
"tiktok_dedupe_room_day": True,
|
||||
|
||||
@ -278,7 +278,9 @@ class TikTokPipeline:
|
||||
"quota_gap": tiktok_db.tiktok_total_quota_gap(),
|
||||
"quota_defaults": db.tiktok_quota_defaults(cfg),
|
||||
"last_error": self.last_error,
|
||||
"clip_sec": max(60, min(90, int(cfg.get("tiktok_clip_sec") or 75))),
|
||||
"clip_sec_min": 61,
|
||||
"clip_sec_max": 120,
|
||||
"clip_sec": 120,
|
||||
"douyin_live_count": live_count,
|
||||
"board": board,
|
||||
"oauth_issues": oauth_issues,
|
||||
@ -530,20 +532,8 @@ class TikTokPipeline:
|
||||
)
|
||||
return
|
||||
|
||||
# TikTok 素材 1–1.5 分钟;多 CDN 线路按 DouyinLiveRecorder 方式试探
|
||||
try:
|
||||
sec = int(cfg.get("tiktok_clip_sec") or 75)
|
||||
except Exception:
|
||||
sec = 75
|
||||
sec = max(60, min(90, sec))
|
||||
try:
|
||||
room_pk = str(job.get("room_pk") or "")
|
||||
room = db.get_room(room_pk) if room_pk else None
|
||||
override = db.room_clip_seconds(room, default=0, platform="tiktok") if room else 0
|
||||
if override > 0:
|
||||
sec = max(60, min(90, override))
|
||||
except Exception:
|
||||
pass
|
||||
# TikTok 素材:>1–2 分钟随机时长(61–120s),不用固定秒数
|
||||
sec = random.randint(61, 120)
|
||||
outcome = await record_clip(
|
||||
job_id=f"tiktok_{jid[:8]}",
|
||||
stream_urls=candidates,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user