public function updatedJob(BatchJob $dbBatchJob) { $data = $dbBatchJob->getData(); $providerData = $data->getProviderData(); $entryId = $providerData->getEntryId(); $partnerId = $dbBatchJob->getPartnerId(); $spokenLanguage = $providerData->getSpokenLanguage(); if ($dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_DONT_PROCESS) { $transcript = $this->getAssetsByLanguage($entryId, array(TranscriptPlugin::getAssetTypeCoreValue(TranscriptAssetType::TRANSCRIPT)), $spokenLanguage, true); if (!$transcript) { $transcript = new TranscriptAsset(); $transcript->setType(TranscriptPlugin::getAssetTypeCoreValue(TranscriptAssetType::TRANSCRIPT)); $transcript->setEntryId($entryId); $transcript->setPartnerId($partnerId); $transcript->setLanguage($spokenLanguage); $transcript->setContainerFormat(AttachmentType::TEXT); $transcript->setAccuracy(self::DEFAULT_ACCURACY); } $transcript->setStatus(AttachmentAsset::ASSET_STATUS_QUEUED); $transcript->save(); return true; } $formatsString = $providerData->getCaptionAssetFormats(); if ($dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FINISHED) { $clientHelper = VoicebasePlugin::getClientHelper($providerData->getApiKey(), $providerData->getApiPassword()); $externalEntryExists = $clientHelper->checkExistingExternalContent($entryId); if (!$externalEntryExists) { KalturaLog::err('remote content does not exist'); return true; } $formatsArray = explode(',', $formatsString); $formatsArray[] = "TXT"; $contentsArray = $clientHelper->getRemoteTranscripts($entryId, $formatsArray); KalturaLog::debug('contents are - ' . print_r($contentsArray, true)); $transcript = $this->getAssetsByLanguage($entryId, array(TranscriptPlugin::getAssetTypeCoreValue(TranscriptAssetType::TRANSCRIPT)), $spokenLanguage, true); $captions = $this->getAssetsByLanguage($entryId, array(CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION)), $spokenLanguage); $this->setObjectContent($transcript, $contentsArray["TXT"], null, true); unset($contentsArray["TXT"]); foreach ($contentsArray as $format => $content) { $captionFormatConst = constant("KalturaCaptionType::" . $format); if (isset($captions[$captionFormatConst])) { $caption = $captions[$captionFormatConst]; } else { $caption = new CaptionAsset(); $caption->setEntryId($entryId); $caption->setPartnerId($partnerId); $caption->setLanguage($spokenLanguage); $caption->setContainerFormat($captionFormatConst); $caption->setAccuracy(self::DEFAULT_ACCURACY); $caption->setStatus(CaptionAsset::ASSET_STATUS_QUEUED); $caption->save(); } $this->setObjectContent($caption, $content, $format); } } return true; }
public static function getObjectClass($baseClass, $enumValue) { if ($baseClass == 'EventNotificationEventObjectType') { if ($enumValue == self::getEventNotificationEventObjectTypeCoreValue(CaptionAssetEventNotificationEventObjectType::CAPTION_ASSET)) { return CaptionPlugin::getObjectClass(assetPeer::OM_CLASS, CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION)); } } return null; }
protected function getCaptions($partnerId, $entryId) { $c = new Criteria(); $c->add(assetPeer::PARTNER_ID, $partnerId); $c->add(assetPeer::ENTRY_ID, $entryId); $c->add(assetPeer::TYPE, CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION)); $c->add(assetPeer::STATUS, asset::ASSET_STATUS_READY); return assetPeer::doSelect($c); }
/** * 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); }
private function addCaptionsData(KalturaDistributionJobData $distributionJobData) { $assetIdsArray = explode(',', $distributionJobData->entryDistribution->assetIds); if (empty($assetIdsArray)) { return; } $this->captionsInfo = new KalturaCaptionDistributionInfoArray(); foreach ($assetIdsArray as $assetId) { $asset = assetPeer::retrieveByIdNoFilter($assetId); if (!$asset) { KalturaLog::err("Asset [{$assetId}] not found"); continue; } if ($asset->getType() != CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION)) { KalturaLog::debug("Asset [{$assetId}] is not a caption"); continue; } if ($asset->getStatus() == asset::ASSET_STATUS_READY) { $syncKey = $asset->getSyncKey(asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); if (kFileSyncUtils::fileSync_exists($syncKey)) { $captionInfo = $this->getCaptionInfo($asset, $distributionJobData, KalturaDistributionAction::SUBMIT); if ($captionInfo) { $captionInfo->filePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); $this->captionsInfo[] = $captionInfo; } } } elseif ($asset->getStatus() == asset::ASSET_STATUS_DELETED) { $captionInfo = $this->getCaptionInfo($asset, $distributionJobData, KalturaDistributionAction::DELETE); if ($captionInfo) { $this->captionsInfo[] = $captionInfo; } } else { KalturaLog::err("Asset [{$assetId}] has status [" . $asset->getStatus() . "]. not added to provider data"); } } }
/** * List caption Assets by filter and pager * * @action list * @param KalturaAssetFilter $filter * @param KalturaFilterPager $pager * @return KalturaCaptionAssetListResponse */ function listAction(KalturaAssetFilter $filter = null, KalturaFilterPager $pager = null) { if (!$filter) { $filter = new KalturaAssetFilter(); } if (!$pager) { $pager = new KalturaFilterPager(); } $captionAssetFilter = new AssetFilter(); $filter->toObject($captionAssetFilter); $c = new Criteria(); $captionAssetFilter->attachToCriteria($c); $types = KalturaPluginManager::getExtendedTypes(assetPeer::OM_CLASS, CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION)); $c->add(assetPeer::TYPE, $types, Criteria::IN); $totalCount = assetPeer::doCount($c); $pager->attachToCriteria($c); $dbList = assetPeer::doSelect($c); $list = KalturaCaptionAssetArray::fromDbArray($dbList); $response = new KalturaCaptionAssetListResponse(); $response->objects = $list; $response->totalCount = $totalCount; return $response; }
/** * List caption Assets by filter and pager * * @action list * @param KalturaAssetFilter $filter * @param KalturaFilterPager $pager * @return KalturaCaptionAssetListResponse */ function listAction(KalturaAssetFilter $filter = null, KalturaFilterPager $pager = null) { if (!$filter) { $filter = new KalturaCaptionAssetFilter(); } elseif (!$filter instanceof KalturaCaptionAssetFilter) { $filter = $filter->cast('KalturaCaptionAssetFilter'); } if (!$pager) { $pager = new KalturaFilterPager(); } $types = KalturaPluginManager::getExtendedTypes(assetPeer::OM_CLASS, CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION)); return $filter->getTypeListResponse($pager, $this->getResponseProfile(), $types); }
public static function getCaptionSearchData(entry $entry) { $captionAssets = assetPeer::retrieveByEntryId($entry->getId(), array(CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION))); if (!$captionAssets || !count($captionAssets)) { return null; } $data = array(); foreach ($captionAssets as $captionAsset) { /* @var $captionAsset CaptionAsset */ $syncKey = $captionAsset->getSyncKey(asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $content = kFileSyncUtils::file_get_contents($syncKey, true, false); if (!$content) { continue; } $captionsContentManager = kCaptionsContentManager::getCoreContentManager($captionAsset->getContainerFormat()); if (!$captionsContentManager) { KalturaLog::err("Captions content manager not found for format [" . $captionAsset->getContainerFormat() . "]"); continue; } $content = $captionsContentManager->getContent($content); if (!$content) { continue; } $data[] = $captionAsset->getId() . " ca_prefix {$content} ca_sufix"; } $dataField = CaptionSearchPlugin::getSearchFieldName(CaptionSearchPlugin::SEARCH_FIELD_DATA); $searchValues = array($dataField => CaptionSearchPlugin::PLUGIN_NAME . ' ' . implode(' ', $data) . ' ' . CaptionSearchPlugin::SEARCH_TEXT_SUFFIX); return $searchValues; }
public function getCaptionAssetInfo($captionAssetIds) { $captionAssetInfo = array(); $assetIdsArray = explode(',', $captionAssetIds); if (empty($assetIdsArray)) { return; } $assets = assetPeer::retrieveByIds($assetIdsArray); foreach ($assets as $asset) { $assetType = $asset->getType(); if ($assetType == CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION)) { /* @var $asset CaptionAsset */ $syncKey = $asset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); if (kFileSyncUtils::fileSync_exists($syncKey)) { $captionAssetInfo[$asset->getId()]['fileUrl'] = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); $captionAssetInfo[$asset->getId()]['fileExt'] = $asset->getFileExt(); $captionAssetInfo[$asset->getId()]['language'] = $asset->getLanguage(); break; } } } return $captionAssetInfo; }
public function updatedJob(BatchJob $dbBatchJob) { $data = $dbBatchJob->getData(); $providerData = $data->getProviderData(); $entryId = $providerData->getEntryId(); $partnerId = $dbBatchJob->getPartnerId(); $spokenLanguage = $providerData->getSpokenLanguage(); $transcript = $this->getAssetsByLanguage($entryId, array(TranscriptPlugin::getAssetTypeCoreValue(TranscriptAssetType::TRANSCRIPT)), $spokenLanguage, true); if ($dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FAILED) { if ($transcript) { $transcript->setStatus(AttachmentAsset::FLAVOR_ASSET_STATUS_ERROR); $transcript->save(); } } if ($dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_DONT_PROCESS) { if (!$transcript) { $transcript = new TranscriptAsset(); $transcript->setType(TranscriptPlugin::getAssetTypeCoreValue(TranscriptAssetType::TRANSCRIPT)); $transcript->setEntryId($entryId); $transcript->setPartnerId($partnerId); $transcript->setLanguage($spokenLanguage); $transcript->setContainerFormat(AttachmentType::TEXT); } $transcript->setStatus(AttachmentAsset::ASSET_STATUS_QUEUED); $transcript->save(); return true; } $formatsString = $providerData->getCaptionAssetFormats(); if ($dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FINISHED) { $clientHelper = Cielo24Plugin::getClientHelper($providerData->getUsername(), $providerData->getPassword()); $remoteJobId = $clientHelper->getRemoteFinishedJobId($entryId); if (!$remoteJobId) { KalturaLog::err('remote content does not exist'); return true; } $formatsArray = explode(',', $formatsString); $transcriptContent = $clientHelper->getRemoteTranscript($remoteJobId); KalturaLog::debug("transcript content - {$transcriptContent}"); $captionsContentArray = $clientHelper->getRemoteCaptions($remoteJobId, $formatsArray); KalturaLog::debug("captions content - " . print_r($captionsContentArray, true)); $captions = $this->getAssetsByLanguage($entryId, array(CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION)), $spokenLanguage); switch ($providerData->getFidelity()) { case KalturaCielo24Fidelity::MECHANICAL: $accuracyRate = self::MECHNICAL_TRANSCRIPTION_ACCURACY_VALUE; break; case KalturaCielo24Fidelity::PREMIUM: $accuracyRate = self::PREMIUM_TRANSCRIPTION_ACCURACY_VALUE; break; case KalturaCielo24Fidelity::PROFESSIONAL: $accuracyRate = self::PROFESSIONAL_TRANSCRIPTION_ACCURACY_VALUE; break; } $this->setObjectContent($transcript, $transcriptContent, $accuracyRate, null, true); foreach ($captionsContentArray as $format => $content) { $captionFormatConst = constant("KalturaCaptionType::" . $format); if (isset($captions[$captionFormatConst])) { $caption = $captions[$captionFormatConst]; } else { $caption = new CaptionAsset(); $caption->setEntryId($entryId); $caption->setPartnerId($partnerId); $caption->setLanguage($spokenLanguage); $caption->setContainerFormat($captionFormatConst); $caption->setStatus(CaptionAsset::ASSET_STATUS_QUEUED); $caption->save(); } $this->setObjectContent($caption, $content, $accuracyRate, $format); } } return true; }
public function applyDefaultValues() { parent::applyDefaultValues(); $this->setType(CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION)); }
public function getOptionalAssetDistributionRules() { $ret = parent::getOptionalAssetDistributionRules(); if (!class_exists('CaptionPlugin') || !CaptionPlugin::isAllowedPartner($this->getPartnerId())) { return $ret; } $isCaptionCondition = new kAssetDistributionPropertyCondition(); $isCaptionCondition->setPropertyName(assetPeer::translateFieldName(assetPeer::TYPE, BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME)); $isCaptionCondition->setPropertyValue(CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION)); $captionDistributionRule = new kAssetDistributionRule(); $captionDistributionRule->setAssetDistributionConditions(array($isCaptionCondition)); $ret[] = $captionDistributionRule; return $ret; }
public function contribute(BaseObject $object, SimpleXMLElement $mrss, kMrssParameters $mrssParams = null) { if (!$object instanceof entry) { return; } $types = KalturaPluginManager::getExtendedTypes(assetPeer::OM_CLASS, CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION)); $captionAssets = assetPeer::retrieveByEntryId($object->getId(), $types); foreach ($captionAssets as $captionAsset) { $this->contributeCaptionAssets($captionAsset, $mrss); } }
public static function getManifestEditors($config) { $contributors = array(); switch ($config->format) { case PlaybackProtocol::APPLE_HTTP: $contributor = new WebVttCaptionsManifestEditor(); $contributor->captions = array(); //retrieve the current working partner's captions according to the entryId $c = new Criteria(); $c->addAnd(assetPeer::ENTRY_ID, $config->entryId); $c->addAnd(assetPeer::TYPE, CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION)); $captionAssets = assetPeer::doSelect($c); if (!count($captionAssets)) { return array(); } foreach ($captionAssets as $captionAsset) { /* @var $captionAsset CaptionAsset */ $captionAssetObj = array(); if ($captionAsset->getContainerFormat() == CaptionType::WEBVTT) { $captionAssetObj['url'] = $captionAsset->getExternalUrl($config->storageId); } else { if (!PermissionPeer::isValidForPartner(CaptionPermissionName::FEATURE_GENERATE_WEBVTT_CAPTIONS, $captionAsset->getPartnerId())) { continue; } $cdnHost = myPartnerUtils::getCdnHost($captionAsset->getPartnerId()); $versionStr = ''; if ($captionAsset->getVersion() > 1) { $versionStr = '/version/' . $captionAsset->getVersion(); } $ksStr = ''; if ($captionAsset->isKsNeededForDownload()) { $ksStr = '/ks/' . self::generateKsForCaptionServe($captionAsset); } $captionAssetObj['url'] = $cdnHost . '/api_v3/index.php/service/caption_captionasset/action/serveWebVTT' . '/captionAssetId/' . $captionAsset->getId() . $ksStr . $versionStr . '/a.m3u8'; } $label = $captionAsset->getLabel(); if (!$label) { $label = $captionAsset->getLanguage(); } if (!$label) { $label = 'Track' . (count($contributor->captions) + 1); } $captionAssetObj['label'] = $label; $captionAssetObj['default'] = $captionAsset->getDefault() ? "YES" : "NO"; if (isset(self::$captionsFormatMap[$captionAsset->getLanguage()])) { $captionAssetObj['language'] = self::$captionsFormatMap[$captionAsset->getLanguage()]; } KalturaLog::info("Object passed into editor: " . print_r($captionAssetObj, true)); $contributor->captions[] = $captionAssetObj; } KalturaLog::debug("contributor captions :" . print_r($contributor->captions, true)); if ($contributor->captions) { $contributors[] = $contributor; } break; } return $contributors; }
/** * @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; }
/** * @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; } } } }
/** * @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; } } } }
/** * @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; }
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 getListResponse(KalturaFilterPager $pager, KalturaDetachedResponseProfile $responseProfile = null) { $types = KalturaPluginManager::getExtendedTypes(assetPeer::OM_CLASS, CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION)); return $this->getTypeListResponse($pager, $responseProfile, $types); }