public function fromObject($sourceObject)
 {
     parent::fromObject($sourceObject);
     $this->mediaFiles = KalturaDistributionRemoteMediaFileArray::fromDbArray($sourceObject->getMediaFiles());
     if (!$this->distributionProfileId) {
         return;
     }
     if (!$this->entryDistributionId) {
         return;
     }
     $distributionProfile = DistributionProfilePeer::retrieveByPK($this->distributionProfileId);
     if (!$distributionProfile || $distributionProfile->getStatus() != DistributionProfileStatus::ENABLED) {
         return;
     }
     $this->distributionProfile = KalturaDistributionProfileFactory::createKalturaDistributionProfile($distributionProfile->getProviderType());
     $this->distributionProfile->fromObject($distributionProfile);
     $entryDistribution = EntryDistributionPeer::retrieveByPK($this->entryDistributionId);
     if ($entryDistribution) {
         $this->entryDistribution = new KalturaEntryDistribution();
         $this->entryDistribution->fromObject($entryDistribution);
     }
     $providerType = $sourceObject->getProviderType();
     if ($providerType) {
         if ($providerType == KalturaDistributionProviderType::GENERIC) {
             $this->providerData = new KalturaGenericDistributionJobProviderData($this);
         } else {
             $this->providerData = KalturaPluginManager::loadObject('KalturaDistributionJobProviderData', $providerType, array($this));
         }
         $providerData = $sourceObject->getProviderData();
         if ($this->providerData && $providerData && $providerData instanceof kDistributionJobProviderData) {
             $this->providerData->fromObject($providerData);
         }
     }
 }
 public function __construct(KalturaDistributionJobData $distributionJobData = null)
 {
     parent::__construct($distributionJobData);
     $this->notificationBaseUrl = 'http://' . kConf::get('cdn_api_host');
     if (!$distributionJobData) {
         return;
     }
     if (!$distributionJobData->distributionProfile instanceof KalturaUnicornDistributionProfile) {
         return;
     }
     $entryDistributionDb = EntryDistributionPeer::retrieveByPK($distributionJobData->entryDistributionId);
     $distributionProfileDb = DistributionProfilePeer::retrieveByPK($distributionJobData->distributionProfileId);
     /* @var $distributionProfileDb UnicornDistributionProfile */
     $flavorAssetIds = explode(',', $entryDistributionDb->getFlavorAssetIds());
     $flavorAssetId = reset($flavorAssetIds);
     $flavorAsset = assetPeer::retrieveById($flavorAssetId);
     $flavorAssetOldVersion = $entryDistributionDb->getFromCustomData(kUnicornDistributionJobProviderData::CUSTOM_DATA_FLAVOR_ASSET_OLD_VERSION);
     $flavorAssetNewVersion = null;
     if ($flavorAsset) {
         $flavorAssetNewVersion = $flavorAsset->getVersion();
     }
     $values = $distributionProfileDb->getAllFieldValues($entryDistributionDb);
     $this->catalogGuid = $values[UnicornDistributionField::CATALOG_GUID];
     $this->title = $values[UnicornDistributionField::TITLE];
     $this->flavorAssetVersion = $flavorAssetNewVersion;
     $this->mediaChanged = $flavorAssetOldVersion != $flavorAssetNewVersion;
 }
 public function getUpdateRequiredMetadataXPaths($distributionProfileId = null)
 {
     $distributionProfile = DistributionProfilePeer::retrieveByPK($distributionProfileId);
     if (!$distributionProfile || !$distributionProfile instanceof ConfigurableDistributionProfile) {
         return array();
     }
     return $distributionProfile->getUpdateRequiredMetadataXPaths();
 }
 /**
  * @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;
 }
 /**
  * @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;
 }
 /**
  * Retrieve all profiles of the provider.
  *
  * @param      int $providerId
  * @param      PropelPDO $con the connection to use
  * @return     array<DistributionProfile>
  */
 public static function retrieveByProviderId($providerId, PropelPDO $con = null)
 {
     $criteria = new Criteria();
     $criteria->add(GenericDistributionProfilePeer::PROVIDER_TYPE, DistributionProviderType::GENERIC);
     $distributionProfiles = DistributionProfilePeer::doSelect($criteria, $con);
     foreach ($distributionProfiles as $key => $distributionProfile) {
         if ($distributionProfile->getGenericProviderId() != $providerId) {
             unset($distributionProfiles[$key]);
         }
     }
     return $distributionProfiles;
 }
 /**
  * @param int $fromPartnerId
  * @param int $toPartnerId
  */
 protected function copyDistributionProfiles($fromPartnerId, $toPartnerId)
 {
     $c = new Criteria();
     $c->add(DistributionProfilePeer::PARTNER_ID, $fromPartnerId);
     $distributionProfiles = DistributionProfilePeer::doSelect($c);
     foreach ($distributionProfiles as $distributionProfile) {
         $newDistributionProfile = $distributionProfile->copy();
         $newDistributionProfile->setPartnerId($toPartnerId);
         $newDistributionProfile->save();
         kFileSyncUtils::createSyncFileLinkForKey($newDistributionProfile->getSyncKey(DistributionProfile::FILE_SYNC_DISTRIBUTION_PROFILE_CONFIG), $distributionProfile->getSyncKey(DistributionProfile::FILE_SYNC_DISTRIBUTION_PROFILE_CONFIG));
     }
 }
 /**
  * @param BatchJob $dbBatchJob
  * @param kDistributionJobData $data
  * @return BatchJob
  */
 public static function onDistributionJobFinished(BatchJob $dbBatchJob, kDistributionJobData $data)
 {
     $entryDistribution = EntryDistributionPeer::retrieveByPK($data->getEntryDistributionId());
     if (!$entryDistribution) {
         KalturaLog::err("Entry distribution [" . $data->getEntryDistributionId() . "] not found");
         return $dbBatchJob;
     }
     $distributionProfileId = $data->getDistributionProfileId();
     $distributionProfile = DistributionProfilePeer::retrieveByPK($distributionProfileId);
     // only feed spec v2 (rights feed) is setting the playlists on submit close action
     if ($distributionProfile && $distributionProfile instanceof YouTubeDistributionProfile && $distributionProfile->getFeedSpecVersion() == YouTubeDistributionFeedSpecVersion::VERSION_2) {
         self::saveCurrentPlaylistsToCustomData($data, $entryDistribution);
     }
     return $dbBatchJob;
 }
 /**
  * @param EntryDistribution $entryDistribution
  * @param SimpleXMLElement $xmlElement
  * @return SimpleXMLElement
  */
 public function contributeDistribution(EntryDistribution $entryDistribution, SimpleXMLElement $mrss)
 {
     $distributionsProvider = null;
     $distributionsProfile = DistributionProfilePeer::retrieveByPK($entryDistribution->getDistributionProfileId());
     if ($distributionsProfile) {
         $distributionsProvider = $distributionsProfile->getProvider();
     }
     $distribution = $mrss->addChild('distribution');
     $distribution->addAttribute('entryDistributionId', $entryDistribution->getId());
     $distribution->addAttribute('distributionProfileId', $entryDistribution->getDistributionProfileId());
     $distribution->addAttribute('lastReport', $entryDistribution->getLastReport(null));
     if ($distributionsProvider) {
         $distribution->addAttribute('provider', $distributionsProvider->getName());
         if ($distributionsProvider->getType() == DistributionProviderType::GENERIC) {
             $distribution->addAttribute('distributionProviderId', $distributionsProvider->getId());
         } elseif ($distributionsProvider->getType() == DistributionProviderType::SYNDICATION) {
             if ($distributionsProfile instanceof SyndicationDistributionProfile) {
                 $distribution->addAttribute('feedId', $distributionsProfile->getFeedId());
             }
         } else {
             $pluginInstances = KalturaPluginManager::getPluginInstances('IKalturaContentDistributionProvider');
             foreach ($pluginInstances as $pluginInstance) {
                 if ($pluginInstance->getProvider() === $distributionsProvider) {
                     $pluginInstance->contributeMRSS($entryDistribution, $distribution);
                 }
             }
         }
     }
     if ($entryDistribution->getRemoteId()) {
         $distribution->addChild('remoteId', $entryDistribution->getRemoteId());
     }
     if ($entryDistribution->getSunrise(null)) {
         $distribution->addChild('sunrise', $entryDistribution->getSunrise(null));
     }
     if ($entryDistribution->getSunset(null)) {
         $distribution->addChild('sunset', $entryDistribution->getSunset(null));
     }
     $flavorAssetIds = explode(',', $entryDistribution->getFlavorAssetIds());
     $flavorAssetIdsNode = $distribution->addChild('flavorAssetIds');
     foreach ($flavorAssetIds as $flavorAssetId) {
         $flavorAssetIdsNode->addChild('flavorAssetId', $flavorAssetId);
     }
     $thumbAssetIds = explode(',', $entryDistribution->getThumbAssetIds());
     $thumbAssetIdsNode = $distribution->addChild('thumbAssetIds');
     foreach ($thumbAssetIds as $thumbAssetId) {
         $thumbAssetIdsNode->addChild('thumbAssetId', $thumbAssetId);
     }
 }
 /**
  * Validates whether a we can fullfill the get feed request.
  * @throws KalturaAPIException In case we can't fullfill the request
  */
 protected function validateRequest($distributionProfileId, $hash)
 {
     if (!$this->getPartnerId() || !$this->getPartner()) {
         throw new KalturaAPIException(KalturaErrors::INVALID_PARTNER_ID, $this->getPartnerId());
     }
     $this->profile = DistributionProfilePeer::retrieveByPK($distributionProfileId);
     $profileClass = $this->getProfileClass();
     if (!$this->profile || !$this->profile instanceof $profileClass) {
         throw new KalturaAPIException(ContentDistributionErrors::DISTRIBUTION_PROFILE_NOT_FOUND, $distributionProfileId);
     }
     if ($this->profile->getStatus() != KalturaDistributionProfileStatus::ENABLED) {
         throw new KalturaAPIException(ContentDistributionErrors::DISTRIBUTION_PROFILE_DISABLED, $distributionProfileId);
     }
     if ($this->profile->getUniqueHashForFeedUrl() != $hash) {
         throw new KalturaAPIException(ContentDistributionErrors::INVALID_FEED_URL);
     }
 }
 public function validateForSubmission(EntryDistribution $entryDistribution, $action)
 {
     $validationErrors = parent::validateForSubmission($entryDistribution, $action);
     $profile = DistributionProfilePeer::retrieveByPK($entryDistribution->getDistributionProfileId());
     if (!$profile) {
         KalturaLog::err("Distribution  profile [" . $entryDistribution->getDistributionProfileId() . "] not found");
         $validationErrors[] = $this->createValidationError($action, DistributionErrorType::INVALID_DATA, 'profile', 'distribution profile not found');
         return $validationErrors;
     }
     if (strlen($profile->getFeedTitle()) <= 0) {
         $newError = $this->createValidationError($action, DistributionErrorType::INVALID_DATA, 'Feed title');
         $newError->setValidationErrorType(DistributionValidationErrorType::STRING_EMPTY);
         $validationErrors[] = $newError;
     }
     if (strlen($profile->getFeedLink()) <= 0) {
         $newError = $this->createValidationError($action, DistributionErrorType::INVALID_DATA, 'Feed link');
         $newError->setValidationErrorType(DistributionValidationErrorType::STRING_EMPTY);
         $validationErrors[] = $newError;
     }
     return $validationErrors;
 }
