public function getScope()
 {
     $scope = parent::getScope();
     $scope->setPartnerId($this->dbBatchJob->getPartnerId());
     $scope->setParentRaisedJob($this->dbBatchJob);
     return $scope;
 }
 public function getScope()
 {
     $scope = parent::getScope();
     if ($this->raisedJob) {
         $scope->setPartnerId($this->raisedJob->getPartnerId());
         $scope->setParentRaisedJob($this->raisedJob);
     } elseif (method_exists($this->object, 'getPartnerId')) {
         $scope->setPartnerId($this->object->getPartnerId());
     }
     return $scope;
 }
 public function updatedJob(BatchJob $dbBatchJob)
 {
     $data = $dbBatchJob->getData();
     $providerData = $data->getProviderData();
     $entryId = $providerData->getEntryId();
     $partnerId = $dbBatchJob->getPartnerId();
     $spokenLanguage = $providerData->getSpokenLanguage();
     if ($dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_DONT_PROCESS) {
         $transcript = $this->getAssetsByLanguage($entryId, array(TranscriptPlugin::getAssetTypeCoreValue(TranscriptAssetType::TRANSCRIPT)), $spokenLanguage, true);
         if (!$transcript) {
             $transcript = new TranscriptAsset();
             $transcript->setType(TranscriptPlugin::getAssetTypeCoreValue(TranscriptAssetType::TRANSCRIPT));
             $transcript->setEntryId($entryId);
             $transcript->setPartnerId($partnerId);
             $transcript->setLanguage($spokenLanguage);
             $transcript->setContainerFormat(AttachmentType::TEXT);
             $transcript->setAccuracy(self::DEFAULT_ACCURACY);
         }
         $transcript->setStatus(AttachmentAsset::ASSET_STATUS_QUEUED);
         $transcript->save();
         return true;
     }
     $formatsString = $providerData->getCaptionAssetFormats();
     if ($dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FINISHED) {
         $clientHelper = VoicebasePlugin::getClientHelper($providerData->getApiKey(), $providerData->getApiPassword());
         $externalEntryExists = $clientHelper->checkExistingExternalContent($entryId);
         if (!$externalEntryExists) {
             KalturaLog::err('remote content does not exist');
             return true;
         }
         $formatsArray = explode(',', $formatsString);
         $formatsArray[] = "TXT";
         $contentsArray = $clientHelper->getRemoteTranscripts($entryId, $formatsArray);
         KalturaLog::debug('contents are - ' . print_r($contentsArray, true));
         $transcript = $this->getAssetsByLanguage($entryId, array(TranscriptPlugin::getAssetTypeCoreValue(TranscriptAssetType::TRANSCRIPT)), $spokenLanguage, true);
         $captions = $this->getAssetsByLanguage($entryId, array(CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION)), $spokenLanguage);
         $this->setObjectContent($transcript, $contentsArray["TXT"], null, true);
         unset($contentsArray["TXT"]);
         foreach ($contentsArray as $format => $content) {
             $captionFormatConst = constant("KalturaCaptionType::" . $format);
             if (isset($captions[$captionFormatConst])) {
                 $caption = $captions[$captionFormatConst];
             } else {
                 $caption = new CaptionAsset();
                 $caption->setEntryId($entryId);
                 $caption->setPartnerId($partnerId);
                 $caption->setLanguage($spokenLanguage);
                 $caption->setContainerFormat($captionFormatConst);
                 $caption->setAccuracy(self::DEFAULT_ACCURACY);
                 $caption->setStatus(CaptionAsset::ASSET_STATUS_QUEUED);
                 $caption->save();
             }
             $this->setObjectContent($caption, $content, $format);
         }
     }
     return true;
 }
