Skip to main content
Glama

get_caption_content

Extract video caption text or download subtitles for reading transcripts, analyzing content, and creating accessible media. Requires a specific caption ID from list_caption_assets.

Instructions

Get actual CAPTION TEXT or download captions file. USE WHEN: Reading video transcript, downloading subtitles, analyzing spoken content, creating accessible content. RETURNS: Full caption text and download URL. EXAMPLE: 'Get English subtitles for video', 'Read transcript to find mentions of topic'. Use after list_caption_assets to get specific caption ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
caption_asset_idYesCaption ID from list_caption_assets (format: '1_xyz789')

Implementation Reference

  • The core handler function that fetches caption asset details using Kaltura API, retrieves the content URL, downloads the caption text via HTTP request, and returns JSON with the transcript or error details.
    async def get_caption_content( manager: KalturaClientManager, caption_asset_id: str, ) -> str: """Get the actual text content of a caption asset.""" if not CAPTION_AVAILABLE: return json.dumps( { "error": "Caption functionality is not available. The Caption plugin is not installed.", "captionAssetId": caption_asset_id, }, indent=2, ) client = manager.get_client() try: # Get caption asset details caption_asset = client.caption.captionAsset.get(caption_asset_id) # Get the caption content URL content_url = client.caption.captionAsset.getUrl(caption_asset_id) # Validate URL before making request if not content_url or not isinstance(content_url, str): download_error = "Invalid or missing caption URL" caption_text = None elif not content_url.startswith(("http://", "https://")): download_error = "Caption URL must use HTTP or HTTPS protocol" caption_text = None else: # Download the actual caption content caption_text = None download_error = None try: # Create a session for downloading session = requests.Session() # Set headers similar to reference implementation headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" } # Download the caption content with timeout response = session.get(content_url, headers=headers, timeout=30) response.raise_for_status() # Get the text content caption_text = response.text except requests.exceptions.RequestException as e: download_error = f"Failed to download caption content: {str(e)}" except Exception as e: download_error = f"Error processing caption content: {str(e)}" result = { "captionAssetId": caption_asset_id, "entryId": caption_asset.entryId, "language": caption_asset.language.value if hasattr(caption_asset.language, "value") else str(caption_asset.language), "label": caption_asset.label, "format": caption_asset.format.value if hasattr(caption_asset.format, "value") else str(caption_asset.format), "contentUrl": content_url, "size": caption_asset.size, "accuracy": caption_asset.accuracy, } if caption_text is not None: result["captionText"] = caption_text result["textLength"] = len(caption_text) result["note"] = "Caption text content has been successfully downloaded and included." else: result["downloadError"] = download_error result[ "note" ] = "Caption asset details retrieved but text content could not be downloaded. Use contentUrl for manual download." return json.dumps(result, indent=2) except Exception as e: return json.dumps( { "error": f"Failed to get caption content: {str(e)}", "captionAssetId": caption_asset_id, }, indent=2, )
  • The tool schema definition in the list_tools() handler, specifying input as caption_asset_id string and detailed usage description.
    types.Tool( name="get_caption_content", description="Get actual CAPTION TEXT or download captions file. USE WHEN: Reading video transcript, downloading subtitles, analyzing spoken content, creating accessible content. RETURNS: Full caption text and download URL. EXAMPLE: 'Get English subtitles for video', 'Read transcript to find mentions of topic'. Use after list_caption_assets to get specific caption ID.", inputSchema={ "type": "object", "properties": { "caption_asset_id": { "type": "string", "description": "Caption ID from list_caption_assets (format: '1_xyz789')", }, }, "required": ["caption_asset_id"], }, ),
  • Tool dispatch registration in the call_tool handler, mapping 'get_caption_content' to the imported function execution.
    elif name == "get_caption_content": result = await get_caption_content(kaltura_manager, **arguments)
  • Alternative registration in the remote HTTP server dispatch for the tool call.
    elif tool_name == "get_caption_content": result = await get_caption_content(kaltura_manager, **arguments)
  • Import registration of the get_caption_content handler into the main server module.
    from .tools import ( get_analytics, get_analytics_timeseries, get_attachment_content, get_caption_content,

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/zoharbabin/kaltura-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server