コード例 #1
0
/**
 * Uploads video to youtube
 */
function youtubeUpload($username, $password, $devkey, $filename, $filetype, $movie_title, $movie_desc, $keywords, $category_name, $coords = '')
{
    require_once 'Zend/Loader.php';
    // the Zend dir must be in your include_path
    Zend_Loader::loadClass('Zend_Gdata_YouTube');
    $yt = new Zend_Gdata_YouTube();
    Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
    $authenticationURL = 'https://www.google.com/youtube/accounts/ClientLogin';
    $httpClient = Zend_Gdata_ClientLogin::getHttpClient($username, $password, $service = 'youtube', $client = null, $source = 'core_dev', $loginToken = null, $loginCaptcha = null, $authenticationURL);
    $httpClient->setHeaders('X-GData-Key', "key={$devkey}");
    $yt = new Zend_Gdata_YouTube($httpClient);
    // create a new Zend_Gdata_YouTube_VideoEntry object
    $myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
    // create a new Zend_Gdata_App_MediaFileSource object
    $filesource = $yt->newMediaFileSource($filename);
    $filesource->setContentType($filetype);
    // set slug header
    $filesource->setSlug($filename);
    //FIXME: vafan är en slug header???
    // add the filesource to the video entry
    $myVideoEntry->setMediaSource($filesource);
    // create a new Zend_Gdata_YouTube_Extension_MediaGroup object
    $mediaGroup = $yt->newMediaGroup();
    $mediaGroup->title = $yt->newMediaTitle()->setText($movie_title);
    $mediaGroup->description = $yt->newMediaDescription()->setText($movie_desc);
    // the category must be a valid YouTube category
    // optionally set some developer tags (see Searching by Developer Tags for more details)
    $mediaGroup->category = array($yt->newMediaCategory()->setText($category_name)->setScheme('http://gdata.youtube.com/schemas/2007/categories.cat'));
    // set keywords, please note that they cannot contain white-space
    $mediaGroup->keywords = $yt->newMediaKeywords()->setText($keywords);
    $myVideoEntry->mediaGroup = $mediaGroup;
    if ($coords) {
        // set video location
        $yt->registerPackage('Zend_Gdata_Geo');
        $yt->registerPackage('Zend_Gdata_Geo_Extension');
        $where = $yt->newGeoRssWhere();
        $position = $yt->newGmlPos($coords);
        $where->point = $yt->newGmlPoint($position);
        $myVideoEntry->setWhere($where);
    }
    // upload URL for the currently authenticated user
    $uploadUrl = 'http://uploads.gdata.youtube.com/feeds/users/default/uploads';
    try {
        $newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
    } catch (Zend_Gdata_App_Exception $e) {
        echo $e->getMessage() . "\n";
    }
}
コード例 #2
0
ファイル: zendyoutube.php プロジェクト: hoanglannet/copar
 function browserBasedUpload($username, $password, $source, $title, $des = '', $cate = 'Entertainment')
 {
     // Note that this example creates an unversioned service object.
     // You do not need to specify a version number to upload content
     // since the upload behavior is the same for all API versions.
     $httpClient = $this->clientLogin($username, $password, $source);
     $yt = new Zend_Gdata_YouTube($httpClient);
     // create a new VideoEntry object
     $myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
     $myVideoEntry->setVideoTitle($title);
     $myVideoEntry->setVideoDescription($des);
     // The category must be a valid YouTube category!
     $myVideoEntry->setVideoCategory($cate);
     // Set keywords. Please note that this must be a comma-separated string
     // and that individual keywords cannot contain whitespace
     $myVideoEntry->SetVideoTags('cars, funny');
     $tokenHandlerUrl = 'http://gdata.youtube.com/action/GetUploadToken';
     try {
         $tokenArray = $yt->getFormUploadToken($myVideoEntry, $tokenHandlerUrl);
         return $tokenArray;
     } catch (Zend_Gdata_App_HttpException $httpException) {
         echo $httpException->getRawResponseBody();
     } catch (Zend_Gdata_App_Exception $e) {
         echo $e->getMessage();
     }
 }
コード例 #3
0
 protected function takeChildFromDOM($child)
 {
     $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
     switch ($absoluteNodeName) {
         case $this->lookupNamespace('yt') . ':' . 'position':
             $position = new Zend_Gdata_YouTube_Extension_Position();
             $position->transferFromDOM($child);
             $this->_position = $position;
             break;
         default:
             parent::takeChildFromDOM($child);
             break;
     }
 }
コード例 #4
0
ファイル: Youtube.php プロジェクト: ngocanh/pimcore
 public static function upload($asset)
 {
     try {
         $credentials = Asset_Video_Youtube::getYoutubeCredentials();
         if (!$credentials) {
             return;
         }
         $httpClient = Zend_Gdata_ClientLogin::getHttpClient($username = $credentials["username"], $password = $credentials["password"], $service = 'youtube', $client = Pimcore_Tool::getHttpClient("Zend_Gdata_HttpClient"), $source = 'Pimcore', $loginToken = null, $loginCaptcha = null, 'https://www.google.com/youtube/accounts/ClientLogin');
         $httpClient->setConfig(array("timeout" => 3600));
         $apikey = $credentials["apiKey"];
         $httpClient->setHeaders('X-GData-Key', "key={$apikey}");
         $yt = new Zend_Gdata_YouTube($httpClient);
         $myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
         $filesource = $yt->newMediaFileSource($asset->getFileSystemPath());
         $filesource->setContentType($asset->getMimetype());
         $filesource->setSlug($asset->getFilename());
         $myVideoEntry->setMediaSource($filesource);
         $myVideoEntry->setVideoTitle($asset->getFullPath());
         $myVideoEntry->setVideoDescription($asset->getFullPath());
         $myVideoEntry->setVideoCategory('Comedy');
         // Set keywords, note that this must be a comma separated string
         // and that each keyword cannot contain whitespace
         $myVideoEntry->SetVideoTags('---, ---');
         // Optionally set some developer tags
         $myVideoEntry->setVideoDeveloperTags(array('mydevelopertag', 'anotherdevelopertag'));
         // Upload URI for the currently authenticated user
         $uploadUrl = 'http://uploads.gdata.youtube.com/feeds/users/default/uploads';
         try {
             $newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
             $asset->setCustomSetting("youtube", array("id" => strval($newEntry->getVideoId())));
             $asset->save();
             return true;
         } catch (Exception $e) {
             $asset->setCustomSetting("youtube", array("failed" => true));
             $asset->save();
         }
     } catch (Exception $e) {
         Logger::error($e);
     }
     return false;
 }
