/**
  * 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);
 }
 /**
  * List attachment Assets by filter and pager
  * 
  * @action list
  * @param KalturaAssetFilter $filter
  * @param KalturaFilterPager $pager
  * @return KalturaAttachmentAssetListResponse
  */
 function listAction(KalturaAssetFilter $filter = null, KalturaFilterPager $pager = null)
 {
     if (!$filter) {
         $filter = new KalturaAssetFilter();
     }
     if (!$pager) {
         $pager = new KalturaFilterPager();
     }
     $attachmentAssetFilter = new AssetFilter();
     $filter->toObject($attachmentAssetFilter);
     $c = new Criteria();
     $attachmentAssetFilter->attachToCriteria($c);
     $types = KalturaPluginManager::getExtendedTypes(assetPeer::OM_CLASS, AttachmentPlugin::getAssetTypeCoreValue(AttachmentAssetType::ATTACHMENT));
     $c->add(assetPeer::TYPE, $types, Criteria::IN);
     $totalCount = assetPeer::doCount($c);
     $pager->attachToCriteria($c);
     $dbList = assetPeer::doSelect($c);
     $list = KalturaAttachmentAssetArray::fromDbArray($dbList);
     $response = new KalturaAttachmentAssetListResponse();
     $response->objects = $list;
     $response->totalCount = $totalCount;
     return $response;
 }
 private function addCaptionsData(KalturaDistributionJobData $distributionJobData)
 {
     /* @var $mediaFile KalturaDistributionRemoteMediaFile */
     $assetIdsArray = explode(',', $distributionJobData->entryDistribution->assetIds);
     if (empty($assetIdsArray)) {
         return;
     }
     $assets = array();
     $this->captionsInfo = new KalturaDailymotionDistributionCaptionInfoArray();
     foreach ($assetIdsArray as $assetId) {
         $asset = assetPeer::retrieveByIdNoFilter($assetId);
         if (!$asset) {
             KalturaLog::err("Asset [{$assetId}] not found");
             continue;
         }
         if ($asset->getStatus() == asset::ASSET_STATUS_READY) {
             $assets[] = $asset;
         } elseif ($asset->getStatus() == asset::ASSET_STATUS_DELETED) {
             $captionInfo = new KalturaDailymotionDistributionCaptionInfo();
             $captionInfo->action = KalturaDailymotionDistributionCaptionAction::DELETE_ACTION;
             $captionInfo->assetId = $assetId;
             //getting the asset's remote id
             foreach ($distributionJobData->mediaFiles as $mediaFile) {
                 if ($mediaFile->assetId == $assetId) {
                     $captionInfo->remoteId = $mediaFile->remoteId;
                     $this->captionsInfo[] = $captionInfo;
                     break;
                 }
             }
         } else {
             KalturaLog::err("Asset [{$assetId}] has status [" . $asset->getStatus() . "]. not added to provider data");
         }
     }
     foreach ($assets as $asset) {
         $assetType = $asset->getType();
         switch ($assetType) {
             case CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION):
                 $syncKey = $asset->getSyncKey(asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
                 if (kFileSyncUtils::fileSync_exists($syncKey)) {
                     $captionInfo = $this->getCaptionInfo($asset, $syncKey, $distributionJobData);
                     if ($captionInfo) {
                         $captionInfo->language = $this->getLanguageCode($asset->getLanguage());
                         $captionInfo->format = $this->getCaptionFormat($asset);
                         if ($captionInfo->language) {
                             $this->captionsInfo[] = $captionInfo;
                         } else {
                             KalturaLog::err('The caption [' . $asset->getId() . '] has unrecognized language [' . $asset->getLanguage() . ']');
                         }
                     }
                 }
                 break;
             case AttachmentPlugin::getAssetTypeCoreValue(AttachmentAssetType::ATTACHMENT):
                 $syncKey = $asset->getSyncKey(asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
                 if (kFileSyncUtils::fileSync_exists($syncKey)) {
                     $captionInfo = $this->getCaptionInfo($asset, $syncKey, $distributionJobData);
                     if ($captionInfo) {
                         //language code should be set in the attachments title
                         $captionInfo->language = $asset->getTitle();
                         $captionInfo->format = $this->getCaptionFormat($asset);
                         $languageCodeReflector = KalturaTypeReflectorCacher::get('KalturaLanguageCode');
                         //check if the language code exists
                         if ($languageCodeReflector && $languageCodeReflector->getConstantName($captionInfo->language)) {
                             $this->captionsInfo[] = $captionInfo;
                         } else {
                             KalturaLog::err('The attachment [' . $asset->getId() . '] has unrecognized language [' . $asset->getTitle() . ']');
                         }
                     }
                 }
                 break;
         }
     }
 }
 public function contribute(BaseObject $object, SimpleXMLElement $mrss, kMrssParameters $mrssParams = null)
 {
     if (!$object instanceof entry) {
         return;
     }
     $types = KalturaPluginManager::getExtendedTypes(assetPeer::OM_CLASS, AttachmentPlugin::getAssetTypeCoreValue(AttachmentAssetType::ATTACHMENT));
     $attachmentAssets = assetPeer::retrieveByEntryId($object->getId(), $types);
     foreach ($attachmentAssets as $attachmentAsset) {
         $this->contributeAttachmentAssets($attachmentAsset, $mrss);
     }
 }
 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');
     }
 }
 /**
  * @param DOMElement $item
  * @param array $captionAssets
  * @param array $remoteCaptionFileUrls
  */
 public function setCaptionAsset($item, array $captionAssets)
 {
     if (is_array($captionAssets)) {
         foreach ($captionAssets as $captionAsset) {
             /* @var $additionalAsset asset */
             $assetType = $captionAsset->getType();
             switch ($assetType) {
                 case CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION):
                     /* @var $captionPlugin CaptionPlugin */
                     $captionPlugin = KalturaPluginManager::getPluginInstance(CaptionPlugin::PLUGIN_NAME);
                     $dummyElement = new SimpleXMLElement('<dummy/>');
                     $captionPlugin->contributeCaptionAssets($captionAsset, $dummyElement);
                     $dummyDom = dom_import_simplexml($dummyElement);
                     $captionDom = $dummyDom->getElementsByTagName('subTitle');
                     $captionDom = $this->doc->importNode($captionDom->item(0), true);
                     $captionDom = $item->appendChild($captionDom);
                     break;
                 case AttachmentPlugin::getAssetTypeCoreValue(AttachmentAssetType::ATTACHMENT):
                     /* @var $attachmentPlugin AttachmentPlugin */
                     $attachmentPlugin = KalturaPluginManager::getPluginInstance(AttachmentPlugin::PLUGIN_NAME);
                     $dummyElement = new SimpleXMLElement('<dummy/>');
                     $attachmentPlugin->contributeAttachmentAssets($captionAsset, $dummyElement);
                     $dummyDom = dom_import_simplexml($dummyElement);
                     $attachmentDom = $dummyDom->getElementsByTagName('attachment');
                     $attachmentDom = $this->doc->importNode($attachmentDom->item(0), true);
                     $attachmentDom = $item->appendChild($attachmentDom);
                     break;
             }
         }
     }
 }
