From 93b2daff3db922541e3cd1cb59081f15025439c8 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 15 Sep 2014 00:43:22 +0200 Subject: fixed typos and improved usability --- dl.php | 21 ++++++++++++--------- func.php | 17 +++++++++++++---- stream.php | 7 ++++--- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/dl.php b/dl.php index 65178a7..3fd0753 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('Already doing the request.', false); + failure('
This is very cpu intensive operation, so thanks for your understanding.
', 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";
@@ -132,7 +132,6 @@ switch($_GET["task"]){
failure("Fetching the video failed.", false);
else
unlink($CACHEDIR."/".$info[2].".txt");
- }
break;
case("player"):
@@ -144,21 +143,25 @@ switch($_GET["task"]){
break;
case("convert"):
+ ignore_user_abort(true);
+ /*
$dir = array_diff(scandir($CACHEDIR), array('.', '..'));
if(!in_array($_GET['vid'], $dir)){
- failure('Video not found.' false);
+ failure('Video not found.', false);
}
+ */
if(file_exists($CACHEDIR."/".$info[2].".webm.txt"))
- exit;
+ failure('( This is very cpu intensive operation, so thanks for your understanding. )
', false);
if(file_exists($CACHEDIR."/".$info[2]."webm")){
echo "cached";
exit;
- }
- if(!convert_video($info[2]))
- failure("Converting video failed.", false);
- else
- unlink($CACHEDIR."/".$info[2].".webm.txt");
+ } else {
+ if(!convert_video($CACHEDIR, $info[2]))
+ failure("Converting video failed.", false);
+ else
+ unlink($CACHEDIR."/".$info[2].".webm.txt");
+ }
$finfo = new finfo(FILEINFO_MIME_TYPE);
$mime = $finfo->file($CACHEDIR . "/" . $info[2]);
diff --git a/func.php b/func.php
index e1bf9bb..0a626c0 100644
--- a/func.php
+++ b/func.php
@@ -68,15 +68,21 @@ function video_xt_audio($VIDEO, $CACHEDIR, $FILENAME){
return true;
}
-function convert_video($FILENAME){
+function convert_video($CACHEDIR, $FILENAME){
$fp=fopen($CACHEDIR."/".$FILENAME.".webm.txt", "w");
$content="extracting audio: ".$FILENAME."\n";
fputs($fp, $content);
fclose($fp);
- if(file_exists($FILENAME.".mp4") || file_exists($FILENAME.".webm"))
- return;
+ /*
+ $fp=fopen($CACHEDIR."/".$FILENAME.".block.txt", "w");
+ $content="blocked because of extracting audio: ".$FILENAME."\n";
+ fputs($fp, $content);
+ fclose($fp);
+ */
+ if(file_exists($CACHEDIR . "/" . $FILENAME.".webm"))
+ return true;
rename($CACHEDIR . "/" . $FILENAME, $CACHEDIR . "/" . $FILENAME. ".mp4");
- exec("ffmpeg -i " . $CACHEDIR . "/" . $VID . ".mp4 " . $CACHEDIR . "/" . $VID . ".webm", $pid, $ret);
+ exec("ffmpeg -i " . $CACHEDIR . "/" . $FILENAME. ".mp4 " . $CACHEDIR . "/" . $FILENAME. ".webm", $pid, $ret);
rename($CACHEDIR . "/" . $FILENAME . ".mp4", $CACHEDIR . "/" . $FILENAME);
if($ret != 0){
return false;
@@ -88,6 +94,9 @@ function convert_video($FILENAME){
function pr_player($file, $thumb, $mime, $title, $vid, $html5 = false){
if($html5)
$WEBMVIDEO = "
( meanwhile we are proving P = NP ... )
-- cgit v1.2.3