Skip to content

Instantly share code, notes, and snippets.

View zoharbabin's full-sized avatar

Zohar Babin zoharbabin

View GitHub Profile
@zoharbabin
zoharbabin / llamaindex_kaltura_esearch_reader_example.py
Created May 20, 2023 20:49
An example use of the Kaltura eSearch Reader for LlamaIndex showing searching for list of Kaltura video entries, and querying ChatGPT against them
import logging
import sys
from llama_index import (
download_loader,
GPTVectorStoreIndex,
LLMPredictor,
ServiceContext,
PromptHelper,
load_index_from_storage,
StorageContext
This file has been truncated, but you can view the full file.
{
"basePath": "/api_v3",
"definitions": {
"KalturaABCScreenersWatermarkCondition": {
"allOf": [
{
"$ref": "#/definitions/KalturaCondition"
}
],
"properties": {},
This file has been truncated, but you can view the full file.
{
"openapi": "3.0.1",
"info": {
"title": "Kaltura Video Experience Cloud API",
"description": "Kaltura Media Services offers a feature-rich API for seamless integration of high-quality video streaming and management. It provides scalability, flexibility, and extensive customization options, empowering developers to build robust media-centric applications.",
"version": "19.4.0"
},
"servers": [
{
"url": "https://cdnapi-ev.kaltura.com/api_v3"
@zoharbabin
zoharbabin / convert-srt-to-transcript-txt.py
Created March 8, 2023 21:34
A python script to strip SRT captions file into a non-timed TXT transcript. Provided an SRT file as input, the script preserves the caption blocks structure in an SRT file input, while merging consecutive lines inside each caption block. Then, the script removes all SRT formatting, and produces a clean TXT file without line index markers, timing…
import sys
import re
def merge_lines(srt_file):
# Read in the SRT file
with open(srt_file, 'r') as f:
srt = f.read()
# Merge consecutive lines in each caption block
merged_srt = re.sub(r'\d+\n(\d\d:\d\d:\d\d,\d+ --> \d\d:\d\d:\d\d,\d+\n)?(.*?\n\n)', lambda match: match.group(2).replace('\n', ' ') + '\n', srt, flags=re.S)
<div style="position: relative; padding-bottom: 56.25%; padding-top: 25px; height: 0;"><iframe style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" src="https://cdnapisec.kaltura.com/p/2539171/sp/253917100/embedIframeJs/uiconf_id/44037791/partner_id/2539171?iframeembed=true&amp;playerId=kaltura_player_1556142794&amp;entry_id=1_vqxvmjj6&amp;flashvars[streamerType]=auto" width="560" height="400" frameborder="0" allowfullscreen="allowfullscreen"></iframe></div>
@zoharbabin
zoharbabin / kaltura-captions-studio-embed.php
Created July 25, 2021 07:23
A quick embed code sample showing how to integrate the Kaltura Captions Editor in web apps via iframe embed
<?php
$partnerId = YOUR_KALTURA_ACCOUNT_ID; //https://kmc.kaltura.com/index.php/kmcng/settings/integrationSettings
$apiAdminSecret = 'YOUR_KALTURA_API_ADMIN_SECRET'; //https://kmc.kaltura.com/index.php/kmcng/settings/integrationSettings
$kalturaServiceUrl = 'https://www.kaltura.com';
//This goes on your backend - never include API secret keys in front end code
$sessionExpire = 60 * 60 * 24; //one day
$uniqueUserId = 'someone@company.com'; //Make sure this is set to your real user IDs so that Analytics and Entitlements will really be tracked according to your business needs
$entryId = 'YOUR_VIDEO_ID'; //The ID of the video entry whose caption asset you wish to edit. Get from media.list or https://kmc.kaltura.com/index.php/kmcng/content/entries/list
$assetId = null; //the ID of the caption Asset to edit. retrieved by captionAsset.list using the entry ID, formatIn="1,2" (SRT or DFXP) and statusEqual=2 (READY). If set to null, the first asset in the list response will be loaded by the editor.
$appName = 'myAppNam
@zoharbabin
zoharbabin / virtualEventAttendanceReports.php
Last active May 5, 2021 12:32
Example PHP code showing how to download Kaltura virtual event session attendance and add-to-calendar analytics reports as CSV files for sync with 3rd party BI systems
<?php
set_time_limit(0);
ini_set('memory_limit', '2048M');
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
date_default_timezone_set('Asia/Jerusalem'); // Make sure to set this to your desired timezone (https://www.php.net/manual/en/timezones.php)
const REPORT_SESSION_ATTENDANCE = 3009;
const REPORT_CERTIFICATE_OF_COMPLETION = 3010;
const REPORT_ADD_TO_CALENDAR = 3006;
@zoharbabin
zoharbabin / exportToCsvExample.php
Last active April 16, 2021 08:06
example of using baseEntry.exportToCsv action to get a full list of Kaltura entries as CSV emailed to you
// IMPORTANT: This action will EMAIL the CSV file to the email defined in the user's email field. Be sure to set userId in the KS that belongs to a user object that has email field properly set to a valid email address
//initialize kaltura
$kConfig = new KalturaConfiguration($pid);
$kConfig->setServiceUrl('https://www.kaltura.com');
$kConfig->setLogger($this);
$this->client = new KalturaClient($kConfig);
$this->ks = $this->client->session->start($secret, 'userIdToSendEmailWithCSV', SessionType::ADMIN, $pid, 86400, 'list:*,disableentitlement,*');
$this->client->setKs($this->ks);
This file has been truncated, but you can view the full file.
{
"basePath": "/api_v3",
"definitions": {
"KalturaABCScreenersWatermarkCondition": {
"allOf": [
{
"$ref": "#/definitions/KalturaCondition"
}
],
"properties": {},
#!/usr/bin/ruby
require 'kaltura'
include Kaltura
config = KalturaConfiguration.new()
config.service_url = 'https://www.kaltura.com'
client = KalturaClient.new(config);
parent_partner_id = # Your Kaltura Parent MultiAccount Partner ID (Kaltura Account ID)
login_id = #Your Kaltura Parent MultiAccount Admin Login Email