public function validateForUsage($sourceObject, $propertiesToSkip = array()) { $entryId = $this->entryId; $entry = entryPeer::retrieveByPK($entryId); if (!$entry || $entry->getType() != entryType::MEDIA_CLIP || !in_array($entry->getMediaType(), array(entry::ENTRY_MEDIA_TYPE_VIDEO, entry::ENTRY_MEDIA_TYPE_AUDIO))) { throw new KalturaAPIException(KalturaErrors::INVALID_ENTRY_ID, $entryId); } $flavorAssetId = $this->flavorAssetId; if ($flavorAssetId) { $flavorAsset = assetPeer::retrieveById($flavorAssetId); if (!$flavorAsset || $flavorAsset->getEntryId() != $entryId) { throw new KalturaAPIException(KalturaErrors::FLAVOR_ASSET_ID_NOT_FOUND, $flavorAssetId); } } $transcriptId = $this->transcriptId; if ($transcriptId) { $transcript = assetPeer::retrieveById($transcriptId); if (!$transcript || $transcript->getEntryId() != $entryId || $transcript->getType() != TranscriptPlugin::getAssetTypeCoreValue(TranscriptAssetType::TRANSCRIPT)) { throw new KalturaAPIException(KalturaErrors::INVALID_OBJECT_ID, $transcriptId); } } $voicebaseParamsMap = kConf::get('voicebase', 'integration'); $supportedLanguages = $voicebaseParamsMap['languages']; if ($this->spokenLanguage) { if (!isset($supportedLanguages[$this->spokenLanguage])) { throw new KalturaAPIException(KalturaVoicebaseErrors::LANGUAGE_NOT_SUPPORTED, $this->spokenLanguage); } } else { $this->spokenLanguage = $voicebaseParamsMap['default_language']; } return parent::validateForUsage($sourceObject, $propertiesToSkip = array()); }
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 function validateForUsage($sourceObject, $propertiesToSkip = array()) { $entryId = $this->entryId; $entry = entryPeer::retrieveByPK($entryId); if (!$entry) { throw new KalturaAPIException(KalturaErrors::INVALID_ENTRY_ID, $entryId); } $transcriptId = $this->transcriptId; if ($transcriptId) { $transcript = assetPeer::retrieveById($transcriptId); if (!$transcript || $transcript->getEntryId() != $entryId || $transcript->getType() != TranscriptPlugin::getAssetTypeCoreValue(TranscriptAssetType::TRANSCRIPT)) { throw new KalturaAPIException(KalturaErrors::INVALID_OBJECT_ID, $transcriptId); } } $voicebaseParamsMap = kConf::get('voicebase', 'integration'); if (!$this->captionAssetFormats) { $defaultFormatsArray = $voicebaseParamsMap['default_formats']; $this->captionAssetFormats = implode(',', $defaultFormatsArray); } else { $formatsString = $this->captionAssetFormats; $formatsArray = explode(',', $formatsString); $excludedFormats = $voicebaseParamsMap['exclude_formats']; foreach ($formatsArray as $format) { if (!constant("KalturaCaptionType::" . $format) || in_array($format, $excludedFormats)) { throw new KalturaAPIException(KalturaVoicebaseErrors::INVALID_TYPES, $formatsString); } } } $supportedLanguages = $voicebaseParamsMap['languages']; if ($this->spokenLanguage) { if (!isset($supportedLanguages[$this->spokenLanguage])) { throw new KalturaAPIException(KalturaVoicebaseErrors::LANGUAGE_NOT_SUPPORTED, $this->spokenLanguage); } } else { $this->spokenLanguage = $voicebaseParamsMap['default_language']; } return parent::validateForUsage($sourceObject, $propertiesToSkip = array()); }
public function getListResponse(KalturaFilterPager $pager, KalturaDetachedResponseProfile $responseProfile = null) { $types = KalturaPluginManager::getExtendedTypes(assetPeer::OM_CLASS, TranscriptPlugin::getAssetTypeCoreValue(TranscriptAssetType::TRANSCRIPT)); return $this->getTypeListResponse($pager, $responseProfile, $types); }
public function applyDefaultValues() { parent::applyDefaultValues(); $this->setType(TranscriptPlugin::getAssetTypeCoreValue(TranscriptAssetType::TRANSCRIPT)); }
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; }