From 08e47a6af99a3f8d2ccf7cc9b3c82fb4fbf927e0 Mon Sep 17 00:00:00 2001 From: Knah Tsaeb Date: Mon, 2 Feb 2015 11:49:44 +0100 Subject: [PATCH] [fix] duration extraction [add] getInfo.sh.sample --- .gitignore | 1 + bin/{getInfo.sh => getInfo.sh.sample} | 11 +- images/getInfo.svg | 533 ++++++++++++++++++++++++++ inc/content.php | 2 +- index.php | 9 +- style.css | 9 + 6 files changed, 560 insertions(+), 5 deletions(-) rename bin/{getInfo.sh => getInfo.sh.sample} (59%) create mode 100644 images/getInfo.svg diff --git a/.gitignore b/.gitignore index 4b3b435..57671ae 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ tmp videos .project bin/cronTask.sh +bin/getInfo.sh option.php pagecache *~ diff --git a/bin/getInfo.sh b/bin/getInfo.sh.sample similarity index 59% rename from bin/getInfo.sh rename to bin/getInfo.sh.sample index 69fe85b..a322a2c 100644 --- a/bin/getInfo.sh +++ b/bin/getInfo.sh.sample @@ -1,6 +1,6 @@ #!/bin/bash/ -finalDest=/srv/http/sovigall.local/videos/ -pageCache=/srv/http/sovigall.local/pagecache/ +finalDest=/path/of/sovigall/videos/ +pageCache=/path/of/sovigall/pagecache/ convertingTool=/usr/bin/ffmpeg video=$1 @@ -11,7 +11,12 @@ heure=$(echo $duration | cut -d":" -f1) minute=$(echo $duration | cut -d":" -f2) seconde=$(echo $duration | cut -d":" -f3 | cut -d"." -f1) total=$(($heure*3600 + $minute*60 + $seconde)) -sizeOfVideo=$(eval $convertingTool -i "$path""$video.webm" 2>&1 | grep "Stream #0:0" | awk '{print $6}' | tr -d ,) +if [[ $convertingTool == "/usr/bin/ffmpeg" ]] +then + sizeOfVideo=$(eval $convertingTool -i "$path""$video.webm" 2>&1 | grep "Stream #0:0" | awk '{print $6}' | tr -d ,) +else + sizeOfVideo=$(eval $convertingTool -i "$path""$video.webm" 2>&1 | grep "Stream #0.0" | awk '{print $6}' | tr -d ,) +fi #createDate=$(stat -c %y "$path""$video.webm" 2>&1 | awk '{print$1}' | sed 's/[\-]//g') echo "$total" echo "$sizeOfVideo" diff --git a/images/getInfo.svg b/images/getInfo.svg new file mode 100644 index 0000000..df1938d --- /dev/null +++ b/images/getInfo.svg @@ -0,0 +1,533 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + Shadow opacity : 30, 15, 10, (8) + + Bevel opacity : 30 / 10 + Bevel opacity : 75 / 15 + + + + + diff --git a/inc/content.php b/inc/content.php index bb96de9..1037458 100644 --- a/inc/content.php +++ b/inc/content.php @@ -231,7 +231,7 @@ if (!empty($ci['ac']) && $ci['ac'] === 'view' && !empty($listCurrentFile)) { Use this thumbnail for folder thumbnail Delete this video Re-download - Re-download + Get info '; } if ($GLOBALS['config']['DOWNLOAD_METHOD'] === 'xsendfile' || $GLOBALS['config']['DOWNLOAD_METHOD'] === 'php') { diff --git a/index.php b/index.php index 0bd4430..61ac778 100644 --- a/index.php +++ b/index.php @@ -517,11 +517,15 @@ function updateVideoInfo($dc,$file) { $path = chunk_split($dc, 8, '/'); $file = escapeshellcmd($file); $bc = escapeshellcmd($path); + if( !is_file('bin/getInfo.sh')){ + return 'You need configure bin/getInfo.sh'; + } exec('bash bin/getInfo.sh '.$file.' '.$bc, $result); $jsonFile = json_decode(file_get_contents($GLOBALS['config']['VIDEODIR'].'/'.$path.$file.'.info.json')); $jsonFile -> duration = $result[0]; $jsonFile -> format = '0 - '.$result[1]; file_put_contents($GLOBALS['config']['VIDEODIR'].'/'.$path.$file.'.info.json', json_encode($jsonFile)); + return true; } function parseVideoDescription($file, $fullInfo = false) { @@ -818,7 +822,10 @@ if (isset($ci['ac']) && !empty($ci['ac'])) { if (!isLog()) { die('Tinker say : Blinded you, with Science! '); } - updateVideoInfo($ci['bc'], $ci['file']); + $updateInfo = updateVideoInfo($ci['bc'], $ci['file']); + if($updateInfo !== true){ + echo '
',$updateInfo,'
'; + } } if ($ci['ac'] === 'viewQueue' || $ci['ac'] === 'clearCache') { verifToken($ci['token']); diff --git a/style.css b/style.css index 9cec471..0cfad54 100644 --- a/style.css +++ b/style.css @@ -304,4 +304,13 @@ video { .confirm .cancel { background-color: #e74638; +} + +.error { + margin: 0 auto; + border: 2px solid red; + border-radius: 0.2em; + padding: 1.2em; + width: 40%; + text-align:center; } \ No newline at end of file