Example #7
0
 public function applyDefaultValues()
 {
     parent::applyDefaultValues();
     $this->setType(AttachmentPlugin::getAssetTypeCoreValue(AttachmentAssetType::ATTACHMENT));
 }
 /**
  * @param array $values
  */
 public function addItem(array $values, flavorAsset $flavorAsset = null, thumbAsset $thumbAsset = null, array $additionalAssets = null)
 {
     $item = $this->item->cloneNode(true);
     $channelNode = $this->xpath->query('/rss/channel', $item)->item(0);
     $channelNode->appendChild($item);
     $pubDate = date('c', $values[TVComDistributionField::ITEM_PUB_DATE]);
     $expDate = date('c', $values[TVComDistributionField::ITEM_EXP_DATE]);
     $node = $this->setNodeValue('guid', $values[TVComDistributionField::GUID_ID], $item);
     $node = $this->setNodeValue('pubDate', $pubDate, $item);
     $node = $this->setNodeValue('expDate', $expDate, $item);
     $node = $this->setNodeValue('link', $values[TVComDistributionField::ITEM_LINK], $item);
     $node = $this->setNodeValue('media:group/media:title', $values[TVComDistributionField::MEDIA_TITLE], $item);
     $node = $this->setNodeValue('media:group/media:description', $values[TVComDistributionField::MEDIA_DESCRIPTION], $item);
     $node = $this->setNodeValue('media:group/media:keywords', $values[TVComDistributionField::MEDIA_KEYWORDS], $item);
     $node = $this->setNodeValue('media:group/media:copyright', $values[TVComDistributionField::MEDIA_COPYRIGHT], $item);
     $node = $this->setNodeValue('media:group/media:rating', $values[TVComDistributionField::MEDIA_RATING], $item);
     $node = $this->setNodeValue('media:group/media:restriction/@relationship', $values[TVComDistributionField::MEDIA_RESTRICTION_TYPE], $item);
     $node = $this->setNodeValue('media:group/media:restriction', $values[TVComDistributionField::MEDIA_RESTRICTION_COUNTRIES], $item);
     $node = $this->setNodeValue('media:group/media:category[@scheme=\'urn:tvcom:show-tmsid\']', $values[TVComDistributionField::MEDIA_CATEGORY_SHOW_TMSID], $item);
     $node = $this->setNodeValue('media:group/media:category[@scheme=\'urn:tvcom:show-tmsid\']/@label', $values[TVComDistributionField::MEDIA_CATEGORY_SHOW_TMSID_LABEL], $item);
     $node = $this->setNodeValue('media:group/media:category[@scheme=\'urn:tvcom:episode-tmsid\']', $values[TVComDistributionField::MEDIA_CATEGORY_EPISODE_TMSID], $item);
     $node = $this->setNodeValue('media:group/media:category[@scheme=\'urn:tvcom:episode-tmsid\']/@label', $values[TVComDistributionField::MEDIA_CATEGORY_EPISODE_TMSID_LABEL], $item);
     $node = $this->setNodeValue('media:group/media:category[@scheme=\'urn:tvcom:episodetype\']', $values[TVComDistributionField::MEDIA_CATEGORY_EPISODE_TYPE], $item);
     $node = $this->setNodeValue('media:group/media:category[@scheme=\'urn:tvcom:original_air_date\']', $values[TVComDistributionField::MEDIA_CATEGORY_ORIGINAL_AIR_DATE], $item);
     $node = $this->setNodeValue('media:group/media:category[@scheme=\'urn:tvcom:video_format\']', $values[TVComDistributionField::MEDIA_CATEGORY_VIDEO_FORMAT], $item);
     $node = $this->setNodeValue('media:group/media:category[@scheme=\'urn:tvcom:season_number\']', $values[TVComDistributionField::MEDIA_CATEGORY_SEASON_NUMBER], $item);
     $node = $this->setNodeValue('media:group/media:category[@scheme=\'urn:tvcom:episode_number\']', $values[TVComDistributionField::MEDIA_CATEGORY_EPISODE_NUMBER], $item);
     $dcTerms = "start={$pubDate}; end={$expDate}; scheme=W3C-DTF";
     $node = $this->setNodeValue('dcterms:valid', $dcTerms, $item);
     if ($flavorAsset) {
         $node = $this->setNodeValue('media:group/media:content/@url', $this->getAssetUrl($flavorAsset), $item);
         $type = '';
         switch ($flavorAsset->getFileExt()) {
             case 'mp4':
                 $type = 'video/mp4';
                 break;
             case 'flv':
                 $type = 'video/x-flv';
                 break;
         }
         $node = $this->setNodeValue('media:group/media:content/@type', $type, $item);
         $node = $this->setNodeValue('media:group/media:content/@fileSize', $flavorAsset->getSize(), $item);
         $node = $this->setNodeValue('media:group/media:content/@expression', $values[TVComDistributionField::MEDIA_CATEGORY_EPISODE_TYPE], $item);
         $node = $this->setNodeValue('media:group/media:content/@duration', floor($flavorAsset->getentry()->getDuration()), $item);
     }
     if ($thumbAsset) {
         $node = $this->setNodeValue('media:group/media:thumbnail/@url', $this->getAssetUrl($thumbAsset), $item);
         $node = $this->setNodeValue('media:group/media:thumbnail/@width', $thumbAsset->getWidth(), $item);
         $node = $this->setNodeValue('media:group/media:thumbnail/@height', $thumbAsset->getHeight(), $item);
     }
     if (is_array($additionalAssets)) {
         foreach ($additionalAssets as $additionalAsset) {
             /* @var $additionalAsset asset */
             $assetType = $additionalAsset->getType();
             switch ($assetType) {
                 case CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION):
                     /* @var $captionPlugin CaptionPlugin */
                     $captionPlugin = KalturaPluginManager::getPluginInstance(CaptionPlugin::PLUGIN_NAME);
                     $dummyElement = new SimpleXMLElement('<dummy/>');
                     $captionPlugin->contributeCaptionAssets($additionalAsset, $dummyElement);
                     $dummyDom = dom_import_simplexml($dummyElement);
                     $captionDom = $dummyDom->getElementsByTagName('subTitle');
                     $captionDom = $this->doc->importNode($captionDom->item(0), true);
                     $captionDom = $item->appendChild($captionDom);
                     break;
                 case AttachmentPlugin::getAssetTypeCoreValue(AttachmentAssetType::ATTACHMENT):
                     /* @var $attachmentPlugin AttachmentPlugin */
                     $attachmentPlugin = KalturaPluginManager::getPluginInstance(AttachmentPlugin::PLUGIN_NAME);
                     $dummyElement = new SimpleXMLElement('<dummy/>');
                     $attachmentPlugin->contributeAttachmentAssets($additionalAsset, $dummyElement);
                     $dummyDom = dom_import_simplexml($dummyElement);
                     $attachmentDom = $dummyDom->getElementsByTagName('attachment');
                     $attachmentDom = $this->doc->importNode($attachmentDom->item(0), true);
                     $attachmentDom = $item->appendChild($attachmentDom);
                     break;
             }
         }
     }
 }