Beispiel #12
0
 protected function attachRemoteAssetResource(entry $entry, kDistributionSubmitJobData $data)
 {
     $distributionProfile = DistributionProfilePeer::retrieveByPK($data->getDistributionProfileId());
     /* @var $distributionProfile UnicornDistributionProfile */
     $domainGuid = $distributionProfile->getDomainGuid();
     $applicationGuid = $distributionProfile->getAdFreeApplicationGuid();
     $assetParamsId = $distributionProfile->getRemoteAssetParamsId();
     $mediaItemGuid = $data->getRemoteId();
     $url = "{$domainGuid}/{$applicationGuid}/{$mediaItemGuid}/content.m3u8";
     $entry->setSource(KalturaSourceType::URL);
     $entry->save();
     $isNewAsset = false;
     $asset = assetPeer::retrieveByEntryIdAndParams($entry->getId(), $assetParamsId);
     if (!$asset) {
         $isNewAsset = true;
         $assetParams = assetParamsPeer::retrieveByPK($assetParamsId);
         $asset = assetPeer::getNewAsset($assetParams->getType());
         $asset->setPartnerId($entry->getPartnerId());
         $asset->setEntryId($entry->getId());
         $asset->setStatus(asset::FLAVOR_ASSET_STATUS_QUEUED);
         $asset->setFlavorParamsId($assetParamsId);
         $asset->setFromAssetParams($assetParams);
         if ($assetParams->hasTag(assetParams::TAG_SOURCE)) {
             $asset->setIsOriginal(true);
         }
     }
     $asset->incrementVersion();
     $asset->setFileExt('m3u8');
     $asset->setStatus(asset::FLAVOR_ASSET_STATUS_READY);
     $asset->save();
     $syncKey = $asset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     $storageProfile = StorageProfilePeer::retrieveByPK($distributionProfile->getStorageProfileId());
     $fileSync = kFileSyncUtils::createReadyExternalSyncFileForKey($syncKey, $url, $storageProfile);
     if ($isNewAsset) {
         kEventsManager::raiseEvent(new kObjectAddedEvent($asset));
     }
     kEventsManager::raiseEvent(new kObjectDataChangedEvent($asset));
     kBusinessPostConvertDL::handleConvertFinished(null, $asset);
 }
