A comprehensive Python code sample demonstrating how to implement Kaltura's DIY (Do-It-Yourself) live session functionality. This developer guide provides working code examples for creating and managing Kaltura entries, rooms, and sub-tenants using the Kaltura Application Framework (KAF).
This project serves as a reference implementation for developers who want to integrate Kaltura's DIY live streaming capabilities into their own platforms. It demonstrates:
- Live Stream Creation: How to programmatically create Kwebcast live entries
- Room Management: How to create and configure embedded rooms
- Session Generation: How to generate secure Kaltura sessions for users
- Sub-tenant Provisioning: How to set up new Kaltura partners with required modules
- API Integration Patterns: Best practices for integrating with Kaltura's REST APIs
- Live Entry Creation: Complete code sample for creating Kwebcast live streams
- Metadata Management: Automatic attachment of KwebcastProfile metadata
- DVR Configuration: Programmatic setup of recording and playback options
- Category Publishing: Integration with Kaltura for entitlments
- Partner Provisioning: Full code example for creating new Kaltura partners
- Module Configuration: Pre-configured with essential KAF modules
- Category Hierarchy: Automatic creation of publishing categories
- Template Support: Reusable partner and room templates
- Service Layer Pattern: Clean separation of concerns with dedicated models
- Error Handling: Comprehensive error management and logging
- Session Management: Secure token generation for embedded components
- Real-time Feedback: Progress tracking and status updates
kaf-standalone-demo/
βββ lib/
β βββ server.py # Flask application with route serving
β βββ routes.py # API route definitions (7 endpoints)
β βββ models/
β β βββ base_model.py # Base model with shared functionality
β β βββ live_event_model.py # Live stream operations
β β βββ room_model.py # Room creation operations
β β βββ sub_tenant_model.py # Sub-tenant and category management
β βββ services/
β β βββ kaltura_service.py # Service layer for API operations
β βββ kaltura_integration/
β βββ simple_client.py # Enhanced Kaltura client wrapper
βββ public/
β βββ index.html # Main navigation interface
β βββ app.js # Shared utilities and navigation
β βββ app.css # Global styles
β βββ en.json # Localization data
β βββ pages/
β βββ entry-create-kaf/ # Enhanced entry creation interface
β β βββ index.html # 3-column responsive layout
β β βββ app.js # Advanced form handling & player integration
β β βββ app.css # Custom styling (500+ lines)
β βββ create-sub-tenant/ # Sub-tenant creation interface
β βββ index.html # Multi-step creation form
β βββ app.js # Automated tenant setup workflow
βββ requirements.txt # Python dependencies
βββ run.py # Application entry point
βββ list_metadata_profiles.py # Utility for metadata profile discovery
βββ README.md # This documentation
-
Clone the repository
git clone <repository-url> cd kaf-standalone-demo
-
Create virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
The application requires several environment variables to be set for proper operation:
# Kaltura Configuration
KALTURA_URL=https://www.kaltura.com
KALTURA_PARENT_PARTNER_ID=your_parent_partner_id
KALTURA_ADMIN_SECRET=your_admin_secret
KALTURA_USER_ID=your_user_id
# Template Room Entry ID for room creation
TEMPLATE_ROOM_ENTRY_ID=your_template_room_entry_id
# Flask Configuration (optional, defaults shown)
FLASK_HOST=0.0.0.0
FLASK_PORT=3033
FLASK_DEBUG=False
Option 1: Export in shell
export TEMPLATE_ROOM_ENTRY_ID=your_template_room_entry_id
export KALTURA_URL=https://www.kaltura.com
# ... other variables
Option 2: Create .env file
# Create .env file in project root
echo "TEMPLATE_ROOM_ENTRY_ID=your_template_room_entry_id" > .env
echo "KALTURA_URL=https://www.kaltura.com" >> .env
# ... add other variables
Option 3: Set in your IDE/terminal
TEMPLATE_ROOM_ENTRY_ID=your_template_room_entry_id python run.py
-
Start the server
python run.py
Or alternatively:
cd lib python server.py
-
Access the application
- Main Application: http://localhost:3033/ (navigation hub)
- Entry Create KAF: http://localhost:3033/entry-create-kaf (primary interface)
- Create Sub Tenant: http://localhost:3033/create-sub-tenant (tenant management)
-
Initial Setup
- Start with the Create Sub Tenant page to set up your Kaltura partner
- Credentials are automatically stored in localStorage for use across pages
- Use the Entry Create KAF page for content creation and management
- No Environment Variables: All configuration via frontend forms
- localStorage Persistence: Credentials saved in browser for convenience
- Cross-Page Sync: Automatic credential sharing between interfaces
- Real-time Updates: Form changes immediately update localStorage
- Partner ID: Your Kaltura partner ID
- Admin Secret: Partner admin secret
- User ID: Admin user ID for operations
- Kaltura URL: Service URL (default: https://www.kaltura.com)
- Template Partner ID: For sub-tenant creation
- Template Room Entry ID: For room creation in Studio mode
tenantId
: Partner IDtenantEmail
: Admin user emailadminSecret
: Admin secretpublishingCategoryId
: Default category for entrieskalturaUrl
: Service URL
- Creation Mode Toggle: Switch between Broadcast (live entries) and Studio (rooms)
- Entry/Room Form: Dynamic form adapting to selected mode
- Entry Details: Fetch information for existing entries
- Activity Logs: Real-time operation logging with JSON display
- Full-Screen Video: Embedded Kaltura player/studio interface
- Responsive Design: Adapts to different screen sizes
- Direct Integration: Seamless loading of generated sessions
- Mode Toggle: Switch between Studio (room creation) and Player (viewing)
- Session Generation: Create Kaltura sessions with custom parameters
- Role Management: Configure user roles and privileges
- LocalStorage Manager: View and edit stored credentials
- Step-by-Step Process: Guided tenant creation workflow
- Automatic Setup: Category creation and module configuration
- Progress Feedback: Real-time status updates and error handling
- Credential Export: Automatic localStorage population for other pages
Flask==2.3.3 # Web framework
python-dotenv==1.0.0 # Environment variable support
requests==2.31.0 # HTTP client for KAF API calls
pycryptodome==3.19.0 # Cryptographic functions
KalturaApiClient==21.19.0 # Official Kaltura Python client
lxml==6.0.0 # XML processing for metadata
- Session Creation Fails: Verify admin secret and partner ID
- Room Creation Errors: Ensure template room entry ID is valid
- Metadata Issues: Check if KwebcastProfile exists in your partner account
- CORS Errors: Ensure proper Kaltura URL configuration
- Browser Developer Tools for JavaScript debugging
- Flask debug output in terminal
- Real-time logs in the Entry Create KAF interface
- Network tab for API request/response inspection
This project is a comprehensive port and enhancement of the original Kaltura KAF standalone demo. Please refer to Kaltura's licensing terms for usage restrictions.
- Fork the repository
- Create a feature branch (
git checkout -b feature/enhancement
) - Test thoroughly with your Kaltura partner account
- Submit a pull request with detailed description
For technical issues:
- Check the real-time logs in the application interface
- Verify Kaltura credentials and partner configuration
- Consult Kaltura's official documentation for API-specific questions
- Review browser console for JavaScript errors
For Kaltura-specific questions, please refer to the official Kaltura documentation or contact Kaltura support.