]*class="[^"]*container[^"]*"[^>]*>',
- r'
]*>',
- ]
-
- insertion_point = None
- for pattern in patterns_to_try:
- import re
- match = re.search(pattern, html_content[body_content_start:], re.IGNORECASE)
- if match:
- match_end = body_content_start + match.end()
- # Find the end of this tag
- tag_content = html_content[body_content_start + match.start():match_end]
- insertion_point = html_content[:match_end] + '\n '
- break
-
- if not insertion_point:
- # Fallback to right after body tag with container div
- insertion_point = html_content[:body_end] + '\n '
- video_with_container = f'\n {video_html}\n
'
- return f"""{SEARCH_START}
-{insertion_point}
-{DIVIDER}
-{insertion_point}
- {video_with_container}
-{REPLACE_END}"""
- else:
- return f"""{SEARCH_START}
-{insertion_point}
-{DIVIDER}
-{insertion_point}
- {video_html}
-{REPLACE_END}"""
+ except Exception:
+ # Non-fatal in preview
+ pass
- # If no , just append
- return f"{SEARCH_START}\n\n{DIVIDER}\n{video_html}\n{REPLACE_END}"
+ return doc
-def create_music_replacement_blocks_text_to_music(html_content: str, prompt: str, session_id: str | None = None) -> str:
- """Create search/replace blocks that insert ONE generated