Blogs

configuring the script for removing deleted videos in Kaltura CE4

June 19, 2012 by Arvind Das

I have seen while deleting videos ,audios and images from Kaltura Management Console , these deleted videos still reside on the disk and consume space.Here , I have explained how u can make a cron job which continuously monitor your file system and delete these file which is no longer available on KMC

  • First of all, download “latest client api libraries” from kaltura admin console. Steps:
    • Log in to your admin_console
    • Go to developer TAB.
    • Download latest php5 client libraries.
  • Create a directory named storagecleanup in /opt/kaltura
  • Create a lib folder in storagecleanup and move all downloaded client libraries into it.
    • (Change permission of all scripts to 777)
  • Now perform following steps
    partner_id:partner_admin_secret
    
    deleteData($splitdelimit[0],$splitdelimit[1]);               //call file deletion method    
    
    }
    
    ?>
    
    serviceUrl = 'http://your_server_address/';
    
    $client = new KalturaClient($config);
    
    $secret = null;
    
    $userId = null;
    
    $type = null;
    
    $partnerId = null;
    
    $expiry = null;
    
    $privileges = null;
    
    $secret = KALTURA_PARTNER_SERVICE_SECRET;
    
    $type = KalturaSessionType::ADMIN;
    
    $partnerId = KALTURA_PARTNER_ID;
    
    $results = $client->session->start($secret, $userId, $type, $partnerId, $expiry, $privileges);
    
    $filter = null;
    
    $pager = null;
    
    $client->setKs($results);
    
    $filter = new KalturaBaseEntryFilter();
    
    $filter->statusEqual = KalturaEntryStatus::DELETED;
    
    $results = $client->baseEntry->listAction($filter, $pager);
    
                   foreach($results->objects as $item)
    
                   {
    
                           $entryRelatedFiles = glob($path.'/'.$item->id.'*');
    
                           foreach($entryRelatedFiles as $filename)
    
                           {  echo "file name:".$filename;
    
                                   //unlink($filename);                    //remove “//” to delete files
    
                           }
    
                   }
    
    }
    
    }
    
    ?>
    
    #!/bin/bash
    
    /bin/echo "disk cleanup started";
    
    /bin/echo `date`
    
    /usr/bin/php /opt/kaltura/storagecleanup/AllPublishersStorageCleanup.php >> /opt/kaltura/log/diskcleanup.log
    
    /bin/echo "disk cleanup completed";
    
    /bin/echo `date`
    
    */2 * * * * /opt/kaltura/storagecleanup/diskcleanup.sh >> /opt/kaltura/log/crontabrun.log 2>&1 &
    
    • Create a file “publishercredentials.properties” to store publisher’s credentials and store credentials as
    • Create a file as “AllPublishersStorageCleanup.php” to read content from credentials file. Add this code to it
    • Create a file as “StorageCleanup.php” which deletes the files with DELETED flag from disk. Add code to it as
    • Create a script as “diskcleanup.sh ” containing command to execute php file. Add command as
    • Edit your crontab and add following command to set it to loop in specified time

Comments

  • Posted : by ARUN

    partner_id:partner_admin_secret plse give an example to enter the values...I am new in linux

  • Posted : by Arvind

    Hi, In file publishercredentials.properties , you can enter values as 100:xxxxxxxxxxxx (partner_id:partner_admin_secret). Please make sure that you enter all these fields line by line.Admin secret you can find in account settings. Cheers!

Leave a comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Follow Us

Recent Entries

Contact Us

We are based in Gurgaon,India.

For more information please email at info@oodlestechnologies.com, call +91.124.4053373 or write to us at Oodles Technologies Pvt Ltd, FF-E307, Sushant Arcade, Sushant Lok-I, Gurgaon , India, 122002.

You can also fill out the contact form below:

send copy to me