public function __construct(KalturaDistributionJobData $distributionJobData = null) { parent::__construct($distributionJobData); if (!$distributionJobData) { return; } if (!$distributionJobData->distributionProfile instanceof KalturaDailymotionDistributionProfile) { 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); $this->videoAssetFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); } // look for krule with action block and condition of country $entry = entryPeer::retrieveByPK($distributionJobData->entryDistribution->entryId); if ($entry && $entry->getAccessControl()) { $this->setGeoBlocking($entry->getAccessControl()); } $this->addCaptionsData($distributionJobData); }
public function validateForSubmission(EntryDistribution $entryDistribution, $action) { $validationErrors = parent::validateForSubmission($entryDistribution, $action); $inListOrNullFields = array(FacebookDistributionField::CALL_TO_ACTION_TYPE_VALID_VALUES => explode(',', self::CALL_TO_ACTION_TYPE_VALID_VALUES)); if (count($entryDistribution->getFlavorAssetIds())) { $flavorAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFlavorAssetIds())); } else { $flavorAssets = assetPeer::retrieveReadyFlavorsByEntryId($entryDistribution->getEntryId()); } $validVideo = false; foreach ($flavorAssets as $flavorAsset) { $validVideo = $this->validateVideo($flavorAsset); if ($validVideo) { // even one valid video is enough break; } } if (!$validVideo) { KalturaLog::err("No valid video found for entry [" . $entryDistribution->getEntryId() . "]"); $validationErrors[] = $this->createCustomValidationError($action, DistributionErrorType::INVALID_DATA, 'flavorAsset', ' No valid flavor found'); } $allFieldValues = $this->getAllFieldValues($entryDistribution); if (!$allFieldValues || !is_array($allFieldValues)) { KalturaLog::err('Error getting field values from entry distribution id [' . $entryDistribution->getId() . '] profile id [' . $this->getId() . ']'); return $validationErrors; } if ($allFieldValues[FacebookDistributionField::SCHEDULE_PUBLISHING_TIME] && $allFieldValues[FacebookDistributionField::SCHEDULE_PUBLISHING_TIME] > time() && !dateUtils::isWithinTimeFrame($allFieldValues[FacebookDistributionField::SCHEDULE_PUBLISHING_TIME], FacebookConstants::FACEBOOK_MIN_POSTPONE_POST_IN_SECONDS, FacebookConstants::FACEBOOK_MAX_POSTPONE_POST_IN_SECONDS)) { KalturaLog::err("Scheduled time to publish defies the facebook restriction of six minute to six months from now got" . $allFieldValues[FacebookDistributionField::SCHEDULE_PUBLISHING_TIME]); $validationErrors[] = $this->createCustomValidationError($action, DistributionErrorType::INVALID_DATA, 'sunrise', 'Distribution sunrise is invalid (should be 6 minutes to 6 months from now)'); } $validationErrors = array_merge($validationErrors, $this->validateInListOrNull($inListOrNullFields, $allFieldValues, $action)); return $validationErrors; }
public function validateForSubmission(EntryDistribution $entryDistribution, $action) { $validationErrors = parent::validateForSubmission($entryDistribution, $action); //validation of flavor format $flavorAsset = null; $flavorAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFlavorAssetIds())); // if we have specific flavor assets for this distribution, grab the first one if (count($flavorAssets)) { $flavorAsset = reset($flavorAssets); $fileExt = $flavorAsset->getFileExt(); $allowedExts = explode(',', self::FLAVOR_VALID_FORMATS); if (!in_array($fileExt, $allowedExts)) { KalturaLog::debug('flavor asset id [' . $flavorAsset->getId() . '] does not have a valid extension [' . $fileExt . ']'); $errorMsg = 'Flavor format must be one of [' . self::FLAVOR_VALID_FORMATS . ']'; $validationError = $this->createValidationError($action, DistributionErrorType::INVALID_DATA); $validationError->setValidationErrorType(DistributionValidationErrorType::CUSTOM_ERROR); $validationError->setValidationErrorParam($errorMsg); $validationError->setDescription($errorMsg); $validationErrors[] = $validationError; } } $inListOrNullFields = array(IdeticDistributionField::GENRE => explode(',', self::GENRE_VALID_VALUES)); $allFieldValues = $this->getAllFieldValues($entryDistribution); if (!$allFieldValues || !is_array($allFieldValues)) { KalturaLog::err('Error getting field values from entry distribution id [' . $entryDistribution->getId() . '] profile id [' . $this->getId() . ']'); return $validationErrors; } $validationErrors = array_merge($validationErrors, $this->validateInListOrNull($inListOrNullFields, $allFieldValues, $action)); //validating Slot is a whole number $validationErrors = array_merge($validationErrors, $this->validateIsWholeNumber(IdeticDistributionField::SLOT, $allFieldValues, $action)); return $validationErrors; }
/** * 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(); }
private function createPlayManifestURLs(KalturaEntryDistribution $entryDistribution, entry $entry, TvinciDistributionFeedHelper $feedHelper) { $distributionFlavorAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->flavorAssetIds)); $videoAssetDataMap = $this->getVideoAssetDataMap(); foreach ($videoAssetDataMap as $videoAssetData) { $tvinciAssetName = $videoAssetData[0]; $playbackProtocol = $videoAssetData[1]; $tags = $videoAssetData[2]; $fileExt = $videoAssetData[3]; $keys = array(); $relevantTags = array(); foreach ($distributionFlavorAssets as $distributionFlavorAsset) { foreach ($tags as $tag) { if ($distributionFlavorAsset->isLocalReadyStatus() && $distributionFlavorAsset->hasTag($tag)) { $key = $this->createFileCoGuid($entry->getEntryId(), $distributionFlavorAsset->getFlavorParamsId()); if (!in_array($key, $keys)) { $keys[] = $key; } if (!in_array($tag, $relevantTags)) { $relevantTags[] = $tag; } } } } if ($keys) { $fileCoGuid = implode(",", $keys); $tagFlag = implode(",", $relevantTags); $url = $this->getPlayManifestUrl($entry, $playbackProtocol, $tagFlag, $fileExt); $feedHelper->setVideoAssetData($tvinciAssetName, $url, $fileCoGuid); } } }
/** * 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); }
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) { parent::__construct($distributionJobData); if (!$distributionJobData) { return; } if (!$distributionJobData->distributionProfile instanceof KalturaMsnDistributionProfile) { return; } $flavorAssetsByMsnId = array(); $entryId = $distributionJobData->entryDistribution->entryId; $distributionProfile = $distributionJobData->distributionProfile; /* @var $distributionProfile KalturaMsnDistributionProfile */ $this->addFlavorByMsnId($flavorAssetsByMsnId, 1001, $entryId, $distributionProfile->sourceFlavorParamsId); $this->addFlavorByMsnId($flavorAssetsByMsnId, 1002, $entryId, $distributionProfile->wmvFlavorParamsId); $this->addFlavorByMsnId($flavorAssetsByMsnId, 1003, $entryId, $distributionProfile->flvFlavorParamsId); $this->addFlavorByMsnId($flavorAssetsByMsnId, 1004, $entryId, $distributionProfile->slFlavorParamsId); $this->addFlavorByMsnId($flavorAssetsByMsnId, 1005, $entryId, $distributionProfile->slHdFlavorParamsId); $thumbAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->thumbAssetIds)); $feed = new MsnDistributionFeed($distributionJobData, $this); $feed->addFlavorAssetsByMsnId($flavorAssetsByMsnId); $feed->addThumbnailAssets($thumbAssets); if ($distributionJobData instanceof KalturaDistributionSubmitJobData) { $this->xml = $feed->getXml(); } if ($distributionJobData instanceof KalturaDistributionUpdateJobData) { $feed->setUUID($distributionJobData->remoteId); $this->xml = $feed->getXml(); } }
protected function handleEntry($context, $feed, entry $entry, Entrydistribution $entryDistribution) { $fields = $this->profile->getAllFieldValues($entryDistribution); $flavorAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFlavorAssetIds())); $thumbAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getThumbAssetIds())); return $feed->getItemXml($fields, count($flavorAssets) ? $flavorAssets[0] : null, count($thumbAssets) ? $thumbAssets[0] : null); }
public function __construct(KalturaDistributionJobData $distributionJobData = null) { parent::__construct($distributionJobData); if (!$distributionJobData) { return; } if (!$distributionJobData->distributionProfile instanceof KalturaYoutubeApiDistributionProfile) { 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->videoAssetFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); } } $thumbAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->thumbAssetIds)); if (count($thumbAssets)) { $syncKey = reset($thumbAssets)->getSyncKey(thumbAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); if (kFileSyncUtils::fileSync_exists($syncKey)) { $this->thumbAssetFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); } } $this->addCaptionsData($distributionJobData); }
/** * @action getFeed * @disableTags TAG_WIDGET_SESSION,TAG_ENTITLEMENT_ENTRY,TAG_ENTITLEMENT_CATEGORY * @param int $distributionProfileId * @param string $hash * @return file */ public function getFeedAction($distributionProfileId, $hash) { if (!$this->getPartnerId() || !$this->getPartner()) { throw new KalturaAPIException(KalturaErrors::INVALID_PARTNER_ID, $this->getPartnerId()); } $profile = DistributionProfilePeer::retrieveByPK($distributionProfileId); if (!$profile || !$profile instanceof UverseDistributionProfile) { throw new KalturaAPIException(ContentDistributionErrors::DISTRIBUTION_PROFILE_NOT_FOUND, $distributionProfileId); } if ($profile->getStatus() != KalturaDistributionProfileStatus::ENABLED) { throw new KalturaAPIException(ContentDistributionErrors::DISTRIBUTION_PROFILE_DISABLED, $distributionProfileId); } if ($profile->getUniqueHashForFeedUrl() != $hash) { throw new KalturaAPIException(UverseDistributionErrors::INVALID_FEED_URL); } // "Creates advanced filter on distribution profile $distributionAdvancedSearch = new ContentDistributionSearchFilter(); $distributionAdvancedSearch->setDistributionProfileId($profile->getId()); $distributionAdvancedSearch->setDistributionSunStatus(EntryDistributionSunStatus::AFTER_SUNRISE); $distributionAdvancedSearch->setEntryDistributionStatus(EntryDistributionStatus::READY); $distributionAdvancedSearch->setHasEntryDistributionValidationErrors(false); //Creates entry filter with advanced filter $entryFilter = new entryFilter(); $entryFilter->setStatusEquel(entryStatus::READY); $entryFilter->setModerationStatusNot(entry::ENTRY_MODERATION_STATUS_REJECTED); $entryFilter->setPartnerSearchScope($this->getPartnerId()); $entryFilter->setAdvancedSearch($distributionAdvancedSearch); $baseCriteria = KalturaCriteria::create(entryPeer::OM_CLASS); $baseCriteria->add(entryPeer::DISPLAY_IN_SEARCH, mySearchUtils::DISPLAY_IN_SEARCH_SYSTEM, Criteria::NOT_EQUAL); $entryFilter->attachToCriteria($baseCriteria); $entries = entryPeer::doSelect($baseCriteria); $feed = new UverseFeed('uverse_template.xml'); $feed->setDistributionProfile($profile); $feed->setChannelFields(); $lastBuildDate = $profile->getUpdatedAt(null); foreach ($entries as $entry) { /* @var $entry entry */ $entryDistribution = EntryDistributionPeer::retrieveByEntryAndProfileId($entry->getId(), $profile->getId()); if (!$entryDistribution) { KalturaLog::err('Entry distribution was not found for entry [' . $entry->getId() . '] and profile [' . $profile->getId() . ']'); continue; } $fields = $profile->getAllFieldValues($entryDistribution); $flavorAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFlavorAssetIds())); $flavorAsset = reset($flavorAssets); $flavorAssetRemoteUrl = $entryDistribution->getFromCustomData(UverseEntryDistributionCustomDataField::REMOTE_ASSET_URL); $thumbAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getThumbAssetIds())); $feed->addItem($fields, $flavorAsset, $flavorAssetRemoteUrl, $thumbAssets); // we want to find the newest update time between all entries if ($entry->getUpdatedAt(null) > $lastBuildDate) { $lastBuildDate = $entry->getUpdatedAt(null); } } $feed->setChannelLastBuildDate($lastBuildDate); header('Content-Type: text/xml'); echo $feed->getXml(); die; }
/** * @action getFeed * @disableTags TAG_WIDGET_SESSION,TAG_ENTITLEMENT_ENTRY,TAG_ENTITLEMENT_CATEGORY * @param int $distributionProfileId * @param string $hash * @return file */ public function getFeedAction($distributionProfileId, $hash) { if (!$this->getPartnerId() || !$this->getPartner()) { throw new KalturaAPIException(KalturaErrors::INVALID_PARTNER_ID, $this->getPartnerId()); } $profile = DistributionProfilePeer::retrieveByPK($distributionProfileId); if (!$profile || !$profile instanceof SynacorHboDistributionProfile) { throw new KalturaAPIException(ContentDistributionErrors::DISTRIBUTION_PROFILE_NOT_FOUND, $distributionProfileId); } if ($profile->getStatus() != KalturaDistributionProfileStatus::ENABLED) { throw new KalturaAPIException(ContentDistributionErrors::DISTRIBUTION_PROFILE_DISABLED, $distributionProfileId); } if ($profile->getUniqueHashForFeedUrl() != $hash) { throw new KalturaAPIException(SynacorHboDistributionErrors::INVALID_FEED_URL); } // "Creates advanced filter on distribution profile $distributionAdvancedSearch = new ContentDistributionSearchFilter(); $distributionAdvancedSearch->setDistributionProfileId($profile->getId()); $distributionAdvancedSearch->setDistributionSunStatus(EntryDistributionSunStatus::AFTER_SUNRISE); $distributionAdvancedSearch->setEntryDistributionStatus(EntryDistributionStatus::READY); $distributionAdvancedSearch->setEntryDistributionFlag(EntryDistributionDirtyStatus::NONE); $distributionAdvancedSearch->setHasEntryDistributionValidationErrors(false); //Creates entry filter with advanced filter $entryFilter = new entryFilter(); $entryFilter->setStatusEquel(entryStatus::READY); $entryFilter->setModerationStatusNot(entry::ENTRY_MODERATION_STATUS_REJECTED); $entryFilter->setPartnerSearchScope($this->getPartnerId()); $entryFilter->setAdvancedSearch($distributionAdvancedSearch); $baseCriteria = KalturaCriteria::create(entryPeer::OM_CLASS); $baseCriteria->add(entryPeer::DISPLAY_IN_SEARCH, mySearchUtils::DISPLAY_IN_SEARCH_SYSTEM, Criteria::NOT_EQUAL); $entryFilter->attachToCriteria($baseCriteria); $entries = entryPeer::doSelect($baseCriteria); $feed = new SynacorHboFeed('synacor_hbo_feed_template.xml'); $feed->setDistributionProfile($profile); $counter = 0; foreach ($entries as $entry) { /* @var $entry entry */ $entryDistribution = EntryDistributionPeer::retrieveByEntryAndProfileId($entry->getId(), $profile->getId()); if (!$entryDistribution) { KalturaLog::err('Entry distribution was not found for entry [' . $entry->getId() . '] and profile [' . $profile->getId() . ']'); continue; } $fields = $profile->getAllFieldValues($entryDistribution); $flavorAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFlavorAssetIds())); $thumbAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getThumbAssetIds())); $additionalAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getAssetIds())); $feed->addItem($fields, $entry, $flavorAssets, $thumbAssets, $additionalAssets); $counter++; //to avoid the cache exceeding the memory size if ($counter >= 100) { kMemoryManager::clearMemory(); $counter = 0; } } header('Content-Type: text/xml'); echo $feed->getXml(); die; }
/** * 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); }
protected function handleEntry($context, $feed, entry $entry, Entrydistribution $entryDistribution) { $fields = $this->profile->getAllFieldValues($entryDistribution); $flavorAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFlavorAssetIds())); $thumbAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getThumbAssetIds())); $xml = $feed->getItemXml($fields, $flavorAssets, $thumbAssets, $entry); if ($entry->getUpdatedAt(null) > $this->lastBuildDate) { $context->lastBuildDate = $entry->getUpdatedAt(null); } return $xml; }
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 handleEntry($context, $feed, entry $entry, Entrydistribution $entryDistribution) { $fields = $this->profile->getAllFieldValues($entryDistribution); $flavorAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFlavorAssetIds())); $flavorAsset = reset($flavorAssets); $flavorAssetRemoteUrl = $entryDistribution->getFromCustomData(UverseEntryDistributionCustomDataField::REMOTE_ASSET_URL); $thumbAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getThumbAssetIds())); $xml = $feed->getItemXml($fields, $flavorAsset, $flavorAssetRemoteUrl, $thumbAssets); // we want to find the newest update time between all entries if ($entry->getUpdatedAt(null) > $context->lastBuildDate) { $context->lastBuildDate = $entry->getUpdatedAt(null); } return $xml; }
public function __construct(KalturaDistributionJobData $distributionJobData = null) { parent::__construct($distributionJobData); if (!$distributionJobData) { return; } if (!$distributionJobData->distributionProfile instanceof KalturaTvinciDistributionProfile) { return; } $fieldValues = unserialize($this->fieldValues); $entry = null; if ($distributionJobData->entryDistribution->entryId) { $entry = entryPeer::retrieveByPK($distributionJobData->entryDistribution->entryId); } if (!$entry) { KalturaLog::err("Can't find entry with id: {$distributionJobData->entryDistribution->entryId}"); return; } $feedHelper = new TvinciDistributionFeedHelper($distributionJobData->distributionProfile, $fieldValues); $feedHelper->setEntryId($entry->getId()); $feedHelper->setCreatedAt($entry->getCreatedAtAsInt()); $broadcasterName = 'Kaltura-' . $entry->getPartnerId(); $feedHelper->setBroadcasterName($broadcasterName); $thumbAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->thumbAssetIds)); $picRatios = array(); $defaultThumbUrl = null; foreach ($thumbAssets as $thumbAsset) { $thumbDownloadUrl = $this->getAssetDownloadUrl($thumbAsset); $ratio = KDLVideoAspectRatio::ConvertFrameSize($thumbAsset->getWidth(), $thumbAsset->getHeight()); $picRatios[] = array('url' => $thumbDownloadUrl, 'ratio' => $ratio); if ($thumbAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) { $defaultThumbUrl = $thumbDownloadUrl; } } $feedHelper->setPicRatiosArray($picRatios); if (!$defaultThumbUrl && count($picRatios)) { // Choose the URL of the first resource in the array $defaultThumbUrl = $picRatios[0]['url']; } $feedHelper->setDefaultThumbnailUrl($defaultThumbUrl); $this->initPlayManifestUrls($entry, $feedHelper); if ($distributionJobData instanceof KalturaDistributionSubmitJobData) { $this->xml = $feedHelper->buildSubmitFeed(); } elseif ($distributionJobData instanceof KalturaDistributionUpdateJobData) { $this->xml = $feedHelper->buildUpdateFeed(); } elseif ($distributionJobData instanceof KalturaDistributionDeleteJobData) { $this->xml = $feedHelper->buildDeleteFeed(); } }
protected function handleEntry($context, $feed, entry $entry, Entrydistribution $entryDistribution) { $fields = $this->profile->getAllFieldValues($entryDistribution); //flavors assets and remote flavor asset file urls $flavorAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFromCustomData(AttUverseEntryDistributionCustomDataField::DISTRIBUTED_FLAVOR_IDS))); $remoteAssetFileUrls = unserialize($entryDistribution->getFromCustomData(AttUverseEntryDistributionCustomDataField::REMOTE_ASSET_FILE_URLS)); //thumb assets and remote thumb asset file urls $thumbAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFromCustomData(AttUverseEntryDistributionCustomDataField::DISTRIBUTED_THUMBNAIL_IDS))); $remoteThumbailFileUrls = unserialize($entryDistribution->getFromCustomData(AttUverseEntryDistributionCustomDataField::REMOTE_THUMBNAIL_FILE_URLS)); //thumb assets and remote thumb asset file urls $captionAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFromCustomData(AttUverseEntryDistributionCustomDataField::DISTRIBUTED_CAPTION_IDS))); $xml = $feed->getItemXml($fields, $flavorAssets, $remoteAssetFileUrls, $thumbAssets, $remoteThumbailFileUrls, $captionAssets); $context->channelTitle = $context->fields[AttUverseDistributionField::CHANNEL_TITLE]; return $xml; }
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; }
protected function handleEntry($context, $feed, entry $entry, Entrydistribution $entryDistribution) { $fields = $this->profile->getAllFieldValues($entryDistribution); $flavorAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFlavorAssetIds())); $thumbAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getThumbAssetIds())); $captionAssets = null; if ($this->profile instanceof ComcastMrssDistributionProfile && $this->profile->getShouldIncludeCaptions()) { KalturaLog::info("Adding entry captions."); $captionAssets = $this->getCaptions($entry->getPartnerId(), $entry->getId()); } $cuePoints = null; if ($this->profile instanceof ComcastMrssDistributionProfile && $this->profile->getShouldIncludeCuePoints()) { KalturaLog::info("Adding entry cue points."); $cuePoints = $this->getCuePoints($entry->getPartnerId(), $entry->getId()); } return $feed->getItemXml($fields, $flavorAssets, $thumbAssets, $captionAssets, $cuePoints); }
/** * 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 KalturaVerizonVcastDistributionProfile) { return; } // 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)); $verizonFeed = new VerizonVcastFeedHelper('verizon_vcast_template.xml', $distributionJobData, $this, $flavorAssets, $thumbAssets); $this->xml = $verizonFeed->getXml(); // save the flavors & their versions that we are sending $distributionJobData->mediaFiles = new KalturaDistributionRemoteMediaFileArray(); foreach ($flavorAssets as $flavorAsset) { $mediaFile = new KalturaDistributionRemoteMediaFile(); $mediaFile->assetId = $flavorAsset->getId(); $mediaFile->version = $flavorAsset->getVersion(); $distributionJobData->mediaFiles[] = $mediaFile; } }
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); } }
/** * 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); } }
public function __construct(KalturaDistributionJobData $distributionJobData = null) { parent::__construct($distributionJobData); if (!$distributionJobData) { return; } if (!$distributionJobData->distributionProfile instanceof KalturaIdeticDistributionProfile) { return; } $flavorAsset = null; $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); } if ($flavorAsset) { $this->flavorAssetUrl = $flavorAsset->getDownloadUrl(); } $thumbAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->thumbAssetIds)); if (count($thumbAssets)) { $thumbAsset = reset($thumbAssets)->getSyncKey(thumbAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $this->thumbnailUrl = $thumbAsset->getDownloadUrl(); } }
/** * Validate video format and video bitrate * @param $entryDistribution * @param $action */ private function validateVideoStreamFormatAndBitrate($entryDistribution, $action) { $validationErrors = array(); //validation of stream format $flavorAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFlavorAssetIds())); // if we have specific flavor assets for this distribution, grab the first one if (count($flavorAssets)) { foreach ($flavorAssets as $flavorAsset) { /* @var $flavorAsset flavorAsset */ $fileExt = strtoupper($flavorAsset->getFileExt()); $allowedExts = explode(',', self::VIDEO_STREAM_FORMAT_VALID_VALUES); //validate file format if (!in_array($fileExt, $allowedExts)) { $errorMsg = 'flavor format must be one of [' . self::VIDEO_STREAM_FORMAT_VALID_VALUES . ']'; $validationError = $this->createValidationError($action, DistributionErrorType::INVALID_DATA); $validationError->setValidationErrorType(DistributionValidationErrorType::CUSTOM_ERROR); $validationError->setValidationErrorParam($errorMsg); $validationError->setDescription($errorMsg); $validationErrors[] = $validationError; } //format is valid -> check bitrate validation /* $videoBitrate = $flavorAsset->getBitrate(); $allowedBitrates = explode(',', self::VIDEO_STREAM_BITRATE_VALID_VALUES); if (!in_array($videoBitrate, $allowedBitrates)) { $errorMsg = 'video bitrate must be one of ['.self::VIDEO_STREAM_BITRATE_VALID_VALUES.']'; $validationError = $this->createValidationError($action, DistributionErrorType::INVALID_DATA); $validationError->setValidationErrorType(DistributionValidationErrorType::CUSTOM_ERROR); $validationError->setValidationErrorParam($errorMsg); $validationError->setDescription($errorMsg); $validationErrors[] = $validationError; } //if bitrate & fileExt had been validated //check formats width and height $fileWidth = $flavorAsset->getWidth(); $fileHeight = $flavorAsset->getHeight(); $flavorDimension = array('width' => $fileWidth, 'height' => $fileHeight); if (!in_array($flavorDimension, $this->FLAVOR_ASSET_DIMENSIONS)) { $errorMsg = 'video dimensions must be one of ['.$this->FLAVOR_ASSET_DIMENSIONS.']'; $validationError = $this->createValidationError($action, DistributionErrorType::INVALID_DATA); $validationError->setValidationErrorType(DistributionValidationErrorType::CUSTOM_ERROR); $validationError->setValidationErrorParam($errorMsg); $validationError->setDescription($errorMsg); $validationErrors[] = $validationError; } */ } } return $validationErrors; }
/** * @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) { $submittingStatuses = array(EntryDistributionStatus::PENDING, EntryDistributionStatus::QUEUED, EntryDistributionStatus::SUBMITTING, EntryDistributionStatus::IMPORT_SUBMITTING, EntryDistributionStatus::ERROR_SUBMITTING); // if not in first submmiting status then it's an update and need to check if update is supported. if (!in_array($entryDistribution->getStatus(), $submittingStatuses)) { $distributionProvider = $distributionProfile->getProvider(); if (!$distributionProvider) { KalturaLog::log("Entry distribution [" . $entryDistribution->getId() . "] provider not found"); return false; } if (!$distributionProvider->isUpdateEnabled() || !$distributionProvider->isMediaUpdateEnabled()) { KalturaLog::log("Entry distribution [" . $entryDistribution->getId() . "] provider [" . $distributionProvider->getName() . "] does not support update"); return false; } } $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) { $assignedThumbAssets = assetPeer::retrieveByIds(explode(',', $assignedThumbAssetIds)); foreach ($assignedThumbAssets as $assignedThumbAsset) { $key = $assignedThumbAsset->getWidth() . 'x' . $assignedThumbAsset->getHeight(); if (isset($thumbDimensionsWithKeys[$key])) { unset($thumbDimensionsWithKeys[$key]); $thumbAssetsIds[] = $assignedThumbAsset->getId(); } } } // add new thumb assets $requiredThumbParamsIds = $distributionProfile->getAutoCreateThumbArray(); $thumbAssets = assetPeer::retrieveReadyThumbnailsByEntryId($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(); }
/** * @action getFeed * @disableTags TAG_WIDGET_SESSION,TAG_ENTITLEMENT_ENTRY,TAG_ENTITLEMENT_CATEGORY * @param int $distributionProfileId * @param string $hash * @return file */ public function getFeedAction($distributionProfileId, $hash) { if (!$this->getPartnerId() || !$this->getPartner()) { throw new KalturaAPIException(KalturaErrors::INVALID_PARTNER_ID, $this->getPartnerId()); } $profile = DistributionProfilePeer::retrieveByPK($distributionProfileId); if (!$profile || !$profile instanceof AttUverseDistributionProfile) { throw new KalturaAPIException(ContentDistributionErrors::DISTRIBUTION_PROFILE_NOT_FOUND, $distributionProfileId); } if ($profile->getStatus() != KalturaDistributionProfileStatus::ENABLED) { throw new KalturaAPIException(ContentDistributionErrors::DISTRIBUTION_PROFILE_DISABLED, $distributionProfileId); } if ($profile->getUniqueHashForFeedUrl() != $hash) { throw new KalturaAPIException(AttUverseDistributionErrors::INVALID_FEED_URL); } // "Creates advanced filter on distribution profile $distributionAdvancedSearch = new ContentDistributionSearchFilter(); $distributionAdvancedSearch->setDistributionProfileId($profile->getId()); $distributionAdvancedSearch->setDistributionSunStatus(EntryDistributionSunStatus::AFTER_SUNRISE); $distributionAdvancedSearch->setEntryDistributionStatus(EntryDistributionStatus::READY); $distributionAdvancedSearch->setEntryDistributionFlag(EntryDistributionDirtyStatus::NONE); $distributionAdvancedSearch->setHasEntryDistributionValidationErrors(false); //Creates entry filter with advanced filter $entryFilter = new entryFilter(); $entryFilter->setStatusEquel(entryStatus::READY); $entryFilter->setModerationStatusNot(entry::ENTRY_MODERATION_STATUS_REJECTED); $entryFilter->setPartnerSearchScope($this->getPartnerId()); $entryFilter->setAdvancedSearch($distributionAdvancedSearch); $baseCriteria = KalturaCriteria::create(entryPeer::OM_CLASS); $baseCriteria->add(entryPeer::DISPLAY_IN_SEARCH, mySearchUtils::DISPLAY_IN_SEARCH_SYSTEM, Criteria::NOT_EQUAL); $entryFilter->attachToCriteria($baseCriteria); $entries = entryPeer::doSelect($baseCriteria); $feed = new AttUverseDistributionFeedHelper('feed_template.xml', $profile); $channelTitle = $profile->getChannelTitle(); $counter = 0; foreach ($entries as $entry) { /* @var $entry entry */ /* @var $entryDistribution Entrydistribution */ $entryDistribution = EntryDistributionPeer::retrieveByEntryAndProfileId($entry->getId(), $profile->getId()); if (!$entryDistribution) { KalturaLog::err('Entry distribution was not found for entry [' . $entry->getId() . '] and profile [' . $profile->getId() . ']'); continue; } $fields = $profile->getAllFieldValues($entryDistribution); //flavors assets and remote flavor asset file urls $flavorAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFromCustomData(AttUverseEntryDistributionCustomDataField::DISTRIBUTED_FLAVOR_IDS))); $remoteAssetFileUrls = unserialize($entryDistribution->getFromCustomData(AttUverseEntryDistributionCustomDataField::REMOTE_ASSET_FILE_URLS)); //thumb assets and remote thumb asset file urls $thumbAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFromCustomData(AttUverseEntryDistributionCustomDataField::DISTRIBUTED_THUMBNAIL_IDS))); $remoteThumbailFileUrls = unserialize($entryDistribution->getFromCustomData(AttUverseEntryDistributionCustomDataField::REMOTE_THUMBNAIL_FILE_URLS)); //thumb assets and remote thumb asset file urls $captionAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFromCustomData(AttUverseEntryDistributionCustomDataField::DISTRIBUTED_CAPTION_IDS))); $feed->addItem($fields, $flavorAssets, $remoteAssetFileUrls, $thumbAssets, $remoteThumbailFileUrls, $captionAssets); $counter++; //to avoid the cache exceeding the memory size if ($counter >= 100) { kMemoryManager::clearMemory(); $counter = 0; } } //set channel title if (isset($fields)) { $channelTitle = $fields[AttUverseDistributionField::CHANNEL_TITLE]; } $feed->setChannelTitle($channelTitle); header('Content-Type: text/xml'); echo str_replace('&', '&', html_entity_decode($feed->getXml(), ENT_QUOTES, 'UTF-8')); die; }
/** * Retrieve by IDs instead of INT_ID * @param $ids * @param $con * @return array<flavorAsset> */ public static function retrieveByIds($ids, $con = null) { self::getInstance(); return parent::retrieveByIds($ids, $con); }
public function __construct(KalturaDistributionJobData $distributionJobData = null) { parent::__construct($distributionJobData); if (!$distributionJobData) { return; } if (!$distributionJobData->distributionProfile instanceof KalturaAttUverseDistributionProfile) { return; } /* @var $distributionProfileDb AttUverseDistributionProfile */ $distributionProfileDb = DistributionProfilePeer::retrieveByPK($distributionJobData->distributionProfileId); $distributedFlavorIds = null; $distributedThumbIds = null; $this->filesForDistribution = new KalturaAttUverseDistributionFileArray(); $entryDistributionDb = EntryDistributionPeer::retrieveByPK($distributionJobData->entryDistributionId); //Flavor Assets $flavorAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->flavorAssetIds)); if (count($flavorAssets)) { $assetLocalIds = array(); foreach ($flavorAssets as $flavorAsset) { $file = new KalturaAttUverseDistributionFile(); $file->assetType = KalturaAssetType::FLAVOR; /* @var $flavorAsset flavorAsset */ $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET); if (kFileSyncUtils::fileSync_exists($syncKey)) { $assetLocalIds[] = $flavorAsset->getId(); $file->assetId = $flavorAsset->getId(); $file->localFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); $defaultFilename = pathinfo($file->localFilePath, PATHINFO_BASENAME); $file->remoteFilename = $distributionProfileDb->getFlavorAssetFilename($entryDistributionDb, $defaultFilename, $flavorAsset->getId()); $this->filesForDistribution[] = $file; } } $distributedFlavorIds = implode(',', $assetLocalIds); } //Thumbnail $thumbAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->thumbAssetIds)); if (count($thumbAssets)) { $thumbLocalIds = array(); foreach ($thumbAssets as $thumbAsset) { $file = new KalturaAttUverseDistributionFile(); $file->assetType = KalturaAssetType::THUMBNAIL; $syncKey = $thumbAsset->getSyncKey(thumbAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET); if (kFileSyncUtils::fileSync_exists($syncKey)) { $thumbLocalIds[] = $thumbAsset->getId(); $file->assetId = $thumbAsset->getId(); $file->localFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); $defaultFilename = pathinfo($file->localFilePath, PATHINFO_BASENAME); $file->remoteFilename = $distributionProfileDb->getThumbnailAssetFilename($entryDistributionDb, $defaultFilename, $thumbAsset->getId()); $this->filesForDistribution[] = $file; } } $distributedThumbIds = implode(',', $thumbLocalIds); } //additional assets $additionalAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->assetIds)); if (count($additionalAssets)) { $captionLocalIds = array(); foreach ($additionalAssets as $additionalAsset) { $file = new KalturaAttUverseDistributionFile(); $file->assetType = kPluginableEnumsManager::coreToApi(KalturaAssetType::getEnumClass(), $additionalAsset->getType()); $syncKey = $additionalAsset->getSyncKey(CaptionAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET); $id = $additionalAsset->getId(); if (kFileSyncUtils::fileSync_exists($syncKey)) { if ($file->assetType == CaptionPlugin::getApiValue(CaptionAssetType::CAPTION) || $file->assetType == AttachmentPlugin::getApiValue(AttachmentAssetType::ATTACHMENT)) { $captionLocalIds[] = $additionalAsset->getId(); $file->assetId = $additionalAsset->getId(); $file->localFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); $defaultFilename = pathinfo($file->localFilePath, PATHINFO_BASENAME); $file->remoteFilename = $distributionProfileDb->getAssetFilename($entryDistributionDb, $defaultFilename, $additionalAsset->getId()); $this->filesForDistribution[] = $file; } } } $distributedCaptionIds = implode(',', $captionLocalIds); } //putting distributed flavors ids and distributed thumbnail ids in entry distribution custom data if ($entryDistributionDb) { $entryDistributionDb->putInCustomData(AttUverseEntryDistributionCustomDataField::DISTRIBUTED_FLAVOR_IDS, $distributedFlavorIds); $entryDistributionDb->putInCustomData(AttUverseEntryDistributionCustomDataField::DISTRIBUTED_THUMBNAIL_IDS, $distributedThumbIds); $entryDistributionDb->putInCustomData(AttUverseEntryDistributionCustomDataField::DISTRIBUTED_CAPTION_IDS, $distributedCaptionIds); $entryDistributionDb->save(); } else { KalturaLog::err('Entry distribution [' . $distributionJobData->entryDistributionId . '] not found'); } }
protected function initFlavorParamsIds() { $this->initFlavorIds(); if (is_null($this->flavorParamsIds) && !is_null($this->flavorIds)) { $flavors = assetPeer::retrieveByIds($this->flavorIds); $this->flavorParamsIds = array(); foreach ($flavors as $flavor) { /* @var $flavor asset */ $this->flavorParamsIds[] = $flavor->getFlavorParamsId(); } } if (is_null($this->flavorParamsIds)) { $this->flavorParamsIds = array(); } }