Remove usage of setCoversConstant function

This commit is contained in:
DariusIII
2023-03-28 19:46:49 +02:00
parent 0f7ec61ad9
commit 9a0aeaee5c
4 changed files with 20 additions and 58 deletions
+14 -24
View File
@@ -5,25 +5,17 @@
// --------------------------------------------------------------
require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
use App\Models\Settings;
use App\Models\Release;
use Blacklight\ColorCLI;
use Blacklight\ConsoleTools;
use Blacklight\NZB;
use Blacklight\ReleaseImage;
use Blacklight\Releases;
use Blacklight\utility\Utility;
use Illuminate\Support\Facades\DB;
$pdo = DB::connection()->getPdo();
$colorCli = new ColorCLI();
$row = Settings::settingValue('site.main.coverspath');
if ($row !== null) {
Utility::setCoversConstant($row);
} else {
exit("Unable to determine covers path!\n");
}
$path2preview = storage_path('covers/preview');
if (isset($argv[1]) && ($argv[1] === 'true' || $argv[1] === 'check')) {
@@ -37,23 +29,21 @@ if (isset($argv[1]) && ($argv[1] === 'true' || $argv[1] === 'check')) {
$limit = $argv[2];
}
$colorCli->header('Scanning for releases missing previews');
$res = $pdo->query('SELECT id, guid FROM releases where nzbstatus = 1 AND haspreview = 1');
if ($res instanceof \Traversable) {
foreach ($res as $row) {
$nzbpath = $path2preview.$row['guid'].'_thumb.jpg';
if (! file_exists($nzbpath)) {
$counterfixed++;
$colorCli->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'])
);
}
$res = Release::query()->select('id', 'guid')->where(['nzbstatus' => 1, 'haspreview' => 1])->get()->toArray();
foreach ($res as $row) {
$nzbpath = $path2preview.$row['guid'].'_thumb.jpg';
if (! file_exists($nzbpath)) {
$counterfixed++;
$colorCli->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'])
);
}
}
if (($limit > 0) && ($counterfixed >= $limit)) {
break;
}
if (($limit > 0) && ($counterfixed >= $limit)) {
break;
}
}
$colorCli->header('Total releases missing previews that '.$couldbe.'reset for reprocessing= '.number_format($counterfixed));