Exemplo n.º 1
0
 public function perform()
 {
     printf("Starting movie %s\n", $this->args['movieId']);
     // Build movie
     try {
         $movie = new Movie_HelioviewerMovie($this->args['movieId']);
         $movie->build();
     } catch (Exception $e) {
         // Handle any errors encountered
         printf("Error processing movie %s\n", $this->args['movieId']);
         logErrorMsg($e->getMessage(), "Resque_");
         // If counter was increased at queue time, decrement
         $this->_updateCounter();
         throw $e;
     }
     printf("Finished movie %s\n", $this->args['movieId']);
     $this->_updateCounter();
     // If the queue is empty and no jobs are being processed, set estimated
     // time counter to zero
     //$numWorking = sizeOf($redis->keys("resque:worker:*".HV_MOVIE_QUEUE));
     //$queueSize  = $redis->llen("resque:queue:".HV_MOVIE_QUEUE);
     //if ($numWorking <= 1 && $queueSize == 0) {
     //    $redis->set('helioviewer:movie_queue_wait', 0);
     //    return;
     //}
 }
Exemplo n.º 2
0
 /**
  * Retrieves recent user-submitted videos from YouTube and returns the
  * result as a JSON array.
  */
 public function getUserVideos()
 {
     include_once HV_ROOT_DIR . '/../src/Database/MovieDatabase.php';
     include_once HV_ROOT_DIR . '/../src/Movie/HelioviewerMovie.php';
     include_once HV_ROOT_DIR . '/../lib/alphaID/alphaID.php';
     $movies = new Database_MovieDatabase();
     // Default options
     $defaults = array('num' => 10, 'skip' => 0, 'since' => '2000/01/01T00:00:00.000Z', 'force' => false);
     $opts = array_replace($defaults, $this->_options);
     // Get a list of recent videos
     $videos = array();
     foreach ($movies->getSharedVideos($opts['num'], $opts['skip'], $opts['since'], $opts['force']) as $video) {
         $youtubeId = $video['youtubeId'];
         $movieId = (int) $video['movieId'];
         // Convert id
         $publicId = alphaID($movieId, false, 5, HV_MOVIE_ID_PASS);
         // Load movie
         $movie = new Movie_HelioviewerMovie($publicId);
         // Check to make sure video was not removed by the user
         // 2011/06/08: Disabling for now since this delays time before
         // videos
         // $handle = curl_init("http://gdata.youtube.com/feeds/api/videos/$youtubeId?v=2");
         // curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE);
         // $response = curl_exec($handle);
         // $httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
         //curl_close($handle);
         // Only add videos with response code 200
         //if ($httpCode == 200) {
         array_push($videos, array('id' => $publicId, 'url' => 'http://www.youtube.com/watch?v=' . $youtubeId, 'thumbnails' => $movie->getPreviewImages(), 'published' => $video['timestamp'], 'title' => $video['title'], 'description' => $video['description'], 'keywords' => $video['keywords'], 'imageScale' => $video['imageScale'], 'dataSourceString' => $video['dataSourceString'], 'eventSourceString' => $video['eventSourceString'], 'movieLength' => $video['movieLength'], 'width' => $video['width'], 'height' => $video['height'], 'startDate' => $video['startDate'], 'endDate' => $video['endDate']));
         //}
     }
     $this->_printJSON(json_encode($videos));
 }