Move colorcli class to helpers

This commit is contained in:
DariusIII
2025-12-26 23:48:37 +01:00
parent ed202f0f9e
commit f50875550d
90 changed files with 1129 additions and 1296 deletions
+7 -7
View File
@@ -8,12 +8,12 @@ require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
use App\Models\Release;
use App\Services\Nzb\NzbService;
use App\Services\ReleaseImageService;
use Blacklight\ColorCLI;
use Blacklight\Releases;
use Illuminate\Support\Facades\DB;
$pdo = DB::connection()->getPdo();
$colorCli = new ColorCLI;
$path2preview = storage_path('covers/preview');
@@ -21,19 +21,19 @@ if (isset($argv[1]) && ($argv[1] === 'true' || $argv[1] === 'check')) {
$releases = new Releases;
$nzb = app(NzbService::class);
$releaseImage = new ReleaseImageService;
$consoletools = new ColorCLI;
$couldbe = $argv[1] === 'true' ? $couldbe = 'were ' : 'could be ';
$limit = $counterfixed = 0;
if (isset($argv[2]) && is_numeric($argv[2])) {
$limit = $argv[2];
}
$colorCli->header('Scanning for releases missing previews');
cli()->header('Scanning for releases missing previews');
$res = Release::query()->select('id', 'guid')->where(['haspreview' => 1])->get()->toArray();
foreach ($res as $row) {
$nzbpath = $path2preview.$row['guid'].'_thumb.jpg';
if (! file_exists($nzbpath)) {
$counterfixed++;
$colorCli->warning('Missing preview '.$nzbpath);
cli()->warning('Missing preview '.$nzbpath);
if ($argv[1] === 'true') {
$pdo->exec(
sprintf('UPDATE releases SET consoleinfo_id = NULL, gamesinfo_id = 0, imdbid = NULL, musicinfo_id = NULL, bookinfo_id = NULL, videos_id = 0, xxxinfo_id = 0, passwordstatus = -1, haspreview = -1, jpgstatus = 0, videostatus = 0, audiostatus = 0, nfostatus = -1 WHERE id = %s', $row['id'])
@@ -45,9 +45,9 @@ if (isset($argv[1]) && ($argv[1] === 'true' || $argv[1] === 'check')) {
break;
}
}
$colorCli->header('Total releases missing previews that '.$couldbe.'reset for reprocessing= '.number_format($counterfixed));
cli()->header('Total releases missing previews that '.$couldbe.'reset for reprocessing= '.number_format($counterfixed));
} else {
$colorCli->header("\nThis script checks if release previews actually exist on disk.\n\n"
cli()->header("\nThis script checks if release previews actually exist on disk.\n\n"
."Releases without previews may be reset for post-processing, thus regenerating them and related meta data.\n\n"
."Useful for recovery after filesystem corruption, or as an alternative re-postprocessing tool.\n\n"
."Optional LIMIT parameter restricts number of releases to be reset.\n\n"