Beispiel #4
0
 public function shouldConsumeJobStatusEvent(BatchJob $dbBatchJob)
 {
     if ($dbBatchJob->getJobType() == BatchJobType::STORAGE_EXPORT && $dbBatchJob->getJobSubType() == KontikiPlugin::getStorageProfileProtocolCoreValue(KontikiStorageProfileProtocol::KONTIKI)) {
         if (KontikiPlugin::isAllowedPartner($dbBatchJob->getPartnerId())) {
             return true;
         }
     }
     return false;
 }
 /**
  * batch decideAddEntryFlavor is the decision layer for adding a single flavor conversion to an entry 
  *
  * @param BatchJob $parentJob
  * @param int $entryId 
  * @param int $flavorParamsId
  * @param string $errDescription
  * @param string $flavorAssetId
  * @return BatchJob 
  */
 public static function decideAddEntryFlavor(BatchJob $parentJob = null, $entryId, $flavorParamsId, &$errDescription)
 {
     KalturaLog::log("entryId [{$entryId}], flavorParamsId [{$flavorParamsId}]");
     $originalFlavorAsset = flavorAssetPeer::retrieveOriginalByEntryId($entryId);
     if (is_null($originalFlavorAsset)) {
         $errDescription = 'Original flavor asset not found';
         KalturaLog::log(__METHOD__ . " - " . $errDescription);
         return null;
     }
     if ($originalFlavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_READY) {
         $errDescription = 'Original flavor asset not ready';
         KalturaLog::log(__METHOD__ . " - " . $errDescription);
         return null;
     }
     $mediaInfoId = null;
     $mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($originalFlavorAsset->getId());
     if ($mediaInfo) {
         $mediaInfoId = $mediaInfo->getId();
     }
     $flavorParams = flavorParamsPeer::retrieveByPK($flavorParamsId);
     $flavor = self::validateFlavorAndMediaInfo($flavorParams, $mediaInfo, $errDescription);
     if (is_null($flavor)) {
         KalturaLog::log(__METHOD__ . " - Failed to validate media info [{$errDescription}]");
         return null;
     }
     if ($parentJob) {
         // prefer the partner id from the parent job, although it should be the same
         $partnerId = $parentJob->getPartnerId();
     } else {
         $partnerId = $originalFlavorAsset->getPartnerId();
     }
     $flavorAssetId = null;
     $flavorAsset = flavorAssetPeer::retrieveByEntryIdAndFlavorParams($entryId, $flavorParamsId);
     if ($flavorAsset) {
         $flavorAssetId = $flavorAsset->getId();
     }
     $srcSyncKey = $originalFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     $flavor->_force = true;
     // force to convert the flavor, even if none complied
     $flavor->setReadyBehavior(flavorParamsConversionProfile::READY_BEHAVIOR_IGNORE);
     // should not be taken in completion rules check
     $flavorAsset = kBatchManager::createFlavorAsset($flavor, $partnerId, $entryId, $flavorAssetId);
     if (!$flavorAsset) {
         KalturaLog::err(__METHOD__ . " - Failed to create flavor asset");
         return null;
     }
     $flavorAssetId = $flavorAsset->getId();
     $collectionTag = $flavor->getCollectionTag();
     if ($collectionTag) {
         $entry = entryPeer::retrieveByPK($entryId);
         if (!$entry) {
             throw new APIException(APIErrors::INVALID_ENTRY, $parentJob, $entryId);
         }
         $dbConvertCollectionJob = null;
         if ($parentJob) {
             $dbConvertCollectionJob = $parentJob->createChild(false);
             $dbConvertCollectionJob->setEntryId($entryId);
             $dbConvertCollectionJob->save();
         }
         $flavorAssets = flavorAssetPeer::retrieveByEntryId($entryId);
         $flavorAssets = flavorAssetPeer::filterByTag($flavorAssets, $collectionTag);
         $flavors = array();
         foreach ($flavorAssets as $tagedFlavorAsset) {
             if ($tagedFlavorAsset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_NOT_APPLICABLE || $tagedFlavorAsset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_DELETED) {
                 continue;
             }
             $flavorParamsOutput = flavorParamsOutputPeer::retrieveByFlavorAssetId($tagedFlavorAsset->getId());
             if (is_null($flavorParamsOutput)) {
                 KalturaLog::log("Creating flavor params output for asset [" . $tagedFlavorAsset->getId() . "]");
                 $flavorParams = flavorParamsPeer::retrieveByPK($tagedFlavorAsset->getId());
                 $flavorParamsOutput = self::validateFlavorAndMediaInfo($flavorParams, $mediaInfo, $errDescription);
                 if (is_null($flavorParamsOutput)) {
                     KalturaLog::log(__METHOD__ . " - Failed to validate media info [{$errDescription}]");
                     continue;
                 }
             }
             if ($flavorParamsOutput) {
                 KalturaLog::log("Adding Collection flavor [" . $flavorParamsOutput->getId() . "] for asset [" . $tagedFlavorAsset->getId() . "]");
                 $flavors[$tagedFlavorAsset->getId()] = flavorParamsOutputPeer::retrieveByFlavorAssetId($tagedFlavorAsset->getId());
             }
         }
         if ($flavorAssetId) {
             KalturaLog::log("Updating Collection flavor [" . $flavor->getId() . "] for asset [" . $tagedFlavorAsset->getId() . "]");
             $flavors[$flavorAssetId] = $flavor;
         }
         switch ($collectionTag) {
             case flavorParams::TAG_ISM:
                 KalturaLog::log("Calling addConvertIsmCollectionJob with [" . count($flavors) . "] flavor params");
                 return kJobsManager::addConvertIsmCollectionJob($collectionTag, $srcSyncKey, $entry, $parentJob, $flavors, $dbConvertCollectionJob);
             default:
                 KalturaLog::log("Error: Invalid collection tag [{$collectionTag}]");
                 return null;
         }
     }
     $dbConvertFlavorJob = null;
     if ($parentJob) {
         $dbConvertFlavorJob = $parentJob->createChild(false);
         $dbConvertFlavorJob->setEntryId($entryId);
         $dbConvertFlavorJob->save();
     }
     return kJobsManager::addFlavorConvertJob($srcSyncKey, $flavor, $flavorAsset->getId(), $mediaInfoId, $parentJob, null, $dbConvertFlavorJob);
 }