Example #9
0
 /**
  * List attachment Assets by filter and pager
  * 
  * @action list
  * @param KalturaAssetFilter $filter
  * @param KalturaFilterPager $pager
  * @return KalturaAttachmentAssetListResponse
  */
 function listAction(KalturaAssetFilter $filter = null, KalturaFilterPager $pager = null)
 {
     if (!$filter) {
         $filter = new KalturaAttachmentAssetFilter();
     } elseif (!$filter instanceof KalturaAttachmentAssetFilter) {
         $filter = $filter->cast('KalturaAttachmentAssetFilter');
     }
     if (!$pager) {
         $pager = new KalturaFilterPager();
     }
     $types = KalturaPluginManager::getExtendedTypes(assetPeer::OM_CLASS, AttachmentPlugin::getAssetTypeCoreValue(AttachmentAssetType::ATTACHMENT));
     return $filter->getTypeListResponse($pager, $this->getResponseProfile(), $types);
 }
 public function getListResponse(KalturaFilterPager $pager, KalturaDetachedResponseProfile $responseProfile = null)
 {
     $types = KalturaPluginManager::getExtendedTypes(assetPeer::OM_CLASS, AttachmentPlugin::getAssetTypeCoreValue(AttachmentAssetType::ATTACHMENT));
     return $this->getTypeListResponse($pager, $responseProfile, $types);
 }
