[add] better download process
[add] can download video directly (without youtube-dl)
This commit is contained in:
parent
463c635855
commit
0b4de0357b
|
@ -6,3 +6,4 @@ bin/cronTask.sh
|
|||
option.php
|
||||
pagecache
|
||||
*~
|
||||
.settings
|
|
@ -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
|
||||
|
|
|
@ -56,13 +56,15 @@ if (!empty($ci['ac']) && $ci['ac'] === 'addVideo' && isLog()) {
|
|||
<label>Name</label>
|
||||
<input type="text" name="name"/>
|
||||
<label>Description</label>
|
||||
<textarea></textarea>
|
||||
<textarea name="desc"></textarea>
|
||||
<label>Via</label>
|
||||
<input type="url" name="via" />
|
||||
<label>Licence</label>
|
||||
<select name="licence">
|
||||
<option>CC-NC</option>
|
||||
</select>
|
||||
<label>Direct download</label>
|
||||
<input type="checkbox" name="ddl" value="1"/>
|
||||
<input type="hidden" name="op" value="1"/>
|
||||
<input type="hidden" name="ac" value="addVideo" />
|
||||
<input type="hidden" name="bc" value="'.$ci['bc'].'" />
|
||||
|
@ -139,7 +141,7 @@ if (!empty($breadcrumb)) {
|
|||
}
|
||||
echo '</div>';
|
||||
if (isset($_SESSION['cutFile']) && !empty($_SESSION['cutFile'])) {
|
||||
echo '<div class="paste"><a href="?bc=', $ci['bc'], '&op=paste&token=', $token, '"><img src="images/paste.svg" alt="Paste here" title="Paste here"/>', substr($fullListFile[$_SESSION['cutFile']]['title'], 0, 22), '...</a></div>';
|
||||
echo '<div class="paste"><a href="?bc=', $ci['bc'], '&op=paste&token=', $token, '"><img src="images/paste.svg" alt="Paste here" title="Paste here"/>', substr($fullListFile[$_SESSION['cutFile']]['title'], 0, 22), '...</a></div>';
|
||||
}
|
||||
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 '<h2>', $fullTitle, '</h2>';
|
||||
echo '<video width="640" controls="controls" poster="', $path.$videoInfo['hash'], '.jpg">';
|
||||
echo '<source src="', $path.$videoInfo['hash'], '.webm" type="video/webm" />';
|
||||
echo '<source src="', $path.$videoInfo['hash'], '.mp4" type="video/mp4" />';
|
||||
echo '
|
||||
<object type="application/x-shockwave-flash" data="lib/flowplayer-3.2.1.swf" width="640" height="360">
|
||||
<param name="movie" value="lib/flowplayer-3.2.1.swf" />
|
||||
<param name="allowFullScreen" value="true" />
|
||||
<param name="wmode" value="transparent" />
|
||||
<param name="flashVars" value="config={\'playlist\':[\'', $path.$videoInfo['hash'], '.jpg\',{\'url\':\'', $path.$videoInfo['hash'], '.webm', '\'autoPlay\':false}]}" />
|
||||
<img alt="Preview" src="', $path.$videoInfo['hash'], '.jpg" width="640" height="360" title="No video playback capabilities, please download the video below or open download link in your video player like VLC." />
|
||||
</object>';
|
||||
echo 'Oops your browser can\'t play webm video. Try a modern browser. Look <a href="http://browsehappy.com/">browsehappy.com</a> for list.';
|
||||
echo '</video>';
|
||||
}
|
||||
|
@ -259,7 +256,7 @@ if (!empty($ci['ac']) && $ci['ac'] === 'view' && !empty($listCurrentFile)) {
|
|||
</tr>
|
||||
<tr>
|
||||
<th>Url</th>
|
||||
<td><a href="', htmlentities($videoInfo['url']), '">', $videoInfo['url'], '</a></td>
|
||||
<td><a href="', $videoInfo['url'], '">', $videoInfo['url'], '</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Duration</th>
|
||||
|
@ -270,13 +267,13 @@ if (!empty($ci['ac']) && $ci['ac'] === 'view' && !empty($listCurrentFile)) {
|
|||
<td>', $videoInfo['size'], '</td>
|
||||
<tr>
|
||||
<th>Publish date</th>
|
||||
<td>', date("d m Y", strtotime($videoInfo['uploadDate'])), '</td>
|
||||
<td>', date("d m Y", strtotime($videoInfo['uploadDate'])), '</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Via</th>
|
||||
<td>';
|
||||
if (!empty($videoInfo['via'])) {
|
||||
echo '<a href="', htmlentities($videoInfo['via']), '">', $videoInfo['via'], '</a>';
|
||||
echo '<a href="', htmlentities($videoInfo['via']), '">', $videoInfo['via'], '</a>';
|
||||
} else {
|
||||
echo '';
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<ul class="topMenu">
|
||||
<li><a href="?ac=newDir&bc=', $ci['bc'], '">New directory</a></li>
|
||||
<li><a href="?ac=renDir&bc=', $ci['bc'], '">Rename directory</a></li>
|
||||
<li><a href="?ac=addVideo&bc=', $ci['bc'], '">Add video</a></li>
|
||||
<li><a href="?ac=addVideo&bc=', $ci['bc'], '">Download video</a></li>
|
||||
<li><a href="?ac=addThumbnail&bc=', $ci['bc'], '">Add thumbnail</a></li>
|
||||
</ul>';
|
||||
} else {
|
||||
|
|
17
index.php
17
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"),
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue