diff --git a/capcut_agent/recommend.py b/capcut_agent/recommend.py index 02c57e7..7ea48c4 100644 --- a/capcut_agent/recommend.py +++ b/capcut_agent/recommend.py @@ -359,14 +359,20 @@ def cuts_from_state(places, orig_ranges, captions, comments, *, key=None): - `orig_ranges` = 원본 영상 시각 → ⭐ 분:초 매칭 둘은 같은 길이여야 하고 인덱스로만 짝지어 다닌다. """ - from .pipeline import captions_for_places # 순환 임포트 회피: pipeline은 draft·comments를 - # 임포트하고 app.py가 pipeline·recommend를 둘 다 임포트하므로, 파일 상단에서 - # pipeline을 가져오면 임포트 순환이 생긴다. 호출 시점(함수 안)에서만 가져온다. + # pipeline은 지금 recommend를 임포트하지 않아 상단 임포트도 동작한다. 다만 앞으로 + # pipeline이 추천을 쓰게 되면 순환이 되므로 함수 안에서 가져와 미리 끊어 둔다. + from .pipeline import captions_for_places if not places or len(places) != len(orig_ranges): return [], 0, False bottoms = captions_for_places(captions, places) quotas = [max(1, int((p1 - p0) // CARD_SEC)) for p0, p1 in places] cuts = [{"start": s, "end": e, "bottom": b, "effect": ""} for (s, e), b in zip(orig_ranges, bottoms)] - return build_highlight_cuts({"paste": {"cuts": cuts}}, comments, - key=key, quotas=quotas) + cuts_out, need, ai_failed = build_highlight_cuts( + {"paste": {"cuts": cuts}}, comments, key=key, quotas=quotas) + # sec 는 화면에서 quota 바로 옆에 찍힌다. quota 가 압축 길이 기준이므로 + # sec 도 압축 길이여야 "20초인데 왜 3장?"이 안 생긴다. + # (start/end 는 ⭐ 매칭용이라 원본 시각 그대로 둔다 — 좌표계가 둘인 이유) + for c, (p0, p1) in zip(cuts_out, places): + c["sec"] = round(p1 - p0, 1) + return cuts_out, need, ai_failed