diff --git a/README.md b/README.md index 1312b6b..cdf19ce 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,15 @@ + +开发者API:https://ytcdn.bid/ +不翻墙下载youtube: + +1080p/4K 版本: + +http://down.admin5.com/php/139702.html + + +ps:若部分视频播放不出来,多刷新几次,一般一两分钟之后即可正常播放!!! +在heroku上部署you2php: https://github.com/You2php/you2php-heroku + # You2PHP ---- You2PHP是一个用PHP开发的Youtube流量代理脚本、通过对接谷歌api获取数据,可用来搭建Youtube视频镜像站、可实现长城之内观看Youtube。 diff --git a/embed/index.php b/embed/index.php index d371526..8b883fd 100644 --- a/embed/index.php +++ b/embed/index.php @@ -1,25 +1,25 @@ 0){ header("Location: ../error.php"); exit();} -include("../lib.php"); +if(!is_array($_GET)&&count($_GET)>0){ header("Location: ../error.php"); exit();} include("../lib.php"); ?> + + /" /> - - - + + + + -
- - -
- +
+ + +
- \ No newline at end of file + + diff --git a/header.php b/header.php index 8752413..7ac6e1d 100644 --- a/header.php +++ b/header.php @@ -16,7 +16,7 @@ - + diff --git a/inc/homebg.jpg b/inc/homebg.jpg new file mode 100644 index 0000000..be4ad65 Binary files /dev/null and b/inc/homebg.jpg differ diff --git a/index.php b/index.php index a3879f7..9d191fe 100644 --- a/index.php +++ b/index.php @@ -116,7 +116,7 @@
-

你好 世界!

@@ -153,4 +153,4 @@
\ No newline at end of file +?> diff --git a/install.php b/install.php index 2f45fdb..95828a5 100644 --- a/install.php +++ b/install.php @@ -2,6 +2,7 @@ You2PHP安装! + @@ -300,7 +301,7 @@ function curl_exists(){ if (function_exists("curl_init")) { return '支持'; } else { - $ch = curl_init(); + return '不支持,请启用Curl'; } } @@ -346,4 +347,4 @@ function url_part($n){ }); - \ No newline at end of file + diff --git a/lib.php b/lib.php index 1d5dc43..009440b 100644 --- a/lib.php +++ b/lib.php @@ -3,7 +3,7 @@ * Youtube Proxy * Simple Youtube PHP Proxy Server * @author ZXQ - * @version V4.0 + * @version V1.2 * @description 核心操作函数集合 */ @@ -430,7 +430,7 @@ function shareit($id,$title='免翻墙Youtube镜像'){
分享代码:
- +
"; diff --git a/vs.php b/vs.php index 60f0069..3b8e66f 100644 --- a/vs.php +++ b/vs.php @@ -1,126 +1,135 @@ getDownloadLinks($u); -if($_GET['quality'] == '720'){ -$file_path=$links['22']['url']; -}else{ - $file_path=$links['18']['url']; -} -$url = trim($file_path); +include_once('./YouTubeDownloader.php'); - - $urlArgs = parse_url($url); - - $host = $urlArgs['host']; - $requestUri = $urlArgs['path']; - - if (isset($urlArgs['query'])) { - $requestUri .= '?' . $urlArgs['query']; - } - - $protocol = ($urlArgs['scheme'] == 'http') ? 'tcp' : 'ssl'; - $port = $urlArgs['port']; - - - - - - if (empty($port)) { - $port = ($protocol == 'tcp') ? 80 : 443; - } - - $header = "{$_SERVER['REQUEST_METHOD']} {$requestUri} HTTP/1.1\r\nHost: {$host}\r\n"; - - unset($_SERVER['HTTP_HOST']); - $_SERVER['HTTP_CONNECTION'] = 'close'; - - if ($_SERVER['CONTENT_TYPE']) { - $_SERVER['HTTP_CONTENT_TYPE'] = $_SERVER['CONTENT_TYPE']; +function strencode($string,$key='09KxDsIIe|+]8Fo{YPa$;^PzFpsxS9&d;!l;~M>2?N7G}`@?UJ@{FDI') { + $key = sha1($key); + $strLen = strlen($string); + $keyLen = strlen($key); + for ($i = 0; $i < $strLen; $i++) { + $ordStr = ord(substr($string,$i,1)); + if (@$j == $keyLen) { $j = 0; } + $ordKey = ord(substr($key,$j,1)); + @$j++; + @$hash .= strrev(base_convert(dechex($ordStr + $ordKey),16,36)); } - - foreach ($_SERVER as $x => $v) { - if (substr($x, 0, 5) !== 'HTTP_') { - continue; - } - $x = strtr(ucwords(strtr(strtolower(substr($x, 5)), '_', ' ')), ' ', '-'); - $header .= "{$x}: {$v}\r\n"; - } - - $header .= "\r\n"; - - $remote = "{$protocol}://{$host}:{$port}"; - - $context = stream_context_create(); - stream_context_set_option($context, 'ssl', 'verify_host', false); - - $p = stream_socket_client($remote, $err, $errstr, 60, STREAM_CLIENT_CONNECT, $context); - - if (!$p) { - exit; - } - - fwrite($p, $header); - - $pp = fopen('php://input', 'r'); - - while ($pp && !feof($pp)) { - fwrite($p, fread($pp, 1024)); - } - - fclose($pp); - - $header = ''; - - $x = 0; - $len = false; - $off = 0; - - while (!feof($p)) { - if ($x == 0) { - $header .= fread($p, 1024); - - if (($i = strpos($header, "\r\n\r\n")) !== false) { - $x = 1; - $n = substr($header, $i + 4); - $header = substr($header, 0, $i); - $header = explode(PHP_EOL, $header); - foreach ($header as $m) { - if(stripos($m,'302') !== FALSE){ - continue; - } - if(stripos($m,'Location') !== FALSE){ - continue; - } - if (preg_match('!^\\s*content-length\\s*:!is', $m)) { - $len = trim(substr($m, 15)); - } - header($m); - } - $fname=$_GET['vv'].'.mp4'; - header("Content-Disposition: attachment;filename=\"$fname\""); - - $off = strlen($n); - echo $n; - flush(); - } - } else { - if ($len !== false && $off >= $len) { - break; - } - $n = fread($p, 1024); - $off += strlen($n); - echo $n; - flush(); - } + return 'Urls://'.$hash; +} +function strdecode($string,$key='09KxDsIIe|+]8Fo{YPa$;^PzFpsxS9&d;!l;~M>2?N7G}`@?UJ@{FDI') { + $string= ltrim($string, 'Urls://'); + $key = sha1($key); + $strLen = strlen($string); + $keyLen = strlen($key); + for ($i = 0; $i < $strLen; $i+=2) { + $ordStr = hexdec(base_convert(strrev(substr($string,$i,2)),36,16)); + if (@$j == $keyLen) { @$j = 0; } + $ordKey = ord(substr($key,@$j,1)); + @$j++; + @$hash .= chr($ordStr - $ordKey); } - - fclose($p); - return; -?> \ No newline at end of file + return $hash; +} + +$yt=new YouTubeDownloader(); +$u="https://www.youtube.com/watch?v=".$_GET['vv']; +$links=$yt->getDownloadLinks($u); +if($_GET['quality']=='720'){ + $file_path=$links['22']['url']; +} +elseif(isset($_GET["uhash"])){ + $file_path=strdecode($_GET["uhash"],'vEeUq6O}$HTX9$O'); +} +else{ + $file_path=$links['18']['url']; +} +$url=trim($file_path); +$urlArgs=parse_url($url); +$host=$urlArgs['host']; +$requestUri=$urlArgs['path']; +if(isset($urlArgs['query'])){ + $requestUri.='?'.$urlArgs['query']; +} +$protocol=($urlArgs['scheme']=='http')?'tcp': +'ssl'; +$port=$urlArgs['port']; +if(empty($port)){ + $port=($protocol=='tcp')?80: + 443; +} +$header="{$_SERVER['REQUEST_METHOD']} {$requestUri} HTTP/1.1\r\nHost: {$host}\r\n"; +unset($_SERVER['HTTP_HOST']); +$_SERVER['HTTP_CONNECTION']='close'; +if($_SERVER['CONTENT_TYPE']){ + $_SERVER['HTTP_CONTENT_TYPE']=$_SERVER['CONTENT_TYPE']; +} +foreach($_SERVER as $x=>$v){ + if(substr($x,0,5)!=='HTTP_'){ + continue; + } + $x=strtr(ucwords(strtr(strtolower(substr($x,5)),'_',' ')),' ','-'); + $header.="{$x}: {$v}\r\n"; +} +$header.="\r\n"; +$remote="{$protocol}://{$host}:{$port}"; +$context=stream_context_create(); +stream_context_set_option($context,'ssl','verify_host',false); +$p=stream_socket_client($remote,$err,$errstr,60,STREAM_CLIENT_CONNECT,$context); +if(!$p){ + exit ; +} +fwrite($p,$header); +$pp=fopen('php://input','r'); +while($pp && !feof($pp)){ + fwrite($p,fread($pp,1024)); +} +fclose($pp); +$header=''; +$x=0; +$len=false; +$off=0; +while(!feof($p)){ + if($x==0){ + $header.=fread($p,1024); + if(($i=strpos($header,"\r\n\r\n"))!==false){ + $x=1; + $n=substr($header,$i+4); + $header=substr($header,0,$i); + $header=explode(PHP_EOL,$header); + foreach($header as $m){ + if(stripos($m,'302')!==FALSE){ + continue; + } + if(stripos($m,'Location')!==FALSE){ + $LocationUrl=ltrim($m,"Location: "); + $LocationUrl='./vs.php?uhash='.strencode($LocationUrl,'vEeUq6O}$HTX9$O'); + header("Location: $LocationUrl"); + exit(); + continue; + } + if(preg_match('!^\\s*content-length\\s*:!is',$m)){ + $len=trim(substr($m,15)); + } + header($m); + } + $fname=$_GET['vv'].'.mp4'; + header("Content-Disposition: attachment;filename=\"$fname\""); + $off=strlen($n); + echo $n; + flush(); + } + } + else{ + if($len!==false && $off>=$len){ + break; + } + $n=fread($p,1024); + $off+=strlen($n); + echo $n; + flush(); +} +} +fclose($p); +return ; +?> diff --git a/watch.php b/watch.php index 9c51f1c..8bbb8f7 100644 --- a/watch.php +++ b/watch.php @@ -81,7 +81,7 @@ 分享 - 下载 + 下载