Last active
October 12, 2015 21:27
-
-
Save mbutler/4089143 to your computer and use it in GitHub Desktop.
export all Kaltura videos in a category to a directory of files containing embed code. Suitable for CONTENTdm .url files in collection image folder to point at. Requires Kaltura's PHP5 library.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//number of videos in the collection | |
$num_of_items = ; | |
//collection name | |
$category_name = ''; | |
//kaltura admin (email) for this account | |
$userId = ''; | |
//found in KMC admin section | |
$adminSecret = ''; | |
//found in KMC settings/integration settings | |
$partnerId = ; | |
//found in KMC settings/integration settings | |
$subpartnerId = ; | |
//found in KMC admin section | |
$uiconfId = ; | |
require_once('php5/KalturaClient.php'); | |
$config = new KalturaConfiguration($partnerId); | |
$config->serviceUrl = 'http://www.kaltura.com'; | |
$client = new KalturaClient($config); | |
$ks = $client->generateSession($adminSecret, $userId, KalturaSessionType::ADMIN, $partnerId); | |
$client->setKs($ks); | |
$filter = new KalturaMediaEntryFilter(); | |
$pager = new KalturaFilterPager(); | |
$pager->pageSize = $num_of_items; | |
$pager->pageIndex = 1; | |
$filter->categoriesMatchOr = $category_name; | |
$filteredListResult = $client->media->listAction($filter, $pager); | |
// loop through the list and build the table: | |
$table = array(); | |
$table[] = array("categoriesMatchOr", "id", "name", "description", "updatedAt", "userId", "download", "partnerData"); | |
//print_r($filteredListResult->objects); | |
foreach ($filteredListResult->objects as $entry) { | |
$row = array(); | |
//to learn more about thumbnail api see: http://knowledge.kaltura.com/kaltura-thumbnail-api | |
//for the default thumbnail, can also use: $entry->thumbnailUrl; | |
$row[] = '<img src="http://cdn.kaltura.com/p/'.$partnerId.'/thumbnail/entry_id/'.$entry->id.'/width/50/height/50/type/1/quality/100" />'; | |
$row[] = $entry->mediaType; | |
$row[] = $entry->id; | |
$row[] = $entry->name; | |
$row[] = $entry->description; | |
$row[] = gmdate("m.d.y", $entry->updatedAt); | |
$row[] = $entry->userId; | |
if ($entry->mediaType == KalturaMediaType::VIDEO || $entry->mediaType == KalturaMediaType::AUDIO) { | |
//to learn more about getting download url - http://knowledge.kaltura.com/faq/how-retrieve-download-or-streaming-url-using-api-calls | |
$downloadUrl = 'http://www.kaltura.com/p/'. $partnerId .'/sp/0/playManifest/entryId/'. $entry->id .'/format/url/flavorParamId/0'; | |
$row[] = '<a href="'.$downloadUrl.'" target="_blank">Download</a>'; | |
} else { | |
$row[] = '<a href="'.$entry->dataUrl.'" target="_blank" class="downloadlink"></a>'; | |
} | |
$row[] = $entry->partnerData; | |
$table[] = $row; | |
} | |
//print_r($table); | |
for ($i=1; $i <= $num_of_items; $i++) { | |
$id = $table[$i][2]; | |
$title = $table[$i][3]; | |
$description = $table[$i][4]; | |
$file = $table[$i][8]; | |
$info = pathinfo($file); | |
$original_file_name = basename($file,'.'.$info['extension']); | |
$contents = '<script src="http://cdnapi.kaltura.com/p/'.$partnerId.'/sp/'.$subpartnerId.'/embedIframeJs/uiconf_id/'.$uiconfId.'/partner_id/'.$partnerId.'?autoembed=true&entry_id='.$id.'&playerId=kaltura_player_1401802847&cache_st=1401802847&width=640&height=480"></script>'; | |
$output_html_file = strtolower('folder='.$category_name.'&url='.$original_file_name.'.html'); | |
$handle = fopen($output_html_file, 'w') or die('Cannot open file: '.$output_html_file); | |
fwrite($handle, $contents); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment