[add] detect duration, size of video
This commit is contained in:
parent
0a5b47e4d5
commit
4ce298f7f7
19
bin/getInfo.sh
Normal file
19
bin/getInfo.sh
Normal file
|
@ -0,0 +1,19 @@
|
|||
#!/bin/bash/
|
||||
finalDest=/srv/http/sovigall.local/videos/
|
||||
pageCache=/srv/http/sovigall.local/pagecache/
|
||||
convertingTool=/usr/bin/ffmpeg
|
||||
|
||||
video=$1
|
||||
path="$finalDest$2"
|
||||
|
||||
duration=$(eval $convertingTool -i "$path""$video.webm" 2>&1 | grep Duration | awk '{print $2}' | tr -d ,)
|
||||
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 ,)
|
||||
#createDate=$(stat -c %y "$path""$video.webm" 2>&1 | awk '{print$1}' | sed 's/[\-]//g')
|
||||
echo "$total"
|
||||
echo "$sizeOfVideo"
|
||||
#echo "$createDate"
|
||||
rm $pageCache*.html 2> /dev/null
|
|
@ -231,6 +231,7 @@ if (!empty($ci['ac']) && $ci['ac'] === 'view' && !empty($listCurrentFile)) {
|
|||
<a href="?ac=view&op=3&bc=', $ci['bc'], '&file=', $ci['file'], '&token=', $token, '"><img src="images/useThumbnail.svg" alt="Use this thumbnail for folder thumbnail" title="Use this thumbnail for folder thumbnail"/></a>
|
||||
<a href="?ac=view&bc=', $ci['bc'], '&file=', $ci['file'], '&token=', $token, '&op=confDelVideo"><img src="images/delete.svg" alt="Delete this video" title="Delete this video"/></a>
|
||||
<a href="?ac=view&bc=', $ci['bc'], '&file=', $ci['file'], '&token=', $token, '&op=reDownload"><img src="images/reload.svg" alt="Re-download" title="Re-download"/></a>
|
||||
<a href="?ac=view&bc=', $ci['bc'], '&file=', $ci['file'], '&token=', $token, '&op=updateInfo"><img src="images/reload.svg" alt="Re-download" title="Re-download"/></a>
|
||||
</div>';
|
||||
}
|
||||
if ($GLOBALS['config']['DOWNLOAD_METHOD'] === 'xsendfile' || $GLOBALS['config']['DOWNLOAD_METHOD'] === 'php') {
|
||||
|
|
20
index.php
20
index.php
|
@ -513,6 +513,17 @@ function makeRss($breadcrumb, $fullListFile) {
|
|||
exit();
|
||||
}
|
||||
|
||||
function updateVideoInfo($dc,$file) {
|
||||
$path = chunk_split($dc, 8, '/');
|
||||
$file = escapeshellcmd($file);
|
||||
$bc = escapeshellcmd($path);
|
||||
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));
|
||||
}
|
||||
|
||||
function parseVideoDescription($file, $fullInfo = false) {
|
||||
$value = json_decode(file_get_contents($file));
|
||||
}
|
||||
|
@ -521,7 +532,7 @@ function getVideoInfo($file, $dir, $fullListFile) {
|
|||
$file = substr($file, 0, 10);
|
||||
$postInfo = $fullListFile[$file];
|
||||
$path = chunk_split($dir, 8, '/');
|
||||
$descFile = glob($GLOBALS['config']['VIDEODIR']."/".$path.$file."*.json");
|
||||
$descFile = glob($GLOBALS['config']['VIDEODIR'].'/'.$path.$file.'*.json');
|
||||
$jsonInfo = json_decode(file_get_contents($descFile[0]));
|
||||
$jsonSize = explode(' - ', htmlentities($jsonInfo -> format));
|
||||
$jsonSize = explode('x', $jsonSize[1]);
|
||||
|
@ -802,6 +813,13 @@ if (isset($ci['ac']) && !empty($ci['ac'])) {
|
|||
}
|
||||
reDownloadVideo($ci['bc'], $ci['file']);
|
||||
}
|
||||
if ($ci['ac'] === 'view' && !empty($ci['op']) && $ci['op'] === 'updateInfo') {
|
||||
verifToken($ci['token']);
|
||||
if (!isLog()) {
|
||||
die('Tinker say : Blinded you, with Science! ');
|
||||
}
|
||||
updateVideoInfo($ci['bc'], $ci['file']);
|
||||
}
|
||||
if ($ci['ac'] === 'viewQueue' || $ci['ac'] === 'clearCache') {
|
||||
verifToken($ci['token']);
|
||||
if (!isLog()) {
|
||||
|
|
Loading…
Reference in a new issue