function getYouTubeFlvUrl($pattern) { require_once "youtube-download-php/phptube.php"; $tube = new PHPTube(); $flv_http_path = $tube->download($pattern); return $flv_http_path; }
function GrabFlvFromYoutube($pattern) { require_once "include/youtube-download-php/phptube.php"; $tube = new PHPTube(); $flv_http_path = $tube->download($pattern); echo $flv_http_path; set_time_limit(0); $data = file_get_contents($flv_http_path); $new_flv_path = dirname(_FILE_) . '/flvs/' . $pattern . '.flv'; file_put_contents($new_flv_path, $data); return $new_flv_path; }
private function DownloadVideo($url, $FileType = FT_VIDEO) { include ISC_BASE_PATH . "/livevideos/phptube.php"; include ISC_BASE_PATH . "/livevideos/functions.php"; @clearstatcache(); @ini_set('output_buffering', 'off'); // output buffer fix @ini_set('max_execution_time', 0); // time limit fix @ini_set('memory_limit', '1024M'); // memory problem fix //error_reporting(1); @ignore_user_abort(1); @set_time_limit(0); //@ob_end_clean(); @ob_implicit_flush(TRUE); $pattern = getPatternFromUrl($url); if ($FileType == FT_INSVIDEO) { $dir = GetConfig('InstallVideoDirectory'); } else { $dir = GetConfig('VideoDirectory'); } if (is_dir(sprintf("../%s", $dir))) { // Images and downloads will be stored within a directory randomly chosen from a-z. $randomDir = strtolower(chr(rand(65, 90))); if (!is_dir("../" . $dir . "/" . $randomDir)) { if (!@mkdir("../" . $dir . "/" . $randomDir, 0777)) { $randomDir = ''; } } } $patternName = $pattern . ".flv"; // $randomFileName = GenRandFileName($patternName); $fileName = $randomDir . "/" . $randomFileName; $dest = realpath(ISC_BASE_PATH . "/" . $dir); while (file_exists($dest . "/" . $fileName)) { $fileName = basename($randomFileName); $fileName = substr_replace($randomFileName, "-" . rand(0, 10000000000.0), strrpos($randomFileName, "."), 0); $fileName = $randomDir . "/" . $fileName; } $dest .= "/" . $fileName; $tube = new PHPTube(); $flv_http_path = $tube->download($pattern); $data = file_get_contents($flv_http_path); file_put_contents($dest, $data); return $fileName; if (filesize($dest) > 0) { return $fileName; } else { return "failed"; } }