mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 01:39:24 +02:00
Improve trhe deletethumbs
This commit is contained in:
parent
b31c9d2ceb
commit
0dd7422dd0
3 changed files with 48 additions and 6 deletions
|
@ -7,7 +7,7 @@ require_once $global['systemRootPath'] . 'objects/video.php';
|
|||
if (!isCommandLineInterface()) {
|
||||
return die('Command Line only');
|
||||
}
|
||||
|
||||
$checkIfIsCorrupted = intval(@$argv[1]);
|
||||
$users_ids = array();
|
||||
$sql = "SELECT * FROM videos ";
|
||||
$res = sqlDAL::readSql($sql);
|
||||
|
@ -20,7 +20,7 @@ if ($res != false) {
|
|||
foreach ($fullData as $key => $row) {
|
||||
$count++;
|
||||
$filename = $row['filename'];
|
||||
Video::deleteThumbs($filename, true);
|
||||
Video::deleteThumbs($filename, true, $checkIfIsCorrupted);
|
||||
echo "{$total}/{$count} Thumbs deleted from {$row['title']}".PHP_EOL;
|
||||
ob_flush();
|
||||
}
|
||||
|
|
|
@ -4484,9 +4484,9 @@ function isLive() {
|
|||
if (!empty($global['doNotLoadPlayer'])) {
|
||||
return false;
|
||||
}
|
||||
if(class_exists('LiveTransmition') && class_exists('Live')){
|
||||
if (class_exists('LiveTransmition') && class_exists('Live')) {
|
||||
$livet = LiveTransmition::getFromRequest();
|
||||
if(!empty($livet)){
|
||||
if (!empty($livet)) {
|
||||
setLiveKey($livet['key'], Live::getLiveServersIdRequest(), @$_REQUEST['live_index']);
|
||||
$isLive = 1;
|
||||
}
|
||||
|
@ -6552,6 +6552,7 @@ function sendSocketErrorMessageToUsers_id($msg, $users_id, $callbackJSFunction =
|
|||
$newMessage->msg = $msg;
|
||||
return sendSocketMessageToUsers_id($newMessage, $users_id, $callbackJSFunction);
|
||||
}
|
||||
|
||||
function sendSocketSuccessMessageToUsers_id($msg, $users_id, $callbackJSFunction = "avideoResponse") {
|
||||
$newMessage = new stdClass();
|
||||
$newMessage->error = false;
|
||||
|
@ -7579,6 +7580,43 @@ function isImage($file) {
|
|||
return false;
|
||||
}
|
||||
|
||||
function isHTMLEmpty($html_string){
|
||||
function isHTMLEmpty($html_string) {
|
||||
return empty(trim(strip_specific_tags($html_string, array('br', 'p'))));
|
||||
}
|
||||
|
||||
function totalImageColors($image_path) {
|
||||
$img = imagecreatefromjpeg($image_path);
|
||||
$w = imagesx($img);
|
||||
$h = imagesy($img);
|
||||
|
||||
// capture the raw data of the image
|
||||
ob_start();
|
||||
imagegd2($img, null, $w);
|
||||
$data = ob_get_clean();
|
||||
$totalLength = strlen($data);
|
||||
|
||||
// calculate the length of the actual pixel data
|
||||
// from that we can derive the header size
|
||||
$pixelDataLength = $w * $h * 4;
|
||||
$headerLength = $totalLength - $pixelDataLength;
|
||||
|
||||
// use each four-byte segment as the key to a hash table
|
||||
$counts = array();
|
||||
for ($i = $headerLength; $i < $totalLength; $i += 4) {
|
||||
$pixel = substr($data, $i, 4);
|
||||
$count = & $counts[$pixel];
|
||||
$count += 1;
|
||||
}
|
||||
$colorCount = count($counts);
|
||||
return $colorCount;
|
||||
}
|
||||
|
||||
function isImageCorrupted($image_path){
|
||||
if(filesize($image_path)<10){
|
||||
return true;
|
||||
}
|
||||
if(totalImageColors($image_path) === 1){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
|
@ -4184,7 +4184,7 @@ if (!class_exists('Video')) {
|
|||
return $r;
|
||||
}
|
||||
|
||||
public static function deleteThumbs($filename, $doNotDeleteSprit = false) {
|
||||
public static function deleteThumbs($filename, $doNotDeleteSprit = false, $checkIfIsCorrupted = false) {
|
||||
if (empty($filename)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -4195,9 +4195,13 @@ if (!class_exists('Video')) {
|
|||
$files = glob("{$filePath}*_thumbs*.jpg");
|
||||
foreach ($files as $file) {
|
||||
if (file_exists($file)) {
|
||||
if($checkIfIsCorrupted && !isImageCorrupted($image_path)){
|
||||
continue;
|
||||
}
|
||||
if ($doNotDeleteSprit && strpos($file, '_thumbsSprit.jpg') !== false) {
|
||||
continue;
|
||||
}
|
||||
echo "Delete {$file}";PHP_EOL;
|
||||
@unlink($file);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue