/** * Parse content of caption asset and index it * * @action parse * @param string $captionAssetId * @throws KalturaCaptionErrors::CAPTION_ASSET_ID_NOT_FOUND */ function parseAction($captionAssetId) { $captionAsset = assetPeer::retrieveById($captionAssetId); if (!$captionAsset) { throw new KalturaAPIException(KalturaCaptionErrors::CAPTION_ASSET_ID_NOT_FOUND, $captionAssetId); } $captionAssetItems = CaptionAssetItemPeer::retrieveByAssetId($captionAssetId); foreach ($captionAssetItems as $captionAssetItem) { /* @var $captionAssetItem CaptionAssetItem */ $captionAssetItem->delete(); } $syncKey = $captionAsset->getSyncKey(asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $content = kFileSyncUtils::file_get_contents($syncKey, true, false); if (!$content) { return; } $captionsContentManager = kCaptionsContentManager::getCoreContentManager($captionAsset->getContainerFormat()); $itemsData = $captionsContentManager->parse($content); foreach ($itemsData as $itemData) { $item = new CaptionAssetItem(); $item->setCaptionAssetId($captionAsset->getId()); $item->setEntryId($captionAsset->getEntryId()); $item->setPartnerId($captionAsset->getPartnerId()); $item->setStartTime($itemData['startTime']); $item->setEndTime($itemData['endTime']); $item->setContent(utf8_encode($itemData['content'])); $item->save(); } }
protected function copyLiveMetadata(baseEntry $object, $liveEntryId) { $recordedEntryId = $object->getId(); $partnerId = $object->getPartnerId(); $metadataProfiles = MetadataProfilePeer::retrieveAllActiveByPartnerId($partnerId, MetadataObjectType::ENTRY); foreach ($metadataProfiles as $metadataProfile) { $originMetadataObj = MetadataPeer::retrieveByObject($metadataProfile->getId(), MetadataObjectType::ENTRY, $liveEntryId); if ($originMetadataObj) { $metadataProfileId = $metadataProfile->getId(); $metadataProfileVersion = $metadataProfile->getVersion(); $destMetadataObj = new Metadata(); $destMetadataObj->setPartnerId($partnerId); $destMetadataObj->setMetadataProfileId($metadataProfileId); $destMetadataObj->setMetadataProfileVersion($metadataProfileVersion); $destMetadataObj->setObjectType(MetadataObjectType::ENTRY); $destMetadataObj->setObjectId($recordedEntryId); $destMetadataObj->setStatus(KalturaMetadataStatus::VALID); $originMetadataKey = $originMetadataObj->getSyncKey(Metadata::FILE_SYNC_METADATA_DATA); $originXml = kFileSyncUtils::file_get_contents($originMetadataKey, true, false); // validate object exists $object = kMetadataManager::getObjectFromPeer($destMetadataObj); if ($object) { $destMetadataObj->save(); } else { KalturaLog::err('invalid object type'); continue; } $destMetadataKey = $destMetadataObj->getSyncKey(Metadata::FILE_SYNC_METADATA_DATA); kFileSyncUtils::file_put_contents($destMetadataKey, $originXml); } } }
public function execute() { $jobId = $this->getRequestParameter("id"); $partnerId = $this->getRequestParameter("pid"); $type = $this->getRequestParameter("type"); $c = new Criteria(); $c->addAnd(BatchJobPeer::ID, $jobId); $c->addAnd(BatchJobPeer::PARTNER_ID, $partnerId); $c->addAnd(BatchJobPeer::JOB_TYPE, BatchJobType::BULKUPLOAD); $batchJob = BatchJobPeer::doSelectOne($c); if (!$batchJob) { die("File not found"); } header("Content-Type: text/plain; charset=UTF-8"); if ($type == "log") { $bulkUploadResults = BulkUploadResultPeer::retrieveByBulkUploadId($jobId); if (!count($bulkUploadResults)) { $syncKey = $batchJob->getSyncKey(BatchJob::FILE_SYNC_BATCHJOB_SUB_TYPE_BULKUPLOADLOG); if (kFileSyncUtils::file_exists($syncKey, true)) { $content = kFileSyncUtils::file_get_contents($syncKey, true); echo $content; die; } die("Log file is not ready"); } $STDOUT = fopen('php://output', 'w'); $data = $batchJob->getData(); foreach ($bulkUploadResults as $bulkUploadResult) { $values = array($bulkUploadResult->getTitle(), $bulkUploadResult->getDescription(), $bulkUploadResult->getTags(), $bulkUploadResult->getUrl(), $bulkUploadResult->getContentType()); if ($data instanceof kBulkUploadJobData && $data->getCsvVersion() > kBulkUploadJobData::BULK_UPLOAD_CSV_VERSION_V1) { $values[] = $bulkUploadResult->getConversionProfileId(); $values[] = $bulkUploadResult->getAccessControlProfileId(); $values[] = $bulkUploadResult->getCategory(); $values[] = $bulkUploadResult->getScheduleStartDate('Y-m-d\\TH:i:s'); $values[] = $bulkUploadResult->getScheduleEndDate('Y-m-d\\TH:i:s'); $values[] = $bulkUploadResult->getThumbnailUrl(); $values[] = $bulkUploadResult->getPartnerData(); } $values[] = $bulkUploadResult->getEntryId(); $values[] = $bulkUploadResult->getEntryStatus(); $values[] = $bulkUploadResult->getErrorDescription(); fputcsv($STDOUT, $values); } fclose($STDOUT); } else { $syncKey = $batchJob->getSyncKey(BatchJob::FILE_SYNC_BATCHJOB_SUB_TYPE_BULKUPLOADCSV); if (kFileSyncUtils::file_exists($syncKey, true)) { $content = kFileSyncUtils::file_get_contents($syncKey, true); echo $content; die; } else { die("File not found"); } } die; // no template needed }
public function __construct(KalturaDistributionJobData $distributionJobData = null) { parent::__construct($distributionJobData); if (!$distributionJobData || !$distributionJobData->distributionProfile instanceof KalturaTvinciDistributionProfile || !$distributionJobData->entryDistribution) { return; } $entry = null; if ($distributionJobData->entryDistribution->entryId) { $entry = entryPeer::retrieveByPK($distributionJobData->entryDistribution->entryId); } if (!$entry) { KalturaLog::err("Can't find entry with id: {$distributionJobData->entryDistribution->entryId}"); return; } $feedHelper = new TvinciDistributionFeedHelper($distributionJobData->distributionProfile); $feedHelper->setEntryId($entry->getId()); $feedHelper->setReferenceId($entry->getReferenceID()); $feedHelper->setDescription($entry->getDescription()); $feedHelper->setTitleName($entry->getName()); $feedHelper->setSunrise($distributionJobData->entryDistribution->sunrise); $feedHelper->setSunset($distributionJobData->entryDistribution->sunset); $thumbAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->thumbAssetIds)); $picRatios = array(); $defaultThumbUrl = null; foreach ($thumbAssets as $thumbAsset) { $thumbDownloadUrl = $this->getAssetDownloadUrl($thumbAsset); $ratio = KDLVideoAspectRatio::ConvertFrameSize($thumbAsset->getWidth(), $thumbAsset->getHeight()); $picRatios[] = array('url' => $thumbDownloadUrl, 'ratio' => $ratio); if ($thumbAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) { $defaultThumbUrl = $thumbDownloadUrl; } } $feedHelper->setPicRatiosArray($picRatios); if (!$defaultThumbUrl && count($picRatios)) { // Choose the URL of the first resource in the array $defaultThumbUrl = $picRatios[0]['url']; } $feedHelper->setDefaultThumbnailUrl($defaultThumbUrl); $this->createPlayManifestURLs($distributionJobData->entryDistribution, $entry, $feedHelper); $metadatas = MetadataPeer::retrieveAllByObject(MetadataObjectType::ENTRY, $distributionJobData->entryDistribution->entryId); $fullMetadataXML = ''; foreach ($metadatas as $metadataField) { $syncKey = $metadataField->getSyncKey(Metadata::FILE_SYNC_METADATA_DATA); $currMetaXML = kFileSyncUtils::file_get_contents($syncKey, true, false); $fullMetadataXML .= $currMetaXML; } $feedHelper->setMetasXML($fullMetadataXML); if ($distributionJobData instanceof KalturaDistributionSubmitJobData) { $this->xml = $feedHelper->buildSubmitFeed(); } elseif ($distributionJobData instanceof KalturaDistributionUpdateJobData) { $this->xml = $feedHelper->buildUpdateFeed(); } elseif ($distributionJobData instanceof KalturaDistributionDeleteJobData) { $this->xml = $feedHelper->buildDeleteFeed(); } KalturaLog::debug("XML Constructed by the Tvinci feed helper :{$this->xml}"); }
public function fromObject($source_object) { parent::fromObject($source_object); $key = $source_object->getSyncKey(genericSyndicationFeed::FILE_SYNC_SYNDICATION_FEED_XSLT); $this->xslt = kFileSyncUtils::file_get_contents($key, true, false); $mrssParams = $source_object->getMrssParameters(); if ($mrssParams) { $this->itemXpathsToExtend = KalturaStringArray::fromStringArray($mrssParams->getItemXpathsToExtend()); } else { $this->itemXpathsToExtend = new KalturaStringArray(); } }
/** * @param Metadata $metadata * @param SimpleXMLElement $mrss * @return SimpleXMLElement */ public function contributeMetadata(Metadata $metadata, SimpleXMLElement $mrss) { $key = $metadata->getSyncKey(Metadata::FILE_SYNC_METADATA_DATA); $xml = kFileSyncUtils::file_get_contents($key, true, false); $metadataXml = new SimpleXMLElement($xml); $customData = $mrss->addChild('customData'); $customData->addAttribute('metadataId', $metadata->getId()); $customData->addAttribute('metadataVersion', $metadata->getVersion()); $customData->addAttribute('metadataProfileId', $metadata->getMetadataProfileId()); $customData->addAttribute('metadataProfileVersion', $metadata->getMetadataProfileVersion()); $this->contributeMetadataObject($customData, $metadataXml); }
public function doFromObject($source_object, KalturaDetachedResponseProfile $responseProfile = null) { parent::doFromObject($source_object, $responseProfile); if ($this->shouldGet('xslt', $responseProfile)) { $key = $source_object->getSyncKey(genericSyndicationFeed::FILE_SYNC_SYNDICATION_FEED_XSLT); $this->xslt = kFileSyncUtils::file_get_contents($key, true, false); } if ($this->shouldGet('itemXpathsToExtend', $responseProfile)) { $mrssParams = $source_object->getMrssParameters(); $this->itemXpathsToExtend = new KalturaExtendingItemMrssParameterArray(); if ($mrssParams && $mrssParams->getItemXpathsToExtend()) { $this->itemXpathsToExtend = KalturaExtendingItemMrssParameterArray::fromDbArray($mrssParams->getItemXpathsToExtend()); } } }
/** * @param Metadata $metadata * @param SimpleXMLElement $mrss * @param kMrssParameters $mrssParams * @return SimpleXMLElement */ public function contributeMetadata(Metadata $metadata, SimpleXMLElement $mrss, kMrssParameters $mrssParams = null) { $key = $metadata->getSyncKey(Metadata::FILE_SYNC_METADATA_DATA); $xml = kFileSyncUtils::file_get_contents($key, true, false); if (is_null($xml)) { KalturaLog::alert("ready file sync was not found for key[{$key}]"); return; } $metadataXml = new SimpleXMLElement($xml); $customData = $mrss->addChild('customData'); $customData->addAttribute('metadataId', $metadata->getId()); $customData->addAttribute('metadataVersion', $metadata->getVersion()); $customData->addAttribute('metadataProfileId', $metadata->getMetadataProfileId()); $customData->addAttribute('metadataProfileVersion', $metadata->getMetadataProfileVersion()); $this->contributeMetadataObject($customData, $metadataXml, $mrssParams, ''); }
public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser) { if (!$puser_kuser) { $this->addError(APIErrors::INVALID_USER_ID, $puser_id); return; } $entry_id = $this->getPM("entry_id"); $entry = entryPeer::retrieveByPK($entry_id); // TODO - verify the user is allowed to modify the entry $source_entry_id = $this->getP("source_entry_id"); if ($source_entry_id) { $source_entry = entryPeer::retrieveByPK($source_entry_id); if (!$source_entry) { return; } } else { $source_entry = $entry; } $time_offset = $this->getP("time_offset", -1); if (!myEntryUtils::createThumbnailFromEntry($entry, $source_entry, $time_offset)) { $this->addError(APIErrors::INVALID_ENTRY_TYPE, "ENTRY_TYPE_MEDIACLIP"); return; } if ($entry->getType() == entryType::MIX) { /* $roughcutPath = myContentStorage::getFSContentRootPath() . $entry->getDataPath(); // replaced__getDataPath $xml_doc = new DOMDocument(); $xml_doc->load( $roughcutPath ); if (myMetadataUtils::updateThumbUrl($xml_doc, $entry->getThumbnailUrl())) $xml_doc->save($roughcutPath); */ $sync_key = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA); $xml_doc = new DOMDocument(); $xml_doc->loadXML(kFileSyncUtils::file_get_contents($sync_key)); if (myMetadataUtils::updateThumbUrl($xml_doc, $entry->getThumbnailUrl())) { $entry->setMetadata(null, $xml_doc->saveXML(), true, null, null); //$entry->getVersion() ); } myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_UPDATE_THUMBNAIL, $entry); } $wrapper = objectWrapperBase::getWrapperClass($entry, objectWrapperBase::DETAIL_LEVEL_DETAILED); $wrapper->removeFromCache("entry", $entry->getId()); $this->addMsg("entry", $wrapper); }
/** * Parse content of caption asset and index it * * @action parse * @param string $captionAssetId * @throws KalturaCaptionErrors::CAPTION_ASSET_ID_NOT_FOUND */ function parseAction($captionAssetId) { $captionAsset = assetPeer::retrieveById($captionAssetId); if (!$captionAsset) { throw new KalturaAPIException(KalturaCaptionErrors::CAPTION_ASSET_ID_NOT_FOUND, $captionAssetId); } $captionAssetItems = CaptionAssetItemPeer::retrieveByAssetId($captionAssetId); foreach ($captionAssetItems as $captionAssetItem) { /* @var $captionAssetItem CaptionAssetItem */ $captionAssetItem->delete(); } // make sure that all old items are deleted from the sphinx before creating the new ones kEventsManager::flushEvents(); $syncKey = $captionAsset->getSyncKey(asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $content = kFileSyncUtils::file_get_contents($syncKey, true, false); if (!$content) { return; } $captionsContentManager = kCaptionsContentManager::getCoreContentManager($captionAsset->getContainerFormat()); if (!$captionsContentManager) { return; } $itemsData = $captionsContentManager->parse($content); foreach ($itemsData as $itemData) { $item = new CaptionAssetItem(); $item->setCaptionAssetId($captionAsset->getId()); $item->setEntryId($captionAsset->getEntryId()); $item->setPartnerId($captionAsset->getPartnerId()); $item->setStartTime($itemData['startTime']); $item->setEndTime($itemData['endTime']); $content = ''; foreach ($itemData['content'] as $curChunk) { $content .= $curChunk['text']; } //Make sure there are no invalid chars in the caption asset items to avoid braking the search request by providing invalid XML $content = kString::stripUtf8InvalidChars($content); $content = kXml::stripXMLInvalidChars($content); $item->setContent($content); $item->save(); } }
public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser) { $entry_id = $this->getP("entry_id"); $kshow_id = $this->getP("kshow_id"); // Make sure the request is for a ready roughcut $c = entryPeer::getCriteriaFilter()->getFilter(); $c->addAnd(entryPeer::STATUS, entryStatus::READY, Criteria::EQUAL); list($kshow, $entry, $error, $error_obj) = myKshowUtils::getKshowAndEntry($kshow_id, $entry_id); if ($error_obj) { $this->addError($error_obj); return; } $version = $this->getP("version"); // it's a path on the disk if (kString::beginsWith($version, ".")) { // someone is trying to hack in the system return sfView::ERROR; } elseif ($version == "-1") { $version = null; } // in case we're making a roughcut out of a regular invite, we start from scratch $entry_data_path = kFileSyncUtils::getLocalFilePathForKey($entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $version)); //replaced__getDataPath if ($entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_SHOW || $entry_data_path === null) { $this->xml_content = "<xml></xml>"; return; } $sync_key = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $version); $file_name = kFileSyncUtils::getReadyLocalFilePathForKey($sync_key, false); // fetch content of file from disk - it should hold the XML if (kString::endsWith($file_name, "xml")) { $xml_content = kFileSyncUtils::file_get_contents($sync_key, false, false); if (!$xml_content) { $xml_content = "<xml></xml>"; } myMetadataUtils::updateEntryForPending($entry, $version, $xml_content); $this->addMsg("metadata", $xml_content); } else { $this->addError(APIErrors::INVALID_FILE_NAME, $file_name); } }
public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser) { if (!$puser_kuser) { $this->addError(APIErrors::INVALID_USER_ID, $puser_id); return; } $entry_id = $this->getPM("entry_id"); $entry = entryPeer::retrieveByPK($entry_id); // TODO - verify the user is allowed to modify the entry if ($entry->getKshowId() === kshow::SANDBOX_ID) { $this->addError(APIErrors::SANDBOX_ALERT); return; } $entry->setThumbnail(".jpg"); $entry->setCreateThumb(false); $entry->save(); if (isset($HTTP_RAW_POST_DATA)) { $thumb_data = $HTTP_RAW_POST_DATA; } else { $thumb_data = file_get_contents("php://input"); } $thumb_data_size = strlen($thumb_data); $fileSyncKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB); $fileSync = FileSync::createForFileSyncKey($fileSyncKey); kFileSyncUtils::file_put_contents($fileSyncKey, $thumb_data); // update the metadata in case of a roughcut if ($entry->getType() == entryType::MIX) { $sync_key = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA); $xml_doc = new DOMDocument(); $xml_doc->loadXML(kFileSyncUtils::file_get_contents($sync_key)); if (myMetadataUtils::updateThumbUrl($xml_doc, $entry->getThumbnailUrl())) { $entry->setMetadata(null, $xml_doc->saveXML(), true, null, null); //$entry->getVersion() ); } myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_UPDATE_THUMBNAIL, $entry); } $this->res = $entry->getBigThumbnailUrl(); $wrapper = objectWrapperBase::getWrapperClass($entry, objectWrapperBase::DETAIL_LEVEL_REGULAR); $wrapper->removeFromCache("entry", $entry->getId()); $this->addMsg("entry", $wrapper); }
public function objectChanged(BaseObject $object, array $modifiedColumns) { // replacing the ismc file name in the ism file $ismPrevVersionFileSyncKey = $object->getSyncKey(flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET); $ismContents = kFileSyncUtils::file_get_contents($ismPrevVersionFileSyncKey); $ismcPrevVersionFileSyncKey = $object->getSyncKey(flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ISMC); $ismcContents = kFileSyncUtils::file_get_contents($ismcPrevVersionFileSyncKey); $ismcPrevVersionFilePath = kFileSyncUtils::getLocalFilePathForKey($ismcPrevVersionFileSyncKey); $object->incrementVersion(); $object->save(); $ismcFileSyncKey = $object->getSyncKey(flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ISMC); kFileSyncUtils::moveFromFile($ismcPrevVersionFilePath, $ismcFileSyncKey); $ismcNewName = basename(kFileSyncUtils::getLocalFilePathForKey($ismcFileSyncKey)); KalturaLog::debug("Editing ISM set content to [{$ismcNewName}]"); $ismXml = new SimpleXMLElement($ismContents); $ismXml->head->meta['content'] = $ismcNewName; $tmpPath = kFileSyncUtils::getLocalFilePathForKey($ismPrevVersionFileSyncKey) . '.tmp'; file_put_contents($tmpPath, $ismXml->asXML()); kFileSyncUtils::moveFromFile($tmpPath, $object->getSyncKey(flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET)); return true; }
/** * @param array<Metadata> $metadataObjects * @param string $field * @return array|string */ protected function findMetadataValue(array $metadataObjects, $field) { $results = array(); foreach ($metadataObjects as $metadata) { $key = $metadata->getSyncKey(Metadata::FILE_SYNC_METADATA_DATA); $xmlContent = kFileSyncUtils::file_get_contents($key, true, false); $xml = new DOMDocument(); $xml->loadXML($xmlContent); $nodes = $xml->getElementsByTagName($field); foreach ($nodes as $node) { $results[] = $node->textContent; } } return $results; }
public function fromObject($source_object) { parent::fromObject($source_object); $key = $source_object->getSyncKey(GenericDistributionProviderAction::FILE_SYNC_DISTRIBUTION_PROVIDER_ACTION_MRSS_TRANSFORMER); $this->mrssTransformer = kFileSyncUtils::file_get_contents($key, true, false); $key = $source_object->getSyncKey(GenericDistributionProviderAction::FILE_SYNC_DISTRIBUTION_PROVIDER_ACTION_MRSS_VALIDATOR); $this->mrssValidator = kFileSyncUtils::file_get_contents($key, true, false); $key = $source_object->getSyncKey(GenericDistributionProviderAction::FILE_SYNC_DISTRIBUTION_PROVIDER_ACTION_RESULTS_TRANSFORMER); $this->resultsTransformer = kFileSyncUtils::file_get_contents($key, true, false); }
/** * Add the data to the flavor asset conversion log, creates it if doesn't exists * * @action logConversion * @param string $flavorAssetId * @param string $data * @throws KalturaErrors::INVALID_FLAVOR_ASSET_ID */ function logConversionAction($flavorAssetId, $data) { $flavorAsset = assetPeer::retrieveById($flavorAssetId); // verifies that flavor asset exists if (!$flavorAsset) { throw new KalturaAPIException(KalturaErrors::INVALID_FLAVOR_ASSET_ID, $flavorAssetId); } $flavorAsset->incLogFileVersion(); $flavorAsset->save(); $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_CONVERT_LOG); $log = kFileSyncUtils::file_get_contents($syncKey, true, false); $log .= $data; kFileSyncUtils::file_put_contents($syncKey, $log, false); }
public function fromObject($source_object) { parent::fromObject($source_object); $key = $source_object->getSyncKey(Metadata::FILE_SYNC_METADATA_DATA); $this->xml = kFileSyncUtils::file_get_contents($key, true, false); }
public function adjustAssetParams($entryId, array &$flavors) { $entry = entryPeer::retrieveByPK($entryId); if (!isset($entry)) { KalturaLog::warning("Bad entry id ({$entryId})."); return; } $partnerId = $entry->getPartnerId(); $profile = MetadataProfilePeer::retrieveBySystemName(self::TRANSCODING_METADATA_PROF_SYSNAME, $partnerId); if (!isset($profile)) { KalturaLog::log("No Transcoding Metadata Profile (sysName:" . self::TRANSCODING_METADATA_PROF_SYSNAME . ", partner:{$partnerId}). Nothing to adjust"); return; } $metadata = MetadataPeer::retrieveByObject($profile->getId(), MetadataObjectType::ENTRY, $entryId); if (!isset($metadata)) { KalturaLog::log("No Metadata for entry({$entryId}), metadata profile (id:" . $profile->getId() . "). Nothing to adjust"); return; } KalturaLog::log("Entry ({$entryId}) has following metadata fields:" . print_r($metadata, 1)); // Retrieve the associated XML file $key = $metadata->getSyncKey(Metadata::FILE_SYNC_METADATA_DATA); if (!isset($key)) { KalturaLog::log("Entry({$entryId}) metadata object misses file sync key! Nothing to adjust"); return; } $xmlStr = kFileSyncUtils::file_get_contents($key, true, false); if (!isset($xmlStr)) { KalturaLog::log("Entry({$entryId}) metadata object misses valid file sync! Nothing to adjust"); return; } KalturaLog::log("Adjusting: entry({$entryId}),metadata profile(" . self::TRANSCODING_METADATA_PROF_SYSNAME . "),xml==>{$xmlStr}"); $watermarkSettingsStr = null; $imageEntry = null; $imageUrl = null; // Retrieve the custom metadata fields from the asocieted XML $xml = new SimpleXMLElement($xmlStr); $fldName = self::TRANSCODING_METADATA_WATERMMARK_SETTINGS; if (isset($xml->{$fldName})) { $watermarkSettingsStr = (string) $xml->{$fldName}; KalturaLog::log("Found metadata - {$fldName}({$watermarkSettingsStr})"); } $fldName = self::TRANSCODING_METADATA_WATERMMARK_IMAGE_ENTRY; if (isset($xml->{$fldName})) { $imageEntry = (string) $xml->{$fldName}; KalturaLog::log("Found metadata - {$fldName}({$imageEntry})"); } $fldName = self::TRANSCODING_METADATA_WATERMMARK_IMAGE_URL; if (isset($xml->{$fldName})) { $imageUrl = (string) $xml->{$fldName}; KalturaLog::log("Found metadata - {$fldName}({$imageUrl})"); } /* * The imageEntry is preffered if both imageEntry and url are set, * in such case - remove the url */ if (isset($imageEntry) && isset($imageUrl)) { KalturaLog::log("Found both " . self::TRANSCODING_METADATA_WATERMMARK_IMAGE_URL . "({$imageEntry}) and {$fldName}({$imageUrl}). Removing {$fldName}"); $imageUrl = null; // } /* * If custom-metadate contains 'full' WM settings ('watermarkSettingsStr' is set), * adjust it to custom meta imageEntry/imageUrl values, * if those provided. */ if (isset($watermarkSettingsStr)) { $watermarkSettings = json_decode($watermarkSettingsStr); $this->adjustWatermarSettings($watermarkSettings, $imageEntry, $imageUrl); } /* * Loop through the flavor params to update the WM settings, * if it is required. */ foreach ($flavors as $k => $flavor) { KalturaLog::log("Processing flavor id:" . $flavor->getId()); $wmDataObj = null; /* * The 'full' WM settings in the custom metadata overides any exitings WM settings */ if (isset($watermarkSettings)) { $wmDataObj = clone $watermarkSettings; } else { /* * No 'full' settings. * Adjust the existing flavor WM data with custom metadata imageEntry/imageUrl */ $wmDataStr = $flavor->getWatermarkData(); if (isset($wmDataStr)) { $wmDataObj = json_decode($wmDataStr); if ($this->adjustWatermarSettings($wmDataObj, $imageEntry, $imageUrl) == false) { continue; } } } if (isset($wmDataObj)) { $toJson = json_encode($wmDataObj); $flavor->setWatermarkData($toJson); $flavors[$k] = $flavor; KalturaLog::log("Set flavor (" . $flavor->getId() . ") WM to {$toJson}"); } } }
public function updateFromXSLImpl($id, $xslData) { $dbMetadataObject = MetadataPeer::retrieveByPK($id); if (!$dbMetadataObject) { throw new KalturaAPIException(MetadataErrors::METADATA_NOT_FOUND); } $dbMetadataObjectFileSyncKey = $dbMetadataObject->getSyncKey(Metadata::FILE_SYNC_METADATA_DATA); $xsltErrors = array(); $transformMetadataObjectData = kXml::transformXmlUsingXslt(kFileSyncUtils::file_get_contents($dbMetadataObjectFileSyncKey), $xslData, array(), $xsltErrors); if (count($xsltErrors)) { throw new KalturaAPIException(MetadataErrors::XSLT_VALIDATION_ERROR, implode(',', $xsltErrors)); } return $this->updateImpl($id, $transformMetadataObjectData); }
/** * @return string */ public function getXsl() { if (!is_null($this->xsl)) { return $this->xsl; } $key = $this->getSyncKey(self::FILE_SYNC_MRSS_XSL); $this->xsl = kFileSyncUtils::file_get_contents($key, true, false); return $this->xsl; }
public function loadProperties(KalturaDistributionJobData $distributionJobData, KalturaGenericDistributionProfile $distributionProfile, $action) { $actionName = self::$actionAttributes[$action]; $genericProviderAction = GenericDistributionProviderActionPeer::retrieveByProviderAndAction($distributionProfile->genericProviderId, $action); if (!$genericProviderAction) { KalturaLog::err("Generic provider [{$distributionProfile->genericProviderId}] action [{$actionName}] not found"); return; } if (!$distributionJobData->entryDistribution) { KalturaLog::err("Entry Distribution object not provided"); return; } if (!$distributionProfile->{$actionName}->protocol) { $distributionProfile->{$actionName}->protocol = $genericProviderAction->getProtocol(); } if (!$distributionProfile->{$actionName}->serverUrl) { $distributionProfile->{$actionName}->serverUrl = $genericProviderAction->getServerAddress(); } if (!$distributionProfile->{$actionName}->serverPath) { $distributionProfile->{$actionName}->serverPath = $genericProviderAction->getRemotePath(); } if (!$distributionProfile->{$actionName}->username) { $distributionProfile->{$actionName}->username = $genericProviderAction->getRemoteUsername(); } if (!$distributionProfile->{$actionName}->password) { $distributionProfile->{$actionName}->password = $genericProviderAction->getRemotePassword(); } if (!$distributionProfile->{$actionName}->ftpPassiveMode) { $distributionProfile->{$actionName}->ftpPassiveMode = $genericProviderAction->getFtpPassiveMode(); } if (!$distributionProfile->{$actionName}->httpFieldName) { $distributionProfile->{$actionName}->httpFieldName = $genericProviderAction->getHttpFieldName(); } if (!$distributionProfile->{$actionName}->httpFileName) { $distributionProfile->{$actionName}->httpFileName = $genericProviderAction->getHttpFileName(); } $entry = entryPeer::retrieveByPKNoFilter($distributionJobData->entryDistribution->entryId); if (!$entry) { KalturaLog::err("Entry [" . $distributionJobData->entryDistribution->entryId . "] not found"); return; } $mrss = kMrssManager::getEntryMrss($entry); if (!$mrss) { KalturaLog::err("MRSS not returned for entry [" . $entry->getId() . "]"); return; } $xml = new KDOMDocument(); if (!$xml->loadXML($mrss)) { KalturaLog::err("MRSS not is not valid XML:\n{$mrss}\n"); return; } $key = $genericProviderAction->getSyncKey(GenericDistributionProviderAction::FILE_SYNC_DISTRIBUTION_PROVIDER_ACTION_MRSS_TRANSFORMER); if (kFileSyncUtils::fileSync_exists($key)) { $xslPath = kFileSyncUtils::getLocalFilePathForKey($key); if ($xslPath) { $xsl = new KDOMDocument(); $xsl->load($xslPath); // set variables in the xsl $varNodes = $xsl->getElementsByTagName('variable'); foreach ($varNodes as $varNode) { $nameAttr = $varNode->attributes->getNamedItem('name'); if (!$nameAttr) { continue; } $name = $nameAttr->value; if ($name && $distributionJobData->{$name}) { $varNode->textContent = $distributionJobData->{$name}; $varNode->appendChild($xsl->createTextNode($distributionJobData->{$name})); } } $proc = new XSLTProcessor(); $proc->registerPHPFunctions(kXml::getXslEnabledPhpFunctions()); $proc->importStyleSheet($xsl); $xml = $proc->transformToDoc($xml); if (!$xml) { KalturaLog::err("Transform returned false"); return; } } } $key = $genericProviderAction->getSyncKey(GenericDistributionProviderAction::FILE_SYNC_DISTRIBUTION_PROVIDER_ACTION_MRSS_VALIDATOR); if (kFileSyncUtils::fileSync_exists($key)) { $xsdPath = kFileSyncUtils::getLocalFilePathForKey($key); if ($xsdPath && !$xml->schemaValidate($xsdPath)) { KalturaLog::err("Inavlid XML:\n" . $xml->saveXML()); KalturaLog::err("Schema [{$xsdPath}]:\n" . file_get_contents($xsdPath)); return; } } $this->xml = $xml->saveXML(); $key = $genericProviderAction->getSyncKey(GenericDistributionProviderAction::FILE_SYNC_DISTRIBUTION_PROVIDER_ACTION_RESULTS_TRANSFORMER); if (kFileSyncUtils::fileSync_exists($key)) { $this->resultParseData = kFileSyncUtils::file_get_contents($key, true, false); } $this->resultParserType = $genericProviderAction->getResultsParser(); }
public static function generateCuePointXml(SimpleXMLElement $scene, $objectType, $cuePointId) { $metadatas = MetadataPeer::retrieveAllByObject($objectType, $cuePointId); foreach ($metadatas as $metadata) { /* @var $metadata Metadata */ $metadataElement = $scene->addChild('scene-customData'); $metadataElement->addAttribute('metadataId', $metadata->getId()); $metadataElement->addAttribute('metadataVersion', $metadata->getVersion()); $metadataElement->addAttribute('metadataProfileId', $metadata->getMetadataProfileId()); $metadataElement->addAttribute('metadataProfileVersion', $metadata->getMetadataProfileVersion()); $key = $metadata->getSyncKey(Metadata::FILE_SYNC_METADATA_DATA); $xml = kFileSyncUtils::file_get_contents($key, true, false); if ($xml) { $xmlElement = new SimpleXMLElement($xml); self::appendXML($metadataElement, $xmlElement); } $metadataProfile = $metadata->getMetadataProfile(); if (!$metadataProfile) { continue; } if ($metadataProfile->getSystemName()) { $metadataElement->addAttribute('metadataProfile', $metadataProfile->getSystemName()); } if ($metadataProfile->getName()) { $metadataElement->addAttribute('metadataProfileName', $metadataProfile->getName()); } } return $scene; }
private function transformMetadata($metadataProfileId, $xmlData) { $result = null; $metadataProfile = MetadataProfilePeer::retrieveByPK($metadataProfileId); if (!$metadataProfile) { KalturaLog::err('Cannot find metadata profile id [' . $metadataProfileId . ']'); return null; } $metadataXsltKey = $metadataProfile->getSyncKey(MetadataProfile::FILE_SYNC_METADATA_XSLT); if (!kFileSyncUtils::file_exists($metadataXsltKey, true)) { return null; } $xsltString = kFileSyncUtils::file_get_contents($metadataXsltKey, true, false); if (!$xsltString) { return null; } $xsltParams = array(XsltParameterName::KALTURA_CURRENT_TIMESTAMP => time()); $xsltErrors = array(); $xmlDataTransformed = kXml::transformXmlUsingXslt($xmlData, $xsltString, $xsltParams, $xsltErrors); if (!empty($xsltErrors)) { throw new KalturaAPIException(MetadataErrors::XSLT_VALIDATION_ERROR, implode(',', $xsltErrors)); } if ($xmlDataTransformed) { return $xmlDataTransformed; } KalturaLog::err('Failed XML [$xmlData] transformation for metadata with XSL [$xsltString]'); return null; }
public static function setMetadata($content, $kshow, $show_entry, $ignore_current = false, $version_info = null) { $xml_content = ""; $show_entry_data_key = $show_entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA); $current_content = $show_entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_SHOW ? "" : kFileSyncUtils::file_get_contents($show_entry_data_key); if ($ignore_current) { $current_content = ""; } $update_kshow = false; // compare the content and store only if different if ($content != $current_content) { $show_entry->setData("metadata.xml"); // re-create data key (to get latest version) $show_entry_data_key = $show_entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA); //$version = myContentStorage::getVersion($file_name); //$comments = "file path: " . $file_name . "\n"; $comments = "version: " . $show_entry_data_key->version . "\n"; $total_duration = 0; $editor_type = null; $content = myFlvStreamer::fixMetadata($content, $show_entry_data_key->version, $total_duration, $editor_type); // TODO - make fixMetadata a more generic funciton to return the editorType as well // save info file about the version if (isset($version_info)) { $content = self::addVersionInfo($content, $version_info); } //fixme $content = myFlvStreamer::modifiedByKeditor ( $content ); // total_duration is in seconds with 2 digits after the decimal point $show_entry->setLengthInMsecs($total_duration * 1000); $show_entry->setMediaType(entry::ENTRY_MEDIA_TYPE_SHOW); $show_entry->setEditorType($editor_type); $show_entry->setModifiedAt(time()); // update the modified_at date $show_entry->save(); kFileSyncUtils::file_put_contents($show_entry_data_key, $content, true); $xml_content = kFileSyncUtils::file_get_contents($show_entry_data_key); // replaced__getFileContent $update_kshow = true; $show_entry_id = $show_entry->getId(); // update the roughcut_entry table $all_entries_for_roughcut = self::getAllEntries($content); roughcutEntry::updateRoughcut($show_entry->getId(), $show_entry->getVersion(), $show_entry->getKshowId(), $all_entries_for_roughcut); $xml_content = $content; } else { $xml_content = $current_content; $comments = "old and new files are the same"; } if (!$kshow->getHasRoughcut() && $kshow->getIntroId() != $show_entry->getId()) { $kshow->setHasRoughcut(true); $update_kshow = true; } myStatisticsMgr::incKshowUpdates($kshow); $kshow->save(); return array($xml_content, $comments, $update_kshow); }
/** * @return string $xsl */ public function getXsl() { if ($this->xsl) { return $this->xsl; } if (!$this->getFeedId()) { return null; } $feed = syndicationFeedPeer::retrieveByPK($this->getFeedId()); if (!$feed || !$feed instanceof genericSyndicationFeed) { return null; } $syncKey = $feed->getSyncKey(genericSyndicationFeed::FILE_SYNC_SYNDICATION_FEED_XSLT); $this->xsl = kFileSyncUtils::file_get_contents($syncKey, true, false); return $this->xsl; }
DbManager::initialize(); $c = new Criteria(); $c->add(uiConfPeer::SWF_URL, "%kcw%", Criteria::LIKE); $c->add(uiConfPeer::OBJ_TYPE, uiConf::UI_CONF_TYPE_CW, Criteria::EQUAL); $c->add(uiConfPeer::PARTNER_ID, $partnerId, Criteria::EQUAL); $kcwUiconfs = uiConfPeer::doSelect($c); if (!count($kcwUiconfs)) { exit; } $fileName = "/manual_uiconfs_paths.log"; $flog = fopen($fileName, 'a+'); //Run a loop for each uiConf to get its filesync key, thus acquiring its confile foreach ($kcwUiconfs as $kcwUiconf) { /* @var $kcwUiconf uiConf */ $kcwUiconfFilesyncKey = $kcwUiconf->getSyncKey(uiConf::FILE_SYNC_UICONF_SUB_TYPE_DATA); $kcwConfile = kFileSyncUtils::file_get_contents($kcwUiconfFilesyncKey, false, false); if (!$kcwConfile) { continue; } $kcwConfileXML = new SimpleXMLElement($kcwConfile); $path = '//provider[@id="kaltura" or @name="kaltura"]'; $nodesToRemove = $kcwConfileXML->xpath($path); if (!count($nodesToRemove)) { continue; } if ($kcwUiconf->getCreationMode() != uiConf::UI_CONF_CREATION_MODE_MANUAL) { //No point in this "for" loop if we can't save the UIConf. foreach ($nodesToRemove as $nodeToRemove) { $nodeToRemoveDom = dom_import_simplexml($nodeToRemove); $nodeToRemoveDom->parentNode->removeChild($nodeToRemoveDom); }
public function getXslt() { if (!is_null($this->xslt)) { return $this->xslt; } $key = $this->getSyncKey(self::FILE_SYNC_SYNDICATION_FEED_XSLT); $this->xslt = kFileSyncUtils::file_get_contents($key, true, false); return $this->xslt; }
public static function old_deepCloneShowEntry(entry $source_show_entry, entry $target_show_entry, array $entry_map, array $entry_cache) { $target_show_entry->setComments(0); $target_show_entry->setTotalRank(0); $target_show_entry->setRank(0); $target_show_entry->setViews(0); $target_show_entry->setVotes(0); $target_show_entry->setFavorites(0); $target_show_entry->save(); if (myContentStorage::isTemplate($source_entry->getData())) { if ($echo) { echo "source thumbnail same as target. skipping file: " . $content . $source_thumbnail_path . "\n"; } } else { if ($echo) { echo "Copying file: " . $content . $source_thumbnail_path . " -> " . $content . $target_thumbnail_path . "\n"; } $sourceThumbFileKey = $source_show_entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB); if (kFileSyncUtils::file_exists($sourceThumbFileKey)) { $targetThumbFileKey = $target_show_entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB); kFileSyncUtils::softCopy($sourceThumbFileKey, $targetThumbFileKey); } //myContentStorage::moveFile( $content . $source_thumbnail_path , $content . $target_thumbnail_path , false , true ); } if (myContentStorage::isTemplate($source_entry->getData())) { if ($echo) { echo "source same as target. skipping file: " . $content . $source_data_path . "\n"; } } else { // fix metadata $source_show_entry_content = kFileSyncUtils::file_get_contents($sourceDataFileKey); // fix the ShowVersion $source_show_version = $source_show_entry->getData(); $target_show_version = $target_show_entry->getData(); // <ShowVersion>100016</ShowVersion> $source_show_entry_content = str_replace("<ShowVersion>{$source_show_version}</ShowVersion>", "<ShowVersion>{$target_show_version}</ShowVersion>", $source_show_entry_content); // now replace entries foreach ($entry_map as $source_entry_id => $target_entry_id) { $source_entry = $entry_cache[$source_entry_id]; $target_entry = $entry_cache[$target_entry_id]; $source_file_name = $source_entry->getDataPath(); // replaced__getDataPath $target_file_name = $target_entry->getDataPath(); // replaced__getDataPath // k_id="11758" $source_show_entry_content = str_replace("k_id=\"{$source_entry_id}\"", "k_id=\"{$target_entry_id}\"", $source_show_entry_content); // file_name="/content/entry/data/0/11/11787_100000.jpg" //$source_show_entry_content = str_replace( "file_name=\"$source_file_name\"" , "file_name=\"$target_file_name\"" , $source_show_entry_content ); // a more general search - will fix file_name= & url= $source_show_entry_content = str_replace("{$source_file_name}\"", "{$target_file_name}\"", $source_show_entry_content); } $sourceDataFileKey = $source_show_entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA); $targetDataFileKey = $target_show_entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA); kFileSyncUtils::file_put_contents($targetDataFileKey, $source_show_entry_content); } }
public function getMetadata($version = null) { if ($this->getMediaType() != entry::ENTRY_MEDIA_TYPE_SHOW) { return null; } if ($version <= 0) { $version = null; } $sync_key = $this->getSyncKey(self::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $version); $content = kFileSyncUtils::file_get_contents($sync_key, true, false); // don't be strict when fetching metadata if ($content) { return $content; } else { return "<xml></xml>"; } }
private function getConfFileBySuffix($suffix = null, $force_fetch = false) { $subType = $this->getSubTypeBySuffix($suffix); $contents = ""; if ($this->isUiConfContentSet($subType) && !$force_fetch) { return $this->content[$subType]['data']; } $sync_key = $this->getSyncKey($subType); $contents = kFileSyncUtils::file_get_contents($sync_key, true, false); if (!$contents) { KalturaLog::debug("Conf file of sub type [{$subType}] not found for key [{$sync_key}]"); } return $contents; }