Beispiel #13
0
 /**
  * Get the [optionally formatted] temporal [next_report] calculated value.
  * 
  * @param      string $format The date/time format string (either date()-style or strftime()-style).
  *							If format is NULL, then the raw unix timestamp integer will be returned.
  * @return     mixed Formatted date/time value as string or (integer) unix timestamp (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
  * @throws     PropelException - if unable to parse/validate the date/time value.
  */
 public function getNextReport($format = 'Y-m-d H:i:s')
 {
     if (!$this->getDistributionProfileId()) {
         return null;
     }
     $distributionProfile = DistributionProfilePeer::retrieveByPK($this->getDistributionProfileId());
     if (!$distributionProfile || $distributionProfile->getStatus() != DistributionProfileStatus::ENABLED || !$distributionProfile->getReportInterval() || $distributionProfile->getReportEnabled() == DistributionProfileActionStatus::DISABLED) {
         return null;
     }
     $reportInterval = $distributionProfile->getReportInterval() + 60 * 60 * 24;
     $lastReport = $this->getLastReport(null);
     $nextReport = time();
     if ($lastReport) {
         $nextReport = $lastReport + $reportInterval;
     }
     if ($format === null) {
         return $nextReport;
     }
     if (strpos($format, '%') !== false) {
         return strftime($format, $nextReport);
     }
     return date($format, $nextReport);
 }
 /**
  * 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 KalturaFtpDistributionProfile) {
         return;
     }
     $entryDistributionDb = EntryDistributionPeer::retrieveByPK($distributionJobData->entryDistributionId);
     $distributionProfileDb = DistributionProfilePeer::retrieveByPK($distributionJobData->distributionProfileId);
     if (is_null($entryDistributionDb)) {
         return KalturaLog::err('Entry distribution #' . $distributionJobData->entryDistributionId . ' not found');
     }
     if (is_null($distributionProfileDb)) {
         return KalturaLog::err('Distribution profile #' . $distributionJobData->distributionProfileId . ' not found');
     }
     if (!$distributionProfileDb instanceof FtpDistributionProfile) {
         return KalturaLog::err('Distribution profile #' . $distributionJobData->distributionProfileId . ' is not instance of FtpDistributionProfile');
     }
     $this->filesForDistribution = $this->getDistributionFiles($distributionProfileDb, $entryDistributionDb);
     KalturaLog::log("Files for distribution: " . print_r($this->filesForDistribution, true));
 }
 /**
  * creates all required jobs according to entry distribution dirty flags 
  * 
  * @action createRequiredJobs
  */
 function createRequiredJobsAction()
 {
     // serach all records that their next report time arrived
     $criteria = KalturaCriteria::create(EntryDistributionPeer::OM_CLASS);
     $criteria->add(EntryDistributionPeer::NEXT_REPORT, time(), Criteria::LESS_EQUAL);
     $entryDistributions = EntryDistributionPeer::doSelect($criteria);
     foreach ($entryDistributions as $entryDistribution) {
         $distributionProfile = DistributionProfilePeer::retrieveByPK($entryDistribution->getDistributionProfileId());
         if ($distributionProfile) {
             kContentDistributionManager::submitFetchEntryDistributionReport($entryDistribution, $distributionProfile);
         } else {
             KalturaLog::err("Distribution profile [" . $entryDistribution->getDistributionProfileId() . "] not found for entry distribution [" . $entryDistribution->getId() . "]");
         }
     }
     // serach all records that arrived their sunrise time and requires submittion
     $criteria = KalturaCriteria::create(EntryDistributionPeer::OM_CLASS);
     $criteria->add(EntryDistributionPeer::DIRTY_STATUS, EntryDistributionDirtyStatus::SUBMIT_REQUIRED);
     $criteria->add(EntryDistributionPeer::SUNRISE, time(), Criteria::LESS_EQUAL);
     $entryDistributions = EntryDistributionPeer::doSelect($criteria);
     foreach ($entryDistributions as $entryDistribution) {
         $distributionProfile = DistributionProfilePeer::retrieveByPK($entryDistribution->getDistributionProfileId());
         if ($distributionProfile) {
             kContentDistributionManager::submitAddEntryDistribution($entryDistribution, $distributionProfile);
         } else {
             KalturaLog::err("Distribution profile [" . $entryDistribution->getDistributionProfileId() . "] not found for entry distribution [" . $entryDistribution->getId() . "]");
         }
     }
     // serach all records that arrived their sunrise time and requires enable
     $criteria = KalturaCriteria::create(EntryDistributionPeer::OM_CLASS);
     $criteria->add(EntryDistributionPeer::DIRTY_STATUS, EntryDistributionDirtyStatus::ENABLE_REQUIRED);
     $criteria->add(EntryDistributionPeer::SUNRISE, time(), Criteria::LESS_EQUAL);
     $entryDistributions = EntryDistributionPeer::doSelect($criteria);
     foreach ($entryDistributions as $entryDistribution) {
         $distributionProfile = DistributionProfilePeer::retrieveByPK($entryDistribution->getDistributionProfileId());
         if ($distributionProfile) {
             kContentDistributionManager::submitEnableEntryDistribution($entryDistribution, $distributionProfile);
         } else {
             KalturaLog::err("Distribution profile [" . $entryDistribution->getDistributionProfileId() . "] not found for entry distribution [" . $entryDistribution->getId() . "]");
         }
     }
     // serach all records that arrived their sunset time and requires deletion
     $criteria = KalturaCriteria::create(EntryDistributionPeer::OM_CLASS);
     $criteria->add(EntryDistributionPeer::DIRTY_STATUS, EntryDistributionDirtyStatus::DELETE_REQUIRED);
     $criteria->add(EntryDistributionPeer::SUNSET, time(), Criteria::LESS_EQUAL);
     $entryDistributions = EntryDistributionPeer::doSelect($criteria);
     foreach ($entryDistributions as $entryDistribution) {
         $distributionProfile = DistributionProfilePeer::retrieveByPK($entryDistribution->getDistributionProfileId());
         if ($distributionProfile) {
             kContentDistributionManager::submitDeleteEntryDistribution($entryDistribution, $distributionProfile);
         } else {
             KalturaLog::err("Distribution profile [" . $entryDistribution->getDistributionProfileId() . "] not found for entry distribution [" . $entryDistribution->getId() . "]");
         }
     }
     // serach all records that arrived their sunset time and requires disable
     $criteria = KalturaCriteria::create(EntryDistributionPeer::OM_CLASS);
     $criteria->add(EntryDistributionPeer::DIRTY_STATUS, EntryDistributionDirtyStatus::DISABLE_REQUIRED);
     $criteria->add(EntryDistributionPeer::SUNSET, time(), Criteria::LESS_EQUAL);
     $entryDistributions = EntryDistributionPeer::doSelect($criteria);
     foreach ($entryDistributions as $entryDistribution) {
         $distributionProfile = DistributionProfilePeer::retrieveByPK($entryDistribution->getDistributionProfileId());
         if ($distributionProfile) {
             kContentDistributionManager::submitDisableEntryDistribution($entryDistribution, $distributionProfile);
         } else {
             KalturaLog::err("Distribution profile [" . $entryDistribution->getDistributionProfileId() . "] not found for entry distribution [" . $entryDistribution->getId() . "]");
         }
     }
 }
