get_download_url
Generate a time-limited secure download link for video files to save locally, export for editing, or share. Specify video ID and optional format for direct access to the file.
Instructions
Get direct DOWNLOAD link for video files. USE WHEN: User needs to download/save video locally, export for editing, backup content, share downloadable link. RETURNS: Time-limited secure URL for downloading. EXAMPLE: 'Download video 1_abc123', 'Get mp4 file for editing'. Different from streaming - this is for saving files.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| entry_id | Yes | Video to download (format: '1_abc123') | |
| flavor_id | No | Optional: Choose specific quality/format. Leave empty for default. Use list_media_entries to see available flavors. |
Implementation Reference
- src/kaltura_mcp/tools/media.py:127-187 (handler)The core handler function that implements the get_download_url tool logic: validates entry_id, fetches media entry and flavor assets, selects target flavor (specific or original), generates download URL using Kaltura client, and returns JSON with details.async def get_download_url( manager: KalturaClientManager, entry_id: str, flavor_id: Optional[str] = None, ) -> str: """Get a direct download URL for a media entry.""" if not validate_entry_id(entry_id): return json.dumps({"error": "Invalid entry ID format"}, indent=2) try: client = manager.get_client() # Get the entry to verify it exists entry = client.media.get(entry_id) except Exception as e: return handle_kaltura_error(e, "get download URL", {"entry_id": entry_id}) # Get flavor assets flavor_filter = KalturaAssetFilter() flavor_filter.entryIdEqual = entry_id flavors = client.flavorAsset.list(flavor_filter) if flavor_id: # Find specific flavor target_flavor = None for flavor in flavors.objects: if flavor.id == flavor_id: target_flavor = flavor break if not target_flavor: return json.dumps({"error": f"Flavor ID {flavor_id} not found for entry {entry_id}"}) else: # Get the source or highest quality flavor target_flavor = None for flavor in flavors.objects: if flavor.isOriginal: target_flavor = flavor break if not target_flavor and flavors.objects: target_flavor = flavors.objects[0] if not target_flavor: return json.dumps({"error": "No flavor assets found for this entry"}) # Get download URL download_url = client.flavorAsset.getUrl(target_flavor.id) return json.dumps( { "entryId": entry_id, "entryName": entry.name, "flavorId": target_flavor.id, "fileSize": target_flavor.size * 1024 if target_flavor.size else None, # Convert KB to bytes "bitrate": target_flavor.bitrate, "format": target_flavor.fileExt, "downloadUrl": download_url, }, indent=2, )
- src/kaltura_mcp/server.py:302-318 (registration)Registers the get_download_url tool in the MCP server's list_tools() handler, defining its name, detailed description, and input schema for entry_id (required) and flavor_id (optional).name="get_download_url", description="Get direct DOWNLOAD link for video files. USE WHEN: User needs to download/save video locally, export for editing, backup content, share downloadable link. RETURNS: Time-limited secure URL for downloading. EXAMPLE: 'Download video 1_abc123', 'Get mp4 file for editing'. Different from streaming - this is for saving files.", inputSchema={ "type": "object", "properties": { "entry_id": { "type": "string", "description": "Video to download (format: '1_abc123')", }, "flavor_id": { "type": "string", "description": "Optional: Choose specific quality/format. Leave empty for default. Use list_media_entries to see available flavors.", }, }, "required": ["entry_id"], }, ),
- src/kaltura_mcp/server.py:515-516 (registration)Dispatches tool calls to the get_download_url handler function in the server's call_tool() method.elif name == "get_download_url": result = await get_download_url(kaltura_manager, **arguments)
- src/kaltura_mcp/remote_server.py:559-560 (registration)Dispatches tool calls to the get_download_url handler in the remote MCP server's call_tool() function.elif tool_name == "get_download_url": result = await get_download_url(kaltura_manager, **arguments)
- Re-exports the get_download_url function from media.py and includes it in __all__ for easy import in server modules.get_download_url, get_media_entry, get_thumbnail_url, list_media_entries, ) from .search import ( esearch_entries, list_categories, search_entries, search_entries_intelligent, ) from .utils import ( handle_kaltura_error, safe_serialize_kaltura_field, validate_entry_id, ) # Export all tools __all__ = [ # Utilities "handle_kaltura_error", "safe_serialize_kaltura_field", "validate_entry_id", # Media operations "get_download_url",