Example #11
0
 /**
  * @param array $values
  * @param array $flavorAssets
  * @param array $thumbAssets
  */
 public function getItem(array $values, array $flavorAssets = null, array $thumbAssets = null, array $additionalAssets = null)
 {
     $item = $this->item->cloneNode(true);
     kXml::setNodeValue($this->xpath, 'guid', $values[TimeWarnerDistributionField::GUID], $item);
     kXml::setNodeValue($this->xpath, 'title', $values[TimeWarnerDistributionField::TITLE], $item);
     kXml::setNodeValue($this->xpath, 'description', $values[TimeWarnerDistributionField::DESCRIPTION], $item);
     kXml::setNodeValue($this->xpath, 'author', $values[TimeWarnerDistributionField::AUTHOR], $item);
     kXml::setNodeValue($this->xpath, 'pubDate', $this->formatTimeWarnerDate($values[TimeWarnerDistributionField::PUB_DATE]), $item);
     kXml::setNodeValue($this->xpath, 'media:copyright', $values[TimeWarnerDistributionField::MEDIA_COPYRIGHT], $item);
     kXml::setNodeValue($this->xpath, 'media:keywords', $values[TimeWarnerDistributionField::MEDIA_KEYWORDS], $item);
     kXml::setNodeValue($this->xpath, 'media:rating', $values[TimeWarnerDistributionField::MEDIA_RATING], $item);
     //handle category
     $this->addCategory($item, 'CT-' . $values[TimeWarnerDistributionField::MEDIA_CATEGORY_CT]);
     if ($values[TimeWarnerDistributionField::MEDIA_CATEGORY_GR] != "") {
         $this->addCategory($item, 'GR-' . $values[TimeWarnerDistributionField::MEDIA_CATEGORY_GR]);
     } else {
         $this->addCategory($item, 'GR-None');
     }
     $this->addCategory($item, 'TX-' . $values[TimeWarnerDistributionField::MEDIA_CATEGORY_TX]);
     $geCategories = explode(',', $values[TimeWarnerDistributionField::MEDIA_CATEGORY_GE]);
     $geCategories = array_unique($geCategories);
     foreach ($geCategories as $geCategory) {
         $this->addCategory($item, 'GE-' . $geCategory);
     }
     kXml::setNodeValue($this->xpath, 'plmedia:approved', $values[TimeWarnerDistributionField::PLMEDIA_APPROVED], $item);
     kXml::setNodeValue($this->xpath, 'twcable:episodeNumber', $values[TimeWarnerDistributionField::CABLE_EPISODE_NUMBER], $item);
     kXml::setNodeValue($this->xpath, 'twcable:externalID', $values[TimeWarnerDistributionField::CABLE_EXTERNAL_ID], $item);
     kXml::setNodeValue($this->xpath, 'twcable:productionDate', $values[TimeWarnerDistributionField::CABLE_PRODUCTION_DATE], $item);
     kXml::setNodeValue($this->xpath, 'twcable:network', $values[TimeWarnerDistributionField::CABLE_NETWORK], $item);
     kXml::setNodeValue($this->xpath, 'twcable:provider', $values[TimeWarnerDistributionField::CABLE_PROVIDER], $item);
     kXml::setNodeValue($this->xpath, 'twcable:shortDescription', $values[TimeWarnerDistributionField::CABLE_SHORT_DESCRIPTION], $item);
     kXml::setNodeValue($this->xpath, 'twcable:shortTitle', $values[TimeWarnerDistributionField::CABLE_SHORT_TITLE], $item);
     kXml::setNodeValue($this->xpath, 'twcable:showName', $values[TimeWarnerDistributionField::CABLE_SHOW_NAME], $item);
     $startTime = date('c', $values[TimeWarnerDistributionField::START_TIME]);
     $endTime = date('c', $values[TimeWarnerDistributionField::END_TIME]);
     $dcTerms = "start={$startTime}; end={$endTime};";
     kXml::setNodeValue($this->xpath, 'dcterms:valid', $dcTerms, $item);
     if (!is_null($flavorAssets) && is_array($flavorAssets) && count($flavorAssets) > 0) {
         $this->setFlavorAsset($item, $flavorAssets);
     }
     if (!is_null($thumbAssets) && is_array($thumbAssets) && count($thumbAssets) > 0) {
         $this->setThumbAsset($item, $thumbAssets);
     }
     if (is_array($additionalAssets)) {
         foreach ($additionalAssets as $additionalAsset) {
             /* @var $additionalAsset asset */
             $assetType = $additionalAsset->getType();
             switch ($assetType) {
                 case CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION):
                     /* @var $captionPlugin CaptionPlugin */
                     $captionPlugin = KalturaPluginManager::getPluginInstance(CaptionPlugin::PLUGIN_NAME);
                     $dummyElement = new SimpleXMLElement('<dummy/>');
                     $captionPlugin->contributeCaptionAssets($additionalAsset, $dummyElement);
                     $dummyDom = dom_import_simplexml($dummyElement);
                     $captionDom = $dummyDom->getElementsByTagName('subTitle');
                     $captionDom = $this->doc->importNode($captionDom->item(0), true);
                     $captionDom = $item->appendChild($captionDom);
                     break;
                 case AttachmentPlugin::getAssetTypeCoreValue(AttachmentAssetType::ATTACHMENT):
                     /* @var $attachmentPlugin AttachmentPlugin */
                     $attachmentPlugin = KalturaPluginManager::getPluginInstance(AttachmentPlugin::PLUGIN_NAME);
                     $dummyElement = new SimpleXMLElement('<dummy/>');
                     $attachmentPlugin->contributeAttachmentAssets($additionalAsset, $dummyElement);
                     $dummyDom = dom_import_simplexml($dummyElement);
                     $attachmentDom = $dummyDom->getElementsByTagName('attachment');
                     $attachmentDom = $this->doc->importNode($attachmentDom->item(0), true);
                     $attachmentDom = $item->appendChild($attachmentDom);
                     break;
             }
         }
     }
     return $item;
 }
 public static function dependsOn()
 {
     $bulkUploadXmlDependency = new KalturaDependency(self::BULK_UPLOAD_XML_PLUGIN_NAME);
     $attachmentDependency = new KalturaDependency(AttachmentPlugin::getPluginName());
     return array($bulkUploadXmlDependency, $attachmentDependency);
 }
