163
* Checks to see if Helioviewer.org is authorized to upload videos for a user
165
public function checkYouTubeAuth ()
167
include_once 'src/Movie/YouTube.php';
169
$youtube = new Movie_YouTube();
171
header('Content-type: application/json');
172
print json_encode($youtube->checkYouTubeAuth());
176
* Requests authorization for Helioviewer.org to upload videos on behalf
179
public function getYouTubeAuth()
181
include_once 'src/Movie/YouTube.php';
183
// Store form data for later use
186
$_SESSION['video-id'] = $this->_params["id"];
187
$_SESSION['video-title'] = $this->_params["title"];
188
$_SESSION['video-description'] = $this->_params["description"];
189
$_SESSION['video-tags'] = $this->_params["tags"];
190
$_SESSION['video-share'] = $this->_params["share"];
192
$youtube = new Movie_YouTube();
193
$youtube->getYouTubeAuth($this->_params['id']);
163
197
* Uploads a user-created video to YouTube
165
199
* TODO 2011/05/09: Make sure movie hasn't already been uploaded
175
209
if ($movie->status !== "FINISHED") {
176
210
throw new Exception("Invalid movie requested");
179
$file = $movie->getFilepath(true);
181
$youtube = new Movie_YouTube();
182
$youtube->uploadVideo($this->_params['id'], $file, $this->_options);
186
* Checks to see if Helioviewer.org is authorized to upload videos for a user
188
public function checkYouTubeAuth () {
189
include_once 'src/Movie/YouTube.php';
191
$youtube = new Movie_YouTube();
193
header('Content-type: application/json');
194
print json_encode($youtube->checkYouTubeAuth());
213
// If this was not the first upload for the current session, then
214
// the form data will have been passed in as GET variables
215
if (isset($this->_options["title"])) {
216
$id = $this->_params["id"];
217
$title = $this->_options["title"];
218
$description = $this->_options["description"];
219
$tags = $this->_options["tags"];
220
$share = $this->_options["share"];
222
// Otherwise read form data back in from session variables
225
$id = $_SESSION['video-id'];
226
$title = $_SESSION['video-title'];
227
$description = $_SESSION['video-description'];
228
$tags = $_SESSION['video-tags'];
229
$share = $_SESSION['video-share'];
232
$youtube = new Movie_YouTube();
233
$video = $youtube->uploadVideo($movie, $id, $title, $description, $tags, $share);
236
if (isset($this->_options['html']) && $this->_options['html']) {
241
<title>Helioviewer.org - YouTube upload complete</title>
242
<link rel="shortcut icon" href="../favicon.ico">
243
<meta charset="utf-8" />
245
<body style='text-align: center;'>
246
<div style='margin-top: 200px;'>
247
<span style='font-size: 32px;'>Finished!</span><br />
248
Your video should appear on youtube in 1-2 minutes.
253
header('Content-type: application/json');
254
echo json_encode(array("id" => $video->getVideoId()));
198
259
* Retrieves recent user-submitted videos from YouTube and returns the
199
260
* result as a JSON array.
201
public function getUserVideos() {
262
public function getUserVideos()
202
264
include_once 'src/Database/MovieDatabase.php';
203
265
include_once 'src/Movie/HelioviewerMovie.php';
204
266
include_once 'lib/alphaID/alphaID.php';
389
451
case "uploadMovieToYouTube":
390
452
$expected = array(
391
453
"required" => array('id'),
392
"optional" => array('title', 'description', 'tags', 'share', 'token', 'ready', 'dialogMode'),
454
"optional" => array('title', 'description', 'tags', 'share', 'token', 'html'),
393
455
"alphanum" => array('id'),
394
"bools" => array('share', 'ready', 'dialogMode')
456
"bools" => array('share', 'html')
398
459
case "getUserVideos":