/** * @param flavorAsset $flavorAsset * @return string */ protected function doGetFlavorAssetUrl(flavorAsset $flavorAsset) { $entry = $flavorAsset->getentry(); $partnerId = $entry->getPartnerId(); $subpId = $entry->getSubpId(); $flavorAssetId = $flavorAsset->getId(); $partnerPath = myPartnerUtils::getUrlForPartner($partnerId, $subpId); $this->setFileExtension($flavorAsset->getFileExt()); $versionString = $this->getFlavorVersionString($flavorAsset); $url = "/s{$partnerPath}/serveFlavor/entryId/" . $flavorAsset->getEntryId() . "{$versionString}/flavorId/{$flavorAssetId}"; if ($this->clipTo) { $url .= "/clipTo/{$this->clipTo}"; } if ($this->extention) { $url .= "/name/a.{$this->extention}"; } $url = str_replace('\\', '/', $url); if ($this->protocol != StorageProfile::PLAY_FORMAT_RTMP) { $url .= '?novar=0'; $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $seekFromBytes = $this->getSeekFromBytes(kFileSyncUtils::getLocalFilePathForKey($syncKey)); if ($seekFromBytes) { $url .= '&fs=' . $seekFromBytes; } } else { if ($this->extention && strtolower($this->extention) != 'flv' || $this->containerFormat && strtolower($this->containerFormat) != 'flash video') { $url = "mp4:{$url}"; } } return $url; }
public function __construct(KalturaDistributionJobData $distributionJobData = null) { if (!$distributionJobData) { return; } if (!$distributionJobData->distributionProfile instanceof KalturaYoutubeApiDistributionProfile) { return; } $flavorAssets = flavorAssetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->flavorAssetIds)); if (count($flavorAssets)) { // if we have specific flavor assets for this distribution, grab the first one $flavorAsset = reset($flavorAssets); } else { // take the source asset $flavorAsset = flavorAssetPeer::retrieveOriginalReadyByEntryId($distributionJobData->entryDistribution->entryId); } if ($flavorAsset) { $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $this->videoAssetFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, true); } $thumbAssets = thumbAssetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->thumbAssetIds)); if (count($thumbAssets)) { $syncKey = reset($thumbAssets)->getSyncKey(thumbAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $this->thumbAssetFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, true); } $this->loadPlaylistsFromMetadata($distributionJobData->entryDistribution->entryId, $distributionJobData->distributionProfile); $entryDistributionDb = EntryDistributionPeer::retrieveByPK($distributionJobData->entryDistributionId); // if ($entryDistributionDb) // $this->currentPlaylists = $entryDistributionDb->getFromCustomData('currentPlaylists'); // else // KalturaLog::err('Entry distribution ['.$distributionJobData->entryDistributionId.'] not found'); }
private function addEcSeek($url, $syncKey) { $seekTime = $this->params->getSeekFromTime(); if (!empty($seekTime)) { // remove default seekFrom parameter $url = preg_replace('/seekFrom\\/-?[0-9]*\\/?/', '', $url); $url = rtrim($url, '/'); // check if seekFromTime is set to something significant if ($seekTime > 0) { // check if flv or not $extension = $this->params->getFileExtension(); $containerFormat = $this->params->getContainerFormat(); $notFlvFormat = $extension && strtolower($extension) != 'flv' || $containerFormat && strtolower($containerFormat) != 'flash video'; if ($notFlvFormat) { // not flv - add ec_seek value in seconds $url .= '?ec_seek=' . $seekTime / 1000; // convert milliseconds to seconds } else { // flv - add ec_seek value in bytes $url .= '?ec_seek=' . $this->getSeekFromBytes(kFileSyncUtils::getLocalFilePathForKey($syncKey)); } } } return $url; }
public function __construct(KalturaDistributionJobData $distributionJobData = null) { parent::__construct($distributionJobData); if (!$distributionJobData) { return; } if (!$distributionJobData->distributionProfile instanceof KalturaUverseDistributionProfile) { return; } $flavorAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->flavorAssetIds)); if (count($flavorAssets)) { // if we have specific flavor assets for this distribution, grab the first one $flavorAsset = reset($flavorAssets); } else { // take the source asset $flavorAsset = assetPeer::retrieveOriginalReadyByEntryId($distributionJobData->entryDistribution->entryId); } if ($flavorAsset) { $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); if (kFileSyncUtils::fileSync_exists($syncKey)) { $this->localAssetFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); } } $entryDistributionDb = EntryDistributionPeer::retrieveByPK($distributionJobData->entryDistributionId); if ($entryDistributionDb) { $this->remoteAssetUrl = $entryDistributionDb->getFromCustomData(UverseEntryDistributionCustomDataField::REMOTE_ASSET_URL); $this->remoteAssetFileName = $entryDistributionDb->getFromCustomData(UverseEntryDistributionCustomDataField::REMOTE_ASSET_FILE_NAME); } else { KalturaLog::err('Entry distribution [' . $distributionJobData->entryDistributionId . '] not found'); } }
public function __construct(KalturaDistributionJobData $distributionJobData = null) { if (!$distributionJobData) { return; } if (!$distributionJobData->distributionProfile instanceof KalturaDailymotionDistributionProfile) { return; } $flavorAssets = flavorAssetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->flavorAssetIds)); if (count($flavorAssets)) { // if we have specific flavor assets for this distribution, grab the first one $flavorAsset = reset($flavorAssets); } else { // take the source asset $flavorAsset = flavorAssetPeer::retrieveOriginalReadyByEntryId($distributionJobData->entryDistribution->entryId); } if ($flavorAsset) { $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $this->videoAssetFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, true); } $thumbAssets = thumbAssetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->thumbAssetIds)); if (count($thumbAssets)) { $syncKey = reset($thumbAssets)->getSyncKey(thumbAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $this->thumbAssetFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, true); } }
public function entryHandled(entry $dbEntry) { parent::entryHandled($dbEntry); $originalFlavorAsset = assetPeer::retrieveOriginalByEntryId($dbEntry->getId()); $syncKey = $originalFlavorAsset->getSyncKey(asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $sourceFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey); // call mediaInfo for file $dbMediaInfo = new mediaInfo(); try { $mediaInfoParser = new KMediaInfoMediaParser($sourceFilePath, kConf::get('bin_path_mediainfo')); $mediaInfo = $mediaInfoParser->getMediaInfo(); $dbMediaInfo = $mediaInfo->toInsertableObject($dbMediaInfo); $dbMediaInfo->setFlavorAssetId($originalFlavorAsset->getId()); $dbMediaInfo->save(); } catch (Exception $e) { KalturaLog::err("Getting media info: " . $e->getMessage()); $dbMediaInfo = null; } // fix flavor asset according to mediainfo if ($dbMediaInfo) { KDLWrap::ConvertMediainfoCdl2FlavorAsset($dbMediaInfo, $originalFlavorAsset); $flavorTags = KDLWrap::CDLMediaInfo2Tags($dbMediaInfo, array(flavorParams::TAG_WEB, flavorParams::TAG_MBR)); $originalFlavorAsset->setTags(implode(',', array_unique($flavorTags))); } $originalFlavorAsset->setStatusLocalReady(); $originalFlavorAsset->save(); $dbEntry->setStatus(entryStatus::READY); $dbEntry->save(); }
/** * Called on the server side and enables you to populate the object with any data from the DB * * @param KalturaDistributionJobData $distributionJobData */ public function __construct(KalturaDistributionJobData $distributionJobData = null) { parent::__construct($distributionJobData); if (!$distributionJobData) { return; } if (!$distributionJobData->distributionProfile instanceof KalturaFreewheelGenericDistributionProfile) { return; } $this->videoAssetFilePaths = new KalturaStringArray(); // loads all the flavor assets that should be submitted to the remote destination site $flavorAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->flavorAssetIds)); foreach ($flavorAssets as $flavorAsset) { $videoAssetFilePath = new KalturaString(); $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $videoAssetFilePath->value = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); $this->videoAssetFilePaths[] = $videoAssetFilePath; } $thumbAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->thumbAssetIds)); if (count($thumbAssets)) { $thumbAsset = reset($thumbAssets); $syncKey = $thumbAssets->getSyncKey(thumbAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $this->thumbAssetFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); } // entry cue points $c = KalturaCriteria::create(CuePointPeer::OM_CLASS); $c->add(CuePointPeer::PARTNER_ID, $distributionJobData->entryDistribution->partnerId); $c->add(CuePointPeer::ENTRY_ID, $distributionJobData->entryDistribution->entryId); $c->add(CuePointPeer::TYPE, AdCuePointPlugin::getCuePointTypeCoreValue(AdCuePointType::AD)); $c->addAscendingOrderByColumn(CuePointPeer::START_TIME); $cuePointsDb = CuePointPeer::doSelect($c); $this->cuePoints = KalturaCuePointArray::fromDbArray($cuePointsDb); }
/** * Called on the server side and enables you to populate the object with any data from the DB * * @param KalturaDistributionJobData $distributionJobData */ public function __construct(KalturaDistributionJobData $distributionJobData = null) { parent::__construct($distributionJobData); if (!$distributionJobData) { return; } if (!$distributionJobData->distributionProfile instanceof KalturaQuickPlayDistributionProfile) { return; } $this->videoFilePaths = new KalturaStringArray(); $this->thumbnailFilePaths = new KalturaStringArray(); // loads all the flavor assets that should be submitted to the remote destination site $flavorAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->flavorAssetIds)); $thumbAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->thumbAssetIds)); $entry = entryPeer::retrieveByPK($distributionJobData->entryDistribution->entryId); foreach ($flavorAssets as $asset) { $syncKey = $asset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); if (kFileSyncUtils::fileSync_exists($syncKey)) { $str = new KalturaString(); $str->value = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); $this->videoFilePaths[] = $str; } } foreach ($thumbAssets as $asset) { $syncKey = $asset->getSyncKey(thumbAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); if (kFileSyncUtils::fileSync_exists($syncKey)) { $str = new KalturaString(); $str->value = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); $this->thumbnailFilePaths[] = $str; } } $feed = new QuickPlayFeed($distributionJobData, $this, $flavorAssets, $thumbAssets, $entry); $this->xml = $feed->getXml(); }
public function getLocalThumbFilePath($version, $width, $height, $type, $bgcolor = "ffffff", $crop_provider = null, $quality = 0, $src_x = 0, $src_y = 0, $src_w = 0, $src_h = 0, $vid_sec = -1, $vid_slice = 0, $vid_slices = -1, $density = 0, $stripProfiles = false, $flavorId = null, $fileName = null) { if ($this->getStatus() == entryStatus::DELETED || $this->getModerationStatus() == moderation::MODERATION_STATUS_BLOCK) { KalturaLog::log("rejected live stream entry - not serving thumbnail"); KExternalErrors::dieError(KExternalErrors::ENTRY_DELETED_MODERATED); } $contentPath = myContentStorage::getFSContentRootPath(); $liveEntryExist = false; $liveThumbEntry = null; $liveThumbEntryId = null; $partner = $this->getPartner(); if ($partner) { $liveThumbEntryId = $partner->getLiveThumbEntryId(); } if ($liveThumbEntryId) { $liveThumbEntry = entryPeer::retrieveByPK($liveThumbEntryId); } if ($liveThumbEntry && $liveThumbEntry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) { $fileSyncVersion = $partner->getLiveThumbEntryVersion(); $liveEntryKey = $liveThumbEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $fileSyncVersion); $contentPath = kFileSyncUtils::getLocalFilePathForKey($liveEntryKey); if ($contentPath) { $msgPath = $contentPath; $liveEntryExist = true; } else { KalturaLog::err('no local file sync for audio entry id'); } } if (!$liveEntryExist) { $msgPath = $contentPath . "content/templates/entry/thumbnail/live_thumb.jpg"; } return myEntryUtils::resizeEntryImage($this, $version, $width, $height, $type, $bgcolor, $crop_provider, $quality, $src_x, $src_y, $src_w, $src_h, $vid_sec, $vid_slice, $vid_slices, $msgPath, $density, $stripProfiles); }
/** * @param flavorAsset $flavorAsset * @return string */ public function getFlavorAssetUrl(flavorAsset $flavorAsset) { $entry = $flavorAsset->getentry(); $partnerId = $entry->getPartnerId(); $subpId = $entry->getSubpId(); $flavorAssetId = $flavorAsset->getId(); $partnerPath = myPartnerUtils::getUrlForPartner($partnerId, $subpId); $this->setFileExtension($flavorAsset->getFileExt()); $url = "/s{$partnerPath}/serveFlavor/flavorId/{$flavorAssetId}"; if ($this->clipTo) { $url .= "/clipTo/{$this->clipTo}"; } if ($this->extention) { $url .= "/name/{$flavorAssetId}.{$this->extention}"; } $url = str_replace('\\', '/', $url); if ($this->protocol != StorageProfile::PLAY_FORMAT_RTMP) { $url .= '?novar=0'; $url .= '&e=' . (time() + 120); $secret = $this->getMediaVault(); $fullUrl = $this->protocol . '://' . $this->domain . $url; $url .= '&h=' . md5($secret . $fullUrl); $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $seekFromBytes = $this->getSeekFromBytes(kFileSyncUtils::getLocalFilePathForKey($syncKey)); if ($seekFromBytes) { $url .= '&fs=' . $seekFromBytes; } } else { $url .= '/forceproxy/true'; } return $url; }
/** * Called on the server side and enables you to populate the object with any data from the DB * * @param KalturaDistributionJobData $distributionJobData */ public function __construct(KalturaDistributionJobData $distributionJobData = null) { parent::__construct($distributionJobData); if (!$distributionJobData) { return; } if (!$distributionJobData->distributionProfile instanceof KalturaHuluDistributionProfile) { return; } // loads all the flavor assets that should be submitted to the remote destination site $flavorAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->flavorAssetIds)); if (count($flavorAssets)) { $flavorAsset = reset($flavorAssets); $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $this->videoAssetFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); } $thumbAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->thumbAssetIds)); if (count($thumbAssets)) { $thumbAsset = reset($thumbAssets); $syncKey = $thumbAsset->getSyncKey(thumbAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $this->thumbAssetFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); } $additionalAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->assetIds)); $this->captionLocalPaths = new KalturaStringArray(); if (count($additionalAssets)) { $captionAssetFilePathArray = array(); foreach ($additionalAssets as $additionalAsset) { $assetType = $additionalAsset->getType(); $syncKey = $additionalAsset->getSyncKey(CaptionAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET); if (kFileSyncUtils::fileSync_exists($syncKey)) { if ($assetType == CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION) || $assetType == AttachmentPlugin::getAssetTypeCoreValue(AttachmentAssetType::ATTACHMENT)) { $string = new KalturaString(); $string->value = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); $this->captionLocalPaths[] = $string; } } } } $tempFieldValues = unserialize($this->fieldValues); $pattern = '/[^A-Za-z0-9_\\-]/'; $seriesTitle = preg_replace($pattern, '', $tempFieldValues[HuluDistributionField::SERIES_TITLE]); $seasonNumber = preg_replace($pattern, '', $tempFieldValues[HuluDistributionField::SEASON_NUMBER]); $videoEpisodeNumber = preg_replace($pattern, '', $tempFieldValues[HuluDistributionField::VIDEO_EPISODE_NUMBER]); $videoTitle = preg_replace($pattern, '', $tempFieldValues[HuluDistributionField::VIDEO_TITLE]); $this->fileBaseName = $seriesTitle . '-' . $seasonNumber . '-' . $videoEpisodeNumber . '-' . $videoTitle; // entry cue points $c = KalturaCriteria::create(CuePointPeer::OM_CLASS); $c->add(CuePointPeer::PARTNER_ID, $distributionJobData->entryDistribution->partnerId); $c->add(CuePointPeer::ENTRY_ID, $distributionJobData->entryDistribution->entryId); $c->add(CuePointPeer::TYPE, AdCuePointPlugin::getCuePointTypeCoreValue(AdCuePointType::AD)); $c->addAscendingOrderByColumn(CuePointPeer::START_TIME); $cuePointsDb = CuePointPeer::doSelect($c); $this->cuePoints = KalturaCuePointArray::fromDbArray($cuePointsDb); }
public function __construct(KalturaDistributionJobData $distributionJobData = null) { parent::__construct($distributionJobData); if (!$distributionJobData) { return; } if (!$distributionJobData->distributionProfile instanceof KalturaYahooDistributionProfile) { return; } //Flavor Assets $flavorAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->flavorAssetIds)); if (count($flavorAssets)) { $videoAssetFilePathArray = array(); foreach ($flavorAssets as $flavorAsset) { if ($flavorAsset) { /* @var $flavorAsset flavorAsset */ $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET); if (kFileSyncUtils::fileSync_exists($syncKey)) { $id = $flavorAsset->getId(); //$this->videoAssetFilePath[$id] = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); $videoAssetFilePathArray[$id] = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); } } } $this->videoAssetFilePath = serialize($videoAssetFilePathArray); } //Thumbnails $c = new Criteria(); $c->addAnd(assetPeer::ID, explode(',', $distributionJobData->entryDistribution->thumbAssetIds), Criteria::IN); $c->addAscendingOrderByColumn(assetPeer::ID); $thumbAssets = assetPeer::doSelect($c); //$thumbAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->thumbAssetIds)); if (count($thumbAssets) >= 2) { if ($thumbAssets[0]->getWidth() <= $thumbAssets[1]->getWidth()) { $smallThumbAsset = $thumbAssets[0]; $largeThumbAsset = $thumbAssets[1]; } else { $smallThumbAsset = $thumbAssets[1]; $largeThumbAsset = $thumbAssets[0]; } $syncKey = $smallThumbAsset->getSyncKey(thumbAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET); if (kFileSyncUtils::fileSync_exists($syncKey)) { $this->smallThumbPath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); } $syncKey = $largeThumbAsset->getSyncKey(thumbAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET); if (kFileSyncUtils::fileSync_exists($syncKey)) { $this->largeThumbPath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); } } }
protected function getDistributionFiles(FtpDistributionProfile $distributionProfileDb, EntryDistribution $entryDistributionDb) { $files = new KalturaFtpDistributionFileArray(); $sendMetadataAfterAssets = false; if (!is_null($distributionProfileDb->getSendMetadataAfterAssets())) { $sendMetadataAfterAssets = $distributionProfileDb->getSendMetadataAfterAssets(); } if (!$distributionProfileDb->getDisableMetadata()) { $metadataFile = new KalturaFtpDistributionFile(); $metadataXml = $distributionProfileDb->getMetadataXml($entryDistributionDb); $metadataFile->filename = $distributionProfileDb->getMetadataFilename($entryDistributionDb); $metadataFile->contents = $metadataXml; $metadataFile->assetId = 'metadata'; $metadataFile->hash = md5($metadataXml); if (!$sendMetadataAfterAssets) { $files[] = $metadataFile; } } $flavorAssetsIds = explode(',', $entryDistributionDb->getFlavorAssetIds()); $thumbnailAssetIds = explode(',', $entryDistributionDb->getThumbAssetIds()); $assetIds = explode(',', $entryDistributionDb->getAssetIds()); $assets = assetPeer::retrieveByIds(array_merge($flavorAssetsIds, $thumbnailAssetIds, $assetIds)); KalturaLog::log("Assets to distribute: " . print_r($assets, true)); foreach ($assets as $asset) { /* @var $assets asset */ $syncKey = $asset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $file = new KalturaFtpDistributionFile(); $file->assetId = $asset->getId(); $file->localFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); $file->version = $syncKey->getVersion(); $defaultFilename = pathinfo($file->localFilePath, PATHINFO_BASENAME); if ($asset instanceof thumbAsset) { $file->filename = $distributionProfileDb->getThumbnailAssetFilename($entryDistributionDb, $defaultFilename, $asset->getId()); } else { if ($asset instanceof flavorAsset) { $file->filename = $distributionProfileDb->getFlavorAssetFilename($entryDistributionDb, $defaultFilename, $asset->getId()); } else { $file->filename = $distributionProfileDb->getAssetFilename($entryDistributionDb, $defaultFilename, $asset->getId()); } } $files[] = $file; } //sending metadata after assets as configured in the connector profile if ($metadataFile && $sendMetadataAfterAssets) { $files[] = $metadataFile; } return $files; }
/** * Update relevant filesync as READY * * @param BatchJob $dbBatchJob * @param kFileSyncImportJobData $data * @param BatchJob $twinJob * @throws KalturaAPIException * @return BatchJob */ protected function updatedFileSyncImportFinished(BatchJob $dbBatchJob, kFileSyncImportJobData $data, BatchJob $twinJob = null) { $fileSyncId = $data->getFilesyncId(); if (!$fileSyncId) { KalturaLog::err('File sync ID not found in job data.'); throw new KalturaAPIException(MultiCentersErrors::INVALID_FILESYNC_ID); } $fileSync = FileSyncPeer::retrieveByPK($fileSyncId); if (!$fileSync) { KalturaLog::err("Invalid filesync record with id [{$fileSyncId}]"); throw new KalturaAPIException(MultiCentersErrors::INVALID_FILESYNC_RECORD, $fileSyncId); } $fileSync->setStatus(FileSync::FILE_SYNC_STATUS_READY); $fileSync->setFileSizeFromPath(kFileSyncUtils::getLocalFilePathForKey(kFileSyncUtils::getKeyForFileSync($fileSync))); $fileSync->save(); return $dbBatchJob; }
/** * Add new bulk upload batch job * Conversion profile id can be specified in the API or in the CSV file, the one in the CSV file will be stronger. * If no conversion profile was specified, partner's default will be used * * @action add * @param int $conversionProfileId Convertion profile id to use for converting the current bulk (-1 to use partner's default) * @param file $csvFileData CSV File * @return KalturaBulkUpload */ function addAction($conversionProfileId, $csvFileData) { // first we copy the file to "content/batchfiles/[partner_id]/" $origFilename = $csvFileData["name"]; $fileInfo = pathinfo($origFilename); $extension = strtolower($fileInfo["extension"]); if ($extension != "csv") { throw new KalturaAPIException(KalturaErrors::INVALID_FILE_EXTENSION); } $job = new BatchJob(); $job->setPartnerId($this->getPartnerId()); $job->save(); $syncKey = $job->getSyncKey(BatchJob::FILE_SYNC_BATCHJOB_SUB_TYPE_BULKUPLOADCSV); // kFileSyncUtils::file_put_contents($syncKey, file_get_contents($csvFileData["tmp_name"])); try { kFileSyncUtils::moveFromFile($csvFileData["tmp_name"], $syncKey, true); } catch (Exception $e) { throw new KalturaAPIException(KalturaErrors::BULK_UPLOAD_CREATE_CSV_FILE_SYNC_ERROR); } $csvPath = kFileSyncUtils::getLocalFilePathForKey($syncKey); $data = new KalturaBulkUploadJobData(); $data->csvFilePath = $csvPath; $data->userId = $this->getKuser()->getPuserId(); $data->uploadedBy = $this->getKuser()->getScreenName(); if ($conversionProfileId === -1) { $conversionProfileId = $this->getPartner()->getDefaultConversionProfileId(); } $kmcVersion = $this->getPartner()->getKmcVersion(); $check = null; if ($kmcVersion < 2) { $check = ConversionProfilePeer::retrieveByPK($conversionProfileId); } else { $check = conversionProfile2Peer::retrieveByPK($conversionProfileId); } if (!$check) { throw new KalturaAPIException(KalturaErrors::CONVERSION_PROFILE_ID_NOT_FOUND, $conversionProfileId); } $data->conversionProfileId = $conversionProfileId; $dbJob = kJobsManager::addJob($job, $data->toObject(), KalturaBatchJobType::BULKUPLOAD); $bulkUpload = new KalturaBulkUpload(); $bulkUpload->fromObject($dbJob); return $bulkUpload; }
/** * batch getExclusiveTransformMetadataJob action allows to get a BatchJob of type METADATA_TRANSFORM * * @action getExclusiveTransformMetadataJobs * @param KalturaExclusiveLockKey $lockKey The unique lock key from the batch-process. Is used for the locking mechanism * @param int $maxExecutionTime The maximum time in seconds the job reguarly take. Is used for the locking mechanism when determining an unexpected termination of a batch-process. * @param int $numberOfJobs The maximum number of jobs to return. * @param KalturaBatchJobFilter $filter Set of rules to fetch only rartial list of jobs * @return KalturaBatchJobArray */ function getExclusiveTransformMetadataJobsAction(KalturaExclusiveLockKey $lockKey, $maxExecutionTime, $numberOfJobs, KalturaBatchJobFilter $filter = null) { $jobs = $this->getExclusiveJobs($lockKey, $maxExecutionTime, $numberOfJobs, $filter, BatchJobType::METADATA_TRANSFORM); if ($jobs) { foreach ($jobs as &$job) { $data = $job->getData(); $metadataProfileId = $data->getMetadataProfileId(); $metadataProfile = MetadataProfilePeer::retrieveByPK($metadataProfileId); if (!$metadataProfile) { continue; } $key = $metadataProfile->getSyncKey(MetadataProfile::FILE_SYNC_METADATA_DEFINITION); $xsdPath = kFileSyncUtils::getLocalFilePathForKey($key); $data->setDestXsdPath($xsdPath); $job->setData($data); } } return KalturaBatchJobArray::fromBatchJobArray($jobs); }
public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser) { $entry_id = $this->getP("entry_id"); $kshow_id = $this->getP("kshow_id"); // Make sure the request is for a ready roughcut $c = entryPeer::getCriteriaFilter()->getFilter(); $c->addAnd(entryPeer::STATUS, entryStatus::READY, Criteria::EQUAL); list($kshow, $entry, $error, $error_obj) = myKshowUtils::getKshowAndEntry($kshow_id, $entry_id); if ($error_obj) { $this->addError($error_obj); return; } $version = $this->getP("version"); // it's a path on the disk if (kString::beginsWith($version, ".")) { // someone is trying to hack in the system return sfView::ERROR; } elseif ($version == "-1") { $version = null; } // in case we're making a roughcut out of a regular invite, we start from scratch $entry_data_path = kFileSyncUtils::getLocalFilePathForKey($entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $version)); //replaced__getDataPath if ($entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_SHOW || $entry_data_path === null) { $this->xml_content = "<xml></xml>"; return; } $sync_key = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $version); $file_name = kFileSyncUtils::getReadyLocalFilePathForKey($sync_key, false); // fetch content of file from disk - it should hold the XML if (kString::endsWith($file_name, "xml")) { $xml_content = kFileSyncUtils::file_get_contents($sync_key, false, false); if (!$xml_content) { $xml_content = "<xml></xml>"; } myMetadataUtils::updateEntryForPending($entry, $version, $xml_content); $this->addMsg("metadata", $xml_content); } else { $this->addError(APIErrors::INVALID_FILE_NAME, $file_name); } }
/** * @param BaseObject $object * @return bool true if should continue to the next consumer */ public function objectAdded(BaseObject $object) { if ($object instanceof flavorAsset && $object->getIsOriginal()) { $entry = $object->getentry(); if ($entry->getType() == entryType::DOCUMENT) { if ($entry->getConversionQuality() > 0) { $syncKey = $object->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $path = kFileSyncUtils::getLocalFilePathForKey($syncKey); kJobsManager::addConvertProfileJob(null, $entry, $object->getId(), $path); } else { // only for documents entry, make the source ready since no conversion profile will be executed by default $object->setFlavorParamsId(flavorParams::SOURCE_FLAVOR_ID); $object->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_READY); $object->save(); $entry->setStatusReady(); $entry->save(); } } } return true; }
public function objectChanged(BaseObject $object, array $modifiedColumns) { // replacing the ismc file name in the ism file $ismPrevVersionFileSyncKey = $object->getSyncKey(flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET); $ismContents = kFileSyncUtils::file_get_contents($ismPrevVersionFileSyncKey); $ismcPrevVersionFileSyncKey = $object->getSyncKey(flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ISMC); $ismcContents = kFileSyncUtils::file_get_contents($ismcPrevVersionFileSyncKey); $ismcPrevVersionFilePath = kFileSyncUtils::getLocalFilePathForKey($ismcPrevVersionFileSyncKey); $object->incrementVersion(); $object->save(); $ismcFileSyncKey = $object->getSyncKey(flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ISMC); kFileSyncUtils::moveFromFile($ismcPrevVersionFilePath, $ismcFileSyncKey); $ismcNewName = basename(kFileSyncUtils::getLocalFilePathForKey($ismcFileSyncKey)); KalturaLog::debug("Editing ISM set content to [{$ismcNewName}]"); $ismXml = new SimpleXMLElement($ismContents); $ismXml->head->meta['content'] = $ismcNewName; $tmpPath = kFileSyncUtils::getLocalFilePathForKey($ismPrevVersionFileSyncKey) . '.tmp'; file_put_contents($tmpPath, $ismXml->asXML()); kFileSyncUtils::moveFromFile($tmpPath, $object->getSyncKey(flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET)); return true; }
public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser) { $fileField = "csv_file"; $profileId = $this->getP("profile_id"); if (count($_FILES) == 0) { $this->addError(APIErrors::NO_FILES_RECEIVED); return; } if (!@$_FILES[$fileField]) { $this->addError(APIErrors::INVALID_FILE_FIELD, $fileField); return; } // first we copy the file to "content/batchfiles/[partner_id]/" $origFilename = $_FILES[$fileField]['name']; $fileInfo = pathinfo($origFilename); $extension = strtolower($fileInfo['extension']); if ($extension != "csv") { $this->addError(APIErrors::INVALID_FILE_EXTENSION); return; } $job = new BatchJob(); $job->setPartnerId($partner_id); $job->save(); $syncKey = $job->getSyncKey(BatchJob::FILE_SYNC_BATCHJOB_SUB_TYPE_BULKUPLOADCSV); // kFileSyncUtils::file_put_contents($syncKey, file_get_contents($csvFileData["tmp_name"])); try { kFileSyncUtils::moveFromFile($_FILES[$fileField]['tmp_name'], $syncKey, true); } catch (Exception $e) { throw new KalturaAPIException(KalturaErrors::BULK_UPLOAD_CREATE_CSV_FILE_SYNC_ERROR); } $csvPath = kFileSyncUtils::getLocalFilePathForKey($syncKey); $data = new kBulkUploadJobData(); $data->setCsvFilePath($csvPath); $data->setUserId($puser_kuser->getPuserId()); $data->setUploadedBy($puser_kuser->getPuserName()); $data->setConversionProfileId($profileId); kJobsManager::addJob($job, $data, BatchJobType::BULKUPLOAD); $this->addMsg("status", "ok"); }
public function __construct(KalturaDistributionJobData $distributionJobData = null) { parent::__construct($distributionJobData); if (!$distributionJobData) { return; } if (!$distributionJobData->distributionProfile instanceof KalturaMetroPcsDistributionProfile) { return; } $distributedFlavorIds = null; $distributedThumbIds = null; //Flavor Assets $flavorAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->flavorAssetIds)); if (count($flavorAssets)) { $videoAssetFilePathArray = array(); foreach ($flavorAssets as $flavorAsset) { if ($flavorAsset) { /* @var $flavorAsset flavorAsset */ $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET); if (kFileSyncUtils::fileSync_exists($syncKey)) { $id = $flavorAsset->getId(); $videoAssetFilePathArray[$id] = kFileSyncUtils::getLocalFilePathForKey($syncKey, true); } } } $this->assetLocalPaths = serialize($videoAssetFilePathArray); } //thumbnails $thumbnails = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->thumbAssetIds)); if (count($thumbnails)) { $thumbUrlsArray = array(); foreach ($thumbnails as $thumb) { $thumbUrlsArray[$thumb->getId()] = self::getAssetUrl($thumb); } $this->thumbUrls = serialize($thumbUrlsArray); } }
/** * @param flavorAsset $flavorAsset * @return string */ public function getFlavorAssetUrl(flavorAsset $flavorAsset) { $entry = $flavorAsset->getentry(); $partnerId = $entry->getPartnerId(); $subpId = $entry->getSubpId(); $flavorAssetId = $flavorAsset->getId(); $partnerPath = myPartnerUtils::getUrlForPartner($partnerId, $subpId); $this->setFileExtension($flavorAsset->getFileExt()); $url = "{$partnerPath}/serveFlavor/flavorId/{$flavorAssetId}"; if ($this->clipTo) { $url .= "/clipTo/{$this->clipTo}"; } if ($this->extention) { $url .= "/name/{$flavorAssetId}.{$this->extention}"; } if ($this->protocol != StorageProfile::PLAY_FORMAT_RTMP) { $url .= '?novar=0'; if ($entry->getSecurityPolicy()) { $url = "/s{$url}"; // set expire time in GMT hence the date("Z") offset $url .= "&nva=" . strftime("%Y%m%d%H%M%S", time() - date("Z") + 30); $secret = kConf::get("level3_authentication_key"); $hash = "0" . substr(self::hmac('sha1', $secret, $url), 0, 20); $url .= "&h={$hash}"; } $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $seekFromBytes = $this->getSeekFromBytes(kFileSyncUtils::getLocalFilePathForKey($syncKey)); if ($seekFromBytes) { $url .= '&start=' . $seekFromBytes; } } else { $url .= '/forceproxy/true'; } $url = str_replace('\\', '/', $url); return $url; }
/** * Called on the server side and enables you to populate the object with any data from the DB * * @param KalturaDistributionJobData $distributionJobData */ public function __construct(KalturaDistributionJobData $distributionJobData = null) { if (!$distributionJobData) { return; } if (!$distributionJobData->distributionProfile instanceof KalturaFreewheelDistributionProfile) { return; } $this->videoAssetFilePaths = new KalturaFreewheelDistributionAssetPathArray(); // loads all the flavor assets that should be submitted to the remote destination site $flavorAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->flavorAssetIds)); foreach ($flavorAssets as $flavorAsset) { $videoAssetFilePath = new KalturaFreewheelDistributionAssetPath(); $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $videoAssetFilePath->path = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); $this->videoAssetFilePaths[] = $videoAssetFilePath; } $thumbAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->thumbAssetIds)); if (count($thumbAssets)) { $thumbAsset = reset($thumbAssets); $syncKey = $thumbAssets->getSyncKey(thumbAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $this->thumbAssetFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); } }
/** * will create thumbnail according to the entry type * @return the thumbnail path. */ public function getLocalThumbFilePath($version, $width, $height, $type, $bgcolor = "ffffff", $crop_provider = null, $quality = 0, $src_x = 0, $src_y = 0, $src_w = 0, $src_h = 0, $vid_sec = -1, $vid_slice = 0, $vid_slices = -1, $density = 0, $stripProfiles = false, $flavorId = null, $fileName = null) { $contentPath = myContentStorage::getFSContentRootPath(); // if entry type is audio - serve generic thumb: if ($this->getMediaType() == entry::ENTRY_MEDIA_TYPE_AUDIO) { if ($this->getStatus() == entryStatus::DELETED || $this->getModerationStatus() == moderation::MODERATION_STATUS_BLOCK) { KalturaLog::log("rejected audio entry - not serving thumbnail"); KExternalErrors::dieError(KExternalErrors::ENTRY_DELETED_MODERATED); } $audioEntryExist = false; $audioThumbEntry = null; $audioThumbEntryId = null; $partner = $this->getPartner(); if ($partner) { $audioThumbEntryId = $partner->getAudioThumbEntryId(); } if ($audioThumbEntryId) { $audioThumbEntry = entryPeer::retrieveByPK($audioThumbEntryId); } if ($audioThumbEntry && $audioThumbEntry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) { $fileSyncVersion = $partner->getAudioThumbEntryVersion(); $audioEntryKey = $audioThumbEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $fileSyncVersion); $contentPath = kFileSyncUtils::getLocalFilePathForKey($audioEntryKey); if ($contentPath) { $msgPath = $contentPath; $audioEntryExist = true; } else { KalturaLog::err('no local file sync for entry id'); } } if (!$audioEntryExist) { $msgPath = $contentPath . "content/templates/entry/thumbnail/audio_thumb.jpg"; } return myEntryUtils::resizeEntryImage($this, $version, $width, $height, $type, $bgcolor, $crop_provider, $quality, $src_x, $src_y, $src_w, $src_h, $vid_sec, $vid_slice, $vid_slices, $msgPath, $density, $stripProfiles); } elseif ($this->getMediaType() == entry::ENTRY_MEDIA_TYPE_SHOW) { // roughcut without any thumbnail, probably just created $msgPath = $contentPath . "content/templates/entry/thumbnail/auto_edit.jpg"; return myEntryUtils::resizeEntryImage($this, $version, $width, $height, $type, $bgcolor, $crop_provider, $quality, $src_x, $src_y, $src_w, $src_h, $vid_sec, $vid_slice, $vid_slices, $msgPath, $density, $stripProfiles); } elseif ($this->getType() == entryType::MEDIA_CLIP) { try { return myEntryUtils::resizeEntryImage($this, $version, $width, $height, $type, $bgcolor, $crop_provider, $quality, $src_x, $src_y, $src_w, $src_h, $vid_sec, $vid_slice, $vid_slices); } catch (Exception $ex) { if ($ex->getCode() == kFileSyncException::FILE_DOES_NOT_EXIST_ON_CURRENT_DC) { // get original flavor asset $origFlavorAsset = assetPeer::retrieveOriginalByEntryId($this->getId()); if ($origFlavorAsset) { $syncKey = $origFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); list($readyFileSync, $isLocal) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, TRUE, FALSE); if ($readyFileSync) { if ($isLocal) { KalturaLog::err('Trying to redirect to myself - stop here.'); KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC); } //Ready fileSync is on the other DC - dumping kFileUtils::dumpApiRequest(kDataCenterMgr::getRemoteDcExternalUrlByDcId(1 - kDataCenterMgr::getCurrentDcId())); } KalturaLog::err('No ready fileSync found on any DC.'); KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC); } } } } }
/** * @param AttachmentAsset $attachmentAsset * @param FileSyncKey $srcSyncKey */ protected function attachFileSync(AttachmentAsset $attachmentAsset, FileSyncKey $srcSyncKey) { $attachmentAsset->incrementVersion(); $attachmentAsset->save(); $newSyncKey = $attachmentAsset->getSyncKey(AttachmentAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET); kFileSyncUtils::createSyncFileLinkForKey($newSyncKey, $srcSyncKey); $finalPath = kFileSyncUtils::getLocalFilePathForKey($newSyncKey); list($width, $height, $type, $attr) = getimagesize($finalPath); $attachmentAsset->setWidth($width); $attachmentAsset->setHeight($height); $attachmentAsset->setSize(kFile::fileSize($finalPath)); $attachmentAsset->setStatus(AttachmentAsset::ASSET_STATUS_READY); $attachmentAsset->save(); }
/** * @param flavorAsset $originalFlavorAsset * @param entry $entry * @param BatchJob $convertProfileJob * @return BatchJob */ public static function bypassConversion(flavorAsset $originalFlavorAsset, entry $entry, BatchJob $convertProfileJob) { if (!$originalFlavorAsset->hasTag(flavorParams::TAG_MBR)) { $mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($originalFlavorAsset->getId()); if ($mediaInfo) { $tagsArray = $originalFlavorAsset->getTagsArray(); $finalTagsArray = KDLWrap::CDLMediaInfo2Tags($mediaInfo, $tagsArray); $originalFlavorAsset->setTagsArray($finalTagsArray); } } $offset = $entry->getThumbOffset(); // entry getThumbOffset now takes the partner DefThumbOffset into consideration $srcSyncKey = $originalFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $srcFileSyncLocalPath = kFileSyncUtils::getLocalFilePathForKey($srcSyncKey); $jobSubType = BatchJob::BATCHJOB_SUB_TYPE_POSTCONVERT_BYPASS; return kJobsManager::addPostConvertJob($convertProfileJob, $jobSubType, $srcFileSyncLocalPath, $originalFlavorAsset->getId(), null, true, $offset); }
/** * Convert entry * * @param string $entryId Media entry id * @param int $conversionProfileId * @param KalturaConversionAttributeArray $dynamicConversionAttributes * @return bigint job id * @throws KalturaErrors::ENTRY_ID_NOT_FOUND * @throws KalturaErrors::CONVERSION_PROFILE_ID_NOT_FOUND * @throws KalturaErrors::FLAVOR_PARAMS_NOT_FOUND */ protected function convert($entryId, $conversionProfileId = null, KalturaConversionAttributeArray $dynamicConversionAttributes = null) { $entry = entryPeer::retrieveByPK($entryId); if (!$entry) { throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId); } $srcFlavorAsset = assetPeer::retrieveOriginalByEntryId($entryId); if (!$srcFlavorAsset) { throw new KalturaAPIException(KalturaErrors::ORIGINAL_FLAVOR_ASSET_IS_MISSING); } if (is_null($conversionProfileId) || $conversionProfileId <= 0) { $conversionProfile = myPartnerUtils::getConversionProfile2ForEntry($entryId); if (!$conversionProfile) { throw new KalturaAPIException(KalturaErrors::CONVERSION_PROFILE_ID_NOT_FOUND, $conversionProfileId); } $conversionProfileId = $conversionProfile->getId(); } else { //The search is with the entry's partnerId. so if conversion profile wasn't found it means that the //conversionId is not exist or the conversion profileId does'nt belong to this partner. $conversionProfile = conversionProfile2Peer::retrieveByPK($conversionProfileId); if (is_null($conversionProfile)) { throw new KalturaAPIException(KalturaErrors::CONVERSION_PROFILE_ID_NOT_FOUND, $conversionProfileId); } } $srcSyncKey = $srcFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); // if the file sync isn't local (wasn't synced yet) proxy request to other datacenter list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($srcSyncKey, true, false); if (!$fileSync) { throw new KalturaAPIException(KalturaErrors::FILE_DOESNT_EXIST); } else { if (!$local) { kFileUtils::dumpApiRequest(kDataCenterMgr::getRemoteDcExternalUrl($fileSync)); } } // even if it null $entry->setConversionQuality($conversionProfileId); $entry->save(); if ($dynamicConversionAttributes) { $flavors = assetParamsPeer::retrieveByProfile($conversionProfileId); if (!count($flavors)) { throw new KalturaAPIException(KalturaErrors::FLAVOR_PARAMS_NOT_FOUND); } $srcFlavorParamsId = null; $flavorParams = $entry->getDynamicFlavorAttributes(); foreach ($flavors as $flavor) { if ($flavor->hasTag(flavorParams::TAG_SOURCE)) { $srcFlavorParamsId = $flavor->getId(); } $flavorParams[$flavor->getId()] = $flavor; } $dynamicAttributes = array(); foreach ($dynamicConversionAttributes as $dynamicConversionAttribute) { if (is_null($dynamicConversionAttribute->flavorParamsId)) { $dynamicConversionAttribute->flavorParamsId = $srcFlavorParamsId; } if (is_null($dynamicConversionAttribute->flavorParamsId)) { continue; } $dynamicAttributes[$dynamicConversionAttribute->flavorParamsId][trim($dynamicConversionAttribute->name)] = trim($dynamicConversionAttribute->value); } if (count($dynamicAttributes)) { $entry->setDynamicFlavorAttributes($dynamicAttributes); $entry->save(); } } $srcFilePath = kFileSyncUtils::getLocalFilePathForKey($srcSyncKey); $job = kJobsManager::addConvertProfileJob(null, $entry, $srcFlavorAsset->getId(), $srcFilePath); if (!$job) { return null; } return $job->getId(); }
private function getCaptionInfo($asset, $syncKey, KalturaDistributionJobData $distributionJobData) { $captionInfo = new KalturaDailymotionDistributionCaptionInfo(); $captionInfo->filePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); $captionInfo->assetId = $asset->getId(); $captionInfo->version = $asset->getVersion(); /* @var $mediaFile KalturaDistributionRemoteMediaFile */ $distributed = false; foreach ($distributionJobData->mediaFiles as $mediaFile) { if ($mediaFile->assetId == $asset->getId()) { $distributed = true; if ($asset->getVersion() > $mediaFile->version) { $captionInfo->action = KalturaDailymotionDistributionCaptionAction::UPDATE_ACTION; } break; } } if (!$distributed) { $captionInfo->action = KalturaDailymotionDistributionCaptionAction::SUBMIT_ACTION; } elseif ($captionInfo->action != KalturaDailymotionDistributionCaptionAction::UPDATE_ACTION) { return; } return $captionInfo; }
public static function handleBulkDownloadPending(BatchJob $dbBatchJob, kBulkDownloadJobData $data, BatchJob $twinJob = null) { $entryIds = explode(',', $data->getEntryIds()); $flavorParamsId = $data->getFlavorParamsId(); $jobIsFinished = true; foreach ($entryIds as $entryId) { $entry = entryPeer::retrieveByPK($entryId); if (is_null($entry)) { KalturaLog::err("Entry id [{$entryId}] not found."); } else { if ($entry->hasDownloadAsset($flavorParamsId)) { // why we don't send the notification in case of image is ready? $flavorAsset = flavorAssetPeer::retrieveByEntryIdAndFlavorParams($entryId, $flavorParamsId); if ($flavorAsset && $flavorAsset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_READY) { $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $downloadUrl = $flavorAsset->getDownloadUrl(); $localPath = kFileSyncUtils::getLocalFilePathForKey($syncKey); $downloadUrl = $flavorAsset->getDownloadUrl(); $notificationData = array("puserId" => $entry->getPuserId(), "entryId" => $entry->getId(), "entryIntId" => $entry->getIntId(), "entryVersion" => $entry->getVersion(), "fileFormat" => $flavorAsset->getFileExt(), "archivedFile" => $localPath, "downoladPath" => $localPath, "conversionQuality" => $entry->getConversionQuality(), "downloadUrl" => $downloadUrl); $extraData = array("data" => json_encode($notificationData), "partner_id" => $entry->getPartnerId(), "puser_id" => $entry->getPuserId(), "entry_id" => $entry->getId(), "entry_int_id" => $entry->getIntId(), "entry_version" => $entry->getVersion(), "file_format" => $flavorAsset->getFileExt(), "archived_file" => $localPath, "downolad_path" => $localPath, "target" => $localPath, "conversion_quality" => $entry->getConversionQuality(), "download_url" => $downloadUrl, "status" => $entry->getStatus(), "abort" => $dbBatchJob->getAbort(), "progress" => $dbBatchJob->getProgress(), "message" => $dbBatchJob->getMessage(), "description" => $dbBatchJob->getDescription(), "updates_count" => $dbBatchJob->getUpdatesCount(), "job_type" => BatchJobType::DOWNLOAD, "status" => BatchJob::BATCHJOB_STATUS_FINISHED, "progress" => 100, "debug" => __LINE__); myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_BATCH_JOB_SUCCEEDED, $dbBatchJob, $dbBatchJob->getPartnerId(), null, null, $extraData, $entryId); } } else { $jobIsFinished = false; $entry->createDownloadAsset($dbBatchJob, $flavorParamsId, $data->getPuserId()); } } } if ($jobIsFinished) { // mark the job as finished $dbBatchJob = kJobsManager::updateBatchJob($dbBatchJob, BatchJob::BATCHJOB_STATUS_FINISHED); } else { // mark the job as almost done $dbBatchJob = kJobsManager::updateBatchJob($dbBatchJob, BatchJob::BATCHJOB_STATUS_ALMOST_DONE); } return $dbBatchJob; }
/** * * Replaces in the uiConf the given replacmentString with the newValue and saves the changes in the UI conf * @param uiConf $uiconf * @param string $newValue * @param string $replacementString */ public static function updateUIConfFile(uiConf $uiconf, $newValue, $replacementString) { $conf_file = $uiconf->getConfFile(true); $conf_file = str_replace($replacementString, $newValue, $conf_file); $uiconf->setConfFile($conf_file); $uiconf->save(); $sync_key = $uiconf->getSyncKey(uiConf::FILE_SYNC_UICONF_SUB_TYPE_DATA); $localPath = kFileSyncUtils::getLocalFilePathForKey($sync_key); $localPath = str_replace(array('/', '\\'), array(DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR), $localPath); chmod($localPath, 0640); if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { return; } $user_group = uiConfDeployment::$arguments['user'] . ':' . uiConfDeployment::$arguments['group']; passthru("chown {$user_group} {$localPath}", $ret); if ($ret !== 0) { KalturaLog::debug("chown [{$user_group}] failed on path [{$localPath}]"); exit(1); } }