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('

Already processing the request. Check back later.


This is very cpu intensive operation, so thanks for your understanding.


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"; @@ -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('

Already processing the request. Check back later.


( This is very cpu intensive operation, so thanks for your understanding. )


ajax-loader', 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 = ""; +else + $WEBMVIDEO = ""; + echo "

".htmlentities($title)."


diff --git a/stream.php b/stream.php index e304d9c..35c8b65 100644 --- a/stream.php +++ b/stream.php @@ -61,7 +61,8 @@ unset($db); 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?")){ + if(window.confirm('It seems your browser doesn\'t support mp4 videos. Do you want to convert it to WebM?')){ + document.getElementById('middle').innerHTML='

Converting the video to WebM.



ajax-loader
'; doVideo("convert"); } } else { @@ -74,7 +75,7 @@ unset($db); doVideo("player"); } } else if(r.status == 504){ - document.getElementById('middle').innerHTML="

The connection timed out


Please refresh the page."; + document.getElementById('middle').innerHTML="

The connection timed out


Please refresh the page."; window.reload; } } @@ -94,7 +95,7 @@ unset($db);
-

This may take some time.

+

This may take some time.

( meanwhile we are proving P = NP ...   )

-- cgit v1.2.3