Example #13
0
 public static function dependsOn()
 {
     $dependency = new KalturaDependency(AttachmentPlugin::getPluginName());
     return array($dependency);
 }
 /**
  * Getting name of attachment
  * @return string|null Attachment name or error
  */
 public function getAttachmentName()
 {
     if ($this->getType() == AttachmentPlugin::getAssetTypeCoreValue(AttachmentAssetType::ATTACHMENT)) {
         return $this->getFromCustomData('filename');
     }
     return null;
 }
Example #15
0
 /**
  * @param array $values
  * @param array $flavorAssets
  * @param array $thumbAssets
  */
 public function getItem(array $values, entry $entry, array $flavorAssets = null, array $thumbAssets = null, array $additionalAssets = null)
 {
     $item = $this->item->cloneNode(true);
     kXml::setNodeValue($this->xpath, 'atom:title', $values[SynacorHboDistributionField::ENTRY_TITLE], $item);
     kXml::setNodeValue($this->xpath, 'atom:summary', $values[SynacorHboDistributionField::ENTRY_SUMMARY], $item);
     $updatedTime = $this->formatSynacorHboTime($values[SynacorHboDistributionField::ENTRY_UPDATED]);
     kXml::setNodeValue($this->xpath, 'atom:updated', $updatedTime, $item);
     kXml::setNodeValue($this->xpath, 'atom:author/atom:name', $values[SynacorHboDistributionField::ENTRY_AUTHOR_NAME], $item);
     $categoryValue = $values[SynacorHboDistributionField::ENTRY_CATEGORY_TERM];
     if (strlen($categoryValue) > 0) {
         kXml::setNodeValue($this->xpath, 'atom:category/@term', $categoryValue, $item);
     } else {
         $this->removeNode('atom:category', $item);
     }
     $genreValue = $values[SynacorHboDistributionField::ENTRY_GENRE_TERM];
     if (strlen($genreValue) > 0) {
         kXml::setNodeValue($this->xpath, 'atom:genre/@term', $genreValue, $item);
     } else {
         $this->removeNode('atom:genre', $item);
     }
     kXml::setNodeValue($this->xpath, 'atom:assetType', $values[SynacorHboDistributionField::ENTRY_ASSET_TYPE], $item);
     kXml::setNodeValue($this->xpath, 'atom:assetId', $values[SynacorHboDistributionField::ENTRY_ASSET_ID], $item);
     $startTime = $this->formatSynacorHboTime($values[SynacorHboDistributionField::ENTRY_OFFERING_START]);
     kXml::setNodeValue($this->xpath, 'atom:offering/atom:start', $startTime, $item);
     $endTime = $this->formatSynacorHboTime($values[SynacorHboDistributionField::ENTRY_OFFERING_END]);
     kXml::setNodeValue($this->xpath, 'atom:offering/atom:end', $endTime, $item);
     $ratingValue = $values[SynacorHboDistributionField::ENTRY_RATING];
     if (strlen($ratingValue) > 0) {
         kXml::setNodeValue($this->xpath, 'atom:rating', $ratingValue, $item);
         $ratingType = stripos($ratingValue, 'tv') === '0' ? 'tv' : 'theatrical';
         kXml::setNodeValue($this->xpath, 'atom:rating/@type', $ratingType, $item);
     } else {
         $this->removeNode('atom:rating', $item);
     }
     $durationInSeconds = ceil($entry->getDuration());
     $durationInMinuesRoundedUp = ceil($durationInSeconds / 60);
     kXml::setNodeValue($this->xpath, 'atom:runtime', $durationInMinuesRoundedUp, $item);
     kXml::setNodeValue($this->xpath, 'atom:runtime/@timeInSeconds', $durationInSeconds, $item);
     kXml::setNodeValue($this->xpath, 'go:series/go:title', $values[SynacorHboDistributionField::ENTRY_SERIES_TITLE], $item);
     kXml::setNodeValue($this->xpath, 'atom:brand', $values[SynacorHboDistributionField::ENTRY_BRAND], $item);
     if (!is_null($flavorAssets) && is_array($flavorAssets) && count($flavorAssets) > 0) {
         $flavorAsset = $flavorAssets[0];
         /* @var $flavorAsset flavorAsset */
         $flavorUrl = $this->getAssetUrl($flavorAsset);
         // we don't have a way to identify the mime type of the file
         // as there is no guarantee that the file exists in the current data center
         // so we will just use those hardcoded conditions
         $mimeType = '';
         switch ($flavorAsset->getFileExt()) {
             case 'flv':
                 $mimeType = 'video/x-flv';
                 break;
             case 'mp4':
                 $mimeType = 'video/mp4';
                 break;
             case 'mpeg':
             case 'mpg':
                 $mimeType = 'video/mpeg';
                 break;
             default:
                 $mimeType = 'video/x-flv';
                 // default requested by synacor
         }
         kXml::setNodeValue($this->xpath, 'atom:link[@type=\'VIDEO_MIME_TYPE\']/@href', $flavorUrl, $item);
         kXml::setNodeValue($this->xpath, 'atom:link[@type=\'VIDEO_MIME_TYPE\']/@type', $mimeType, $item);
     }
     if (!is_null($thumbAssets) && is_array($thumbAssets) && count($thumbAssets) > 0) {
         $thumbAsset = $thumbAssets[0];
         /* @var $thumbAssets thumbAssets */
         $thumbUrl = $this->getAssetUrl($thumbAsset);
         kXml::setNodeValue($this->xpath, 'atom:link[@type=\'image/jpeg\']/@href', $thumbUrl, $item);
     }
     if (is_array($additionalAssets)) {
         foreach ($additionalAssets as $additionalAsset) {
             /* @var $additionalAsset asset */
             $assetType = $additionalAsset->getType();
             switch ($assetType) {
                 case CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION):
                     /* @var $captionPlugin CaptionPlugin */
                     $captionPlugin = KalturaPluginManager::getPluginInstance(CaptionPlugin::PLUGIN_NAME);
                     $dummyElement = new SimpleXMLElement('<dummy/>');
                     $captionPlugin->contributeCaptionAssets($additionalAsset, $dummyElement);
                     $dummyDom = dom_import_simplexml($dummyElement);
                     $captionDom = $dummyDom->getElementsByTagName('subTitle');
                     $captionDom = $this->doc->importNode($captionDom->item(0), true);
                     $captionDom = $item->appendChild($captionDom);
                     break;
                 case AttachmentPlugin::getAssetTypeCoreValue(AttachmentAssetType::ATTACHMENT):
                     /* @var $attachmentPlugin AttachmentPlugin */
                     $attachmentPlugin = KalturaPluginManager::getPluginInstance(AttachmentPlugin::PLUGIN_NAME);
                     $dummyElement = new SimpleXMLElement('<dummy/>');
                     $attachmentPlugin->contributeAttachmentAssets($additionalAsset, $dummyElement);
                     $dummyDom = dom_import_simplexml($dummyElement);
                     $attachmentDom = $dummyDom->getElementsByTagName('attachment');
                     $attachmentDom = $this->doc->importNode($attachmentDom->item(0), true);
                     $attachmentDom = $item->appendChild($attachmentDom);
                     break;
             }
         }
     }
     return $item;
 }