diff --git a/.gitignore b/.gitignore index dce5c1d..4b3b435 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ bin/cronTask.sh option.php pagecache *~ +.settings \ No newline at end of file diff --git a/bin/cronTask.sh.sample b/bin/cronTask.sh.sample index 7bfebf8..463b54a 100644 --- a/bin/cronTask.sh.sample +++ b/bin/cronTask.sh.sample @@ -1,8 +1,15 @@ #!/bin/bash/ +#################### +#### START CONFIG #### finalDest=/path/of/sovigall/videos/ tempDest=/path/of/sovigall/tmp/ pageCache=/path/of/sovigall/pagecache/ threads=3 # nb cpu core - 1 +convertingTool=/usr/bin/ffmpeg +mimeMagic=/etc/mime.types +#### END CONFIG #### +#################### + cd $tempDest nbProcessLauch=$(ps -ef | grep -v grep | grep youtube-dl | wc -l) @@ -18,23 +25,54 @@ do then while read ddl urlHash url destination do - if [ ddl != 0 ] + if [ "$ddl" -eq 0 ] then - /usr/local/bin/youtube-dl -R 0 -c --write-thumbnail --write-info-json --no-check-certificate -f 45/46/37/45/22/44/35/34/5 -o "$urlHash.%(ext)s" "$url" + youtube-dl -c --write-thumbnail --write-info-json --prefer-free-formats --no-check-certificate -f "[height <=?720]" -o "$urlHash.raw" "$url" + if [ ! -f $urlHash.*.jpg ] + then + eval $convertingTool -i $urlHash.raw -vframes 1 -an -ss 3 $urlHash.jpg + fi convert "$urlHash.jpg" -resize 260 "$urlHash.thumb.jpg" - sleep 2 - avconv -i $urlHash\.mp4 -codec:v libvpx -cpu-used 0 -b:v 500k -qmin 20 -qmax 42 -maxrate 500k -bufsize 1000k -threads $threads -codec:a libvorbis -b:a 128k $urlHash\.webm - sleep 2 + mimeFile=$(file --mime-type -b "$urlHash.raw") + if [[ "$mimeFile" != "video/webm" ]] + then + createDate=$(stat -c %y $urlHash.raw 2>&1 | awk '{print$1}' | sed 's/[\-]//g') + eval $convertingTool -i $urlHash.raw -threads $threads -quality good -cpu-used 0 -bufsize 1600k -b:v 800K -metadata creation_time="$createDate" $urlHash.webm + else + mv $urlHash.raw $urlHash.webm + fi else - wget -O urlHash url + wget -c -O $urlHash.webm $url + + #exit + mimeFile=$(file --mime-type -b "$urlHash.webm") + if [[ "$mimeFile" != "video/webm" ]] + then + eval $convertingTool -i $urlHash.webm -threads $threads -quality good -cpu-used 0 -bufsize 1600k -b:v 800K -metadata creation_time="$createDate" $urlHash.webm + fi + eval $convertingTool -i $urlHash.webm -vframes 1 -an -ss 3 $urlHash.jpg + convert "$urlHash.jpg" -resize 260 "$urlHash.thumb.jpg" + sizeOfVideo=$(eval $convertingTool -i "$urlHash.webm" 2>&1 | grep "Stream #0:0" | awk '{print $6}' | tr -d ,) + duration=$(eval $convertingTool -i "$urlHash.webm" 2>&1 | grep Duration | awk '{print $2}' | tr -d ,) + createDate=$(stat -c %y $urlHash.raw 2>&1 | awk '{print$1}' | sed 's/[\-]//g') + echo '{' > $urlHash.info.json + echo "\"url\"":"\"$url\"," >> $urlHash.info.json + echo "\"format\"": "\"22 - $sizeOfVideo\"," >> $urlHash.info.json + echo "\"duration\"": "\"22 - $duration\"," >> $urlHash.info.json + echo "\"upload_date\"":"\"$createDate"\" >> $urlHash.info.json + echo '}' >> $urlHash.info.json fi if [ ! -f $urlHash.*.part ] then - rm $file - sleep 2 - mv $urlHash* $destination + if [ -f "$urlHash.webm" ] + then + sleep 2 + mv $urlHash* $destination + fi + else + mv $file $file.error fi done < $file fi - rm $pageCache*.html 2> /dev/null + rm $pageCache*.html done diff --git a/inc/content.php b/inc/content.php index ab3aba1..8aa4a95 100644 --- a/inc/content.php +++ b/inc/content.php @@ -56,13 +56,15 @@ if (!empty($ci['ac']) && $ci['ac'] === 'addVideo' && isLog()) { - + + + @@ -139,7 +141,7 @@ if (!empty($breadcrumb)) { } echo ''; if (isset($_SESSION['cutFile']) && !empty($_SESSION['cutFile'])) { - echo '
Paste here', substr($fullListFile[$_SESSION['cutFile']]['title'], 0, 22), '...
'; + echo '
Paste here', substr($fullListFile[$_SESSION['cutFile']]['title'], 0, 22), '...
'; } if (empty($listCurrentDir) && empty($listCurrentFile)) { if ($ci['ac'] === 'confDelDir' && isLog()) { @@ -203,7 +205,11 @@ if (!empty($ci['ac']) && $ci['ac'] === 'view' && !empty($listCurrentFile)) { $_SESSION['video'] = $videoInfo['hash']; if (!empty($videoInfo)) { if (empty($videoInfo['title']) || empty($videoInfo['uploadDateSort'])) { - $fullTitle = $videoInfo['originalTitle']; + if (empty($videoInfo['title'])) { + $fullTitle = $videoInfo['originalTitle']; + } else { + $fullTitle = $videoInfo['title']; + } $uploadDate = $videoInfo['uploadDate']; updateFileInfo($videoInfo['hash'], $fullTitle, $uploadDate); $videoInfo['title'] = $fullTitle = $videoInfo['originalTitle'].' ('.$videoInfo['originalTitle'].')'; @@ -216,15 +222,6 @@ if (!empty($ci['ac']) && $ci['ac'] === 'view' && !empty($listCurrentFile)) { echo '

