public function doUpdate(KalturaDistributionUpdateJobData $data, KalturaYoutubeApiDistributionProfile $distributionProfile, $enabled = null) { $this->fieldValues = unserialize($data->providerData->fieldValues); $private = true; if ($enabled === true || is_null($enabled) && $data->entryDistribution->sunStatus == KalturaEntryDistributionSunStatus::AFTER_SUNRISE) { $private = false; } $entry = $this->getEntry($data->entryDistribution->partnerId, $data->entryDistribution->entryId); $props = $this->getYoutubeApiProps(); $youTubeApiImpl = new YouTubeApiImpl($distributionProfile->username, $distributionProfile->password, $this->getHttpClientConfig()); $youTubeApiImpl->updateEntry($data->remoteId, $props, $private); $captionsInfo = $data->providerData->captionsInfo; /* @var $captionInfo KalturaYouTubeApiCaptionDistributionInfo */ foreach ($captionsInfo as $captionInfo) { switch ($captionInfo->action) { case KalturaYouTubeApiDistributionCaptionAction::SUBMIT_ACTION: $data->mediaFiles[] = $this->submitCaption($youTubeApiImpl, $captionInfo, $data->remoteId); break; case KalturaYouTubeApiDistributionCaptionAction::UPDATE_ACTION: if (!file_exists($captionInfo->filePath)) { throw new KalturaDistributionException('The caption file [' . $captionInfo->filePath . '] was not found (probably not synced yet), the job will retry'); } $captionContent = $this->getFileBinaryContent($captionInfo->filePath); $youTubeApiImpl->updateCaption($data->remoteId, $captionInfo->remoteId, $captionContent); $this->updateRemoteMediaFileVersion($data, $captionInfo); break; case KalturaYouTubeApiDistributionCaptionAction::DELETE_ACTION: $youTubeApiImpl->deleteCaption($data->remoteId, $captionInfo->remoteId); break; } } return true; }
public function doUpdate(KalturaDistributionUpdateJobData $data, KalturaYoutubeApiDistributionProfile $distributionProfile, $enabled = null) { $private = true; if ($enabled === true || is_null($enabled) && $data->entryDistribution->sunStatus == KalturaEntryDistributionSunStatus::AFTER_SUNRISE) { $private = false; } $entry = $this->getEntry($data->entryDistribution->partnerId, $data->entryDistribution->entryId); $props = $this->getYoutubeApiProps($entry, $data, $distributionProfile); $youTubeApiImpl = new YouTubeApiImpl($distributionProfile->username, $distributionProfile->password); $youTubeApiImpl->updateEntry($data->remoteId, $props, $private); // $data->sentData = $youtubeApiMediaService->request; // $data->results = $youtubeApiMediaService->response; return true; }