Skip to main content
Glama

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
NameRequiredDescriptionDefault
entry_idYesVideo to download (format: '1_abc123')
flavor_idNoOptional: Choose specific quality/format. Leave empty for default. Use list_media_entries to see available flavors.

Implementation Reference

  • 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,
        )
  • 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"],
        },
    ),
  • 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)
  • 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,
    )

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