diff options
| author | root | 2014-09-15 00:43:22 +0200 |
|---|---|---|
| committer | root | 2014-09-15 00:43:22 +0200 |
| commit | 93b2daff3db922541e3cd1cb59081f15025439c8 (patch) | |
| tree | fbdbe33e13df7a5da17f14d3a75bd44c51b1b31c | |
| parent | dfc4ee6bfbff601328f6bf8dadf9716a58cbd903 (diff) | |
| download | video-dl-93b2daff3db922541e3cd1cb59081f15025439c8.tar.gz | |
fixed typos and improved usability
| -rw-r--r-- | dl.php | 21 | ||||
| -rw-r--r-- | func.php | 17 | ||||
| -rw-r--r-- | stream.php | 7 |
3 files changed, 29 insertions, 16 deletions
@@ -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('<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); # 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('<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); 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]); @@ -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 = "<source src=\"/".htmlentities($file.".webm")."\" type='video/webm' />"; +else + $WEBMVIDEO = ""; + echo " <h1>".htmlentities($title)."</h1> <br> @@ -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='<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"); } } else { @@ -74,7 +75,7 @@ unset($db); doVideo("player"); } } else if(r.status == 504){ - document.getElementById('middle').innerHTML="<h1>The connection timed out</h1><br>Please refresh the page."; + document.getElementById('middle').innerHTML="<h3>The connection timed out</h3><br>Please refresh the page."; window.reload; } } @@ -94,7 +95,7 @@ unset($db); <div class="text-center"> <div id='middle'> <div class="row"> - <h1>This may take <span id='counter'>some</span> time.</h1> + <h3>This may take <span id='counter'>some</span> time.</h3> </div> <div class="row"> <p>( meanwhile we are proving P = NP ...   )</p> |
