我发现PHP代码的YouTube-DL这样
<?php
define('YOUTUBE_DL', '/usr/local/bin/youtube-dl'); // find your youtube-dl path and replace with it
$youtube_video = 'https://www.youtube.com/watch?v=e4Uq8O5ZhUA'; // replace with any youtube video
/**
* Fetches direct URL of given youtube video
*/
function getDirectUrl($youtube_video) {
// lets build command to get direct url via youtube-dl
$video_json_command = YOUTUBE_DL.' -g '.$youtube_video;
// get url
$direct_url = shell_exec($video_json_command);
// remove any possible white spaces
$direct_url = str_replace(array(' ',"\n"), '', $direct_url);
return $direct_url;
}
function buildPlayer($direct_url) {
echo '<video width="400" controls>
<source src="'.$direct_url.'" type="video/mp4">
Your browser does not support HTML5 video.
</video>';
}
function playVideo($youtube_video) {
$url = getDirectUrl($youtube_video);
buildPlayer($url);
}
// call below function and play any video
playVideo($youtube_video);
?>
我想改变外界PHP代码的URL https://www.youtube.com/watch?v=e4Uq8O5ZhUA
例如:site.com/youtube-dl.php?link=https://www.youtube.com/watch?v=e4Uq8O5ZhUA
它存在于$ youtube_video = 'https://www.youtube.com/watch?v=e4Uq8O5ZhUA'
更换至$ youtube_video = '$ _GET [' 链接 ']',但错误
它如何工作?
其固定
if (ereg("^[0-9A-z_-]+$",$_GET['link'])) $youtube_video = "https://www.youtube.com/watch?v=".$_GET['link'];