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 '
'; + echo ''; } 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 '