Upload Sourcevideo in Entry by API/Script

Hi,

I did some silly. So I Have round about 500 Videos that dont have any flavors and sources.

I Cant reupload them because a big part of this entrys is already embedded.

Is there a way to Upload the Sourcevideos per script?

Hi @Raumen837,

You can use the media service addContent() and updateContent() methods.
There is a script demonstrating usage here:
/opt/kaltura/bin/clip_test.php

In that context it is done for clipping and trimming but it’s the same general idea. Just need to use a different resource type.

Hi @jess,

i tried something but i stuck on one Problem.
I cant create upload Tokens.
If I want to create the uploadToken this error appears:

PHP Fatal error: Call to a member function add() on a non-object in /opt/kaltura/reupload.php on line 30

I dont know what is wrong with this code.
I tried to use the TestConsole. This one works fine. But is not automated.
I have round about 450 Videos.

<?php require_once('/opt/kaltura/web/content/clientlibs/php5/KalturaClient.php'); $userId = null; $expiry = null; $privileges = "disableentitlement"; $partnerId = 102; $secret = 'xxxxxxxxxxxxx'; $type = KalturaSessionType::ADMIN; $config = new KalturaConfiguration($partnerId); $config->serviceUrl = 'https://foobar.foo/'; $client = new KalturaClient($config); $ks = $client->generateSession($secret, $userId, $type, $partnerId); $client->setKs($ks);

$uploadToken = new KalturaUploadToken();
$result = $client->uploadtoken->add($uploadToken);

$uploadTokenId = $result;
$fileData = ‘/opt/kaltura/temp_reupload/0_00kkyg79.mpg’;
$resume = null;
$finalChunk = null;
$resumeAt = null;
$result2 = $client->uploadtoken->upload($uploadTokenId, $fileData, $resume, $finalChunk, $resumeAt);

$entryId = ‘0_00kkyg79’;
$resource = new KalturaUploadedFileTokenResource();
$resource->token = $result;
$conversionProfileId = null;
$advancedOptions = null;
$result = $client->media->updateContent($entryId, $resource, $conversionProfileId, $advancedOptions)

I cant really test the rest of the code. I stuck on this Error.

Did you have an idea ?

Thx for your help (all the time ^^)

Hi @Raumen837,

$result2 = $client->uploadtoken->upload($uploadTokenId, $fileData, $resume, $finalChunk, $resumeAt);

Should be:

$result2 = $client->uploadToken->upload($uploadTokenId, $fileData, $resume, $finalChunk, $resumeAt);

See /opt/kaltura/bin/upload_test.php as reference.