configuring the script for removing deleted videos in Kaltura CE4

Posted By : Arvind Das | 19-Jun-2012

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

About Author

Author Image
Arvind Das

Technical Product Manager experienced in developing Real Time Planning Solutions, Video CMS with experience in Product Management and technical expertise in Reactive applications , Micro-services . Spending most of his time in planning , new solutions.

Request for Proposal

Name is required

Comment is required

Sending message..