', $fullTitle, '

'; echo ''; } @@ -259,7 +256,7 @@ if (!empty($ci['ac']) && $ci['ac'] === 'view' && !empty($listCurrentFile)) { Url - ', $videoInfo['url'], ' + ', $videoInfo['url'], ' Duration @@ -270,13 +267,13 @@ if (!empty($ci['ac']) && $ci['ac'] === 'view' && !empty($listCurrentFile)) { ', $videoInfo['size'], ' Publish date - ', date("d m Y", strtotime($videoInfo['uploadDate'])), ' + ', date("d m Y", strtotime($videoInfo['uploadDate'])), ' Via '; if (!empty($videoInfo['via'])) { - echo '', $videoInfo['via'], ''; + echo '', $videoInfo['via'], ''; } else { echo ''; } diff --git a/inc/topMenu.php b/inc/topMenu.php index 448ac5a..1795176 100644 --- a/inc/topMenu.php +++ b/inc/topMenu.php @@ -13,7 +13,7 @@ '; } else { diff --git a/index.php b/index.php index 8acabf0..054551b 100644 --- a/index.php +++ b/index.php @@ -342,13 +342,18 @@ function removeDir($dir, $fullListDir) { function addVideo($ci, $fullListFile) { $nameHash = substr(sha1($ci['name'].$ci['url']), 0, 10); - $url = escapeshellcmd($ci['url']); + $url = escapeshellcmd(html_entity_decode($ci['url'])); if (!empty($ci['bc'])) { $path = chunk_split($ci['bc'], 8, '/'); } else { $path = ''; } - $data = $nameHash.' '.$url.' '.$_SERVER['DOCUMENT_ROOT'].'/'.$GLOBALS['config']['VIDEODIR'].'/'.$path."\n"; + if(isset($ci['ddl']) && (int)$ci['ddl'] === 1){ + $ddl = 1; + } else { + $ddl = 0; + } + $data = $ddl.' '.$nameHash.' '.$url.' '.$_SERVER['DOCUMENT_ROOT'].'/'.$GLOBALS['config']['VIDEODIR'].'/'.$path."\n"; file_put_contents($GLOBALS['config']['TMPDIR'].'/'.$nameHash.'.hash', $data); $fullListFile[$nameHash] = array( 'title' => $ci['name'], @@ -514,8 +519,12 @@ function getVideoInfo($file, $dir, $fullListFile) { $jsonInfo = json_decode(file_get_contents($descFile[0])); $jsonSize = explode(' - ', htmlentities($jsonInfo -> format)); $jsonSize = explode('x', $jsonSize[1]); - $size = $jsonSize[1].'x'.$jsonSize[0]; + $size = $jsonSize[0].'x'.$jsonSize[1]; $time = gmdate('H\hi\ms\s', $jsonInfo -> duration); + $uploadDate = htmlentities($jsonInfo -> upload_date, ENT_QUOTES, "UTF-8"); + if(empty($uploadDate)){ + $uploadDate = gmdate ("Ymd", filemtime($GLOBALS['config']['VIDEODIR']."/".$path.$file.".webm")); + } $info = array( 'hash' => $file, 'title' => $postInfo['title'], @@ -524,7 +533,7 @@ function getVideoInfo($file, $dir, $fullListFile) { 'desc' => $postInfo['desc'], 'originalDesc' => htmlentities($jsonInfo -> description, ENT_QUOTES, "UTF-8"), 'uploadDateSort' => $postInfo['uploadDateSort'], - 'uploadDate' => htmlentities($jsonInfo -> upload_date, ENT_QUOTES, "UTF-8"), + 'uploadDate' => $uploadDate, 'format' => htmlentities($jsonInfo -> format, ENT_QUOTES, "UTF-8"), 'ext' => htmlentities($jsonInfo -> ext, ENT_QUOTES, "UTF-8"), 'duration' => htmlentities($time, ENT_QUOTES, "UTF-8"), diff --git a/lib/flowplayer-3.2.1.swf b/lib/flowplayer-3.2.1.swf deleted file mode 100644 index db34bd1..0000000 Binary files a/lib/flowplayer-3.2.1.swf and /dev/null differ