Quantcast
Channel: Kaltura - Latest posts
Viewing all articles
Browse latest Browse all 7410

Use the PHP API to get a list of uncaptioned videos

$
0
0

Hi,

Here it is:

<?php


if ($argc < 3){
    echo "\nUsage: ".$argv[0] . ' <partner id> <admin secret> <service url>'."\n\n";
    exit (1);
}
require_once('/opt/kaltura/web/content/clientlibs/php5/KalturaClient.php');
$userId = null;
$expiry = null;
$privileges = null;
$partnerId=$argv[1];
$secret = $argv[2];
$type = KalturaSessionType::ADMIN;
$config = new KalturaConfiguration($partnerId);
$config->serviceUrl = $argv[3];
$client = new KalturaClient($config);
$ks = $client->session->start($secret, $userId, $type, $partnerId, $expiry, $privileges);
$client->setKs($ks);

$filter = new KalturaMediaEntryFilter();
$total_media_entries = $client->media->count($filter);
$pager = new KalturaFilterPager();
$page_index=1;
$pager->pageSize = 500;
$processed_entries=0;

while ($processed_entries < $total_media_entries){
    $pager->pageIndex=$page_index;
    $result = $client->media->listAction($filter, $pager);
        foreach ($result->objects as $entry) {
            $processed_entries++;
            $filter = new KalturaAssetFilter();
            $filter->entryIdEqual = $entry->id;
            $pager = null;
            $captionPlugin = KalturaCaptionClientPlugin::get($client);
            $cap_result = $captionPlugin->captionAsset->listAction($filter, $pager);
            if ($cap_result->totalCount){
                echo $cap_result->totalCount. ' found for entry ID: '. $entry->id. "\n\n";
                foreach ($cap_result->objects as $cap_obj) {
                    echo 'Caption lang is: '. $cap_obj->language."\nCaption ID is: ".$cap_obj->id."\n\n";
                }
                echo "==================\n";
            }
        }
    $page_index++;
}

Run like so:

$ captions.php <partner id> <admin secret> <service url>

Sample output:

1 found for entry ID: 0_0cgmx910

Caption lang is: English
Caption ID is: 0_30975jlh

==================
3 found for entry ID: 0_ckl8o219

Caption lang is: English
Caption ID is: 0_bvdv7yor

Caption lang is: English
Caption ID is: 0_hrxr8xdc

Caption lang is: English
Caption ID is: 0_sygf2hu0

==================

Viewing all articles
Browse latest Browse all 7410

Trending Articles