Skip to content

feat: player embed code generator#69

Open
omgate234 wants to merge 4 commits intovideo-db:mainfrom
omgate234:feat/player-embed-code
Open

feat: player embed code generator#69
omgate234 wants to merge 4 commits intovideo-db:mainfrom
omgate234:feat/player-embed-code

Conversation

@omgate234
Copy link
Contributor

Pull Request

Description:
Add get_embed_code() API across SDK objects to generate iframe embed HTML from player_url values, enabling users to easily share embeddable video players.

Changes:

  • Add player_url_to_embed_url() utility to convert /watch?v= URLs to /embed?v= URLs
  • Add build_iframe_embed_code() utility to generate iframe HTML strings
  • Add get_embed_code() method to Video, Shot, SearchResult
  • Add get_embed_code() method to timeline.Timeline, editor.Timeline
  • Add get_embed_code() method to RTStreamShot, RTStreamExportResult, RTStream
  • Export build_iframe_embed_code from videodb for use with raw dict responses
  • Fix Video.generate_stream() to save player_url to instance (consistency with other classes)

Related Issues:

  • N/A

Testing:

  • Unit tests added in tests/test_embed_code.py covering:
    • player_url_to_embed_url() URL conversion and error cases
    • build_iframe_embed_code() iframe generation with various parameters
    • get_embed_code() method behavior on SDK objects
    • Error handling when player_url is unavailable

Usage Examples:

# Video
video = coll.get_video("...")
embed = video.get_embed_code()

# Search result with custom params
search_result = coll.search("launch announcement")
embed = search_result.get_embed_code(height=480, title="Search Highlights")

# For raw dict responses (CaptureSession.export)
from videodb import build_iframe_embed_code
resp = capture_session.export()
embed = build_iframe_embed_code(resp["player_url"])

Copy link
Collaborator

@ankit-v2-3 ankit-v2-3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@omgate234
Copy link
Contributor Author

Looks good to me

Let me test more rigorously before we merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants