summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot2014-09-15 15:04:39 +0200
committerroot2014-09-15 15:04:39 +0200
commitb44a26eb73010260922d242875a3b4773936a084 (patch)
treefb52e73785afc46cb66ae627811c0b1485aef77a
parent93b2daff3db922541e3cd1cb59081f15025439c8 (diff)
downloadvideo-dl-b44a26eb73010260922d242875a3b4773936a084.tar.gz
f5 protection and improved UI
-rw-r--r--404.php1
-rw-r--r--504.php1
-rw-r--r--dl.php12
-rw-r--r--error.php1
-rw-r--r--faq.php1
-rw-r--r--func.php10
-rw-r--r--func_youtube.php3
-rw-r--r--help.php1
-rw-r--r--index.php2
-rw-r--r--random.php1
-rw-r--r--stream.php30
-rw-r--r--video.php1
12 files changed, 36 insertions, 28 deletions
diff --git a/404.php b/404.php
index b72a40a..eea3fc5 100644
--- a/404.php
+++ b/404.php
@@ -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>
diff --git a/504.php b/504.php
index bc7dd29..a2d414b 100644
--- a/504.php
+++ b/504.php
@@ -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>
diff --git a/dl.php b/dl.php
index 3fd0753..0cf9f59 100644
--- a/dl.php
+++ b/dl.php
@@ -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;
diff --git a/error.php b/error.php
index 3265184..9fecf27 100644
--- a/error.php
+++ b/error.php
@@ -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>
diff --git a/faq.php b/faq.php
index 16832e1..9a435ab 100644
--- a/faq.php
+++ b/faq.php
@@ -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>
diff --git a/func.php b/func.php
index 0a626c0..0efa43a 100644
--- a/func.php
+++ b/func.php
@@ -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;
}
diff --git a/help.php b/help.php
index eef5dc6..a2cda89 100644
--- a/help.php
+++ b/help.php
@@ -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>
diff --git a/index.php b/index.php
index 9cad5db..da964d0 100644
--- a/index.php
+++ b/index.php
@@ -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">
*/ ?>
diff --git a/random.php b/random.php
index 02194dd..3c99705 100644
--- a/random.php
+++ b/random.php
@@ -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>
diff --git a/stream.php b/stream.php
index 35c8b65..bd32444 100644
--- a/stream.php
+++ b/stream.php
@@ -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"){
diff --git a/video.php b/video.php
index a56c3c1..66043b9 100644
--- a/video.php
+++ b/video.php
@@ -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(); ?>