[add] thumb generation for preview of folder and video
[add] option for active or not the cache [fix] change path of option.php
This commit is contained in:
parent
77b6fe53a2
commit
e32e499c8f
|
@ -19,7 +19,8 @@ do
|
|||
while read urlHash url destination
|
||||
do
|
||||
youtube-dl -R 0 -c --write-thumbnail --write-info-json --recode-video webm --no-check-certificate -f 45/46/37/45/22/44/35/34/5 -o "$urlHash.%(ext)s" "$url"
|
||||
sleep 5
|
||||
convert "$urlHash.jpg" -resize 260 "$urlHash.thumb.jpg"
|
||||
sleep 10
|
||||
if [ ! -f $urlHash.*.part ]
|
||||
then
|
||||
rm $file
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 64 B |
|
@ -5,5 +5,12 @@ if (!isLog()) {
|
|||
require 'inc/topMenu.php';
|
||||
if (!empty($ci['ac']) && $ci['ac'] === 'viewQueue' && $_SESSION['log'] === true) {
|
||||
$getQueue = getQueue();
|
||||
echo 'You have ',$getQueue,' video in download queue.';
|
||||
echo 'You have ', $getQueue, ' video in download queue.';
|
||||
}
|
||||
if (!empty($ci['ac']) && $ci['ac'] === 'clearCache' && $_SESSION['log'] === true) {
|
||||
if (clearCache() === true) {
|
||||
echo 'Cache are clear.';
|
||||
} else {
|
||||
echo 'Error on delete cache.';
|
||||
}
|
||||
}
|
|
@ -162,10 +162,20 @@ if (!empty($listCurrentDir) && $ci['ac'] !== 'view') {
|
|||
if (!empty($listCurrentFile) && $ci['ac'] !== 'view') {
|
||||
$listCurrentFile = sortFile($listCurrentFile, $fullListFile, $ci['sort']);
|
||||
foreach ($listCurrentFile as $key => $value) {
|
||||
$thumb = '';
|
||||
if ($key == 'thumb') {
|
||||
continue;
|
||||
}
|
||||
echo '<a href="?bc=', $ci['bc'], '&file=', $key, '&ac=view"><span class="video"></span><img alt="', $path.$key, '" src="', $path.$key, '.jpg" />', $value['title'], '</a>';
|
||||
if (file_exists($_SERVER['DOCUMENT_ROOT'].'/'.$path.$key.'.thumb.jpg')) {
|
||||
$thumb = $path.$key.'.thumb.jpg';
|
||||
}
|
||||
if (empty($thumb) && file_exists($_SERVER['DOCUMENT_ROOT'].'/'.$path.$key.'.jpg')) {
|
||||
$thumb = makeThumb($path, $key);
|
||||
}
|
||||
if (empty($thumb)) {
|
||||
$thumb = 'images/noThumb.gif';
|
||||
}
|
||||
echo '<a href="?bc=', $ci['bc'], '&file=', $key, '&ac=view"><span class="video"></span><img alt="', $path.$key, '" src="', $thumb, '" />', $value['title'], '</a>';
|
||||
}
|
||||
}
|
||||
echo '</div>';
|
||||
|
@ -226,20 +236,20 @@ 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="', htmlentities($videoInfo['url']), '">', $videoInfo['url'], '</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Duration</th>
|
||||
<td>', $videoInfo['duration'], '</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 '';
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
echo '
|
||||
<ul class="topMenu">
|
||||
<li><a href="?ac=viewQueue&token=',$token,'">Download queue</a></li>
|
||||
<li><a href="?ac=clearCache&token=',$token,'">Clear cache</a></li>
|
||||
</ul>
|
||||
<ul class="topMenu">
|
||||
<li><a href="?ac=newDir&bc=', $ci['bc'], '">New directory</a></li>
|
||||
|
|
56
index.php
56
index.php
|
@ -27,7 +27,7 @@ $GLOBALS['config']['BAN_AFTER'] = 4;
|
|||
// Ban duration for IP address after login failures (in seconds) (1800 sec. = 30 minutes)
|
||||
$GLOBALS['config']['BAN_DURATION'] = 1800;
|
||||
// Use cache
|
||||
$GLOBALS['config']['USECACHE'] = false;
|
||||
$GLOBALS['config']['USECACHE'] = true;
|
||||
// Page cache directory.
|
||||
$GLOBALS['config']['PAGECACHE'] = 'pagecache';
|
||||
// Download method
|
||||
|
@ -36,8 +36,8 @@ $GLOBALS['config']['PAGECACHE'] = 'pagecache';
|
|||
// php
|
||||
$GLOBALS['config']['DOWNLOAD_METHOD'] = 'xsendfile';
|
||||
|
||||
if (file_exists('option.php')) {
|
||||
require_once 'option.php';
|
||||
if (file_exists($GLOBALS['config']['DATADIR'].'/'.'option.php')) {
|
||||
require_once $GLOBALS['config']['DATADIR'].'/'.'option.php';
|
||||
}
|
||||
|
||||
if (get_magic_quotes_gpc()) {
|
||||
|
@ -204,9 +204,9 @@ function n_print($data, $name = '') {
|
|||
<fieldset style="border: 1px solid orange; padding: 5px;color:#1E1915; background-color: #fff;">';
|
||||
echo '
|
||||
<legend style="border:1px solid orange;padding: 1px;background-color:#eee;color:orange;">
|
||||
', basename($aBackTrace[0]['file']), ' ligne => ', $aBackTrace[0]['line'], '
|
||||
', basename($aBackTrace[0]['file']), ' ligne => ', $aBackTrace[0]['line'], '
|
||||
</legend>';
|
||||
echo '<pre style="color:#1E1915;">', htmlentities(print_r($data, 1)), '</pre>';
|
||||
echo '<pre style="color:#1E1915;">', htmlentities(print_r($data, 1)), '</pre>';
|
||||
echo '
|
||||
</fieldset>
|
||||
<br />';
|
||||
|
@ -320,7 +320,7 @@ function sortDir($listCurrentDir, $fullListDir) {
|
|||
|
||||
function sortFile($listCurrentFile, $fullListFile, $sort = 'name') {
|
||||
foreach ($listCurrentFile as $value) {
|
||||
$hash = str_replace('.jpg', '', $value);
|
||||
$hash = str_replace('.webm', '', $value);
|
||||
$rows[$hash] = array(
|
||||
'uploadDateSort' => $fullListFile[$hash]['uploadDateSort'],
|
||||
'title' => $fullListFile[$hash]['title']
|
||||
|
@ -360,7 +360,7 @@ function makeBreadcrumb($bc, $fullListDir) {
|
|||
}
|
||||
|
||||
function listVideo($breadcrumb) {
|
||||
return glob("*.jpg");
|
||||
return glob("*.webm");
|
||||
}
|
||||
|
||||
function parseVideoDescription($file, $fullInfo = false) {
|
||||
|
@ -472,11 +472,35 @@ function convertToJpeg($path, $type) {
|
|||
if ($type == 'image/gif') {
|
||||
$image = imagecreatefromgif($pathAndNameFile);
|
||||
}
|
||||
imagejpeg($image, $GLOBALS['config']['VIDEODIR'].'/'.$path.'thumb'.'.jpg', 100);
|
||||
imagejpeg($image, $GLOBALS['config']['VIDEODIR'].'/'.$path.'thumb.jpg', 100);
|
||||
imagedestroy($image);
|
||||
unlink($pathAndNameFile);
|
||||
}
|
||||
|
||||
/*
|
||||
* http://www.php.net/manual/en/function.imagecopyresampled.php
|
||||
*/
|
||||
function makeThumb($path, $file) {
|
||||
$filename = $_SERVER['DOCUMENT_ROOT'].'/'.$path.$file.'.jpg';
|
||||
$width = 260;
|
||||
$height = 200;
|
||||
list($width_orig, $height_orig) = getimagesize($filename);
|
||||
$ratio_orig = $width_orig / $height_orig;
|
||||
|
||||
if ($width / $height > $ratio_orig) {
|
||||
$width = $height * $ratio_orig;
|
||||
} else {
|
||||
$height = $width / $ratio_orig;
|
||||
}
|
||||
|
||||
$image_p = imagecreatetruecolor($width, $height);
|
||||
$image = imagecreatefromjpeg($filename);
|
||||
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
|
||||
imagejpeg($image_p, $_SERVER['DOCUMENT_ROOT'].'/'.$path.$file.'.thumb.jpg', 100);
|
||||
imagedestroy($image_p);
|
||||
return $path.$file.'.thumb.jpg';
|
||||
}
|
||||
|
||||
function sendVideo($bc, $file) {
|
||||
global $fullListFile;
|
||||
$path = chunk_split($bc, 8, '/');
|
||||
|
@ -544,6 +568,20 @@ function deleteCache($bc = '', $file = '', $sort = '', $parent = false) {
|
|||
}
|
||||
}
|
||||
|
||||
function clearCache() {
|
||||
$listOfCache = glob($_SERVER['DOCUMENT_ROOT'].'/'.$GLOBALS['config']['PAGECACHE'].'/*.html');
|
||||
foreach ($listOfCache as $value) {
|
||||
if (!unlink($value)) {
|
||||
$error = 1;
|
||||
}
|
||||
}
|
||||
if ($error === 1) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($ci['ac']) && $ci['ac'] === 'login' && !empty($ci['op']) && (int)$ci['op'] === 2) {
|
||||
verifToken($ci['token']);
|
||||
if (login($ci) === true) {
|
||||
|
@ -595,7 +633,7 @@ if (isset($ci['ac']) && !empty($ci['ac'])) {
|
|||
$defineThumb = defineThumb($ci['bc'], $ci['file']);
|
||||
deleteCache($ci['bc'], '', $ci['sort'], true);
|
||||
}
|
||||
if ($ci['ac'] === 'viewQueue') {
|
||||
if ($ci['ac'] === 'viewQueue' || $ci['ac'] === 'clearCache') {
|
||||
verifToken($ci['token']);
|
||||
if (!isLog()) {
|
||||
die('Tinker say : Seek the heat! ');
|
||||
|
|
Loading…
Reference in New Issue