무음 제거 후 실제 길이 기준 카드 장수를 외부에서 주입 가능하게

build_highlight_cuts()에 quotas 파라미터 추가. 무음 제거 후 줄어든 타임라인에 맞춰
카드 장수를 계산한 후 넘길 수 있다. quotas를 넘기지 않으면 기존 동작(원본 길이 기준)
그대로여야 한다 — 기존 호출부에는 변화 없다.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
hehihoho3@gmail.com 2026-08-04 17:06:35 +09:00
parent 2525fb5231
commit a1f98b0b53

View File

@ -223,20 +223,18 @@ def _time_based_picks(cuts, comments, quotas) -> List[List[dict]]:
return out
def build_highlight_cuts(hl, comments, *, key=None):
def build_highlight_cuts(hl, comments, *, key=None, quotas=None):
"""하이라이트 하나 → (cuts[], need, ai_failed). 모드는 컷 모양으로 판별한다.
quotas: 컷별 카드 장수를 밖에서 정해 넘길 쓴다(무음 제거 실제 길이 기준).
넘기면 `quotas_for(cuts)` 원본 길이 기준.
Returns: ([{"i","sec","bottom","quota","picks"}], need, ai_failed)
need = Σ quota 기존 int(total//3) 대체한다( 경계에 맞추는 쪽이 맞다).
ai_failed = Gemini 호출이 **실패**했는가(429·타임아웃·파싱). 통짜 모드는 Gemini
부르므로 항상 False. 호출부는 값으로만 경고를 띄운다 실패해도 cuts
타임스탬프만으로 채워져 비지 않으므로, cuts 비었는지로는 실패를 없다.
Gemini 실패는 여기서 흡수된다(ai_pick_cuts None 준다) 예외를 올리지 않는다.
need = Σ quota. Gemini 실패는 ai_failed=True 알린다(예외는 올린다).
"""
cuts = (hl.get("paste") or {}).get("cuts") or []
if not cuts:
return [], 0, False
quotas = quotas_for(cuts)
quotas = list(quotas) if quotas is not None else quotas_for(cuts)
ai_failed = False
if is_time_based(cuts):
picks = _time_based_picks(cuts, comments, quotas)