diff --git a/backend/app/services/ai_analysis.py b/backend/app/services/ai_analysis.py index 3ee07b2..3bd12f7 100644 --- a/backend/app/services/ai_analysis.py +++ b/backend/app/services/ai_analysis.py @@ -57,7 +57,7 @@ def _sample_segments(segments: list[dict], max_chars: int) -> list[dict]: lines = [] for s in segments: line = ( - f"[{_fmt_time(s.get('start', 0))} - {_fmt_time(s.get('end', 0))}] " + f"[{s.get('start', 0):.1f}s - {s.get('end', 0):.1f}s] " f"{s.get('text', '').strip()}" ) lines.append((s, line)) @@ -148,7 +148,7 @@ async def analyze_transcript( if segments: sampled = _sample_segments(segments, MAX_TRANSCRIPT_CHARS) timestamped = "\n".join( - f"[{_fmt_time(s.get('start', 0))} - {_fmt_time(s.get('end', 0))}] " + f"[{s.get('start', 0):.1f}s - {s.get('end', 0):.1f}s] " f"{s.get('text', '').strip()}" for s in sampled ) @@ -163,7 +163,7 @@ async def analyze_transcript( ) user_prompt = f"""Video Title: {video_title} -Video Duration: {_fmt_time(video_duration)} +Video Duration: {video_duration:.0f} seconds Transcript: {timestamped} @@ -358,9 +358,3 @@ def _parse_clips(content: str, video_duration: float) -> list[dict]: # Sort by virality score descending clips.sort(key=lambda x: x["virality_score"], reverse=True) return clips - - -def _fmt_time(seconds: float) -> str: - """Format seconds as MM:SS.""" - m, s = divmod(int(seconds), 60) - return f"{m:02d}:{s:02d}"