MCPcopy Index your code
hub / github.com/Hrishikesh332/dev-ai / create_video_embed

Function create_video_embed

utils.py:467–509  ·  view source on GitHub ↗
(video_url, start_time=0, end_time=0)

Source from the content-addressed store, hash-verified

465 return "0"
466
467def create_video_embed(video_url, start_time=0, end_time=0):
468 try:
469 video_id, platform = get_video_id_from_url(video_url)
470 start_seconds = format_time_for_url(start_time)
471
472 if not video_id:
473 return f"<p>Unable to process video URL: {video_url}</p>"
474
475 if platform == 'vimeo':
476 return f"""
477 <iframe
478 width="100%"
479 height="315"
480 src="https://player.vimeo.com/video/{video_id}?autoplay=0#t={start_seconds}s"
481 frameborder="0"
482 allow="fullscreen; picture-in-picture"
483 allowfullscreen>
484 </iframe>
485 """
486 elif platform == 'direct':
487 return f"""
488 <video
489 width="100%"
490 height="315"
491 controls
492 preload="metadata"
493 id="video-player">
494 <source src="{video_url}" type="video/mp4">
495 Your browser does not support the video tag.
496 </video>
497 <script>
498 document.getElementById('video-player').addEventListener('loadedmetadata', function() {{
499 this.currentTime = {start_time};
500 this.pause();
501 }});
502 </script>
503 """
504 else:
505 return f"<p>Unsupported video platform for URL: {video_url}</p>"
506
507 except Exception as e:
508 st.error(f"Error creating video embed: {str(e)}")
509 return f"<p>Error creating video embed for URL: {video_url}</p>"

Callers 2

mainFunction · 0.90
get_rag_responseFunction · 0.70

Calls 2

get_video_id_from_urlFunction · 0.85
format_time_for_urlFunction · 0.85

Tested by

no test coverage detected