Beispiel #6
0
 public static function handleBulkDownloadFinished(BatchJob $dbBatchJob, kBulkDownloadJobData $data, BatchJob $twinJob = null)
 {
     if ($dbBatchJob->getAbort()) {
         return $dbBatchJob;
     }
     $partner = PartnerPeer::retrieveByPK($dbBatchJob->getPartnerId());
     if (!$partner) {
         KalturaLog::err("Partner id [" . $dbBatchJob->getPartnerId() . "] not found, not sending mail");
         return $dbBatchJob;
     }
     $adminName = $partner->getAdminName();
     $entryIds = explode(",", $data->getEntryIds());
     $flavorParamsId = $data->getFlavorParamsId();
     $links = array();
     foreach ($entryIds as $entryId) {
         $entry = entryPeer::retrieveByPK($entryId);
         if (is_null($entry)) {
             continue;
         }
         $link = $entry->getDownloadAssetUrl($flavorParamsId);
         if (is_null($link)) {
             $link = "Failed to prepare";
         } else {
             $link = '<a href="' . $link . '">Download</a>';
         }
         $links[] = $entry->getName() . " - " . $link;
     }
     $linksHtml = implode("<br />", $links);
     // add mail job
     $jobData = new kMailJobData();
     $jobData->setIsHtml(true);
     $jobData->setMailPriority(kMailJobData::MAIL_PRIORITY_NORMAL);
     $jobData->setStatus(kMailJobData::MAIL_STATUS_PENDING);
     if (count($links) <= 1) {
         $jobData->setMailType(62);
     } else {
         $jobData->setMailType(63);
     }
     $jobData->setBodyParamsArray(array($adminName, $linksHtml));
     $jobData->setFromEmail(kConf::get("batch_download_video_sender_email"));
     $jobData->setFromName(kConf::get("batch_download_video_sender_name"));
     $kuser = kuserPeer::getKuserByPartnerAndUid($dbBatchJob->getPartnerId(), $data->getPuserId());
     if ($kuser) {
         $recipientEmail = $kuser->getEmail();
     } else {
         KalturaLog::err('Cannot find kuser with puserId [' . $dbBatchJob->getPartnerId() . '] and partnerId [' . $data->getPuserId() . ']. Sending mail to admin user instead.');
         $recipientEmail = $partner->getAdminEmail();
     }
     $jobData->setRecipientEmail($recipientEmail);
     $jobData->setSubjectParamsArray(array());
     kJobsManager::addJob($dbBatchJob->createChild(), $jobData, BatchJobType::MAIL, $jobData->getMailType());
     return $dbBatchJob;
 }
 public static function prepareNotificationData($url, $signature_key, BatchJob $job, $prefix = null)
 {
     $type = $job->getData()->getType();
     $params = array("notification_id" => $job->getId(), "notification_type" => $job->getData()->getTypeAsString(), "puser_id" => $job->getData()->getUserId(), "partner_id" => $job->getPartnerId());
     if (kNotificationJobData::isEntryNotification($type)) {
         $params["entry_id"] = $job->getData()->getObjectId();
     }
     //$params["entryId"] = $not->getObjectId();
     if (kNotificationJobData::isKshowNotification($type)) {
         $params["kshow_id"] = $job->getData()->getObjectId();
     }
     //			$params["kshowId"] = $not->getObjectId();
     $object_data_params = myNotificationMgr::getDataAsArray($job->getData()->getData());
     if ($object_data_params) {
         $params = array_merge($params, $object_data_params);
     }
     $params = self::fixParams($params, $prefix);
     $params['signed_fields'] = '';
     foreach ($params as $key => $value) {
         $params['signed_fields'] .= $key . ',';
     }
     return self::signParams($signature_key, $params);
 }
 /**
  * batch decideAddEntryFlavor is the decision layer for adding a single flavor conversion to an entry
  *
  * @param BatchJob $parentJob
  * @param int $entryId
  * @param int $flavorParamsId
  * @param string $errDescription
  * @param string $flavorAssetId
  * @param array<kOperationAttributes> $dynamicAttributes
  * @return BatchJob
  */
 public static function decideAddEntryFlavor(BatchJob $parentJob = null, $entryId, $flavorParamsId, &$errDescription, $flavorAssetId = null, array $dynamicAttributes = array(), $priority = 0)
 {
     KalturaLog::log("entryId [{$entryId}], flavorParamsId [{$flavorParamsId}]");
     $originalFlavorAsset = assetPeer::retrieveOriginalByEntryId($entryId);
     if (is_null($originalFlavorAsset)) {
         $errDescription = 'Original flavor asset not found';
         KalturaLog::err($errDescription);
         return null;
     }
     if ($originalFlavorAsset->getId() != $flavorAssetId && !$originalFlavorAsset->isLocalReadyStatus()) {
         $errDescription = 'Original flavor asset not ready';
         KalturaLog::err($errDescription);
         return null;
     }
     // TODO - if source flavor is remote storage, create import job and mark the flavor as FLAVOR_ASSET_STATUS_WAIT_FOR_CONVERT
     $mediaInfoId = null;
     $mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($originalFlavorAsset->getId());
     if ($mediaInfo) {
         $mediaInfoId = $mediaInfo->getId();
     }
     $flavorParams = assetParamsPeer::retrieveByPK($flavorParamsId);
     if (!$flavorParams) {
         KalturaLog::err("Flavor Params Id [{$flavorParamsId}] not found");
         return null;
     }
     $flavorParams->setDynamicAttributes($dynamicAttributes);
     self::adjustAssetParams($entryId, array($flavorParams));
     $flavor = self::validateFlavorAndMediaInfo($flavorParams, $mediaInfo, $errDescription);
     if (is_null($flavor)) {
         KalturaLog::err("Failed to validate media info [{$errDescription}]");
         return null;
     }
     if ($parentJob) {
         // prefer the partner id from the parent job, although it should be the same
         $partnerId = $parentJob->getPartnerId();
     } else {
         $partnerId = $originalFlavorAsset->getPartnerId();
     }
     if (is_null($flavorAssetId)) {
         $flavorAsset = assetPeer::retrieveByEntryIdAndParams($entryId, $flavorParamsId);
         if ($flavorAsset) {
             $flavorAssetId = $flavorAsset->getId();
         }
     }
     $flavor->_force = true;
     // force to convert the flavor, even if none complied
     $conversionProfile = myPartnerUtils::getConversionProfile2ForEntry($entryId);
     if ($conversionProfile) {
         $flavorParamsConversionProfile = flavorParamsConversionProfilePeer::retrieveByFlavorParamsAndConversionProfile($flavor->getFlavorParamsId(), $conversionProfile->getId());
         if ($flavorParamsConversionProfile) {
             $flavor->setReadyBehavior($flavorParamsConversionProfile->getReadyBehavior());
         }
     }
     $flavorAsset = kBatchManager::createFlavorAsset($flavor, $partnerId, $entryId, $flavorAssetId);
     if (!$flavorAsset) {
         return null;
     }
     if (!$flavorAsset->getIsOriginal()) {
         $flavor->setReadyBehavior(flavorParamsConversionProfile::READY_BEHAVIOR_IGNORE);
     }
     // should not be taken in completion rules check
     $flavorAssetId = $flavorAsset->getId();
     $collectionTag = $flavor->getCollectionTag();
     /*
      * CHANGE: collection porcessing only for ExpressionEncoder jobs
      * to allow FFmpeg/ISMV processing
      */
     KalturaLog::log("Check for collection case - asset(" . $flavorAssetId . "),engines(" . $flavor->getConversionEngines() . ")");
     if ($collectionTag && $flavor->getConversionEngines() == conversionEngineType::EXPRESSION_ENCODER3) {
         $entry = entryPeer::retrieveByPK($entryId);
         if (!$entry) {
             throw new APIException(APIErrors::INVALID_ENTRY, $parentJob, $entryId);
         }
         $flavorAssets = assetPeer::retrieveFlavorsByEntryId($entryId);
         $flavorAssets = assetPeer::filterByTag($flavorAssets, $collectionTag);
         $flavors = array();
         foreach ($flavorAssets as $tagedFlavorAsset) {
             $errDescription = null;
             if ($tagedFlavorAsset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_NOT_APPLICABLE || $tagedFlavorAsset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_DELETED) {
                 continue;
             }
             $flavorParamsOutput = assetParamsOutputPeer::retrieveByAssetId($tagedFlavorAsset->getId());
             if (is_null($flavorParamsOutput)) {
                 KalturaLog::log("Creating flavor params output for asset [" . $tagedFlavorAsset->getId() . "]");
                 $flavorParams = assetParamsPeer::retrieveByPK($tagedFlavorAsset->getId());
                 self::adjustAssetParams($entryId, array($flavorParams));
                 $flavorParamsOutput = self::validateFlavorAndMediaInfo($flavorParams, $mediaInfo, $errDescription);
                 if (is_null($flavorParamsOutput)) {
                     KalturaLog::err("Failed to validate media info [{$errDescription}]");
                     continue;
                 }
             }
             if ($flavorParamsOutput) {
                 KalturaLog::log("Adding Collection flavor [" . $flavorParamsOutput->getId() . "] for asset [" . $tagedFlavorAsset->getId() . "]");
                 $flavors[$tagedFlavorAsset->getId()] = assetParamsOutputPeer::retrieveByAssetId($tagedFlavorAsset->getId());
             }
         }
         if ($flavorAssetId) {
             KalturaLog::log("Updating Collection flavor [" . $flavor->getId() . "] for asset [" . $tagedFlavorAsset->getId() . "]");
             $flavors[$flavorAssetId] = $flavor;
         }
         return self::decideCollectionConvert($collectionTag, $originalFlavorAsset, $entry, $parentJob, $flavors);
     } else {
         return self::decideFlavorConvert($flavorAsset, $flavor, $originalFlavorAsset, $conversionProfile->getId(), $mediaInfoId, $parentJob, null, false, $priority);
     }
 }
