/** * Download video using wget or curl * * @param YouTubeBean $bean */ public function startDownload(YouTubeBean $bean) { $this->createDownloadLink($bean->getVideoId(), $bean->getVideoFormat()); $bean->getMethod() == "curl" ? $this->curlDOwnload($bean->getDestination()) : $this->wgetDownload($bean->getDestination()); }
} else { if (isset($_GET['video'])) { // via browser $videos = @trim($_GET['video']); if (!empty($videos)) { $videoList = explode(",", $videos); } } else { $videoList = array(); // add video id manually } } try { header('Content-Type: text/html; charset=utf-8'); for ($i = 0; $i < sizeof($videoList); $i++) { $bean = new YouTubeBean(); $bean->setVideoId($videoList[$i]); $bean->setVideoFormat("22"); $bean->setMethod("curl"); $bean->setDestination("/root/Videos/"); // Make sure this folder is writable $downloader = new YouTubeVideoDownloader(); $downloader->startDownload($bean); } } catch (YouTubeInvalidVideoIdException $e) { die("<strong>YouTubeInvalidVideoIdException</strong> : " . $e->getMessage()); } catch (YouTubeUnsupportedVideoFormatException $e) { die("<strong>YouTubeUnsupportedVideoFormatException</strong> : " . $e->getMessage()); } catch (YouTubeUnsupportedDownloadMethodException $e) { die("<strong>YouTubeUnsupportedDownloadMethodException</strong> : " . $e->getMessage()); } catch (YouTubeCurlNotAvailableException $e) {