From aec738309bb949105f5db189cede2d4f7966bdaa Mon Sep 17 00:00:00 2001 From: Avi Bueno Date: Tue, 24 Jun 2014 12:28:02 +0300 Subject: [PATCH] Added ALT_RAW_FILENAME to allow setting different content for a YouTube entry's "raw file" field PLAT-1375 #time 1d --- .../youtube_api/lib/YoutubeApiDistributionEngine.php | 4 +++- .../providers/youtube_api/lib/YoutubeApiImpl.php | 5 +++-- .../youtube_api/lib/model/YouTubeApiDistributionField.php | 2 ++ .../lib/model/YoutubeApiDistributionProfile.php | 8 ++++++++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/plugins/content_distribution/providers/youtube_api/lib/YoutubeApiDistributionEngine.php b/plugins/content_distribution/providers/youtube_api/lib/YoutubeApiDistributionEngine.php index 6f03afaea9e..ac16bc06c8b 100644 --- a/plugins/content_distribution/providers/youtube_api/lib/YoutubeApiDistributionEngine.php +++ b/plugins/content_distribution/providers/youtube_api/lib/YoutubeApiDistributionEngine.php @@ -77,6 +77,8 @@ protected function getYoutubeApiProps() $props['commentVote'] = $this->getValueForField(KalturaYouTubeApiDistributionField::ALLOW_RATINGS); $props['videoRespond'] = $this->getValueForField(KalturaYouTubeApiDistributionField::ALLOW_RESPONSES); $props['embed'] = $this->getValueForField(KalturaYouTubeApiDistributionField::ALLOW_EMBEDDING); + + $props['slugHeader'] = $this->getValueForField(KalturaYouTubeApiDistributionField::ALT_RAW_FILENAME); KalturaLog::debug("Props [" . print_r($props, true) . "]"); @@ -138,7 +140,7 @@ public function doSubmit(KalturaDistributionSubmitJobData $data, KalturaYoutubeA } $youTubeApiImpl = new YouTubeApiImpl($distributionProfile->username, $distributionProfile->password, $this->getHttpClientConfig()); - $remoteId = $youTubeApiImpl->uploadVideo($videoFilePath, $videoFilePath, $props, $private); + $remoteId = $youTubeApiImpl->uploadVideo($videoFilePath, $props, $private); if ($needDel == true) { diff --git a/plugins/content_distribution/providers/youtube_api/lib/YoutubeApiImpl.php b/plugins/content_distribution/providers/youtube_api/lib/YoutubeApiImpl.php index d4568a0b136..a27585d4340 100644 --- a/plugins/content_distribution/providers/youtube_api/lib/YoutubeApiImpl.php +++ b/plugins/content_distribution/providers/youtube_api/lib/YoutubeApiImpl.php @@ -68,7 +68,7 @@ public function __construct($user, $pass, array $config = null) $this->yt->setMajorProtocolVersion(2); } - public function uploadVideo($fileDisk, $fileUrl, $props, $private = false) + public function uploadVideo($fileDisk, $props, $private = false) { // foreach ($props as $key => $val) // { @@ -82,7 +82,8 @@ public function uploadVideo($fileDisk, $fileUrl, $props, $private = false) $filesource->setContentType('video/quicktime'); // print_r($filesource); // set slug header - $filesource->setSlug($fileUrl); + $slugHeader = $props['slugHeader'] ? $props['slugHeader'] : $fileDisk; + $filesource->setSlug($slugHeader); // add the filesource to the video entry $myVideoEntry->setMediaSource($filesource); $myVideoEntry->setVideoTitle($props['title']); diff --git a/plugins/content_distribution/providers/youtube_api/lib/model/YouTubeApiDistributionField.php b/plugins/content_distribution/providers/youtube_api/lib/model/YouTubeApiDistributionField.php index dacf079bb53..4200733e77b 100644 --- a/plugins/content_distribution/providers/youtube_api/lib/model/YouTubeApiDistributionField.php +++ b/plugins/content_distribution/providers/youtube_api/lib/model/YouTubeApiDistributionField.php @@ -18,4 +18,6 @@ interface YouTubeApiDistributionField extends BaseEnum const ALLOW_RESPONSES = 'ALLOW_RESPONSES'; const ALLOW_RATINGS = 'ALLOW_RATINGS'; const ALLOW_EMBEDDING = 'ALLOW_EMBEDDING'; + + const ALT_RAW_FILENAME = 'ALT_RAW_FILENAME'; // Alternative raw filename } \ No newline at end of file diff --git a/plugins/content_distribution/providers/youtube_api/lib/model/YoutubeApiDistributionProfile.php b/plugins/content_distribution/providers/youtube_api/lib/model/YoutubeApiDistributionProfile.php index 85d5feea63d..b5ac435603f 100644 --- a/plugins/content_distribution/providers/youtube_api/lib/model/YoutubeApiDistributionProfile.php +++ b/plugins/content_distribution/providers/youtube_api/lib/model/YoutubeApiDistributionProfile.php @@ -268,6 +268,14 @@ protected function getDefaultFieldConfigArray() $fieldConfig->setEntryMrssXslt(''); $fieldConfigArray[$fieldConfig->getFieldName()] = $fieldConfig; + // The following allows defining an alternative slug header for an uploaded video, which + // affects the "raw file" field of a YouTube video entry. + // A typical MRSS XSLT value would be the entry's title (similar to MEDIA_TITLE) + $fieldConfig = new DistributionFieldConfig(); + $fieldConfig->setFieldName(YouTubeApiDistributionField::ALT_RAW_FILENAME); + $fieldConfig->setUserFriendlyFieldName('Alternative Raw File Name '); + $fieldConfig->setEntryMrssXslt(''); // Empty by default to indicate that the feature is switched off. + $fieldConfigArray[$fieldConfig->getFieldName()] = $fieldConfig; return $fieldConfigArray; }