Beispiel #9
0
 public static function handleLiveReportExportAborted(BatchJob $dbBatchJob, kLiveReportExportJobData $data)
 {
     $time = date("m-d-y H:i", $data->timeReference + $data->timeZoneOffset);
     $email_id = MailType::MAIL_TYPE_LIVE_REPORT_EXPORT_ABORT;
     $params = array($dbBatchJob->getPartner()->getName(), $time, $dbBatchJob->getId());
     $titleParams = array($time);
     kJobsManager::addMailJob(null, 0, $dbBatchJob->getPartnerId(), $email_id, kMailJobData::MAIL_PRIORITY_NORMAL, kConf::get("live_report_sender_email"), kConf::get("live_report_sender_name"), $data->recipientEmail, $params, $titleParams);
     return $dbBatchJob;
 }
 /**
  * @param BatchJob $batchJob
  * @param $data
  * @param int $type
  * @param int $subType
  * @return BatchJob
  */
 public static function addJob(BatchJob $batchJob, $data, $type, $subType = null)
 {
     $batchJob->setJobType($type);
     $batchJob->setJobSubType($subType);
     $batchJob->setData($data);
     if (!$batchJob->getParentJobId() && $batchJob->getEntryId()) {
         $currentJob = kBatchManager::getCurrentUpdatingJob();
         if ($currentJob && $currentJob->getEntryId() == $batchJob->getEntryId()) {
             $batchJob->setParentJobId($currentJob->getId());
             $batchJob->setBulkJobId($currentJob->getBulkJobId());
             $batchJob->setRootJobId($currentJob->getRootJobId());
         } else {
             $entry = entryPeer::retrieveByPKNoFilter($batchJob->getEntryId());
             // some jobs could be on deleted entry
             if ($entry) {
                 $batchJob->setRootJobId($entry->getBulkUploadId());
                 $batchJob->setBulkJobId($entry->getBulkUploadId());
             }
         }
     }
     // validate partner id
     $partnerId = $batchJob->getPartnerId();
     //		if(!$partnerId)
     //			throw new APIException(APIErrors::PARTNER_NOT_SET);
     // validate that partner exists
     $partner = PartnerPeer::retrieveByPK($partnerId);
     if (!$partner) {
         KalturaLog::err("Invalid partner id [{$partnerId}]");
         throw new APIException(APIErrors::INVALID_PARTNER_ID, $partnerId);
     }
     // set the priority and work group
     $batchJob->setPriority($partner->getPriority($batchJob->getBulkJobId()));
     $batchJob = self::updateBatchJob($batchJob, BatchJob::BATCHJOB_STATUS_PENDING);
     // look for identical jobs
     $twinJobs = BatchJobPeer::retrieveDuplicated($type, $data);
     $twinJob = null;
     if (count($twinJobs)) {
         foreach ($twinJobs as $currentTwinJob) {
             if ($currentTwinJob->getId() != $batchJob->getId()) {
                 $twinJob = reset($twinJobs);
             }
         }
     }
     if (!is_null($twinJob)) {
         $batchJob->setTwinJobId($twinJob->getId());
         if (!kConf::get("batch_ignore_duplication")) {
             $batchJob = self::updateBatchJob($batchJob, $twinJob->getStatus(), $twinJob);
         } else {
             $batchJob->save();
         }
     }
     return $batchJob;
 }
 public static function exportSourceAssetFromJob(BatchJob $dbBatchJob)
 {
     // convert profile finished - export source flavor
     if ($dbBatchJob->getJobType() == BatchJobType::CONVERT_PROFILE) {
         $externalStorages = StorageProfilePeer::retrieveAutomaticByPartnerId($dbBatchJob->getPartnerId());
         $sourceFlavor = assetPeer::retrieveOriginalByEntryId($dbBatchJob->getEntryId());
         if (!$sourceFlavor) {
             KalturaLog::debug('Cannot find source flavor for entry id [' . $dbBatchJob->getEntryId() . ']');
         } else {
             if (!$sourceFlavor->isLocalReadyStatus()) {
                 KalturaLog::debug('Source flavor id [' . $sourceFlavor->getId() . '] has status [' . $sourceFlavor->getStatus() . '] - not ready for export');
             } else {
                 foreach ($externalStorages as $externalStorage) {
                     if ($externalStorage->triggerFitsReadyAsset($dbBatchJob->getEntryId())) {
                         self::exportFlavorAsset($sourceFlavor, $externalStorage);
                     }
                 }
             }
         }
     }
     // convert collection finished - export ism and ismc files
     if ($dbBatchJob->getJobType() == BatchJobType::CONVERT_COLLECTION && $dbBatchJob->getJobSubType() == conversionEngineType::EXPRESSION_ENCODER3) {
         $entry = $dbBatchJob->getEntry();
         $externalStorages = StorageProfilePeer::retrieveAutomaticByPartnerId($dbBatchJob->getPartnerId());
         foreach ($externalStorages as $externalStorage) {
             if ($externalStorage->triggerFitsReadyAsset($entry->getId())) {
                 $ismKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM);
                 if (kFileSyncUtils::fileSync_exists($ismKey)) {
                     self::export($entry, $externalStorage, $ismKey);
                 }
                 $ismcKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISMC);
                 if (kFileSyncUtils::fileSync_exists($ismcKey)) {
                     self::export($entry, $externalStorage, $ismcKey);
                 }
             }
         }
     }
     return true;
 }
