Php 服务器端的Youtube下载程序脚本

Php 服务器端的Youtube下载程序脚本,php,youtube,Php,Youtube,我正在尝试生成一个脚本,可以下载服务器上的youtube视频,我想用户提供的视频url 我找了很多,但都找不到。这是我的密码 <?php // Check download token if (empty($_GET['mime']) OR empty($_GET['token'])) { exit('Invalid download token 8{'); } // Set operation params $mime = filter_var($_GET['mime']); $

我正在尝试生成一个脚本,可以下载服务器上的youtube视频,我想用户提供的视频url

我找了很多,但都找不到。这是我的密码

    <?php
// Check download token
if (empty($_GET['mime']) OR empty($_GET['token']))
{
exit('Invalid download token 8{');
}
// Set operation params
$mime = filter_var($_GET['mime']);
$ext  = str_replace(array('/', 'x-'), '', strstr($mime, '/'));
$url  = base64_decode(filter_var($_GET['token']));
$name = urldecode($_GET['title']). '.' .$ext; 
// Fetch and serve
if ($url)
{
// Generate the server headers
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE)
{/*
    header('Content-Type: "' . $mime . '"');
    header('Content-Disposition: attachment; filename="' . $name . '"');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header("Content-Transfer-Encoding: binary");
    header('Pragma: public');
*/}
else
{/*
    header('Content-Type: "' . $mime . '"');
    header('Content-Disposition: attachment; filename="' . $name . '"');
    header("Content-Transfer-Encoding: binary");
    header('Expires: 0');
    header('Pragma: no-cache');
*/}
$download_video_file = file_put_contents($file_path, fopen($url, 'r'));
exit;
}
// Not found
exit('File not found 8{');
?>


但是我仍然无法解决这个问题,请帮我解决。

您将从这里获得代码

参考:



GitHub:

您从GitHub获取了这篇文章,为什么不问问写这篇文章的人呢?
<?php
require_once('youtube.lib.php');
$download_link = get_youtube('http://www.youtube.com/watch?v=SAQZ0BDXn48'); 

// we will have array here, index 0 is the video ID and index 1 is the download link.
echo $download_link[1];
?>