コード例 #5
0
 public function doYoutubeUpload($options = array('title' => '', 'titleAlias' => '', 'introText' => '', 'source' => '', 'tags' => '', 'description' => ''))
 {
     $this->fileVideoName = $this->upload->getUploadName();
     $title = $options['title'];
     $titleAlias = $options['titleAlias'];
     $introText = $options['introText'];
     $uploadUrl = 'http://uploads.gdata.youtube.com/feeds/api/users/default/uploads';
     $fileName = $this->fileVideoName;
     Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
     $httpclient = Zend_Gdata_ClientLogin::getHttpClient($this->username, $this->password, $service = 'youtube', $client = null, $source = $options['source'], $loginToken = null, $loginCaptcha = null, $this->authenticationURL);
     Zend_Loader::loadClass('Zend_Gdata_YouTube');
     $yt = new Zend_Gdata_YouTube($httpclient, $options['name'], $options['name'], $this->developerKey);
     $videoEntry = new Zend_Gdata_YouTube_VideoEntry();
     $filesource = $yt->newMediaFileSource($fileName);
     $filesource->setContentType('video/' . $this->upload->fileExt);
     $filesource->setSlug($fileName);
     $videoEntry->setMediaSource($filesource);
     $videoEntry->setVideoTitle($title);
     $videoEntry->setVideoDescription($options['description']);
     $videoEntry->setVideoCategory($options['category']);
     $videoEntry->SetVideoTags($options['tags']);
     try {
         $videoEntry = $yt->insertEntry($videoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
         $state = $videoEntry->getVideoState();
         if ($state) {
             $youtubeId = $videoEntry->getVideoId();
             $this->videoId = $youtubeId;
             $this->videoUrl = "http://youtu.be/{$youtubeId}";
             $this->thumbSrc = "http://img.youtube.com/vi/{$youtubeId}/default.jpg";
             $this->duration = $this->length = 0;
             $this->parseAdditionalMetadata();
         } else {
             throw new Exception("Not able to retrieve the video status information yet. " . "Please try again later.\n");
         }
     } catch (Zend_Gdata_App_HttpException $httpException) {
         throw new Exception($httpException->getRawResponseBody());
     } catch (Zend_Gdata_App_Exception $e) {
         throw new Exception($e->getMessage());
     }
 }
コード例 #6
0
ファイル: ElementTest.php プロジェクト: nlegoff/Phraseanet
 public function setUp()
 {
     parent::setUp();
     $published = new Zend_Gdata_App_Extension_Published("2011-10-21 12:00:00");
     $updated = new Zend_Gdata_App_Extension_Updated("2011-10-21 12:20:00");
     $id = new Zend_Gdata_App_Extension_Id("Az2cv12");
     $rating = new Zend_Gdata_Extension_Rating(4, 1, 5, 200, 4);
     $duration = new Zend_Gdata_YouTube_Extension_Duration(80);
     $player = new Zend_Gdata_Media_Extension_MediaPlayer();
     $player->setUrl("coucou");
     $stat = new Zend_Gdata_YouTube_Extension_Statistics();
     $stat->setViewCount("5");
     $thumb = new Zend_Gdata_Media_Extension_MediaThumbnail('une url', '120', '90');
     $media = new Zend_Gdata_YouTube_Extension_MediaGroup();
     $media->setPlayer([$player]);
     $media->setDuration($duration);
     $media->setVideoId($id);
     $media->setThumbnail([$thumb]);
     $entry = new Zend_Gdata_YouTube_VideoEntry();
     $entry->setMajorProtocolVersion(2);
     $entry->setMediaGroup($media);
     $entry->setStatistics($stat);
     $entry->setRating($rating);
     $entry->setVideoCategory("category");
     $entry->setVideoDescription("one description");
     $entry->setVideoPrivate();
     $entry->setVideoTags(['tags']);
     $entry->setVideoTitle("hellow");
     $entry->setUpdated($updated);
     $entry->setPublished($published);
     $this->object = new Bridge_Api_Youtube_Element($entry, 'video');
 }
コード例 #7
0
ファイル: video.php プロジェクト: sauravpratihar/fcms
 /**
  * displayYouTubeUploadFilePage 
  * 
  * Takes the post data from the previous form, sends to youtube, creates new entry,
  * and prints the video file upload form.
  * 
  * @return void
  */
 function displayYouTubeUploadFilePage()
 {
     $this->displayHeader();
     $videoTitle = '';
     $videoDescription = '';
     if (isset($_POST['title'])) {
         $videoTitle = strip_tags($_POST['title']);
     }
     if (isset($_POST['description'])) {
         $videoDescription = strip_tags($_POST['description']);
     }
     $videoCategory = isset($_POST['category']) ? $_POST['category'] : '';
     $videoUnlisted = isset($_POST['unlisted']) ? true : false;
     // Create fcms video - we update after the youtube video is created
     $sql = "INSERT INTO `fcms_video` (\n                    `source_id`, \n                    `title`, \n                    `description`, \n                    `source`, \n                    `created`, \n                    `created_id`, \n                    `updated`, \n                    `updated_id`\n                )\n                VALUES\n                    ('0', ?, ?, 'youtube', NOW(), ?, NOW(), ?)";
     $params = array($videoTitle, $videoDescription, $this->fcmsUser->id, $this->fcmsUser->id);
     $lastId = $this->fcmsDatabase->insert($sql, $params);
     if ($lastId === false) {
         $this->fcmsError->displayError();
         $this->displayFooter();
         return;
     }
     // Save fcms video id
     $_SESSION['fcmsVideoId'] = $lastId;
     $sessionToken = $this->getSessionToken($this->fcmsUser->id);
     $youtubeConfig = getYouTubeConfigData();
     $httpClient = getYouTubeAuthSubHttpClient($youtubeConfig['youtube_key'], $sessionToken);
     if ($httpClient === false) {
         // Error message was already displayed by getYouTubeAuthSubHttpClient()
         $this->displayFooter();
         die;
     }
     $youTubeService = new Zend_Gdata_YouTube($httpClient);
     $newVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
     $newVideoEntry->setVideoTitle($videoTitle);
     $newVideoEntry->setVideoDescription($videoDescription);
     $newVideoEntry->setVideoCategory($videoCategory);
     // make video unlisted
     if ($videoUnlisted) {
         $unlisted = new Zend_Gdata_App_Extension_Element('yt:accessControl', 'yt', 'http://gdata.youtube.com/schemas/2007', '');
         $unlisted->setExtensionAttributes(array(array('namespaceUri' => '', 'name' => 'action', 'value' => 'list'), array('namespaceUri' => '', 'name' => 'permission', 'value' => 'denied')));
         $newVideoEntry->setExtensionElements(array($unlisted));
     }
     try {
         $tokenArray = $youTubeService->getFormUploadToken($newVideoEntry, 'http://gdata.youtube.com/action/GetUploadToken');
     } catch (Exception $e) {
         echo '
         <div class="error-alert">
             <p>' . T('Could not retrieve token for syndicated upload.') . '</p>
             <p>' . $e->getMessage() . '</p>
         </div>';
         $this->displayFooter();
         return;
     }
     $tokenValue = $tokenArray['token'];
     $postUrl = $tokenArray['url'];
     $nextUrl = getDomainAndDir() . 'video.php?upload=youtube';
     echo '
     <form action="' . $postUrl . '?nexturl=' . $nextUrl . '" method="post" enctype="multipart/form-data">
         <fieldset>
             <legend><span>' . T_('Upload YouTube Video') . '</span></legend>
             <div class="field-row">
                 <div class="field-label"><label><b>' . T_('Title') . '</b></label></div>
                 <div class="field-widget"><b>' . $videoTitle . '</b></div>
             </div>
             <div class="field-row">
                 <div class="field-label"><label><b>' . T_('Video') . '</b></label></div>
                 <div class="field-widget">
                     <input type="file" name="file" size="50"/>
                 </div>
             </div>
             <input name="token" type="hidden" value="' . $tokenValue . '"/>
             <input class="sub1" type="submit" id="upload_file" name="upload_file" value="' . T_('Upload') . '"/>
         </fieldset>
     </form>';
     $this->displayFooter();
 }
コード例 #8
0
ファイル: locallib.php プロジェクト: upegh/youtube
 public function fetch_youtube_uploadform($yt, $videotitle, $videodescription)
 {
     global $CFG, $USER;
     // create a new VideoEntry object
     $myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
     $myVideoEntry->setVideoTitle($videotitle);
     $myVideoEntry->setVideoDescription($videodescription);
     // The category must be a valid YouTube category!
     $myVideoEntry->setVideoCategory('Education');
     //This sets videos private, but then can't view if not logged in as the account owner
     //$myVideoEntry->setVideoPrivate();
     //So instead we set them to unlisted(but its more complex)
     $unlisted = new Zend_Gdata_App_Extension_Element('yt:accessControl', 'yt', 'http://gdata.youtube.com/schemas/2007', '');
     $unlisted->setExtensionAttributes(array(array('namespaceUri' => '', 'name' => 'action', 'value' => 'list'), array('namespaceUri' => '', 'name' => 'permission', 'value' => 'denied')));
     $myVideoEntry->setExtensionElements(array($unlisted));
     // Set keywords. This must be a comma-separated string
     // Individual keywords cannot contain whitespace
     // We are not doing this, but it would be possible
     //$myVideoEntry->SetVideoTags('cars, funny');
     //data is all set, so we get our upload token from google
     $tokenHandlerUrl = 'http://gdata.youtube.com/action/GetUploadToken';
     $tokenArray = $yt->getFormUploadToken($myVideoEntry, $tokenHandlerUrl);
     $tokenValue = $tokenArray['token'];
     $postUrl = $tokenArray['url'];
     //Set the URL YouTube should redirect user to after upload
     //that will be the same iframe
     $nextUrl = $CFG->httpswwwroot . '/mod/assign/submission/youtube/uploader.php';
     // Now that we have the token, we build the form
     $form = '<form action="' . $postUrl . '?nexturl=' . $nextUrl . '" method="post" enctype="multipart/form-data">' . '<input name="file" type="file"/>' . '<input name="token" type="hidden" value="' . $tokenValue . '"/>' . '<input value="Upload Video File" type="submit" onclick="document.getElementById(\'id_uploadanim\').style.display=\'block\';" />' . '</form>';
     // We tag on a hidden uploading icon. YouTube gives us no progress events, sigh.
     // So its the best we can do to show an animated gif.
     // But if it fails, user will wait forever.
     $form .= '<img id="id_uploadanim" style="display: none;margin-left: auto;margin-right: auto;" src="' . $CFG->httpswwwroot . '/mod/assign/submission/youtube/pix/uploading.gif"/>';
     return $form;
 }
 public function uploadVideo($fileDisk, $fileUrl, $props, $private = false)
 {
     //		foreach ($props as $key => $val)
     //		{
     //			error_log($key . " is " . $val);
     //		}
     // create a new VideoEntry object
     $myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
     // create a new Zend_Gdata_App_MediaFileSource object
     $filesource = $this->yt->newMediaFileSource($fileDisk);
     $filesource->setContentType('video/quicktime');
     //	print_r($filesource);
     // set slug header
     $filesource->setSlug($fileUrl);
     // add the filesource to the video entry
     $myVideoEntry->setMediaSource($filesource);
     $myVideoEntry->setVideoTitle($props['title']);
     $myVideoEntry->setVideoDescription($props['description']);
     // The category must be a valid YouTube category!
     $myVideoEntry->setVideoCategory($props['category']);
     // Set keywords. Please note that this must be a comma-separated string
     // and that individual keywords cannot contain whitespace
     $myVideoEntry->setVideoTags($props['keywords']);
     if ($private) {
         $myVideoEntry->setVideoPrivate();
     } else {
         $myVideoEntry->setVideoPublic();
     }
     $access = array();
     $access[] = new Zend_Gdata_YouTube_Extension_Access('comment', $props['comment']);
     $access[] = new Zend_Gdata_YouTube_Extension_Access('rate', $props['rate']);
     $access[] = new Zend_Gdata_YouTube_Extension_Access('commentVote', $props['commentVote']);
     $access[] = new Zend_Gdata_YouTube_Extension_Access('videoRespond', $props['videoRespond']);
     $access[] = new Zend_Gdata_YouTube_Extension_Access('embed', $props['embed']);
     $myVideoEntry->setAccess($access);
     // set some developer tags -- this is optional
     // (see Searching by Developer Tags for more details)
     //		$myVideoEntry->setVideoDeveloperTags(array('mydevtag', 'anotherdevtag'));
     // set the video's location -- this is also optional
     //	$yt->registerPackage('Zend_Gdata_Geo');
     //	$yt->registerPackage('Zend_Gdata_Geo_Extension');
     //	$where = $yt->newGeoRssWhere();
     //	$position = $yt->newGmlPos('37.0 -122.0');
     //	$where->point = $yt->newGmlPoint($position);
     //	$myVideoEntry->setWhere($where);
     // upload URI for the currently authenticated user
     $uploadUrl = 'http://uploads.gdata.youtube.com/feeds/api/users/default/uploads';
     // try to upload the video, catching a Zend_Gdata_App_HttpException,
     // if available, or just a regular Zend_Gdata_App_Exception otherwise
     /*		try 
     		{   */
     $newEntry = $this->yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
     $newEntry->setMajorProtocolVersion(2);
     //if(isset($props['playlists']))
     //$this->handlePlaylists($newEntry, explode(',', $props['playlists']));
     return $newEntry->getVideoId();
     /*		}
     		catch (Zend_Gdata_App_HttpException $httpException) 
     		{   
     	//		print_r($httpException);
     			echo $httpException->getRawResponseBody(); 
     			return null;
     		} 
     		catch (Zend_Gdata_App_Exception $e) 
     		{     
     	//		print_r($e);
     			echo $e->getMessage(); 
     			return null;
     		}*/
 }
コード例 #10
0
ファイル: fbmember.php プロジェクト: ki8asui/isography
 function uploadvideo()
 {
     if (!empty($_FILES['image'])) {
         $uploaddir = BASEPATH . '../video';
         $fname = $_FILES['image']['name'];
         $fsize = $_FILES['image']['size'];
         $ftmpname = $_FILES['image']['tmp_name'];
         $ext = '';
         if (preg_match("/.+(\\..+)\$/", $fname, $matches)) {
             $ext = strtolower($matches[1]);
         }
         //file extension
         $filename = $this->_genFileName($ext, $uploaddir);
         $uploadfile = $uploaddir . '/' . $filename;
         //debug: //echo $uploadfile;
         //$fsize < 3000000  //allow to upload only pics that less then file_upload_size bytes
         if (in_array($ext, array('.avi', '.3gp', '.mov', '.mp4', '.mpeg', '.flv', '.swf', '.mkv'))) {
             if (move_uploaded_file($ftmpname, $uploadfile)) {
                 //uploaded
                 $uploaded = TRUE;
             } else {
                 //Error while uploading file
             }
         } else {
             //Picture shouldn't exceed file_upload_size bytes
             $_data['msg'] = $msg = 'Uploaded file should be a video';
         }
     } else {
         $_data['msg'] = $msg = 'You should select a video to upload';
     }
     if (empty($uploaded)) {
         if (empty($msg)) {
             $_data['msg'] = $msg = 'Cannot upload file';
         }
         $this->load->view('member_post_video', $_data);
     } else {
         $yt = new Zend_Gdata_YouTube($this->client);
         // create a new Zend_Gdata_YouTube_VideoEntry object
         $myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
         // create a new Zend_Gdata_App_MediaFileSource object
         $filesource = $yt->newMediaFileSource($uploadfile);
         $filesource->setContentType('video/quicktime');
         // set slug header
         $filesource->setSlug($uploadfile);
         // add the filesource to the video entry
         $myVideoEntry->setMediaSource($filesource);
         // create a new Zend_Gdata_YouTube_MediaGroup object
         $mediaGroup = $yt->newMediaGroup();
         $mediaGroup->title = $yt->newMediaTitle()->setText('My Movie');
         $mediaGroup->description = $yt->newMediaDescription()->setText('My Movie Description');
         // the category must be a valid YouTube category
         // optionally set some developer tags (see Searching by Developer Tags for more details)
         $mediaGroup->category = array($yt->newMediaCategory()->setText('Autos')->setScheme('http://gdata.youtube.com/schemas/2007/categories.cat'));
         // set keywords
         $mediaGroup->keywords = $yt->newMediaKeywords()->setText('test');
         $myVideoEntry->mediaGroup = $mediaGroup;
         // set video location
         //$yt->registerPackage('Zend_Gdata_Geo');
         //$yt->registerPackage('Zend_Gdata_Geo_Extension');
         //$where = $yt->newGeoRssWhere();
         //$position = $yt->newGmlPos('37.0 -122.0');
         //$where->point = $yt->newGmlPoint($position);
         //$entry->setWhere($where);
         // upload URL for the currently authenticated user
         $uploadUrl = 'http://uploads.gdata.youtube.com/feeds/users/default/uploads';
         try {
             $newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
             //print"<pre>";var_dump($newEntry->getVideoWatchPageUrl());print"</pre>";
             if (!empty($this->fbUserId) && !empty($this->userSettings) && $this->userSettings[0]['facebook_vids_y_n'] == 1) {
                 // uploading video to Facebook
                 try {
                     $this->facebook->api_client->video_upload($uploadfile, "Uploading video with " . $this->conf['site_name'], null);
                 } catch (Exception $ex) {
                     echo $ex->getMessage();
                     //echo "Cannot upload video to facebook";
                 }
             }
             $lastMessage = $this->Post_model->getWhere(null, $limit = 1, $offset = 0, $order = 'id DESC');
             if (!empty($lastMessage) && $lastMessage[0]['user_id'] == $this->getUserId() && $lastMessage[0]['site_id'] == $this->subdomainId && $lastMessage[0]['post_type'] == 'video') {
                 $this->Post_videos_model->insert($lastMessage[0]['id'], $newEntry->getVideoWatchPageUrl());
             } else {
                 $this->Post_model->insert($this->getUserId(), $this->subdomainId, date("Y-m-d H:i"), 'video', NULL, $newEntry->getVideoWatchPageUrl(), NULL);
             }
             $this->load->view('member_post_video_success');
             $sitedata = $this->Site_model->getById($this->subdomainId);
             $users = $this->User_is_member_of_site_model->getList(0, 0, array('subscribe_y_n' => 1, 'site_id' => $this->subdomainId), '', array('table' => 'users', 'field1' => 'id', 'field2' => 'user_id'));
             foreach ($users as $user) {
                 $this->_sendemail('newpost', array('sitename' => $sitedata['name'], 'subdomain' => $sitedata['subdomain'], 'email' => $user['email']));
             }
             //$this->load->view('member_post_video_success', $_data);
         } catch (Zend_Gdata_App_Exception $e) {
             echo $e->getMessage();
         }
         @unlink($uploadfile);
     }
 }
コード例 #11
0
		function uploadAction()
		{
			//echo $this->user.' - '.$this->pass.' - '.$this->gallery;
			$this->view->headTitle('UNC - Admin website');
			$this->view->headLink()->appendStylesheet($this->view->baseUrl().'/application/templates/admin/css/layout.css');
			$this->view->headScript()->appendFile($this->view->baseUrl().'/application/templates/admin/js/jquery-1.7.2.min.js','text/javascript');
			$this->view->headScript()->appendFile($this->view->baseUrl().'/application/templates/admin/js/hideshow.js','text/javascript');

			$form = $this->setForm();
			$this->view->form = $form;
			
			if($this->_request->isPost())
			{	
				if($form->isValid($_POST))
				{
					$title =  $this->_request->getPost('title');
					$description = $this->_request->getPost('description');
					//echo $title.$description;die();
					if ($_FILES["file"]["name"]!='')
					{
						$dir = dirname($_FILES["file"]["tmp_name"]);
						$destination = $dir . DIRECTORY_SEPARATOR . $_FILES["file"]["name"];
						rename($_FILES["file"]["tmp_name"], $destination);
						
						$httpClient = $this->_httpClient();
									   
						Zend_Loader::loadClass('Zend_Gdata_YouTube');
					 	$yt = new Zend_Gdata_YouTube($httpClient, 'NIW-App-1.0', '661085061264.apps.googleusercontent.com', 'AI39si4UPUxw1FE5hqSi0Z-B-5z3PIVovbBWKmqiMI3cXJ7lhvjJcABV-eqimb2EeSiuedWK8N9OGOdB1namX1CqqYki8jEfSQ');
						$yt->setMajorProtocolVersion(2);
						$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
						
						$filesource = $yt->newMediaFileSource($destination);
					    $filesource->setContentType('video/quicktime');
					    $filesource->setSlug($destination);
						
						$myVideoEntry->setMediaSource($filesource);
						$myVideoEntry->setVideoTitle($title);
						$myVideoEntry->setVideoDescription($description);
						
						$myVideoEntry->setVideoCategory('Autos');
						$myVideoEntry->SetVideoTags('cars, funny');
						$myVideoEntry->setVideoDeveloperTags(array('mydevtag', 'anotherdevtag'));
						
						// set the video's location -- this is also optional
						$yt->registerPackage('Zend_Gdata_Geo');
						$yt->registerPackage('Zend_Gdata_Geo_Extension');
						$where = $yt->newGeoRssWhere();
						$position = $yt->newGmlPos('37.0 -122.0');
						$where->point = $yt->newGmlPoint($position);
						$myVideoEntry->setWhere($where);
						
						$uploadUrl = 'http://uploads.gdata.youtube.com/feeds/api/users/default/uploads';
						try {
						  	$newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
						} catch (Zend_Gdata_App_HttpException $httpException) {
						  echo $httpException->getRawResponseBody();
						} catch (Zend_Gdata_App_Exception $e) {
						    echo $e->getMessage();
						}
						
						if(file_exists($destination))
							unlink($destination);
						
						echo '<script type="text/javascript">
							alert("Video đang được upload trên YOUTUBE !");
						</script>';
						$this->_redirect($this->view->baseUrl().'/../admin/uploadvideo');
						
						//
					}
					else echo '<script type="text/javascript">alert("Vui lòng chọn file !");</script>';
				}
				
			//}
			$this->view->title = 'Tải lên video';
			}
		}
コード例 #12
0
ファイル: Youtube.php プロジェクト: nlegoff/Phraseanet
 /**
  *
  * @param  record_adapter $record
  * @param  array          $options
  * @return string         The new distant Id
  */
 public function upload(record_adapter $record, array $options = [])
 {
     switch ($record->get_type()) {
         case 'video':
             $video_entry = new Zend_Gdata_YouTube_VideoEntry();
             $filesource = new Zend_Gdata_App_MediaFileSource($record->get_hd_file()->getRealPath());
             $filesource->setContentType($record->get_hd_file()->get_mime());
             $filesource->setSlug($record->get_title());
             $video_entry->setMediaSource($filesource);
             $video_entry->setVideoTitle($options['title']);
             $video_entry->setVideoDescription($options['description']);
             $video_entry->setVideoCategory($options['category']);
             $video_entry->SetVideoTags(explode(' ', $options['tags']));
             $video_entry->setVideoDeveloperTags(['phraseanet']);
             if ($options['privacy'] == "public") {
                 $video_entry->setVideoPublic();
             } else {
                 $video_entry->setVideoPrivate();
             }
             $app_entry = $this->_api->insertEntry($video_entry, self::UPLOAD_URL, 'Zend_Gdata_YouTube_VideoEntry');
             /*
              * set major protocole version to 2 otherwise you get exception when calling getVideoId
              * but setting setMajorProtocolVersion to 2 at the new entry introduce a new bug with getVideoState
              * @see http://groups.google.com/group/youtube-api-gdata/browse_thread/thread/7d86cac0d3f90e3f/d9291d7314f99be7?pli=1
              */
             $app_entry->setMajorProtocolVersion(2);
             return $app_entry->getVideoId();
             break;
         default:
             throw new Bridge_Exception_InvalidRecordType('Unknown format');
             break;
     }
 }
コード例 #13
0
ファイル: upload-videos.php プロジェクト: nickavv/iSENSE
 if (!isset($_FILES['video_file'])) {
     array_push($errors, 'No session file was entered.');
 }
 if (strpos($_FILES['video_file']['type'], "video") === FALSE) {
     array_push($errors, 'The file you uploaded is not a video');
 }
 if (count($errors) == 0) {
     /* Might want to check the move code, this could cause colisions */
     $target_path = '/tmp/';
     $target_path = $target_path . basename($_FILES['video_file']['name']);
     if (!move_uploaded_file($_FILES['video_file']['tmp_name'], $target_path)) {
         array_push($errors, 'Error uploading file!');
     }
 }
 if (count($errors) == 0) {
     $videoEntry = new Zend_Gdata_YouTube_VideoEntry();
     $fs = $yt->newMediaFileSource($target_path);
     $fs->setContentType($_FILES['video_file']['type']);
     $fs->setSlug($_FILES['video_file']['name']);
     $videoEntry->setMediaSource($fs);
     $videoEntry->setVideoTitle($vtitle);
     $videoEntry->setVideoDescription($description);
     $videoEntry->setVideoCategory('Education');
     $videoEntry->setVideoTags('isense');
     $uploadUrl = 'http://uploads.gdata.youtube.com/feeds/api/users/default/uploads';
     $newEntry = null;
     try {
         $newEntry = $yt->insertEntry($videoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
     } catch (Zend_Gdata_App_HttpException $httpException) {
         array_push($errors, $httpException->getRawResponseBody());
     } catch (Zend_Gdata_App_Exception $e) {
コード例 #14
0
ファイル: izap-videos.php プロジェクト: justangel/izap-videos
/**
 * Get page components to upload youtube video.
 * 
 * @param string  $page
 * @param integer $guid
 * @param string  $revision
 * 
 * @return array  array of content for YouTube video uploading
 * 
 * @version 5.0
 */
function izap_video_get_page_content_youtube_upload($page, $guid = 0, $revision = NULL)
{
    $return = array('filter' => '');
    $form_vars = array();
    $params = array();
    $video = IzapGYoutube::getAuthSubHttpClient(get_input('token', false));
    //get youtube api authorization via users application access.
    //	if (get_input('token')) {
    $video = IzapGYoutube::getAuthSubHttpClient(get_input('token', false));
    if ($video instanceof IzapGYoutube) {
        $yt = $video->YoutubeObject();
        $myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
        $myVideoEntry->setVideoTitle($_SESSION['youtube_attributes']['title']);
        $description = strip_tags($_SESSION['youtube_attributes']['description']);
        $myVideoEntry->setVideoDescription($description);
        // Note that category must be a valid YouTube category
        $myVideoEntry->setVideoCategory($_SESSION['youtube_attributes']['youtube_cats']);
        $myVideoEntry->SetVideoTags($_SESSION['youtube_attributes']['tags']);
        $tokenHandlerUrl = 'http://gdata.youtube.com/action/GetUploadToken';
        try {
            $tokenArray = $yt->getFormUploadToken($myVideoEntry, $tokenHandlerUrl);
        } catch (Exception $e) {
            if (preg_match("/<code>([a-z_]+)<\\/code>/", $e->getMessage(), $matches)) {
                register_error('YouTube Error: ' . $matches[1]);
            } else {
                register_error('YouTube Error: ' . $e->getMessage());
            }
            forward(izap_set_href(array('context' => GLOBAL_IZAP_VIDEOS_PAGEHANDLER, 'action' => 'add', 'page_owner' => elgg_get_logged_in_user_guid(), 'vars' => array('tab' => 'youtube'))));
        }
        $params['token'] = $tokenArray['token'];
        $params['action'] = $tokenArray['url'] . '?nexturl=' . elgg_get_site_url() . GLOBAL_IZAP_VIDEOS_PAGEHANDLER . '/next&scope=https://gdata.youtube.com&session=1&secure=0';
        elgg_push_breadcrumb(elgg_echo('upload'));
        $form_vars = array('enctype' => 'multipart/form-data', 'name' => 'video_upload', 'action' => $params['action'], 'id' => 'izap-video-form');
        $title = elgg_echo('Upload video with title: "' . $_SESSION['youtube_attributes']['title'] . '"');
        $content = elgg_view_form('izap-videos/youtube_upload', $form_vars, $params);
        $return['title'] = $title;
        $return['content'] = $content;
        return $return;
    } else {
        register_error('You must have to grant access for youtube upload');
        forward();
    }
}
コード例 #15
0
ファイル: upload_videos.php プロジェクト: pushpen/class2go
$username = '******';
$passwd = 'parseitup';
$authenticationURL = 'https://www.google.com/accounts/ClientLogin';
try {
    $httpClient = Zend_Gdata_ClientLogin::getHttpClient($username, $passwd, $service = 'youtube', $client = null, $source = 'MySource', $loginToken = null, $loginCaptcha = null, $authenticationURL);
} catch (Zend_Gdata_App_CaptchaRequiredException $cre) {
    echo 'URL of CAPTCHA image: ' . $cre->getCaptchaUrl() . "\n";
    echo 'Token ID: ' . $cre->getCaptchaToken() . "\n";
} catch (Zend_Gdata_App_AuthException $ae) {
    echo 'Problem authenticating: ' . $ae->exception() . "\n";
}
$developerKey = "AI39si5GlWcy9S4eVFtajbVZk-DjFEhlM4Zt7CYzJG3f2bwIpsBSaGd8SCWts6V5lbqBHJYXAn73-8emsZg5zWt4EUlJJ4rpQA";
$applicationId = "class2go";
$clientId = "";
$yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, $developerKey);
$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
$dirs_ary = glob('*', GLOB_ONLYDIR);
foreach ($dirs_ary as $dir) {
    $filestring = file_get_contents($dir . '/lecture_settings.html');
    $dom = new DOMDocument();
    @$dom->loadHTML($filestring);
    $vidName = $dom->getElementById("source_video")->getAttribute('value');
    $lectureTitle = $dom->getElementById("title")->getAttribute('value');
    if ($lectureTitle == "CKY Example (21:52)" || $lectureTitle == "CKY Parsing (23:25)" || $lectureTitle == "Charniak's Model (18:23)" || $lectureTitle == "Discriminative Model Features") {
        echo $lectureTitle . ": " . $vidName . "\n";
        $filesource = $yt->newMediaFileSource('../source_videos/' . $vidName);
        $filesource->setContentType('video/mp4');
        $filesource->setSlug($vidName);
        $myVideoEntry->setMediaSource($filesource);
        $myVideoEntry->setVideoTitle($lectureTitle);
        $myVideoEntry->setVideoDescription($lectureTitle);
コード例 #16
0
ファイル: YouTube.php プロジェクト: idiscussforum/providence
 /**
  *
  * @param string $ps_filepath
  * @param array $pa_data
  * @param array $pa_options
  * @return string Unique request token. The token can be used on subsequent calls to fetch information about the replication request
  */
 public function initiateReplication($ps_filepath, $pa_data, $pa_options = null)
 {
     if (!($o_client = $this->getClient($pa_options))) {
         throw new Exception(_t('Could not connect to YouTube'));
     }
     $va_path_info = pathinfo($ps_filepath);
     $o_video_entry = new Zend_Gdata_YouTube_VideoEntry();
     $o_filesource = $o_client->newMediaFileSource($ps_filepath);
     $ID3 = new getID3();
     $ID3->option_max_2gb_check = false;
     $va_info = $ID3->analyze($ps_filepath);
     $o_filesource->setContentType($va_info['mime_type']);
     $o_filesource->setSlug($va_path_info['filename'] . '.' . $va_path_info['extension']);
     $o_video_entry->setMediaSource($o_filesource);
     $o_video_entry->setVideoTitle(isset($pa_data['title']) ? $pa_data['title'] : $va_path_info['filename']);
     $o_video_entry->setVideoDescription($pa_data['description'] ? $pa_data['description'] : '');
     // Note that category must be a valid YouTube category!
     $o_video_entry->setVideoCategory($pa_data['category'] ? $pa_data['category'] : 'Movies');
     // Set keywords, note that this must be a comma separated string
     // and that each keyword cannot contain whitespace
     $o_video_entry->SetVideoTags(is_array($pa_data['tags']) ? join(",", $pa_data['tags']) : '');
     if (isset($pa_options['private']) && $pa_options['private']) {
         $o_video_entry->setVideoPrivate();
     }
     // This may throw an exception
     $o_new_entry = $o_client->insertEntry($o_video_entry, WLPlugMediaReplicationYouTube::$s_upload_url, 'Zend_Gdata_YouTube_VideoEntry');
     $this->opa_request_list[$o_new_entry->getVideoID()] = array('entry' => $o_video_entry, 'errors' => array());
     return $this->info['NAME'] . "://" . $o_new_entry->getVideoID();
 }
コード例 #17
0
 public function upload()
 {
     if (isset($this->httpClient)) {
         $response = "No Response From Server";
         $this->yt = new Zend_Gdata_YouTube($this->httpClient, $this->applicationId, $this->clientId, $this->developerKey);
         $this->yt->setMajorProtocolVersion(2);
         // create a new VideoEntry object
         $myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
         // create a new Zend_Gdata_App_MediaFileSource object
         //$filesource = $this->yt->newMediaFileSource ( $this->video->path );
         $filesource = new Zend_Gdata_App_MediaFileSource($this->video->path);
         //echo ("Media Source Path " . $this->video->path . "<br>\n");
         $filesource->setContentType('video/mpeg');
         // set slug header
         $filesource->setSlug($this->video->slug);
         // add the filesource to the video entry
         $myVideoEntry->setMediaSource($filesource);
         //echo ("Media Source Set<br>\n");
         $myVideoEntry->setVideoTitle($this->getWebTitle());
         //echo ("Video Title Set<br>\n");
         $myVideoEntry->setVideoDescription($this->getWebDescription());
         //echo ("Description Set<br>\n");
         //TODO: Figure out how to set video response access as allowed
         // The category must be a valid YouTube category!
         $relevantVideosFeed = $this->getRelevantVideos($this->getWebTitle());
         $category = "Entertainment";
         if (isset($relevantVideosFeed)) {
             $categoryMap = $this->getRelevantYoutubeCategories($relevantVideosFeed);
             if (count($categoryMap) > 0) {
                 $category = $this->getRelevantCategoryFromCategoryMap($categoryMap);
             }
         }
         // Check to see if category is deprecated then use Category Chooser to find best category
         if (!$this->isValidCategory($category)) {
             //echo ("$category Is not valid. Looking for another valid category");
             $categorizer = new Categorizer($this->video->pid);
             $categorizer->chooseCategory($this->getPossibleCategories());
             $category = $categorizer->getPossCategoryName();
         }
         //echo ("Choosen Category: $category<br>");
         $myVideoEntry->setVideoCategory($category);
         //echo ("Category Set<br>\n");
         // Set keywords. Please note that this must be a comma-separated string
         // and that individual keywords cannot contain whitespace
         //$keywords = $this->getWebKeywords ();
         //echo ("Web Keywords: $keywords<br>\n");
         $keywords = $this->getYoutubeModifiedKeywords();
         //echo ( "Mod Keywords: $keywords<br>\n" );
         if (strlen($keywords) > 0) {
             $myVideoEntry->SetVideoTags($keywords);
         }
         //echo ("Tags Set<br>\n");
         // upload URI for the currently authenticated user
         $uploadUrl = 'http://uploads.gdata.youtube.com/feeds/api/users/default/uploads';
         // try to upload the video, catching a Zend_Gdata_App_HttpException,
         // if available, or just a regular Zend_Gdata_App_Exception otherwise
         try {
             //echo ("Inserting Video Entry<br>\n");
             $newEntry = $this->yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
             $response = $this->getVideoState($newEntry);
             $this->uploadLocation = $newEntry->getVideoWatchPageUrl();
         } catch (Exception $except) {
             //echo ("Exception Thrown<br>\n");
             $response = $except->getMessage();
         }
     } else {
         $response = "No Http Client to upload video for user: "******"| Youtube HttpClient Response: " . $this->httpException;
         //echo ($response . "<br>");
     }
     return $response;
 }
コード例 #18
0
ファイル: videos.php プロジェクト: alvaropereyra/shrekcms
 /**
  * Sube un archivo
  * @param boolean $ie6 es Internet Explorer 6
  * @return array 
  */
 function _upload($ie = NULL)
 {
     $this->load->library('zend');
     $this->zend->load('Zend/Gdata/YouTube');
     $this->zend->load('Zend/Gdata/ClientLogin');
     $authenticationURL = 'https://www.google.com/youtube/accounts/ClientLogin';
     $httpClient = Zend_Gdata_ClientLogin::getHttpClient($username = '******', $password = '******', $service = 'youtube', $client = null, $source = 'LaMulaSRD', $loginToken = null, $loginCaptcha = null, $authenticationURL);
     $clientId = "ytapi-AlvaroPereyraRab-WebPublishing-afg0bc0f-0";
     $developerKey = "AI39si77SKdfoJ3spb7HZHe_tUVcOKX_TAn7Fne7BU8ux6ixJ6E8ZdNmZ7UeJs7y3ZGOfVyNAzSe4nYJqIX3Lu7RNryf-dOn9A";
     $httpClient->setHeaders('X-GData-Key', "key={$developerKey}");
     $applicationId = "SRD-LaMula-1.0";
     $yt = new Zend_Gdata_YouTube($httpClient);
     $filesource = $yt->newMediaFileSource($_FILES["Filedata"]['tmp_name']);
     $filesource->setContentType('video/quicktime');
     // set slug header
     $filesource->setSlug($_FILES["Filedata"]['tmp_name']);
     $myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
     // add the filesource to the video entry
     $myVideoEntry->setMediaSource($filesource);
     // create a new Zend_Gdata_YouTube_MediaGroup object
     $mediaGroup = $yt->newMediaGroup();
     $mediaGroup->title = $yt->newMediaTitle()->setText('LaMula');
     $mediaGroup->description = $yt->newMediaDescription()->setText('Subido desde LaMula');
     $mediaGroup->keywords = $yt->newMediaKeywords()->setText('lamula');
     // the category must be a valid YouTube category
     // optionally set some developer tags (see Searching by Developer Tags for more details)
     $mediaGroup->category = array($yt->newMediaCategory()->setText('Entertainment')->setScheme('http://gdata.youtube.com/schemas/2007/categories.cat'));
     // set keywords
     //     $mediaGroup->keywords = $service->newMediaKeywords()->setText('cars, funny');
     $myVideoEntry->mediaGroup = $mediaGroup;
     // upload URL for the currently authenticated user
     $uploadUrl = 'http://uploads.gdata.youtube.com/feeds/users/default/uploads';
     try {
         $newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
         //returns the video URL and the thumbnail URB
         getVideoThumbnails();
         if ($this->_is_ie6() == TRUE or $ie != NULL) {
             //return htmlspecialchars($this->findFlashUrl($newEntry));
             return htmlspecialchars($newEntry->getVideoWatchPageUrl());
         } else {
             echo htmlspecialchars($newEntry->getVideoWatchPageUrl());
         }
     } catch (Zend_Gdata_App_Exception $e) {
         return $e->getMessage();
     }
 }
コード例 #19
0
ファイル: lib.php プロジェクト: e-rasvet/videoboard
function videoboard_cron()
{
    global $DB, $CFG;
    if ($data = $DB->get_record_sql("SELECT * FROM {videoboard_process} WHERE `status`='open' LIMIT 1")) {
        $CFG->videoboard_convert = 0;
        if (in_array($data->type, json_decode(VIDEOBOARD_VIDEOTYPES))) {
            $CFG->videoboard_convert = $CFG->videoboard_video_convert;
        } else {
            if (in_array($data->type, json_decode(VIDEOBOARD_AUDIOTYPES))) {
                $CFG->videoboard_convert = $CFG->videoboard_audio_convert;
            }
        }
        //Check converting method local or mserver
        if ($CFG->videoboard_convert == 1) {
            if (strstr($CFG->videoboard_convert_url, "ffmpeg")) {
                $CFG->videoboard_convert = 2;
            }
        }
        //local
        if ($CFG->videoboard_convert == 1) {
            $from = videoboard_getfileid($data->itemid);
            $add = new stdClass();
            $add->id = $data->id;
            $add->status = 'send';
            $DB->update_record("videoboard_process", $add);
            $ch = curl_init();
            if (in_array($data->type, json_decode(VIDEOBOARD_AUDIOTYPES))) {
                $datasend = array('name' => $data->name, 'mconverter_wav' => '@' . $from->fullpatch);
            }
            if (in_array($data->type, json_decode(VIDEOBOARD_VIDEOTYPES))) {
                $datasend = array('name' => $data->name, 'mconverter_m4a' => '@' . $from->fullpatch);
            }
            curl_setopt($ch, CURLOPT_URL, $CFG->videoboard_convert_url . '/send.php');
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $datasend);
            curl_exec($ch);
        } else {
            if ($CFG->videoboard_convert == 3) {
                $from = videoboard_getfileid($data->itemid);
                $add = new stdClass();
                $add->id = $data->id;
                $add->status = 'send';
                $DB->update_record("videoboard_process", $add);
                if (in_array($data->type, json_decode(VIDEOBOARD_VIDEOTYPES))) {
                    if ($item = $DB->get_record("videoboard_files", array("itemoldid" => $data->itemid))) {
                        $table = 'videoboard_files';
                    } else {
                        if ($item = $DB->get_record("videoboard_comments", array("itemoldid" => $data->itemid))) {
                            $table = 'videoboard_comments';
                        }
                    }
                    @set_include_path($CFG->dirroot . '/mod/videoboard/library');
                    require_once "Zend/Gdata/ClientLogin.php";
                    require_once "Zend/Gdata/HttpClient.php";
                    require_once "Zend/Gdata/YouTube.php";
                    require_once "Zend/Gdata/App/HttpException.php";
                    require_once 'Zend/Uri/Http.php';
                    $authenticationURL = 'https://www.google.com/youtube/accounts/ClientLogin';
                    $httpClient = Zend_Gdata_ClientLogin::getHttpClient($username = $CFG->videoboard_youtube_email, $password = $CFG->videoboard_youtube_password, $service = 'youtube', $client = null, $source = 'VideoBoard', $loginToken = null, $loginCaptcha = null, $authenticationURL);
                    $yt = new Zend_Gdata_YouTube($httpClient, 'VideoBoard', NULL, $CFG->videoboard_youtube_apikey);
                    $myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
                    /// unlisted upload
                    $accessControlElement = new Zend_Gdata_App_Extension_Element('yt:accessControl', 'yt', 'http://gdata.youtube.com/schemas/2007', '');
                    $accessControlElement->extensionAttributes = array(array('namespaceUri' => '', 'name' => 'action', 'value' => 'list'), array('namespaceUri' => '', 'name' => 'permission', 'value' => 'denied'));
                    $myVideoEntry->extensionElements = array($accessControlElement);
                    $filesource = $yt->newMediaFileSource($from->fullpatch);
                    $filesource->setContentType($data->type);
                    $filesource->setSlug('slug');
                    $myVideoEntry->setMediaSource($filesource);
                    $myVideoEntry->setVideoTitle($from->author);
                    $myVideoEntry->setVideoDescription($from->author);
                    $myVideoEntry->setVideoCategory('Education');
                    $myVideoEntry->SetVideoTags('videoboard');
                    //$myVideoEntry->setVideoDeveloperTags(array($item->id));
                    //$yt->registerPackage('Zend_Gdata_Geo');
                    //$yt->registerPackage('Zend_Gdata_Geo_Extension');
                    //$where = $yt->newGeoRssWhere();
                    //$position = $yt->newGmlPos('37.0 -122.0');
                    //$where->point = $yt->newGmlPoint($position);
                    //$myVideoEntry->setWhere($where);
                    $uploadUrl = 'http://uploads.gdata.youtube.com/feeds/api/users/default/uploads';
                    try {
                        $newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
                    } catch (Zend_Gdata_App_HttpException $httpException) {
                        echo $httpException->getRawResponseBody();
                        $DB->delete_records('videoboard_process', array('id' => $data->id));
                    } catch (Zend_Gdata_App_Exception $e) {
                        echo $e->getMessage();
                        $DB->delete_records('videoboard_process', array('id' => $data->id));
                    }
                    $itemidyoutube = $newEntry->getVideoId();
                    if (!empty($itemidyoutube)) {
                        $DB->set_field($table, "itemyoutube", $itemidyoutube, array("id" => $item->id));
                    }
                    $DB->delete_records('videoboard_process', array('id' => $data->id));
                } else {
                    $DB->delete_records('videoboard_process', array('id' => $data->id));
                }
            } else {
                if ($CFG->videoboard_convert == 2) {
                    ///Old method
                    $DB->delete_records('videoboard_process', array('id' => $data->id));
                    if (!($item = $DB->get_record("videoboard_files", array("itemoldid" => $data->itemid)))) {
                        $item = $DB->get_record("videoboard_comments", array("itemoldid" => $data->itemid));
                        $table = 'videoboard_comments';
                    } else {
                        $table = 'videoboard_files';
                    }
                    $student = $DB->get_record("user", array("id" => $item->userid));
                    $context = get_context_instance(CONTEXT_MODULE, $item->instance);
                    $fs = get_file_storage();
                    $file_record = new stdClass();
                    $file_record->component = 'mod_videoboard';
                    $file_record->contextid = $context->id;
                    $file_record->userid = $item->userid;
                    $file_record->filearea = 'private';
                    $file_record->filepath = "/";
                    $file_record->itemid = $item->id;
                    $file_record->license = $CFG->sitedefaultlicense;
                    $file_record->author = fullname($student);
                    $file_record->source = '';
                    if (in_array($data->type, json_decode(VIDEOBOARD_VIDEOTYPES))) {
                        $from = videoboard_getfileid($data->itemid);
                        $to = $CFG->dataroot . "/temp/" . $item->filename . ".mp4";
                        $toimg = $CFG->dataroot . "/temp/" . $item->filename . ".jpg";
                        videoboard_runExternal("/opt/handbrake/HandBrakeCLI -Z Universal -i {$from->fullpatch} -o {$to} -w 432 -l 320", $code);
                        videoboard_runExternal("{$CFG->videoboard_convert_url} -i {$to} -f image2 -s 432x320 {$toimg}", $code);
                        $file_record->filename = $item->filename . ".mp4";
                        $itemid = $fs->create_file_from_pathname($file_record, $to);
                        $file_record->filename = $item->filename . ".jpg";
                        $itemimgid = $fs->create_file_from_pathname($file_record, $toimg);
                        $DB->set_field($table, "itemid", $itemid->get_id(), array("id" => $item->id));
                        $DB->set_field($table, "itemimgid", $itemimgid->get_id(), array("id" => $item->id));
                        unlink($to);
                        unlink($toimg);
                    } else {
                        if (in_array($data->type, json_decode(VIDEOBOARD_AUDIOTYPES))) {
                            $from = videoboard_getfileid($data->itemid);
                            $to = $CFG->dataroot . "/temp/" . $item->filename . ".mp3";
                            videoboard_runExternal("{$CFG->videoboard_convert_url} -y -i {$from->fullpatch} -acodec libmp3lame -ab 68k -ar 44100 {$to}", $code);
                            $file_record->filename = $item->filename . ".mp3";
                            $itemid = $fs->create_file_from_pathname($file_record, $to);
                            $DB->set_field($table, "itemid", $itemid->get_id(), array("id" => $item->id));
                            unlink($to);
                        }
                    }
                }
            }
        }
    }
    ///Check convert server file ready
    if ($dataall = $DB->get_records_sql("SELECT * FROM {videoboard_process} WHERE `status` = 'send'")) {
        foreach ($dataall as $data) {
            if (!($item = $DB->get_record("videoboard_files", array("itemoldid" => $data->itemid)))) {
                if (!($item = $DB->get_record("videoboard_comments", array("itemoldid" => $data->itemid)))) {
                    if ($videoboard = $DB->get_record("videoboard", array("fileid" => $data->itemid))) {
                        $module = $DB->get_record("modules", array("name" => "videoboard"));
                        $instance = $DB->get_record("course_modules", array("module" => $module->id, "instance" => $videoboard->id));
                        $item = new stdClass();
                        $item->userid = $videoboard->teacher;
                        $item->instance = $instance->id;
                        $item->id = $videoboard->id;
                        $item->filename = "videoboard_" . $videoboard->id;
                        $table = 'videoboard';
                    } else {
                        $DB->delete_records('videoboard_process', array('id' => $data->id));
                        return true;
                    }
                } else {
                    $table = 'videoboard_comments';
                }
            } else {
                $table = 'videoboard_files';
            }
            $student = $DB->get_record("user", array("id" => $item->userid));
            $context = get_context_instance(CONTEXT_MODULE, $item->instance);
            $fs = get_file_storage();
            $file_record = new stdClass();
            $file_record->component = 'mod_videoboard';
            $file_record->contextid = $context->id;
            $file_record->userid = $item->userid;
            $file_record->filearea = 'private';
            $file_record->filepath = "/";
            $file_record->itemid = $item->id;
            $file_record->license = $CFG->sitedefaultlicense;
            $file_record->author = fullname($student);
            $file_record->source = '';
            if (in_array($data->type, json_decode(VIDEOBOARD_VIDEOTYPES)) && $CFG->videoboard_video_convert == 1) {
                $json = json_decode(file_get_contents($CFG->videoboard_convert_url . "/get.php?name={$data->name}.mp4"));
                $jsonimg = json_decode(file_get_contents($CFG->videoboard_convert_url . "/get.php?name={$data->name}.jpg"));
            } else {
                if ($CFG->videoboard_audio_convert == 1) {
                    $json = json_decode(file_get_contents($CFG->videoboard_convert_url . "/get.php?name={$data->name}.mp3"));
                }
            }
            if (@(!empty($json->url))) {
                $DB->delete_records('videoboard_process', array('id' => $data->id));
                if (in_array($data->type, json_decode(VIDEOBOARD_VIDEOTYPES))) {
                    $to = $CFG->dataroot . "/temp/" . $item->filename . ".mp4";
                    file_put_contents($to, file_get_contents($json->url));
                    $file_record->filename = $item->filename . ".mp4";
                    $itemid = $fs->create_file_from_pathname($file_record, $to);
                    $file = videoboard_getfileid($itemid->get_id());
                    @chmod($file->fullpatch, 0755);
                    $DB->set_field($table, "itemid", $itemid->get_id(), array("id" => $item->id));
                    $toimg = $CFG->dataroot . "/temp/" . $item->filename . ".jpg";
                    file_put_contents($toimg, file_get_contents($jsonimg->url));
                    $file_record->filename = $item->filename . ".jpg";
                    $itemid = $fs->create_file_from_pathname($file_record, $toimg);
                    $file = videoboard_getfileid($itemid->get_id());
                    @chmod($file->fullpatch, 0755);
                    $DB->set_field($table, "itemimgid", $itemid->get_id(), array("id" => $item->id));
                } else {
                    $to = $CFG->dataroot . "/temp/" . $item->filename . ".mp3";
                    file_put_contents($to, file_get_contents($json->url));
                    $file_record->filename = $item->filename . ".mp3";
                    $itemid = $fs->create_file_from_pathname($file_record, $to);
                    $file = videoboard_getfileid($itemid->get_id());
                    @chmod($file->fullpatch, 0755);
                    $DB->set_field($table, "itemid", $itemid->get_id(), array("id" => $item->id));
                }
                unlink($to);
                @unlink($toimg);
                break;
            }
        }
    }
    return true;
}
コード例 #20
0
ファイル: Video.php プロジェクト: EntityFX/QuikiJAR
 public function uploadOnYT()
 {
     $httpClient = $this->authYT($username, $password);
     $yt = new Zend_Gdata_YouTube($httpClient);
     // create a new Zend_Gdata_YouTube_VideoEntry object
     $myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
     // create a new Zend_Gdata_App_MediaFileSource object
     $filesource = $yt->newMediaFileSource('mytestmovie.mov');
     $filesource->setContentType('video/quicktime');
     // set slug header
     $filesource->setSlug('mytestmovie.mov');
     // add the filesource to the video entry
     $myVideoEntry->setMediaSource($filesource);
     // create a new Zend_Gdata_YouTube_MediaGroup object
     $mediaGroup = $yt->newMediaGroup();
     $mediaGroup->title = $yt->newMediaTitle()->setText('My Test Movie');
     $mediaGroup->description = $yt->newMediaDescription()->setText('My description');
     // the category must be a valid YouTube category
     // optionally set some developer tags (see Searching by Developer Tags for more details)
     $mediaGroup->category = array($yt->newMediaCategory()->setText('Autos')->setScheme('http://gdata.youtube.com/schemas/2007/categories.cat'), $yt->newMediaCategory()->setText('mydevelopertag')->setScheme('http://gdata.youtube.com/schemas/2007/developertags.cat'), $yt->newMediaCategory()->setText('anotherdevelopertag')->setScheme('http://gdata.youtube.com/schemas/2007/developertags.cat'));
     // set keywords
     $mediaGroup->keywords = $service->newMediaKeywords()->setText('cars, funny');
     $myVideoEntry->mediaGroup = $mediaGroup;
     // set video location
     $yt->registerPackage('Zend_Gdata_Geo');
     $yt->registerPackage('Zend_Gdata_Geo_Extension');
     $where = $yt->newGeoRssWhere();
     $position = $yt->newGmlPos('37.0 -122.0');
     $where->point = $yt->newGmlPoint($position);
     $entry->setWhere($where);
     // upload URL for the currently authenticated user
     $uploadUrl = 'http://uploads.gdata.youtube.com/feeds/users/default/uploads';
     try {
         $newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
     } catch (Zend_Gdata_App_Exception $e) {
         echo $e->getMessage();
     }
 }
コード例 #21
0
ファイル: AddFiles.php プロジェクト: villos/tree_admin
    function for_youtube($file_convert_for_youtube, $id_row)
    {
        $db = Zend_Db_Table::getDefaultAdapter();
        $films_info = $db->fetchRow("SELECT f.id, f.name, m.id as menu_activ, f.for_youtube, f.text, f.year\n\t\t\t, ( SELECT GROUP_CONCAT( s.name  ORDER BY fj.id SEPARATOR ', ') FROM film_janr fj join spravochnik s on s.id = fj.id_janr WHERE fj.films_id = f.id) as janr\n\t\t\t\t\t\tFROM menu m\n\t\t\t\t\t\tjoin films f on f.page_id = m.id\n\t\t\t\t\t\tWHERE m.type = 'films' and f.id = " . $id_row);
        $films_info['translit_url'] = $this->translitUrlName($films_info['name']);
        if ($films_info['for_youtube'] == 1) {
            $authenticationURL = 'https://www.google.com/accounts/ClientLogin';
            try {
                $httpClient = Zend_Gdata_ClientLogin::getHttpClient($username = '******', $password = '******', $service = 'youtube', $client = null, $source = 'MySource', $loginToken = null, $loginCaptcha = null, $authenticationURL);
            } catch (Zend_Gdata_App_CaptchaRequiredException $cre) {
                echo 'URL of CAPTCHA image: ' . $cre->getCaptchaUrl() . "\n";
                echo 'Token ID: ' . $cre->getCaptchaToken() . "\n";
            } catch (Zend_Gdata_App_AuthException $ae) {
                echo 'Problem authenticating: ' . $ae->exception() . "\n";
            }
            $applicationId = "causal-rite-634";
            $clientId = "748030821368-ddkt4brpcq7623jii6l2bhc6ujfi08e9.apps.googleusercontent.com";
            //"11588627092-akui7d8un28eerombrt8784j4fpn1p12.apps.googleusercontent.com";
            $developerKey = "AI39si7LpRb8zR-_eP9tR-TPRAuBTBdM1gBHFssCCnc1sGCyJozLbYYPmlHW7lBSYxBYC4VKYmOp1mXMKQveeyXgOjsLNF0oQA";
            $yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, $developerKey);
            $myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
            $filesource = $yt->newMediaFileSource($file_convert_for_youtube);
            $filesource->setContentType('video/quicktime');
            $filesource->setSlug($file_convert_for_youtube);
            $myVideoEntry->setMediaSource($filesource);
            ///названиефильма/ - Русский трейлер /год
            $name_trayler = $films_info['name'] . ' - Русский трейлер ' . $films_info['year'];
            if (mb_strlen($name_trayler) >= 60) {
                $temp_name_trayler = mb_substr($name_trayler, 0, 60, 'utf-8');
                $name_trayler = mb_substr($temp_name_trayler, 0, mb_strrpos($temp_name_trayler, ' '), 'utf-8');
            }
            $myVideoEntry->setVideoTitle($name_trayler);
            $myVideoEntry->setVideoDescription('Смотреть онлайн или скачать полную версию: http://tree.tv/film/' . $id_row . '-' . $films_info['translit_url'] . '
			' . $films_info['text']);
            // Note that category must be a valid YouTube category !
            $myVideoEntry->setVideoCategory('Film');
            // Set keywords, note that this must be a comma separated string
            // and that each keyword cannot contain whitespace
            $myVideoEntry->SetVideoTags('русский трейлер, смотреть, русский, онлайн, ' . date("Y") . ', фильм, кино, бесплатно, трейлер, trailer, тизер,' . $films_info['janr']);
            //('cars, funny');
            // Optionally set some developer tags
            $myVideoEntry->setVideoDeveloperTags(array('mydevelopertag', 'anotherdevelopertag'));
            // Optionally set the video's location
            $yt->registerPackage('Zend_Gdata_Geo');
            $yt->registerPackage('Zend_Gdata_Geo_Extension');
            $where = $yt->newGeoRssWhere();
            $position = $yt->newGmlPos('37.0 -122.0');
            $where->point = $yt->newGmlPoint($position);
            $myVideoEntry->setWhere($where);
            // Upload URI for the currently authenticated user
            $uploadUrl = 'http://uploads.gdata.youtube.com/feeds/users/default/uploads';
            // Try to upload the video, catching a Zend_Gdata_App_HttpException
            // if availableor just a regular Zend_Gdata_App_Exception
            try {
                $newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
            } catch (Zend_Gdata_App_HttpException $httpException) {
                echo $httpException->getRawResponseBody();
            } catch (Zend_Gdata_App_Exception $e) {
                echo $e->getMessage();
            }
            $db->query("update films SET for_youtube = '0' \n\t\t\t\t\t\t\tWHERE id = " . $id_row);
        }
    }
コード例 #22
0
ファイル: lib.php プロジェクト: e-rasvet/mediaboard
/**
 * Function to be run periodically according to the moodle cron
 * This function searches for things that need to be done, such 
 * as sending out mail, toggling flags etc ... 
 *
 * @uses $CFG
 * @return boolean
 * @todo Finish documenting this function
 **/
function mediaboard_cron()
{
    global $CFG, $DB;
    $fs = get_file_storage();
    if ($data = $DB->get_record_sql("SELECT * FROM {mediaboard_process} WHERE `status`='open' LIMIT 1")) {
        $CFG->mediaboard_convert = 0;
        if (in_array($data->type, json_decode(MEDIABOARD_VIDEOTYPES))) {
            $CFG->mediaboard_convert = $CFG->mediaboard_video_convert;
        } else {
            if (in_array($data->type, json_decode(MEDIABOARD_AUDIOTYPES))) {
                $CFG->mediaboard_convert = $CFG->mediaboard_audio_convert;
            }
        }
        //Check converting method local or mserver
        if ($CFG->mediaboard_convert == 1) {
            if (strstr($CFG->mediaboard_convert_url, "ffmpeg")) {
                $CFG->mediaboard_convert = 2;
            }
        }
        //local
        if ($CFG->mediaboard_convert == 1) {
            $from = mediaboard_getfileid($data->itemid);
            $add = new stdClass();
            $add->id = $data->id;
            $add->status = 'send';
            $DB->update_record("mediaboard_process", $add);
            $ch = curl_init();
            if (in_array($data->type, json_decode(MEDIABOARD_AUDIOTYPES))) {
                $datasend = array('name' => $data->name, 'mconverter_wav' => '@' . $from->fullpatch);
            }
            if (in_array($data->type, json_decode(MEDIABOARD_VIDEOTYPES))) {
                $datasend = array('name' => $data->name, 'mconverter_m4a' => '@' . $from->fullpatch);
            }
            curl_setopt($ch, CURLOPT_URL, $CFG->mediaboard_convert_url . '/send.php');
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $datasend);
            curl_exec($ch);
        } else {
            if ($CFG->mediaboard_convert == 3) {
                $from = mediaboard_getfileid($data->itemid);
                $add = new stdClass();
                $add->id = $data->id;
                $add->status = 'send';
                $DB->update_record("mediaboard_process", $add);
                if (in_array($data->type, json_decode(MEDIABOARD_VIDEOTYPES))) {
                    if ($item = $DB->get_record("mediaboard_files", array("itemoldid" => $data->itemid))) {
                        $table = 'mediaboard_files';
                    } else {
                        if ($item = $DB->get_record("mediaboard_comments", array("itemoldid" => $data->itemid))) {
                            $table = 'mediaboard_comments';
                        }
                    }
                    @set_include_path($CFG->dirroot . '/mod/mediaboard/library');
                    require_once "Zend/Gdata/ClientLogin.php";
                    require_once "Zend/Gdata/HttpClient.php";
                    require_once "Zend/Gdata/YouTube.php";
                    require_once "Zend/Gdata/App/HttpException.php";
                    require_once 'Zend/Uri/Http.php';
                    $authenticationURL = 'https://www.google.com/youtube/accounts/ClientLogin';
                    $httpClient = Zend_Gdata_ClientLogin::getHttpClient($username = $CFG->mediaboard_youtube_email, $password = $CFG->mediaboard_youtube_password, $service = 'youtube', $client = null, $source = 'mediaboard', $loginToken = null, $loginCaptcha = null, $authenticationURL);
                    $yt = new Zend_Gdata_YouTube($httpClient, 'mediaboard', NULL, $CFG->mediaboard_youtube_apikey);
                    $myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
                    /// unlisted upload
                    $accessControlElement = new Zend_Gdata_App_Extension_Element('yt:accessControl', 'yt', 'http://gdata.youtube.com/schemas/2007', '');
                    $accessControlElement->extensionAttributes = array(array('namespaceUri' => '', 'name' => 'action', 'value' => 'list'), array('namespaceUri' => '', 'name' => 'permission', 'value' => 'denied'));
                    $myVideoEntry->extensionElements = array($accessControlElement);
                    $filesource = $yt->newMediaFileSource($from->fullpatch);
                    $filesource->setContentType($data->type);
                    $filesource->setSlug('slug');
                    $myVideoEntry->setMediaSource($filesource);
                    $myVideoEntry->setVideoTitle($from->author);
                    $myVideoEntry->setVideoDescription($from->author);
                    $myVideoEntry->setVideoCategory('Education');
                    $myVideoEntry->SetVideoTags('mediaboard');
                    //$myVideoEntry->setVideoDeveloperTags(array($item->id));
                    //$yt->registerPackage('Zend_Gdata_Geo');
                    //$yt->registerPackage('Zend_Gdata_Geo_Extension');
                    //$where = $yt->newGeoRssWhere();
                    //$position = $yt->newGmlPos('37.0 -122.0');
                    //$where->point = $yt->newGmlPoint($position);
                    //$myVideoEntry->setWhere($where);
                    $uploadUrl = 'http://uploads.gdata.youtube.com/feeds/api/users/default/uploads';
                    try {
                        $newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
                    } catch (Zend_Gdata_App_HttpException $httpException) {
                        echo $httpException->getRawResponseBody();
                        $DB->delete_records('mediaboard_process', array('id' => $data->id));
                    } catch (Zend_Gdata_App_Exception $e) {
                        echo $e->getMessage();
                        $DB->delete_records('mediaboard_process', array('id' => $data->id));
                    }
                    $itemidyoutube = $newEntry->getVideoId();
                    if (!empty($itemidyoutube)) {
                        $DB->set_field($table, "itemyoutube", $itemidyoutube, array("id" => $item->id));
                    }
                    $DB->delete_records('mediaboard_process', array('id' => $data->id));
                } else {
                    $DB->delete_records('mediaboard_process', array('id' => $data->id));
                }
            } else {
                if ($CFG->mediaboard_convert == 2) {
                    ///Old method
                    $DB->delete_records('mediaboard_process', array('id' => $data->id));
                    if (!($item = $DB->get_record("mediaboard_files", array("itemoldid" => $data->itemid)))) {
                        $item = $DB->get_record("mediaboard_comments", array("itemoldid" => $data->itemid));
                        $table = 'mediaboard_comments';
                    } else {
                        $table = 'mediaboard_files';
                    }
                    $student = $DB->get_record("user", array("id" => $item->userid));
                    $context = get_context_instance(CONTEXT_MODULE, $item->instance);
                    $file_record = new stdClass();
                    $file_record->component = 'mod_mediaboard';
                    $file_record->contextid = $context->id;
                    $file_record->userid = $item->userid;
                    $file_record->filearea = 'private';
                    $file_record->filepath = "/";
                    $file_record->itemid = $item->id;
                    $file_record->license = $CFG->sitedefaultlicense;
                    $file_record->author = fullname($student);
                    $file_record->source = '';
                    if (in_array($data->type, json_decode(MEDIABOARD_VIDEOTYPES))) {
                        $from = mediaboard_getfileid($data->itemid);
                        $to = $CFG->dataroot . "/temp/" . $item->filename . ".mp4";
                        $toimg = $CFG->dataroot . "/temp/" . $item->filename . ".jpg";
                        mediaboard_runExternal("/opt/handbrake/HandBrakeCLI -Z Universal -i {$from->fullpatch} -o {$to} -w 432 -l 320", $code);
                        mediaboard_runExternal("{$CFG->mediaboard_convert_url} -i {$to} -f image2 -s 432x320 {$toimg}", $code);
                        $file_record->filename = $item->filename . ".mp4";
                        $itemid = $fs->create_file_from_pathname($file_record, $to);
                        $file_record->filename = $item->filename . ".jpg";
                        $itemimgid = $fs->create_file_from_pathname($file_record, $toimg);
                        $DB->set_field($table, "itemid", $itemid->get_id(), array("id" => $item->id));
                        $DB->set_field($table, "itemimgid", $itemimgid->get_id(), array("id" => $item->id));
                        unlink($to);
                        unlink($toimg);
                    } else {
                        if (in_array($data->type, json_decode(MEDIABOARD_AUDIOTYPES))) {
                            $from = mediaboard_getfileid($data->itemid);
                            $to = $CFG->dataroot . "/temp/" . $item->filename . ".mp3";
                            mediaboard_runExternal("{$CFG->mediaboard_convert_url} -y -i {$from->fullpatch} -acodec libmp3lame -ab 68k -ar 44100 {$to}", $code);
                            $file_record->filename = $item->filename . ".mp3";
                            $itemid = $fs->create_file_from_pathname($file_record, $to);
                            $DB->set_field($table, "itemid", $itemid->get_id(), array("id" => $item->id));
                            unlink($to);
                        }
                    }
                }
            }
        }
    }
    ///Check convert server file ready
    if ($dataall = $DB->get_records_sql("SELECT * FROM {mediaboard_process} WHERE `status` = 'send'")) {
        foreach ($dataall as $data) {
            if (!($item = $DB->get_record("mediaboard_files", array("itemoldid" => $data->itemid)))) {
                if ($item = $DB->get_record("mediaboard_items", array("audio1" => $data->itemid))) {
                    $mark = 1;
                    $table = 'mediaboard_items';
                } else {
                    if ($item = $DB->get_record("mediaboard_items", array("audio2" => $data->itemid))) {
                        $mark = 2;
                        $table = 'mediaboard_items';
                    } else {
                        if ($item = $DB->get_record("mediaboard_items", array("audio3" => $data->itemid))) {
                            $mark = 3;
                            $table = 'mediaboard_items';
                        } else {
                            if ($item = $DB->get_record("mediaboard_items", array("audio4" => $data->itemid))) {
                                $mark = 4;
                                $table = 'mediaboard_items';
                            } else {
                                if ($item = $DB->get_record("mediaboard_items", array("audio5" => $data->itemid))) {
                                    $mark = 5;
                                    $table = 'mediaboard_items';
                                } else {
                                    if ($item = $DB->get_record("mediaboard_items", array("audio6" => $data->itemid))) {
                                        $mark = 6;
                                        $table = 'mediaboard_items';
                                    } else {
                                        if ($item = $DB->get_record("mediaboard_items", array("audio7" => $data->itemid))) {
                                            $mark = 7;
                                            $table = 'mediaboard_items';
                                        } else {
                                            if ($item = $DB->get_record("mediaboard_items", array("audio8" => $data->itemid))) {
                                                $mark = 8;
                                                $table = 'mediaboard_items';
                                            } else {
                                                if ($item = $DB->get_record("mediaboard_items", array("audio9" => $data->itemid))) {
                                                    $mark = 9;
                                                    $table = 'mediaboard_items';
                                                } else {
                                                    if ($item = $DB->get_record("mediaboard_items", array("audio10" => $data->itemid))) {
                                                        $mark = 10;
                                                        $table = 'mediaboard_items';
                                                    } else {
                                                        $DB->delete_records('mediaboard_process', array('id' => $data->id));
                                                        return true;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                $fid = $DB->get_record("mediaboard_files", array("id" => $item->fileid));
                $itemdata = new stdClass();
                $itemdata->userid = $item->userid;
                $itemdata->instance = $fid->instance;
                $itemdata->id = $item->id;
                $itemdata->filename = 'slide_audio';
            } else {
                $table = 'mediaboard_files';
                $itemdata = new stdClass();
                $itemdata->userid = $item->userid;
                $itemdata->instance = $item->instance;
                $itemdata->id = $item->id;
                $itemdata->filename = $item->filename;
            }
            $unicalid = substr(time(), 2) . rand(0, 9);
            $student = $DB->get_record("user", array("id" => $itemdata->userid));
            $context = get_context_instance(CONTEXT_MODULE, $itemdata->instance);
            $file_record = new stdClass();
            $file_record->component = 'mod_mediaboard';
            $file_record->contextid = $context->id;
            $file_record->userid = $itemdata->userid;
            $file_record->filearea = 'private';
            $file_record->filepath = "/";
            $file_record->itemid = $unicalid;
            $file_record->license = $CFG->sitedefaultlicense;
            $file_record->author = fullname($student);
            $file_record->source = '';
            if (in_array($data->type, json_decode(MEDIABOARD_VIDEOTYPES)) && $CFG->mediaboard_video_convert == 1) {
                $json = json_decode(file_get_contents($CFG->mediaboard_convert_url . "/get.php?name={$data->name}.mp4"));
                $jsonimg = json_decode(file_get_contents($CFG->mediaboard_convert_url . "/get.php?name={$data->name}.jpg"));
            } else {
                if ($CFG->mediaboard_audio_convert == 1) {
                    $json = json_decode(file_get_contents($CFG->mediaboard_convert_url . "/get.php?name={$data->name}.mp3"));
                }
            }
            if (@(!empty($json->url))) {
                $DB->delete_records('mediaboard_process', array('id' => $data->id));
                if (in_array($data->type, json_decode(MEDIABOARD_VIDEOTYPES))) {
                    $to = $CFG->dataroot . "/temp/" . $itemdata->filename . ".mp4";
                    file_put_contents($to, file_get_contents($json->url));
                    $file_record->filename = $itemdata->filename . ".mp4";
                    $itemid = $fs->create_file_from_pathname($file_record, $to);
                    $file = mediaboard_getfileid($itemid->get_id());
                    @chmod($file->fullpatch, 0755);
                    $DB->set_field($table, "itemid", $itemid->get_id(), array("id" => $itemdata->id));
                    $toimg = $CFG->dataroot . "/temp/" . $itemdata->filename . ".jpg";
                    file_put_contents($toimg, file_get_contents($jsonimg->url));
                    $file_record->filename = $itemdata->filename . ".jpg";
                    $itemid = $fs->create_file_from_pathname($file_record, $toimg);
                    $file = mediaboard_getfileid($itemid->get_id());
                    @chmod($file->fullpatch, 0755);
                    $DB->set_field($table, "itemimgid", $itemid->get_id(), array("id" => $itemdata->id));
                } else {
                    $to = $CFG->dataroot . "/temp/" . $itemdata->filename . ".mp3";
                    file_put_contents($to, file_get_contents($json->url));
                    $file_record->filename = $itemdata->filename . ".mp3";
                    $itemid = $fs->create_file_from_pathname($file_record, $to);
                    $file = mediaboard_getfileid($itemid->get_id());
                    @chmod($file->fullpatch, 0755);
                    if ($table != 'mediaboard_items') {
                        $DB->set_field($table, "itemid", $itemid->get_id(), array("id" => $itemdata->id));
                    } else {
                        $DB->set_field($table, "audio" . $mark, $itemid->get_id(), array("id" => $itemdata->id));
                    }
                }
                unlink($to);
                @unlink($toimg);
                break;
            }
        }
    }
    $item = $DB->get_record_sql("SELECT * FROM {mediaboard_items} WHERE `combinateaudio`=0 AND `type`='photo' LIMIT 1");
    if ($item && $DB->count_records("mediaboard_process", array()) == 0) {
        if ($CFG->mediaboard_audio_convert == 2) {
            $combinatefiles = "";
            for ($i = 1; $i <= 10; $i++) {
                $name = 'audio' . $i;
                if ($file = mediaboard_getfile($item->{$name})) {
                    $combinatefiles .= $file->fullpatch . "\\|";
                }
            }
            mediaboard_runExternal("{$CFG->mediaboard_convert_url} -i concat:{$combinatefiles} -acodec libmp3lame {$CFG->dataroot}/combinate.mp3", $code);
            $filedata = $DB->get_record("mediaboard_files", array("id" => $item->fileid));
            $contextmodule = get_context_instance(CONTEXT_MODULE, $filedata->instance);
            $unicalid = substr(time(), 2) . rand(0, 9);
            $file_record = new stdClass();
            $file_record->component = 'mod_mediaboard';
            $file_record->contextid = $contextmodule->id;
            $file_record->userid = $USER->id;
            $file_record->filearea = 'private';
            $file_record->filepath = "/";
            $file_record->itemid = $unicalid;
            $file_record->license = $CFG->sitedefaultlicense;
            $file_record->author = fullname($USER);
            $file_record->source = '';
            $file_record->filename = "combinate.mp3";
            $itemid = $fs->create_file_from_pathname($file_record, "{$CFG->dataroot}/combinate.mp3");
            unlink("{$CFG->dataroot}/combinate.mp3");
            $DB->set_field("mediaboard_items", "combinateaudio", $itemid->get_id(), array("id" => $item->id));
        } else {
            if ($CFG->mediaboard_audio_convert == 1) {
                $combinatefiles = "";
                for ($i = 1; $i <= 10; $i++) {
                    $name = 'audio' . $i;
                    if ($file = mediaboard_getfileid($item->{$name})) {
                        $link = new moodle_url("/pluginfile.php/{$file->contextid}/mod_mediaboard/0/{$file->id}/");
                        $combinatefiles .= $link . "\\|";
                    }
                }
                $combinatefiles = substr($combinatefiles, 0, -2);
                if (!empty($combinatefiles)) {
                    $data = array('combinate' => $combinatefiles);
                    $options = array('http' => array('method' => 'POST', 'content' => http_build_query($data)));
                    $context = stream_context_create($options);
                    @file_put_contents("{$CFG->dataroot}/combinate.mp3", file_get_contents($CFG->mediaboard_convert_url . '/combinate.php', false, $context));
                    $filedata = $DB->get_record("mediaboard_files", array("id" => $item->fileid));
                    $contextmodule = get_context_instance(CONTEXT_MODULE, $filedata->instance);
                    if (!empty($contextmodule->id) && !empty($item->userid)) {
                        $unicalid = substr(time(), 2) . rand(0, 9);
                        $student = $DB->get_record("user", array("id" => $item->userid));
                        //$fs->delete_area_files($contextmodule->id, 'mod_mediaboard', 'private', $unicalid);
                        $file_record = new stdClass();
                        $file_record->component = 'mod_mediaboard';
                        $file_record->contextid = $contextmodule->id;
                        $file_record->userid = $item->userid;
                        $file_record->filearea = 'private';
                        $file_record->filepath = "/";
                        $file_record->itemid = $unicalid;
                        $file_record->license = $CFG->sitedefaultlicense;
                        $file_record->author = fullname($student);
                        $file_record->source = '';
                        $file_record->filename = "combinate.mp3";
                        $itemid = $fs->create_file_from_pathname($file_record, "{$CFG->dataroot}/combinate.mp3");
                        unlink("{$CFG->dataroot}/combinate.mp3");
                        $DB->set_field("mediaboard_items", "combinateaudio", $itemid->get_id(), array("id" => $item->id));
                    } else {
                        $DB->set_field("mediaboard_items", "combinateaudio", 1, array("id" => $item->id));
                    }
                } else {
                    $DB->set_field("mediaboard_items", "combinateaudio", 1, array("id" => $item->id));
                }
            }
        }
    }
    return true;
}
コード例 #23
0
ファイル: YoutubeApi.php プロジェクト: josephbergdoll/berrics
 public function uploadVideo($Dailyop = false, $videoFile = false)
 {
     //if(!$Dailyop) throw new Exception("Invalid Dailyops ID");
     //let's get the video that needs to be uploaded
     $DailyopsShareParameter = ClassRegistry::init("DailyopsShareParameter");
     $MediaFile = ClassRegistry::init("MediaFile");
     //download the file to tmp
     $tmpFile = $MediaFile->downloadVideoToTmp($videoFile['MediaFile']['id']);
     //start the yt uploading processes
     Zend_Loader::loadClass('Zend_Gdata_YouTube_VideoEntry');
     $videoEntry = new Zend_Gdata_YouTube_VideoEntry();
     $src = $this->youtube->newMediaFileSource($tmpFile);
     $src->setContentType('video/mp4');
     $src->setSlug($videoFile['MediaFile']['limelight_file']);
     $videoEntry->setMediaSource($src);
     //make the video title
     $videoTitle = $Dailyop['Dailyop']['name'];
     if (!empty($Dailyop['Dailyop']['sub_title'])) {
         $videoTitle .= " - " . $Dailyop['Dailyop']['sub_title'];
     }
     $videoEntry->setVideoTitle($videoTitle);
     //now make the video description
     ///////Make the links for the top of the posting
     $videoDescription = "http://theberrics.com \n";
     //////make the link to the post
     $videoDescription .= "Original Post: http://theberrics.com/" . $Dailyop['DailyopSection']['uri'] . "/" . $Dailyop['Dailyop']['uri'] . "\n";
     //////make a link to the section of the video
     $videoDescription .= "More Like This: http://theberrics.com/" . $Dailyop['DailyopSection']['uri'] . "\n\n";
     //////now stuff in the text description if any
     if (!empty($Dailyop['Dailyop']['text_content'])) {
         $videoDescription .= Sanitize::html($Dailyop['Dailyop']['text_content'], array("remove" => true));
     }
     $videoEntry->setVideoDescription($videoDescription);
     //now lets set the tags for the post
     $tags = Set::extract("/Tag/name", $Dailyop);
     $tag_len = 0;
     foreach ($tags as $k => $v) {
         if (strlen($v) > 30) {
             unset($tags[$k]);
         } else {
             $tag_len += strlen($v);
         }
         if ($tag_len >= 470) {
             unset($tags[$k]);
         }
     }
     $tags[] = "Skateboarding";
     $tags[] = "The Berrics";
     $tags = implode(",", $tags);
     $videoEntry->setVideoTags($tags);
     //set the category
     $videoEntry->setVideoCategory('Sports');
     //set some dev tags
     $videoEntry->setVideoDeveloperTags(array("berricsapi", "berricsupload"));
     //start the upload processes
     $uploadUrl = 'http://uploads.gdata.youtube.com/feeds/api/users/default/uploads';
     try {
         $newEntry = $this->youtube->insertEntry($videoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
     } catch (Zend_Gdata_App_HttpException $httpException) {
         echo $httpException->getRawResponseBody();
     } catch (Zend_Gdata_App_Exception $e) {
         echo $e->getMessage();
     }
     $newEntry->setMajorProtocolVersion(2);
     $videoid = $newEntry->getVideoId();
     //get some additional info that we will need later
     $params = serialize(array("editHref" => $newEntry->getEditLink()->getHref()));
     //now create a share parameter entry for the post
     $DailyopsShareParameter->create();
     $DailyopsShareParameter->save(array("service" => "youtube", "dailyop_id" => $Dailyop['Dailyop']['id'], "foreign_key" => $videoid, "parameters" => $params));
     return $DailyopsShareParameter->read();
 }
コード例 #24
0
 public function sendFile($file)
 {
     ignore_user_abort(true);
     set_time_limit(0);
     $uploadUrl = $this->getUploadUrl();
     $entry = new Zend_Gdata_YouTube_VideoEntry();
     $source = $this->getApi()->newMediaFileSource($file);
     $source->setContentType('video/x-ms-wmv');
     //make sure to set the proper content type.
     $source->setSlug($file);
     $entry->setMediaSource($source);
     $entry->setVideoTitle($this->title);
     $entry->setVideoDescription($this->description);
     //        no supported yet
     $entry->setVideoCategory('Autos');
     $entry->SetVideoTags('cars, funny');
     $newEntry = $this->getApi()->insertEntry($entry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
     return $this->populateRecord($newEntry);
 }
コード例 #25
0
<?php

//<form onsubmit="ytVideoApp.prepareSyndicatedUpload(this.videoTitle.value, this.videoDescription.value, this.videoCategory.value, this.videoTags.value); return false;" id="uploadForm">Enter video title:<br><input type="text" name="videoTitle" size="50"><br>Enter video description:<br><textarea name="videoDescription" cols="50"></textarea><br>Select a category: <select name="videoCategory"><option value="Autos">Autos &amp; Vehicles</option><option value="Music">Music</option><option value="Animals">Pets &amp; Animals</option><option value="Sports">Sports</option><option value="Travel">Travel &amp; Events</option><option value="Games">Gadgets &amp; Games</option><option value="Comedy">Comedy</option><option value="People">People &amp; Blogs</option><option value="News">News &amp; Politics</option><option value="Entertainment">Entertainment</option><option value="Education">Education</option><option value="Howto">Howto &amp; Style</option><option value="Nonprofit">Nonprofit &amp; Activism</option><option value="Tech">Science &amp; Technology</option></select><br>Enter some tags to describe your video <em>(separated by spaces)</em>:<br><input type="text" value="video" size="50" name="videoTags"><br><input type="submit" value="go"></form>
$videoTitle = null;
$videoDescription = null;
$videoCategory = null;
$videoTags = null;
$nextUrl = null;
$httpClient = getAuthSubHttpClient();
$youTubeService = new Zend_Gdata_YouTube($httpClient);
$newVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
$newVideoEntry->setVideoTitle($videoTitle);
$newVideoEntry->setVideoDescription($videoDescription);
//make sure first character in category is capitalized
$videoCategory = strtoupper(substr($videoCategory, 0, 1)) . substr($videoCategory, 1);
$newVideoEntry->setVideoCategory($videoCategory);
// convert videoTags from whitespace separated into comma separated
$videoTagsArray = explode(' ', trim($videoTags));
$newVideoEntry->setVideoTags(implode(', ', $videoTagsArray));
$tokenHandlerUrl = 'http://gdata.youtube.com/action/GetUploadToken';
try {
    $tokenArray = $youTubeService->getFormUploadToken($newVideoEntry, $tokenHandlerUrl);
    if (loggingEnabled()) {
        logMessage($httpClient->getLastRequest(), 'request');
        logMessage($httpClient->getLastResponse()->getBody(), 'response');
    }
} catch (Zend_Gdata_App_HttpException $httpException) {
    print 'ERROR ' . $httpException->getMessage() . ' HTTP details<br /><textarea cols="100" rows="20">' . $httpException->getRawResponseBody() . '</textarea><br />' . '<a href="session_details.php">' . 'click here to view details of last request</a><br />';
    return;
} catch (Zend_Gdata_App_Exception $e) {
    print 'ERROR - Could not retrieve token for syndicated upload. ' . $e->getMessage() . '<br /><a href="session_details.php">' . 'click here to view details of last request</a><br />';
コード例 #26
0
 public function testConvertVideoEntryToAndFromString() {
     $this->entry->transferFromXML($this->entryText);
     $entryXml = $this->entry->saveXML();
     $newVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
     $newVideoEntry->transferFromXML($entryXml);
     $this->verifyAllSamplePropertiesAreCorrect($newVideoEntry);
     $newVideoEntryXml = $newVideoEntry->saveXML();
     $this->assertEquals($entryXml, $newVideoEntryXml);
 }
 /**
  * youtube_api_upload_video
  * 
  * Uploads a video attachment to YouTube via API. Harnesses Zend YouTube api class
  * 
  * @param	Array		$attachment_data - Video file upload data
  * @access 	private
  * @author	Ben Moody
  */
 private function youtube_api_upload_video($attachment_data)
 {
     //Init vars
     $file_type = NULL;
     $path_info = NULL;
     $myVideoEntry = NULL;
     $uploadUrl = NULL;
     $filesource = NULL;
     $newEntry = NULL;
     $output = NULL;
     //Cache plugin options
     $plugin_options = get_option(PRSOGFORMSADVUPLOADER__OPTIONS_NAME);
     //Check for required data
     if (isset($attachment_data['file_path'], $attachment_data['mime_type'], $attachment_data['title'], $attachment_data['description'])) {
         // upload URI for the currently authenticated user
         $uploadUrl = $this->youtube_uploads_url;
         // create a new VideoEntry object
         $myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
         //Get file path
         $file_path = $attachment_data['file_path'];
         //Get file type
         $file_type = $attachment_data['mime_type'];
         //Get file slug - filename plus ext
         $path_info = pathinfo($file_path);
         // create a new Zend_Gdata_App_MediaFileSource object
         $filesource = $this->data['YouTubeClass']->newMediaFileSource($file_path);
         $filesource->setContentType($file_type);
         // set slug header
         $filesource->setSlug($path_info['basename']);
         // add the filesource to the video entry
         $myVideoEntry->setMediaSource($filesource);
         $myVideoEntry->setVideoTitle($attachment_data['title']);
         $myVideoEntry->setVideoDescription($attachment_data['description']);
         // The category must be a valid YouTube category!
         $myVideoEntry->setVideoCategory('Autos');
         //Set video upload as private
         if ($plugin_options['video_is_private']) {
             $myVideoEntry->setVideoPrivate();
         }
         // try to upload the video, catching a Zend_Gdata_App_HttpException,
         // if available, or just a regular Zend_Gdata_App_Exception otherwise
         try {
             $output = $this->data['YouTubeClass']->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
         } catch (Zend_Gdata_App_HttpException $httpException) {
             $output = $httpException->getRawResponseBody();
             $this->plugin_error_log($output);
         } catch (Zend_Gdata_App_Exception $e) {
             $output = $e->getMessage();
             $this->plugin_error_log($output);
         }
     }
     return $output;
 }
コード例 #28
0
/**
 * Echo video metadata
 *
 * @param Zend_Gdata_YouTube_VideoEntry $entry The video entry
 * @return void
 */
function echoVideoMetadata($entry)
{
    $title = htmlspecialchars($entry->getVideoTitle());
    $description = htmlspecialchars($entry->getVideoDescription());
    $authorUsername = htmlspecialchars($entry->author[0]->name);
    $authorUrl = 'http://www.youtube.com/profile?user='******', ', $entry->getVideoTags()));
    $duration = htmlspecialchars($entry->getVideoDuration());
    $watchPage = htmlspecialchars($entry->getVideoWatchPageUrl());
    $viewCount = htmlspecialchars($entry->getVideoViewCount());
    $rating = 0;
    if (isset($entry->rating->average)) {
        $rating = $entry->rating->average;
    }
    $numRaters = 0;
    if (isset($entry->rating->numRaters)) {
        $numRaters = $entry->rating->numRaters;
    }
    $flashUrl = htmlspecialchars(findFlashUrl($entry));
    print <<<END
        <b>Title:</b> {$title}<br />
        <b>Description:</b> {$description}<br />
        <b>Author:</b> <a href="{$authorUrl}">{$authorUsername}</a><br />
        <b>Tags:</b> {$tags}<br />
        <b>Duration:</b> {$duration} seconds<br />
        <b>View count:</b> {$viewCount}<br />
        <b>Rating:</b> {$rating} ({$numRaters} ratings)<br />
        <b>Flash:</b> <a href="{$flashUrl}">{$flashUrl}</a><br />
        <b>Watch page:</b> <a href="{$watchPage}">{$watchPage}</a> <br />
END;
}
コード例 #29
0
 private function youtube_upload_video($file_name, $file_path, $file_data)
 {
     $return = array("errors" => array(), "data" => array());
     $yt_data = $this->youtube_auth();
     $yt = $yt_data['yt'];
     Zend_Loader::loadClass('Zend_Gdata_YouTube_VideoEntry');
     $myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
     $filesource = $yt->newMediaFileSource($file_path . $file_name);
     $filesource->setContentType($file_data["type"]);
     $filesource->setSlug($file_name);
     $myVideoEntry->setMediaSource($filesource);
     $mediaGroup = $yt->newMediaGroup();
     $mediaGroup->title = $yt->newMediaTitle()->setText($file_data["name"] ? $file_data["name"] : $this->defaults['name']);
     $mediaGroup->description = $yt->newMediaDescription()->setText($file_data["description"] ? $file_data["description"] : $this->defaults['description']);
     // the category must be a valid YouTube category
     // optionally set some developer tags (see Searching by Developer Tags for more details)
     $mediaGroup->category = array($yt->newMediaCategory()->setText('People')->setScheme('http://gdata.youtube.com/schemas/2007/categories.cat'));
     // set keywords
     $mediaGroup->keywords = $yt->newMediaKeywords()->setText($file_data["tags"] ? $file_data["tags"] : $this->defaults['tags']);
     $myVideoEntry->mediaGroup = $mediaGroup;
     if (strval($file_data["lat"]) || strval($file_data["lon"])) {
         $yt->registerPackage('Zend_Gdata_Geo');
         $yt->registerPackage('Zend_Gdata_Geo_Extension');
         $where = $yt->newGeoRssWhere();
         $position = $yt->newGmlPos($file_data["lat"] . ' ' . $file_data["lon"]);
         $where->point = $yt->newGmlPoint($position);
         $myVideoEntry->setWhere($where);
     }
     $uploadUrl = 'http://uploads.gdata.youtube.com/feeds/users/default/uploads';
     try {
         $newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
         $video_id = $newEntry->getVideoId();
         if ($video_id) {
             $return["data"]["video"] = $video_id;
         } else {
             $return["errors"][] = 'upload error';
         }
     } catch (Zend_Gdata_App_Exception $e) {
         $return["errors"][] = $e->getMessage();
     }
     return $return;
 }