diff --git a/backend/app/services/ai_analysis.py b/backend/app/services/ai_analysis.py index 7f3fc9f..00f0210 100644 --- a/backend/app/services/ai_analysis.py +++ b/backend/app/services/ai_analysis.py @@ -259,6 +259,9 @@ async def _call_openai(system: str, user_prompt: str) -> str: def _parse_clips(content: str, video_duration: float) -> list[dict]: """Parse LLM response into clip list, handling imperfect JSON.""" + # Strip markdown code fences (e.g. ```json ... ```) + content = re.sub(r"```(?:json)?\s*", "", content).strip() + # Try to extract JSON from response json_match = re.search(r"\{[\s\S]*\}", content) if not json_match: