diff options
| author | root | 2014-09-15 15:04:39 +0200 |
|---|---|---|
| committer | root | 2014-09-15 15:04:39 +0200 |
| commit | b44a26eb73010260922d242875a3b4773936a084 (patch) | |
| tree | fb52e73785afc46cb66ae627811c0b1485aef77a | |
| parent | 93b2daff3db922541e3cd1cb59081f15025439c8 (diff) | |
| download | video-dl-b44a26eb73010260922d242875a3b4773936a084.tar.gz | |
f5 protection and improved UI
| -rw-r--r-- | 404.php | 1 | ||||
| -rw-r--r-- | 504.php | 1 | ||||
| -rw-r--r-- | dl.php | 12 | ||||
| -rw-r--r-- | error.php | 1 | ||||
| -rw-r--r-- | faq.php | 1 | ||||
| -rw-r--r-- | func.php | 10 | ||||
| -rw-r--r-- | func_youtube.php | 3 | ||||
| -rw-r--r-- | help.php | 1 | ||||
| -rw-r--r-- | index.php | 2 | ||||
| -rw-r--r-- | random.php | 1 | ||||
| -rw-r--r-- | stream.php | 30 | ||||
| -rw-r--r-- | video.php | 1 |
12 files changed, 36 insertions, 28 deletions
@@ -8,7 +8,6 @@ <link rel='shortcut icon' href='/favicon.ico' type='image/x-icon'> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> - <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css"> <style><?php echo file_get_contents('./css/style.min.css'); ?></style> <?php require_once("static/noscript.html"); ?> </head> @@ -8,7 +8,6 @@ <link rel='shortcut icon' href='/favicon.ico' type='image/x-icon'> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> - <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css"> <style><?php echo file_get_contents('./css/style.min.css'); ?></style> <?php require_once("static/noscript.html"); ?> </head> @@ -120,7 +120,7 @@ switch($_GET["task"]){ case("stream"): ignore_user_abort(true); if(file_exists($CACHEDIR."/".$info[2].".txt")) - failure('<h3>Already processing the request. Check back later.</h3><br><p>This is very cpu intensive operation, so thanks for your understanding.</p><br><img src="/static/ajax-loader.gif" alt="ajax-loader"/>', false); + failure('<h3>Stream: Already processing the request.</h3><p>This page will refresh when the task is done.</p><br><img src="/static/ajax-loader.gif" alt="ajax-loader"/>', false); # send 'cached' response in case we already have the video on disk if(file_exists($CACHEDIR."/".$info[2]) && !file_exists($CACHEDIR."/".$info[2].".txt")){ echo "cached"; @@ -151,20 +151,20 @@ switch($_GET["task"]){ } */ if(file_exists($CACHEDIR."/".$info[2].".webm.txt")) - failure('<h3>Already processing the request. Check back later.</h3><br><p>( This is very cpu intensive operation, so thanks for your understanding. )</p><br><img src="/static/ajax-loader.gif" alt="ajax-loader"/>', false); + failure('<h3>Convert: Already processing the request.</h3><p>This page will refresh when the task is done.</p><br><p>( This is a very cpu intensive operation, so it may take a while. )</p><br><img src="/static/ajax-loader.gif" alt="ajax-loader"/>', false); if(file_exists($CACHEDIR."/".$info[2]."webm")){ echo "cached"; exit; } else { - if(!convert_video($CACHEDIR, $info[2])) + $finfo = new finfo(FILEINFO_MIME_TYPE); + $mime = $finfo->file($CACHEDIR . "/" . $info[2]); + + if(!convert_video($CACHEDIR, $info[2], $mime)) failure("Converting video failed.", false); else unlink($CACHEDIR."/".$info[2].".webm.txt"); } - $finfo = new finfo(FILEINFO_MIME_TYPE); - $mime = $finfo->file($CACHEDIR . "/" . $info[2]); - pr_player(htmlentities($CACHEDIR . "/" . $info[2]), htmlentities($info[4]), htmlentities($mime), htmlentities($info[1]), htmlentities($info[2]), true); break; @@ -9,7 +9,6 @@ <link rel='shortcut icon' href='/favicon.ico' type='image/x-icon'> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> - <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css"> <style><?php echo file_get_contents('./css/style.min.css'); ?></style> <?php require_once("static/noscript.html"); ?> </head> @@ -8,7 +8,6 @@ <link rel='shortcut icon' href='/favicon.ico' type='image/x-icon'> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> - <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css"> <style><?php echo file_get_contents('./css/style.min.css'); ?></style> <?php require_once("static/noscript.html"); ?> </head> @@ -68,9 +68,9 @@ function video_xt_audio($VIDEO, $CACHEDIR, $FILENAME){ return true; } -function convert_video($CACHEDIR, $FILENAME){ +function convert_video($CACHEDIR, $FILENAME, $MIME){ $fp=fopen($CACHEDIR."/".$FILENAME.".webm.txt", "w"); - $content="extracting audio: ".$FILENAME."\n"; + $content="converting video ".$FILENAME." to .webm\n"; fputs($fp, $content); fclose($fp); /* @@ -81,9 +81,9 @@ function convert_video($CACHEDIR, $FILENAME){ */ if(file_exists($CACHEDIR . "/" . $FILENAME.".webm")) return true; - rename($CACHEDIR . "/" . $FILENAME, $CACHEDIR . "/" . $FILENAME. ".mp4"); - exec("ffmpeg -i " . $CACHEDIR . "/" . $FILENAME. ".mp4 " . $CACHEDIR . "/" . $FILENAME. ".webm", $pid, $ret); - rename($CACHEDIR . "/" . $FILENAME . ".mp4", $CACHEDIR . "/" . $FILENAME); +// rename($CACHEDIR . "/" . $FILENAME, $CACHEDIR . "/" . $FILENAME. ".mp4"); + exec("ffmpeg -f ".escapeshellarg(preg_replace("/^video\//i", "", $MIME))." -i " . escapeshellarg($CACHEDIR . "/" . $FILENAME). " " . escapeshellarg($CACHEDIR . "/" . $FILENAME. ".webm"), $output, $ret); +// rename($CACHEDIR . "/" . $FILENAME . ".mp4", $CACHEDIR . "/" . $FILENAME); if($ret != 0){ return false; } diff --git a/func_youtube.php b/func_youtube.php index 9affc33..692cc90 100644 --- a/func_youtube.php +++ b/func_youtube.php @@ -11,7 +11,8 @@ $yt->setMajorProtocolVersion(2); function error(){ - header("Refresh: 0; /youtube"); + header($_SERVER['SERVER_PROTOCOL'] . " 503 Temporary unavailable"); + header("Refresh: 0; /random"); exit; } @@ -8,7 +8,6 @@ <link rel='shortcut icon' href='/favicon.ico' type='image/x-icon'> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> - <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css"> <style><?php echo file_get_contents('./css/style.min.css'); ?></style> <?php require_once("static/noscript.html"); ?> </head> @@ -8,8 +8,8 @@ <link rel='shortcut icon' href='/favicon.ico' type='image/x-icon'> <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> - <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css"> <?php /* + <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css"> <link rel="stylesheet" href="/css/form.min.css"> <link rel="stylesheet" href="/css/style.css"> */ ?> @@ -7,7 +7,6 @@ <link rel='shortcut icon' href='/favicon.ico' type='image/x-icon'> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> - <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css"> <style><?php echo file_get_contents('./css/style.min.css'); ?></style> <?php require("static/noscript.html"); ?> <style> @@ -21,7 +21,6 @@ unset($db); <meta charset="utf-8"> <title><?php echo $title; ?> :: streaming</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> - <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css"> <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> <style><?php echo file_get_contents('./css/style.min.css'); ?></style> <link rel='shortcut icon' href='/favicon.ico' type='image/x-icon'> @@ -47,26 +46,41 @@ unset($db); if(r.readyState == 4){ if(r.status == 404){ document.getElementById('middle').innerHTML=r.responseText; + var checkIfReload = r.responseText.match(/Convert|Stream/); + //alert(checkIfReload); + var checkIfFailed = r.responseText.match(/failed/); + if(checkIfFailed != 'failed' && (checkIfReload == 'Convert' || checkIfReload == 'Stream')){ + var todo = checkIfReload.toString().toLowerCase(); + setTimeout(function(){ + doVideo(todo); + }, 5000); + } } else if(r.status == 200){ if(r.responseText == "cached"){ doVideo("player"); } else if(task == "player"){ document.getElementById('middle').innerHTML=r.responseText; + var askToConvert = localStorage.getItem('askToConvert') || ''; var canPlay = false; var v = document.createElement('video'); if(v.canPlayType && v.canPlayType('video/mp4').replace(/no/, '')) { canPlay = true; } if(canPlay != true){ - var canWebm = false; - if(v.canPlayType && v.canPlayType('video/webm').replace(/no/, '')){ - if(window.confirm('It seems your browser doesn\'t support mp4 videos. Do you want to convert it to WebM?')){ - document.getElementById('middle').innerHTML='<div class="row"><h3>Converting the video to <a href="//en.wikipedia.org/wiki/WebM" title="Wikipedia: WebM" target="__blank">WebM.</h3></div><div class="row"><br><br><img src="/static/ajax-loader.gif" alt="ajax-loader"/></div>'; - doVideo("convert"); + if(askToConvert != '<?php echo htmlentities($_GET["vid"]); ?>'){ + var canWebm = false; + if(v.canPlayType && v.canPlayType('video/webm').replace(/no/, '')){ + if(window.confirm('It seems your browser doesn\'t support mp4 videos. Do you want to convert it to WebM?')){ + document.getElementById('middle').innerHTML='<div class="row"><h3>Converting the video to <a href="//en.wikipedia.org/wiki/WebM" title="Wikipedia: WebM" target="__blank">WebM.</a></h3><p>This page will refresh when the task is done.</p><br><p>( This is a very cpu intensive operation, so it may take a while. )</div><br><div class="row"><br><br><img src="/static/ajax-loader.gif" alt="ajax-loader"/></div>'; + localStorage.setItem('askToConvert','<?php echo htmlentities($_GET["vid"]); ?>'); + doVideo("convert"); + } + } else { + alert("Sorry, it seems your browser doesn't support our video formats."); } - } else { - alert("Sorry, it seems your browser doesn't support our video formats."); + } else if(askToConvert == '<?php echo htmlentities($_GET["vid"]); ?>'){ + doVideo("convert"); } } } else if(task == "convert"){ @@ -33,7 +33,6 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){ <link rel='shortcut icon' href='/favicon.ico' type='image/x-icon'> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> - <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css"> <style><?php echo file_get_contents('./css/style.min.css'); ?></style> <?php require_once("static/noscript.html"); ?> <?php ob_end_flush(); ?> |
