get_download_url
Generate time-limited secure URLs to download video files from Kaltura for local saving, editing, backups, or sharing downloadable links.
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 async handler function implementing the get_download_url tool logic: validates entry_id, fetches media entry, selects flavor asset (specific or original), generates and returns download URL with metadata in JSON format.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:301-318 (schema)Defines the tool schema, description, and input parameters (entry_id required, flavor_id optional) for registration in MCP server's list_tools().types.Tool( 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 calls to the get_download_url handler function in the MCP server's call_tool method.elif name == "get_download_url": result = await get_download_url(kaltura_manager, **arguments)
- src/kaltura_mcp/tools/__init__.py:21-26 (registration)Registers/exports the get_download_url function from media.py module for import in server.py.from .media import ( get_download_url, get_media_entry, get_thumbnail_url, list_media_entries, )