1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 01:39:24 +02:00
Oinktube/install/deleteUselessVideos.php
Daniel Neto 8db8d44a92 Refactor Video Status Constants
- Updated references from Video::$status* to Video::STATUS_* for consistency across multiple files.
- Ensured that all instances of video status checks and assignments utilize the new constant format.
- This change improves code readability and maintainability by standardizing the way video statuses are referenced throughout the codebase.
2025-07-11 12:52:02 -03:00

40 lines
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::STATUS_BROKEN_MISSING_FILES,
Video::STATUS_DOWNLOADING,
Video::STATUS_ENCODING,
Video::STATUS_ENCODING_ERROR,
Video::STATUS_TRANFERING,
);
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;
}
}
}