Beispiel #16
0
		$fileTransferMgr = kFileTransferMgr::getInstance(kFileTransferMgrType::FTP);
		if(!$fileTransferMgr)
			throw new Exception("SFTP manager not loaded");
			
		$fileTransferMgr->login('ftp-int.vzw.real.com', 'vp_foxsports', 'X4ul3ap');
		print_r($fileTransferMgr->listDir("/pub/in"));
//		$fileTransferMgr->putFile($destFile, $srcFile, true);

		return;*/
$entry = entryPeer::retrieveByPKNoFilter($entryId);
$mrss = kMrssManager::getEntryMrss($entry);
file_put_contents('mrss.xml', $mrss);
KalturaLog::debug("MRSS [{$mrss}]");
$distributionJobData = new KalturaDistributionSubmitJobData();
$dbDistributionProfile = DistributionProfilePeer::retrieveByPK(3);
$distributionProfile = new KalturaDailymotionDistributionProfile();
$distributionProfile->fromObject($dbDistributionProfile);
$distributionJobData->distributionProfileId = $distributionProfile->id;
$distributionJobData->distributionProfile = $distributionProfile;
$dbEntryDistribution = EntryDistributionPeer::retrieveByPK(24);
$entryDistribution = new KalturaEntryDistribution();
$entryDistribution->fromObject($dbEntryDistribution);
$distributionJobData->entryDistributionId = $entryDistribution->id;
$distributionJobData->entryDistribution = $entryDistribution;
$myp = new DailymotionDistributionProfile();
print_r($myp->validateForSubmission($dbEntryDistribution, "submit"));
$providerData = new KalturaDailymotionDistributionJobProviderData($distributionJobData);
$distributionJobData->providerData = $providerData;
//file_put_contents('out.xml', $providerData->xml);
//KalturaLog::debug("XML [$providerData->xml]");
 /**
  * Append provider specific nodes and attributes to the MRSS
  * 
  * @param EntryDistribution $entryDistribution
  * @param SimpleXMLElement $mrss
  */
 public static function contributeMRSS(EntryDistribution $entryDistribution, SimpleXMLElement $mrss)
 {
     // append YouTube specific report statistics
     $distributionProfile = DistributionProfilePeer::retrieveByPK($entryDistribution->getDistributionProfileId());
     $mrss->addChild('allow_comments', $distributionProfile->getAllowComments());
     $mrss->addChild('allow_responses', $distributionProfile->getAllowResponses());
     $mrss->addChild('allow_ratings', $distributionProfile->getAllowRatings());
     $mrss->addChild('allow_embedding', $distributionProfile->getAllowEmbedding());
     $mrss->addChild('commerical_policy', $distributionProfile->getCommercialPolicy());
     $mrss->addChild('ugc_policy', $distributionProfile->getUgcPolicy());
     $mrss->addChild('default_category', $distributionProfile->getDefaultCategory());
     $mrss->addChild('target', $distributionProfile->getTarget());
     $mrss->addChild('notification_email', $distributionProfile->getNotificationEmail());
     $mrss->addChild('account_username', $distributionProfile->getUsername());
     $mrss->addChild('ad_server_partner_id', $distributionProfile->getAdServerPartnerId());
     $mrss->addChild('allow_pre_roll_ads', $distributionProfile->getAllowPreRollAds());
     $mrss->addChild('allow_post_roll_ads', $distributionProfile->getAllowPostRollAds());
     $mrss->addChild('claim_type', $distributionProfile->getClaimType());
     $mrss->addChild('instream_standard', $distributionProfile->getInstreamStandard());
 }
 public static function loadObject($baseClass, $enumValue, array $constructorArgs = null)
 {
     if ($baseClass == 'ISyncableFile' && isset($constructorArgs['objectId'])) {
         $objectId = $constructorArgs['objectId'];
         if ($enumValue == self::getContentDistributionFileSyncObjectTypeCoreValue(ContentDistributionFileSyncObjectType::GENERIC_DISTRIBUTION_ACTION)) {
             GenericDistributionProviderActionPeer::setUseCriteriaFilter(false);
             $object = GenericDistributionProviderActionPeer::retrieveByPK($objectId);
             GenericDistributionProviderActionPeer::setUseCriteriaFilter(true);
             return $object;
         }
         if ($enumValue == self::getContentDistributionFileSyncObjectTypeCoreValue(ContentDistributionFileSyncObjectType::ENTRY_DISTRIBUTION)) {
             EntryDistributionPeer::setUseCriteriaFilter(false);
             $object = EntryDistributionPeer::retrieveByPK($objectId);
             EntryDistributionPeer::setUseCriteriaFilter(true);
             return $object;
         }
         if ($enumValue == self::getContentDistributionFileSyncObjectTypeCoreValue(ContentDistributionFileSyncObjectType::DISTRIBUTION_PROFILE)) {
             DistributionProfilePeer::setUseCriteriaFilter(false);
             $object = DistributionProfilePeer::retrieveByPK($objectId);
             DistributionProfilePeer::setUseCriteriaFilter(true);
             return $object;
         }
     }
     if ($baseClass == 'kJobData') {
         if ($enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_SUBMIT)) {
             return new kDistributionSubmitJobData();
         }
         if ($enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_UPDATE)) {
             return new kDistributionUpdateJobData();
         }
         if ($enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_DELETE)) {
             return new kDistributionDeleteJobData();
         }
         if ($enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_FETCH_REPORT)) {
             return new kDistributionFetchReportJobData();
         }
         if ($enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_ENABLE)) {
             return new kDistributionEnableJobData();
         }
         if ($enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_DISABLE)) {
             return new kDistributionDisableJobData();
         }
     }
     if ($baseClass == 'KalturaJobData') {
         if ($enumValue == self::getApiValue(ContentDistributionBatchJobType::DISTRIBUTION_SUBMIT) || $enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_SUBMIT)) {
             return new KalturaDistributionSubmitJobData();
         }
         if ($enumValue == self::getApiValue(ContentDistributionBatchJobType::DISTRIBUTION_UPDATE) || $enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_UPDATE)) {
             return new KalturaDistributionUpdateJobData();
         }
         if ($enumValue == self::getApiValue(ContentDistributionBatchJobType::DISTRIBUTION_DELETE) || $enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_DELETE)) {
             return new KalturaDistributionDeleteJobData();
         }
         if ($enumValue == self::getApiValue(ContentDistributionBatchJobType::DISTRIBUTION_FETCH_REPORT) || $enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_FETCH_REPORT)) {
             return new KalturaDistributionFetchReportJobData();
         }
         if ($enumValue == self::getApiValue(ContentDistributionBatchJobType::DISTRIBUTION_ENABLE) || $enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_ENABLE)) {
             return new KalturaDistributionEnableJobData();
         }
         if ($enumValue == self::getApiValue(ContentDistributionBatchJobType::DISTRIBUTION_DISABLE) || $enumValue == self::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_DISABLE)) {
             return new KalturaDistributionDisableJobData();
         }
     }
     return null;
 }
 /**
  * @param asset $asset
  */
 public static function onAssetReadyOrDeleted(asset $asset)
 {
     if (!ContentDistributionPlugin::isAllowedPartner($asset->getPartnerId())) {
         KalturaLog::log("Partner [" . $asset->getPartnerId() . "] is not allowed");
         return true;
     }
     $entry = $asset->getentry();
     if (!$entry) {
         KalturaLog::log("Entry [" . $asset->getEntryId() . "] not found");
         return true;
     }
     $entryDistributions = EntryDistributionPeer::retrieveByEntryId($asset->getEntryId());
     foreach ($entryDistributions as $entryDistribution) {
         $distributionProfileId = $entryDistribution->getDistributionProfileId();
         $distributionProfile = DistributionProfilePeer::retrieveByPK($distributionProfileId);
         if (!$distributionProfile) {
             KalturaLog::log("Entry distribution [" . $entryDistribution->getId() . "] profile [{$distributionProfileId}] not found");
             continue;
         }
         if ($entryDistribution->getStatus() == EntryDistributionStatus::QUEUED || $entryDistribution->getStatus() == EntryDistributionStatus::PENDING) {
             $listChanged = kContentDistributionManager::assignFlavorAssets($entryDistribution, $entry, $distributionProfile);
             $listChanged = $listChanged | kContentDistributionManager::assignThumbAssets($entryDistribution, $entry, $distributionProfile);
             $listChanged = $listChanged | kContentDistributionManager::assignAssets($entryDistribution, $entry, $distributionProfile);
             if (!$listChanged) {
                 KalturaLog::log("Entry distribution [" . $entryDistribution->getId() . "] asset lists didn't change");
                 continue;
             }
             $validationErrors = $distributionProfile->validateForSubmission($entryDistribution, DistributionAction::SUBMIT);
             $entryDistribution->setValidationErrorsArray($validationErrors);
             $entryDistribution->save();
             if ($entryDistribution->getStatus() == EntryDistributionStatus::QUEUED) {
                 if ($entryDistribution->getDirtyStatus() != EntryDistributionDirtyStatus::SUBMIT_REQUIRED) {
                     self::submitAddEntryDistribution($entryDistribution, $distributionProfile);
                 }
             }
         }
         // submit
         if ($entryDistribution->getStatus() == EntryDistributionStatus::READY || $entryDistribution->getStatus() == EntryDistributionStatus::ERROR_UPDATING) {
             $distributionProvider = $distributionProfile->getProvider();
             if (!$distributionProvider) {
                 KalturaLog::log("Entry distribution [" . $entryDistribution->getId() . "] provider not found");
                 continue;
             }
             if (!$distributionProvider->isUpdateEnabled() || !$distributionProvider->isMediaUpdateEnabled()) {
                 KalturaLog::log("Entry distribution [" . $entryDistribution->getId() . "] provider [" . $distributionProvider->getName() . "] does not support update");
                 continue;
             }
             $listChanged = kContentDistributionManager::assignFlavorAssets($entryDistribution, $entry, $distributionProfile);
             $listChanged = $listChanged | kContentDistributionManager::assignThumbAssets($entryDistribution, $entry, $distributionProfile);
             $listChanged = $listChanged | kContentDistributionManager::assignAssets($entryDistribution, $entry, $distributionProfile);
             if (!$listChanged) {
                 KalturaLog::log("Entry distribution [" . $entryDistribution->getId() . "] asset lists didn't change");
                 continue;
             }
             $validationErrors = $distributionProfile->validateForSubmission($entryDistribution, DistributionAction::UPDATE);
             $entryDistribution->setValidationErrorsArray($validationErrors);
             $entryDistribution->save();
             if (!count($validationErrors) && $distributionProfile->getUpdateEnabled() == DistributionProfileActionStatus::AUTOMATIC) {
                 self::submitUpdateEntryDistribution($entryDistribution, $distributionProfile);
             } else {
                 KalturaLog::log("Entry distribution [" . $entryDistribution->getId() . "] should not be updated automatically");
                 $entryDistribution->setDirtyStatus(EntryDistributionDirtyStatus::UPDATE_REQUIRED);
                 $entryDistribution->save();
                 continue;
             }
         }
         // update
     }
     return true;
 }
 /**
  * Append provider specific nodes and attributes to the MRSS
  * 
  * @param EntryDistribution $entryDistribution
  * @param SimpleXMLElement $mrss
  */
 public static function contributeMRSS(EntryDistribution $entryDistribution, SimpleXMLElement $mrss)
 {
     $distributionProfile = DistributionProfilePeer::retrieveByPK($entryDistribution->getDistributionProfileId());
     $mrss->addChild('channel_title', $distributionProfile->getChannelTitle());
     $mrss->addChild('channel_link', $distributionProfile->getChannelLink());
     $mrss->addChild('channel_description', $distributionProfile->getChannelDescription());
     $mrss->addChild('channel_language', $distributionProfile->getChannelLanguage());
     $mrss->addChild('channel_copyright', $distributionProfile->getChannelCopyright());
     $mrss->addChild('channel_image_title', $distributionProfile->getChannelImageTitle());
     $mrss->addChild('channel_image_url', $distributionProfile->getChannelImageUrl());
     $mrss->addChild('channel_image_link', $distributionProfile->getChannelImageLink());
     $mrss->addChild('item_media_rating', $distributionProfile->getItemMediaRating());
 }
 /**
  * @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('&', '&amp;', html_entity_decode($feed->getXml(), ENT_QUOTES, 'UTF-8'));
     die;
 }
 /**
  * Append provider specific nodes and attributes to the MRSS
  * 
  * @param EntryDistribution $entryDistribution
  * @param SimpleXMLElement $mrss
  */
 public static function contributeMRSS(EntryDistribution $entryDistribution, SimpleXMLElement $mrss)
 {
     // append AttUverse specific report statistics
     $distributionProfile = DistributionProfilePeer::retrieveByPK($entryDistribution->getDistributionProfileId());
     $mrss->addChild('channel_title', $distributionProfile->getChannelTitle());
 }
 /**
  * Append provider specific nodes and attributes to the MRSS
  * 
  * @param EntryDistribution $entryDistribution
  * @param SimpleXMLElement $mrss
  */
 public static function contributeMRSS(EntryDistribution $entryDistribution, SimpleXMLElement $mrss)
 {
     // append Yahoo specific report statistics
     $distributionProfile = DistributionProfilePeer::retrieveByPK($entryDistribution->getDistributionProfileId());
     $mrss->addChild('contact_telephone', $distributionProfile->getContactTelephone());
     $mrss->addChild('contact_email', $distributionProfile->getContactEmail());
 }
 /**
  * Append provider specific nodes and attributes to the MRSS
  * 
  * @param EntryDistribution $entryDistribution
  * @param SimpleXMLElement $mrss
  */
 public static function contributeMRSS(EntryDistribution $entryDistribution, SimpleXMLElement $mrss)
 {
     $distributionProfile = DistributionProfilePeer::retrieveByPK($entryDistribution->getDistributionProfileId());
     /* @var $distributionProfile VerizonVcastDistributionProfile */
     $mrss->addChild('ProviderName', $distributionProfile->getProviderName());
     $mrss->addChild('ProviderId', $distributionProfile->getProviderId());
     $mrss->addChild('Entitlement', $distributionProfile->getEntitlement());
     $mrss->addChild('Priority', $distributionProfile->getPriority());
     $mrss->addChild('AllowStreaming', $distributionProfile->getAllowStreaming());
     $mrss->addChild('StreamingPriceCode', $distributionProfile->getStreamingPriceCode());
     $mrss->addChild('AllowDownload', $distributionProfile->getAllowDownload());
     $mrss->addChild('DownloadPriceCode', $distributionProfile->getDownloadPriceCode());
 }
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(DistributionProfilePeer::DATABASE_NAME);
         $criteria->add(DistributionProfilePeer::ID, $pks, Criteria::IN);
         $objs = DistributionProfilePeer::doSelect($criteria, $con);
     }
     return $objs;
 }
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = DistributionProfilePeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setCreatedAt($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setUpdatedAt($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setPartnerId($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setProviderType($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setName($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setStatus($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setSubmitEnabled($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setUpdateEnabled($arr[$keys[8]]);
     }
     if (array_key_exists($keys[9], $arr)) {
         $this->setDeleteEnabled($arr[$keys[9]]);
     }
     if (array_key_exists($keys[10], $arr)) {
         $this->setReportEnabled($arr[$keys[10]]);
     }
     if (array_key_exists($keys[11], $arr)) {
         $this->setAutoCreateFlavors($arr[$keys[11]]);
     }
     if (array_key_exists($keys[12], $arr)) {
         $this->setAutoCreateThumb($arr[$keys[12]]);
     }
     if (array_key_exists($keys[13], $arr)) {
         $this->setOptionalFlavorParamsIds($arr[$keys[13]]);
     }
     if (array_key_exists($keys[14], $arr)) {
         $this->setRequiredFlavorParamsIds($arr[$keys[14]]);
     }
     if (array_key_exists($keys[15], $arr)) {
         $this->setOptionalThumbDimensions($arr[$keys[15]]);
     }
     if (array_key_exists($keys[16], $arr)) {
         $this->setRequiredThumbDimensions($arr[$keys[16]]);
     }
     if (array_key_exists($keys[17], $arr)) {
         $this->setReportInterval($arr[$keys[17]]);
     }
     if (array_key_exists($keys[18], $arr)) {
         $this->setCustomData($arr[$keys[18]]);
     }
 }
 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');
     }
 }
Beispiel #28
0
 * This script lists all distribution profiles and check if they have a valid authentication info
 */
chdir('/opt/kaltura/Jupiter-10.9.0/alpha/scripts/utils');
require_once '/opt/kaltura/Jupiter-10.9.0/alpha/scripts/bootstrap.php';
$realRun = in_array('realrun', $argv);
KalturaStatement::setDryRun(!$realRun);
if (count($argv) < 2) {
    die("Partner id is required input.\n");
}
$partnerId = intval($argv[1]);
if ($partnerId <= 0) {
    die("Partner id must be a real partner id.\n");
}
$customDataKey = null;
if (!isset($argv[2])) {
    $distributionProfile = DistributionProfilePeer::retrieveByPK(intval($argv[2]));
    $objectIdentifier = null;
    if ($distributionProfile instanceof YoutubeApiDistributionProfile) {
        $appId = YoutubeApiDistributionPlugin::GOOGLE_APP_ID;
        $objectIdentifier = md5(get_class($distributionProfile) . $distributionProfile->getUsername());
    } elseif ($distributionProfile instanceof YouTubeDistributionProfile) {
        $appId = YoutubeApiDistributionPlugin::GOOGLE_APP_ID;
        $objectIdentifier = $distributionProfile->getId();
    } else {
        die("Distribution-profile [" . $argv[2] . "] not found.\n");
    }
    $customDataKey = $appId . '_' . $objectIdentifier;
}
$partner = PartnerPeer::retrieveByPK($partnerId);
$partner->removeFromCustomData($customDataKey, 'googleAuth');
$partner->save();
 /**
  * Append provider specific nodes and attributes to the MRSS
  * 
  * @param EntryDistribution $entryDistribution
  * @param SimpleXMLElement $mrss
  */
 public static function contributeMRSS(EntryDistribution $entryDistribution, SimpleXMLElement $mrss)
 {
     $distributionProfile = DistributionProfilePeer::retrieveByPK($entryDistribution->getDistributionProfileId());
     /* @var $distributionProfile HuluDistributionProfile */
     $mrss->addChild('SeriesChannel', $distributionProfile->getSeriesChannel());
     $mrss->addChild('SeriesPrimaryCategory', $distributionProfile->getSeriesPrimaryCategory());
     foreach ($distributionProfile->getSeriesAdditionalCategories() as $category) {
         $mrss->addChild('AdditionalCategories', $category);
     }
     $mrss->addChild('SeasonNumber', $distributionProfile->getSeasonNumber());
     $mrss->addChild('SeasonSynopsis', $distributionProfile->getSeasonSynopsis());
     $mrss->addChild('SeasonTuneInInformation', $distributionProfile->getSeasonTuneInInformation());
     $mrss->addChild('MediaType', $distributionProfile->getVideoMediaType());
 }
 /**
  * Append provider specific nodes and attributes to the MRSS
  * 
  * @param EntryDistribution $entryDistribution
  * @param SimpleXMLElement $mrss
  */
 public static function contributeMRSS(EntryDistribution $entryDistribution, SimpleXMLElement $mrss)
 {
     // append comcast mrss specific configuration
     $distributionProfile = DistributionProfilePeer::retrieveByPK($entryDistribution->getDistributionProfileId());
     /* @var $distributionProfile TVComDistributionProfile */
     $mrss->addChild('feed_copyright', $distributionProfile->getFeedCopyright());
 }