1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 09:49:28 +02:00
Oinktube/install/deleteUselessVideos.php
Daniel Neto ee16ae2bc4 update
2023-09-28 10:55:46 -03:00

40 lines
No EOL
1.3 KiB
PHP

<?php
//streamer config
require_once '../videos/configuration.php';
require_once $global['systemRootPath'] . 'objects/video.php';
if (!isCommandLineInterface()) {
return die('Command Line only');
}
$arrayStatusToDelete = array(
Video::$statusBrokenMissingFiles,
Video::$statusDownloading,
Video::$statusEncoding,
Video::$statusEncodingError,
Video::$statusTranfering,
);
ob_end_flush();
$sql = "SELECT * FROM videos where status in ('".implode("', '", $arrayStatusToDelete)."') ";
$res = sqlDAL::readSql($sql);
$fullData = sqlDAL::fetchAllAssoc($res);
$total = count($fullData);
sqlDAL::close($res);
$rows = [];
if ($res != false) {
$count = 0;
foreach ($fullData as $key => $row) {
$count++;
if(!in_array($row['status'], $arrayStatusToDelete)){
echo "{$total}/{$count} Deleteuseless skip status={$row['status']} title={$row['title']}".PHP_EOL;
continue;
}
$v = new Video('', '', $row['id']);
if ($v->delete(true)) {
echo "{$total}/{$count} Deleteuseless deleted from status={$row['status']} title={$row['title']}".PHP_EOL;
} else {
echo "{$total}/{$count} Deleteuseless ERROR status={$row['status']} title={$row['title']}".PHP_EOL;
}
}
}