public function doSubmit(KalturaDistributionSubmitJobData $data, KalturaYoutubeApiDistributionProfile $distributionProfile)
 {
     $this->fieldValues = unserialize($data->providerData->fieldValues);
     $private = true;
     if ($data->entryDistribution->sunStatus == KalturaEntryDistributionSunStatus::AFTER_SUNRISE) {
         $private = false;
     }
     $needDel = false;
     $entry = $this->getEntry($data->entryDistribution->partnerId, $data->entryDistribution->entryId);
     $props = $this->getYoutubeApiProps();
     if ($data->entryDistribution->remoteId) {
         $youTubeApiImpl = new YouTubeApiImpl($distributionProfile->username, $distributionProfile->password, $this->getHttpClientConfig());
         $youTubeApiImpl->updateEntry($data->entryDistribution->remoteId, $props, $private);
         $data->remoteId = $data->entryDistribution->remoteId;
         return true;
     }
     $videoFilePath = $data->providerData->videoAssetFilePath;
     if (!$videoFilePath) {
         throw new KalturaException('No video asset to distribute, the job will fail');
     }
     if (!file_exists($videoFilePath)) {
         throw new KalturaDistributionException('The file [' . $videoFilePath . '] was not found (probably not synced yet), the job will retry');
     }
     if (FALSE === strstr($videoFilePath, ".")) {
         $videoFilePathNew = $this->tempXmlPath . "/" . uniqid() . ".dme";
         if (!file_exists($videoFilePathNew)) {
             copy($videoFilePath, $videoFilePathNew);
             $needDel = true;
         }
         $videoFilePath = $videoFilePathNew;
     }
     $youTubeApiImpl = new YouTubeApiImpl($distributionProfile->username, $distributionProfile->password, $this->getHttpClientConfig());
     $remoteId = $youTubeApiImpl->uploadVideo($videoFilePath, $videoFilePath, $props, $private);
     if ($needDel == true) {
         unlink($videoFilePath);
     }
     $data->remoteId = $remoteId;
     $captionsInfo = $data->providerData->captionsInfo;
     /* @var $captionInfo KalturaYouTubeApiCaptionDistributionInfo */
     foreach ($captionsInfo as $captionInfo) {
         if ($captionInfo->action == KalturaYouTubeApiDistributionCaptionAction::SUBMIT_ACTION) {
             $data->mediaFiles[] = $this->submitCaption($youTubeApiImpl, $captionInfo, $data->remoteId);
         }
     }
     return true;
 }
コード例 #2
0
 public function doSubmit(KalturaDistributionSubmitJobData $data, KalturaYoutubeApiDistributionProfile $distributionProfile)
 {
     $private = true;
     if ($data->entryDistribution->sunStatus == KalturaEntryDistributionSunStatus::AFTER_SUNRISE) {
         $private = false;
     }
     $needDel = false;
     $entry = $this->getEntry($data->entryDistribution->partnerId, $data->entryDistribution->entryId);
     $props = $this->getYoutubeApiProps($entry, $data, $distributionProfile);
     if ($data->entryDistribution->remoteId) {
         $youTubeApiImpl = new YouTubeApiImpl($distributionProfile->username, $distributionProfile->password);
         $youTubeApiImpl->updateEntry($data->entryDistribution->remoteId, $props, $private);
         $data->remoteId = $data->entryDistribution->remoteId;
         return true;
     }
     $videoFilePath = $data->providerData->videoAssetFilePath;
     if (!$videoFilePath) {
         throw new KalturaException('No video asset to distribute, the job will fail');
     }
     if (!file_exists($videoFilePath)) {
         throw new KalturaDistributionException('The file [' . $videoFilePath . '] was not found (probably not synced yet), the job will retry');
     }
     if (FALSE === strstr($videoFilePath, ".")) {
         $videoFilePathNew = $this->tempXmlPath . "/" . uniqid() . ".dme";
         /*			try
         			{
             		KalturaLog::debug("DM : before " . $videoFilePathNew);
             			@symlink ($videoFilePath, $videoFilePathNew);
             		KalturaLog::debug("DM : after");
             		}
             		catch(Exception $ex)
             		{
             		KalturaLog::debug("DM : exception");
             		}*/
         if (!file_exists($videoFilePathNew)) {
             copy($videoFilePath, $videoFilePathNew);
             $needDel = true;
         }
         $videoFilePath = $videoFilePathNew;
     }
     $youTubeApiImpl = new YouTubeApiImpl($distributionProfile->username, $distributionProfile->password);
     $remoteId = $youTubeApiImpl->uploadVideo($videoFilePath, $videoFilePath, $props, $private);
     if ($needDel == true) {
         unlink($videoFilePath);
     }
     $data->remoteId = $remoteId;
     return true;
 }