本文整理汇总了PHP中kJobsManager::addImportJob方法的典型用法代码示例。如果您正苦于以下问题:PHP kJobsManager::addImportJob方法的具体用法?PHP kJobsManager::addImportJob怎么用?PHP kJobsManager::addImportJob使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kJobsManager
的用法示例。
在下文中一共展示了kJobsManager::addImportJob方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: attachCreatedObject
/**
* @param BaseObject $object
*/
public function attachCreatedObject(BaseObject $object)
{
$dropFolderFile = DropFolderFilePeer::retrieveByPK($this->getDropFolderFileId());
$dropFolder = DropFolderPeer::retrieveByPK($dropFolderFile->getDropFolderId());
$entryId = $asset = null;
// create import job for remote drop folder files
if ($dropFolder instanceof RemoteDropFolder) {
// get params
if ($object instanceof asset) {
$entryId = $object->getEntryId();
$asset = $object;
} else {
if ($object instanceof entry) {
$entryId = $object->getId();
$asset = null;
} else {
return;
}
}
$importUrl = $dropFolder->getFolderUrl();
$importUrl .= '/' . $dropFolderFile->getFileName();
$jobData = $dropFolder->getImportJobData();
$jobData->setDropFolderFileId($this->getDropFolderFileId());
// add job
kJobsManager::addImportJob(null, $entryId, $dropFolderFile->getPartnerId(), $importUrl, $asset, $dropFolder->getFileTransferMgrType(), $jobData);
// set file status to DOWNLOADING
$dropFolderFile->setStatus(DropFolderFileStatus::DOWNLOADING);
$dropFolderFile->save();
}
}
示例2: attachUrlResource
/**
* @param kUrlResource $resource
* @param entry $dbEntry
* @param asset $dbAsset
* @return asset
*/
protected function attachUrlResource(kUrlResource $resource, entry $dbEntry, asset $dbAsset = null)
{
if ($dbAsset instanceof flavorAsset) {
$dbEntry->setSource(KalturaSourceType::URL);
$dbEntry->save();
}
$url = $resource->getUrl();
if (!$resource->getForceAsyncDownload()) {
// TODO - move image handling to media service
if ($dbEntry->getMediaType() == KalturaMediaType::IMAGE) {
$entryFullPath = myContentStorage::getFSUploadsPath() . '/' . $dbEntry->getId() . '.jpg';
if (KCurlWrapper::getDataFromFile($url, $entryFullPath)) {
return $this->attachFile($entryFullPath, $dbEntry, $dbAsset);
}
KalturaLog::err("Failed downloading file[{$url}]");
$dbEntry->setStatus(entryStatus::ERROR_IMPORTING);
$dbEntry->save();
return null;
}
if ($dbAsset && !$dbAsset instanceof flavorAsset) {
$ext = pathinfo($url, PATHINFO_EXTENSION);
$entryFullPath = myContentStorage::getFSUploadsPath() . '/' . $dbEntry->getId() . '.' . $ext;
if (KCurlWrapper::getDataFromFile($url, $entryFullPath)) {
$dbAsset = $this->attachFile($entryFullPath, $dbEntry, $dbAsset);
return $dbAsset;
}
KalturaLog::err("Failed downloading file[{$url}]");
$dbAsset->setStatus(asset::FLAVOR_ASSET_STATUS_ERROR);
$dbAsset->save();
return null;
}
}
kJobsManager::addImportJob(null, $dbEntry->getId(), $this->getPartnerId(), $url, $dbAsset, null, $resource->getImportJobData());
return $dbAsset;
}
示例3: handleEntry
//.........这里部分代码省略.........
$this->entry_id = $entry->getId();
}
// move thumb to final destination and set db entry
if ($media_type != entry::ENTRY_MEDIA_TYPE_AUDIO && $entry_thumbNum && $need_thumb) {
KalturaLog::debug("handleEntry: saving none audio thumb [{$thumbBigFullPath}]");
$entry->setThumbnail('.jpg');
if ($thumbBigFullPath) {
if ($media_type != entry::ENTRY_MEDIA_TYPE_IMAGE) {
myFileConverter::convertImage($thumbBigFullPath, $thumbFullPath);
}
/*$thumbBigFinalPath = $content.$entry->getBigThumbnailPath();
myContentStorage::moveFile($thumbBigFullPath, $thumbBigFinalPath, true , $should_copy );
*/
$entryThumbKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
try {
if (!$should_copy) {
kFileSyncUtils::moveFromFile($thumbBigFullPath, $entryThumbKey);
} else {
kFileSyncUtils::copyFromFile($thumbBigFullPath, $entryThumbKey);
}
} catch (Exception $e) {
$entry->setStatus(entryStatus::ERROR_CONVERTING);
$entry->save();
throw $e;
}
}
}
// after extracting the thumb we can move the entry to its next destination
KalturaLog::debug("handleEntry: current status [" . $entry->getStatus() . "]");
// if needed a job will be submitted for importing external media sources
if ($entry->getStatus() == entryStatus::IMPORT) {
KalturaLog::debug("handleEntry: creating import job");
// changed by Tan-Tan, Nov 09 to support the new batch mechanism
kJobsManager::addImportJob(null, $this->entry_id, $this->partner_id, $entry_url);
// remarked by Tan-Tan
// $entry_fullPath = $content.'/content/imports/data/'.$this->entry_id.".".$ext;
// myContentStorage::fullMkdir($entry_fullPath);
//
// $batchClient = new myBatchUrlImportClient();
// $batchClient->addJob($this->entry_id, $entry_url, $entry_fullPath);
} else {
if ($entry->getStatus() == entryStatus::PRECONVERT) {
if (!$skip_conversion) {
// changed by Tan-Tan, Dec 09 to support the new batch mechanism
KalturaLog::debug("handleEntry: creating original flavor asset for pre convert");
$flavorAsset = kFlowHelper::createOriginalFlavorAsset($this->partner_id, $this->entry_id);
if ($flavorAsset) {
$flavorAsset->setFileExt($ext);
$flavorAsset->save();
$syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
try {
kFileSyncUtils::moveFromFile($entry_fullPath, $syncKey);
} catch (Exception $e) {
$entry->setStatus(entryStatus::ERROR_CONVERTING);
$flavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_ERROR);
$entry->save();
$flavorAsset->save();
throw $e;
}
kEventsManager::raiseEvent(new kObjectAddedEvent($flavorAsset));
} else {
$entry->setStatus(entryStatus::ERROR_CONVERTING);
}
// Remarked by Tan-Tan
// $targetFileName = $this->entry_id.".".$ext;
// if ( false /* old conversion */)
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:67,代码来源:myInsertEntryHelper.class.php
示例4: addConvertProfileJob
/**
* @param BatchJob $batchJob
* @param entry $entry
* @param string $flavorAssetId
* @param string $inputFileSyncLocalPath
* @return BatchJob
*/
public static function addConvertProfileJob(BatchJob $parentJob = null, entry $entry, $flavorAssetId, $inputFileSyncLocalPath)
{
KalturaLog::debug("Parent job [" . ($parentJob ? $parentJob->getId() : 'none') . "] entry [" . $entry->getId() . "] flavor asset [{$flavorAssetId}] input file [{$inputFileSyncLocalPath}]");
if ($entry->getConversionQuality() == conversionProfile2::CONVERSION_PROFILE_NONE) {
$entry->setStatus(entryStatus::PENDING);
$entry->save();
KalturaLog::notice('Entry should not be converted');
return null;
}
$importingSources = false;
// if file size is 0, do not create conversion profile and set entry status as error converting
if (!file_exists($inputFileSyncLocalPath) || kFile::fileSize($inputFileSyncLocalPath) == 0) {
KalturaLog::debug("Input file [{$inputFileSyncLocalPath}] does not exist");
$partner = $entry->getPartner();
$conversionProfile = myPartnerUtils::getConversionProfile2ForEntry($entry->getId());
// load the asset params to the instance pool
$flavorIds = flavorParamsConversionProfilePeer::getFlavorIdsByProfileId($conversionProfile->getId());
assetParamsPeer::retrieveByPKs($flavorIds);
$conversionRequired = false;
$sourceFileRequiredStorages = array();
$sourceIncludedInProfile = false;
$flavorAsset = assetPeer::retrieveById($flavorAssetId);
$flavors = flavorParamsConversionProfilePeer::retrieveByConversionProfile($conversionProfile->getId());
KalturaLog::debug("Found flavors [" . count($flavors) . "] in conversion profile [" . $conversionProfile->getId() . "]");
foreach ($flavors as $flavor) {
/* @var $flavor flavorParamsConversionProfile */
if ($flavor->getFlavorParamsId() == $flavorAsset->getFlavorParamsId()) {
KalturaLog::debug("Flavor [" . $flavor->getFlavorParamsId() . "] is ingested source");
$sourceIncludedInProfile = true;
continue;
}
$flavorParams = assetParamsPeer::retrieveByPK($flavor->getFlavorParamsId());
if ($flavorParams instanceof liveParams || $flavor->getOrigin() == assetParamsOrigin::INGEST) {
KalturaLog::debug("Flavor [" . $flavor->getFlavorParamsId() . "] should be ingested");
continue;
}
if ($flavor->getOrigin() == assetParamsOrigin::CONVERT_WHEN_MISSING) {
$siblingFlavorAsset = assetPeer::retrieveByEntryIdAndParams($entry->getId(), $flavor->getFlavorParamsId());
if ($siblingFlavorAsset) {
KalturaLog::debug("Flavor [" . $flavor->getFlavorParamsId() . "] already ingested");
continue;
}
}
$sourceFileRequiredStorages[] = $flavorParams->getSourceRemoteStorageProfileId();
$conversionRequired = true;
break;
}
if ($conversionRequired) {
foreach ($sourceFileRequiredStorages as $storageId) {
if ($storageId == StorageProfile::STORAGE_KALTURA_DC) {
$key = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
list($syncFile, $local) = kFileSyncUtils::getReadyFileSyncForKey($key, true, false);
if ($syncFile && $syncFile->getFileType() == FileSync::FILE_SYNC_FILE_TYPE_URL && $partner && $partner->getImportRemoteSourceForConvert()) {
KalturaLog::debug("Creates import job for remote file sync");
$url = $syncFile->getExternalUrl($entry->getId());
kJobsManager::addImportJob($parentJob, $entry->getId(), $partner->getId(), $url, $flavorAsset, null, null, true);
$importingSources = true;
continue;
}
} elseif ($flavorAsset->getExternalUrl($storageId)) {
continue;
}
kBatchManager::updateEntry($entry->getId(), entryStatus::ERROR_CONVERTING);
$flavorAsset = assetPeer::retrieveById($flavorAssetId);
$flavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_ERROR);
$flavorAsset->setDescription('Entry of size 0 should not be converted');
$flavorAsset->save();
KalturaLog::err('Entry of size 0 should not be converted');
return null;
}
} else {
if ($flavorAsset->getStatus() == asset::FLAVOR_ASSET_STATUS_QUEUED) {
if ($sourceIncludedInProfile) {
$flavorAsset->setStatusLocalReady();
} else {
$flavorAsset->setStatus(asset::FLAVOR_ASSET_STATUS_DELETED);
$flavorAsset->setDeletedAt(time());
}
$flavorAsset->save();
if ($sourceIncludedInProfile) {
kBusinessPostConvertDL::handleConvertFinished(null, $flavorAsset);
}
}
return null;
}
}
if ($entry->getStatus() != entryStatus::READY) {
$entry->setStatus(entryStatus::PRECONVERT);
}
$jobData = new kConvertProfileJobData();
$jobData->setFlavorAssetId($flavorAssetId);
$jobData->setInputFileSyncLocalPath($inputFileSyncLocalPath);
$jobData->setExtractMedia(true);
//.........这里部分代码省略.........
示例5: attachUrl
/**
* @param flavorAsset $flavorAsset
* @param string $url
* @param kImportJobData $importJobData
*/
protected function attachUrl(flavorAsset $flavorAsset, $url, kImportJobData $importJobData = null)
{
$flavorAsset->save();
kJobsManager::addImportJob(null, $flavorAsset->getEntryId(), $this->getPartnerId(), $url, $flavorAsset, null, $importJobData);
}