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'); }
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); } }
/** * 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 KalturaExampleDistributionProfile) { return; } $this->videoAssetFilePaths = new KalturaExampleDistributionAssetPathArray(); // loads all the flavor assets that should be submitted to the remote destination site $flavorAssets = flavorAssetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->flavorAssetIds)); foreach ($flavorAssets as $flavorAsset) { $videoAssetFilePath = new KalturaExampleDistributionAssetPath(); $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $videoAssetFilePath->path = kFileSyncUtils::getLocalFilePathForKey($syncKey, true); $this->videoAssetFilePaths[] = $videoAssetFilePath; } $thumbAssets = thumbAssetPeer::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, true); } }
/** * @param EntryDistribution $entryDistribution * @param entry $entry * @param DistributionProfile $distributionProfile * @return boolean true if the list of thumbnails modified */ public static function assignThumbAssets(EntryDistribution $entryDistribution, entry $entry, DistributionProfile $distributionProfile) { $thumbAssetsIds = array(); $thumbDimensions = $distributionProfile->getThumbDimensionsObjects(); $thumbDimensionsWithKeys = array(); foreach ($thumbDimensions as $thumbDimension) { $thumbDimensionsWithKeys[$thumbDimension->getKey()] = $thumbDimension; } $originalList = $entryDistribution->getThumbAssetIds(); // remove deleted thumb assets $assignedThumbAssetIds = $originalList; if ($assignedThumbAssetIds) { $thumbAssetsIds = explode(',', $assignedThumbAssetIds); $assignedThumbAssets = thumbAssetPeer::retrieveByIds($thumbAssetsIds); foreach ($assignedThumbAssets as $assignedThumbAsset) { $key = $assignedThumbAsset->getWidth() . 'x' . $assignedThumbAsset->getHeight(); if (isset($thumbDimensionsWithKeys[$key])) { unset($thumbDimensionsWithKeys[$key]); } } } // add new thumb assets $requiredThumbParamsIds = $distributionProfile->getAutoCreateThumbArray(); $thumbAssets = thumbAssetPeer::retreiveReadyByEntryId($entry->getId()); foreach ($thumbAssets as $thumbAsset) { if (in_array($thumbAsset->getFlavorParamsId(), $requiredThumbParamsIds)) { $thumbAssetsIds[] = $thumbAsset->getId(); KalturaLog::log("Assign thumb asset [" . $thumbAsset->getId() . "] from required thumbnail params ids"); continue; } $key = $thumbAsset->getWidth() . 'x' . $thumbAsset->getHeight(); if (isset($thumbDimensionsWithKeys[$key])) { unset($thumbDimensionsWithKeys[$key]); KalturaLog::log("Assign thumb asset [" . $thumbAsset->getId() . "] from dimension [{$key}]"); $thumbAssetsIds[] = $thumbAsset->getId(); } } $entryDistribution->setThumbAssetIds($thumbAssetsIds); return $originalList != $entryDistribution->getThumbAssetIds(); }