Beispiel #12
0
 public function updatedJob(BatchJob $dbBatchJob)
 {
     $data = $dbBatchJob->getData();
     $providerData = $data->getProviderData();
     $entryId = $providerData->getEntryId();
     $partnerId = $dbBatchJob->getPartnerId();
     $spokenLanguage = $providerData->getSpokenLanguage();
     $transcript = $this->getAssetsByLanguage($entryId, array(TranscriptPlugin::getAssetTypeCoreValue(TranscriptAssetType::TRANSCRIPT)), $spokenLanguage, true);
     if ($dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FAILED) {
         if ($transcript) {
             $transcript->setStatus(AttachmentAsset::FLAVOR_ASSET_STATUS_ERROR);
             $transcript->save();
         }
     }
     if ($dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_DONT_PROCESS) {
         if (!$transcript) {
             $transcript = new TranscriptAsset();
             $transcript->setType(TranscriptPlugin::getAssetTypeCoreValue(TranscriptAssetType::TRANSCRIPT));
             $transcript->setEntryId($entryId);
             $transcript->setPartnerId($partnerId);
             $transcript->setLanguage($spokenLanguage);
             $transcript->setContainerFormat(AttachmentType::TEXT);
         }
         $transcript->setStatus(AttachmentAsset::ASSET_STATUS_QUEUED);
         $transcript->save();
         return true;
     }
     $formatsString = $providerData->getCaptionAssetFormats();
     if ($dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FINISHED) {
         $clientHelper = Cielo24Plugin::getClientHelper($providerData->getUsername(), $providerData->getPassword());
         $remoteJobId = $clientHelper->getRemoteFinishedJobId($entryId);
         if (!$remoteJobId) {
             KalturaLog::err('remote content does not exist');
             return true;
         }
         $formatsArray = explode(',', $formatsString);
         $transcriptContent = $clientHelper->getRemoteTranscript($remoteJobId);
         KalturaLog::debug("transcript content - {$transcriptContent}");
         $captionsContentArray = $clientHelper->getRemoteCaptions($remoteJobId, $formatsArray);
         KalturaLog::debug("captions content - " . print_r($captionsContentArray, true));
         $captions = $this->getAssetsByLanguage($entryId, array(CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION)), $spokenLanguage);
         switch ($providerData->getFidelity()) {
             case KalturaCielo24Fidelity::MECHANICAL:
                 $accuracyRate = self::MECHNICAL_TRANSCRIPTION_ACCURACY_VALUE;
                 break;
             case KalturaCielo24Fidelity::PREMIUM:
                 $accuracyRate = self::PREMIUM_TRANSCRIPTION_ACCURACY_VALUE;
                 break;
             case KalturaCielo24Fidelity::PROFESSIONAL:
                 $accuracyRate = self::PROFESSIONAL_TRANSCRIPTION_ACCURACY_VALUE;
                 break;
         }
         $this->setObjectContent($transcript, $transcriptContent, $accuracyRate, null, true);
         foreach ($captionsContentArray as $format => $content) {
             $captionFormatConst = constant("KalturaCaptionType::" . $format);
             if (isset($captions[$captionFormatConst])) {
                 $caption = $captions[$captionFormatConst];
             } else {
                 $caption = new CaptionAsset();
                 $caption->setEntryId($entryId);
                 $caption->setPartnerId($partnerId);
                 $caption->setLanguage($spokenLanguage);
                 $caption->setContainerFormat($captionFormatConst);
                 $caption->setStatus(CaptionAsset::ASSET_STATUS_QUEUED);
                 $caption->save();
             }
             $this->setObjectContent($caption, $content, $accuracyRate, $format);
         }
     }
     return true;
 }
Beispiel #13
0
 public static function exportSourceAssetFromJob(BatchJob $dbBatchJob)
 {
     // convert collection finished - export ism and ismc files
     if ($dbBatchJob->getJobType() == BatchJobType::CONVERT_COLLECTION && $dbBatchJob->getJobSubType() == conversionEngineType::EXPRESSION_ENCODER3) {
         $entry = $dbBatchJob->getEntry();
         $externalStorages = StorageProfilePeer::retrieveAutomaticByPartnerId($dbBatchJob->getPartnerId());
         foreach ($externalStorages as $externalStorage) {
             if ($externalStorage->triggerFitsReadyAsset($entry->getId())) {
                 $ismKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM);
                 if (kFileSyncUtils::fileSync_exists($ismKey)) {
                     self::export($entry, $externalStorage, $ismKey);
                 }
                 $ismcKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISMC);
                 if (kFileSyncUtils::fileSync_exists($ismcKey)) {
                     self::export($entry, $externalStorage, $ismcKey);
                 }
             }
         }
     }
     return true;
 }
Beispiel #14
0
 /**
  * @param BatchJob $dbBatchJob
  * @param BatchJob $twinJob
  * @return bool true if should continue to the next consumer
  */
 public function updatedJob(BatchJob $dbBatchJob, BatchJob $twinJob = null)
 {
     if ($dbBatchJob->getStatus() != BatchJob::BATCHJOB_STATUS_FINISHED) {
         return true;
     }
     // convert profile finished - export source flavor
     if ($dbBatchJob->getJobType() == BatchJobType::CONVERT_PROFILE) {
         $externalStorages = StorageProfilePeer::retrieveAutomaticByPartnerId($dbBatchJob->getPartnerId());
         foreach ($externalStorages as $externalStorage) {
             if ($externalStorage->getTrigger() == StorageProfile::STORAGE_TEMP_TRIGGER_FLAVOR_READY || $externalStorage->getTrigger() == StorageProfile::STORAGE_TEMP_TRIGGER_MODERATION_APPROVED && $dbBatchJob->getEntry()->getModerationStatus() == entry::ENTRY_MODERATION_STATUS_APPROVED) {
                 $sourceFlavor = flavorAssetPeer::retrieveOriginalReadyByEntryId($dbBatchJob->getEntryId());
                 if ($sourceFlavor) {
                     $this->exportFlavorAsset($sourceFlavor, $externalStorage);
                 }
             }
         }
     }
     // convert collection finished - export ism and ismc files
     if ($dbBatchJob->getJobType() == BatchJobType::CONVERT_COLLECTION && $dbBatchJob->getJobSubType() == conversionEngineType::EXPRESSION_ENCODER3) {
         $entry = $dbBatchJob->getEntry();
         $externalStorages = StorageProfilePeer::retrieveAutomaticByPartnerId($dbBatchJob->getPartnerId());
         foreach ($externalStorages as $externalStorage) {
             if ($externalStorage->getTrigger() == StorageProfile::STORAGE_TEMP_TRIGGER_FLAVOR_READY || $externalStorage->getTrigger() == StorageProfile::STORAGE_TEMP_TRIGGER_MODERATION_APPROVED && $entry->getModerationStatus() == entry::ENTRY_MODERATION_STATUS_APPROVED) {
                 $ismKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM);
                 if (kFileSyncUtils::fileSync_exists($ismKey)) {
                     $this->export($entry, $externalStorage, $ismKey);
                 }
                 $ismcKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISMC);
                 if (kFileSyncUtils::fileSync_exists($ismcKey)) {
                     $this->export($entry, $externalStorage, $ismcKey);
                 }
             }
         }
     }
     return true;
 }