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
-9
View File
@@ -5,22 +5,13 @@
// --------------------------------------------------------------
require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
use App\Models\Settings;
use Blacklight\ColorCLI;
use Blacklight\Movie;
use Blacklight\utility\Utility;
use Illuminate\Support\Facades\DB;
$movie = new Movie(['Echo' => true]);
$colorCli = new ColorCLI();
$row = Settings::settingValue('site.main.coverspath');
if ($row !== null) {
Utility::setCoversConstant($row);
} else {
exit('Unable to determine covers path!'.PHP_EOL);
}
$path2cover = storage_path('covers/movies/');
if (isset($argv[1]) && ($argv[1] === 'true' || $argv[1] === 'check')) {
+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));
@@ -3,10 +3,7 @@
require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
use App\Models\GamesInfo;
use App\Models\Settings;
use Blacklight\ColorCLI;
use Blacklight\utility\Utility;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\File;
$covers = $updated = $deleted = 0;
@@ -17,14 +14,6 @@ if ($argc === 1 || $argv[1] !== 'true') {
exit();
}
$pdo = DB::connection()->getPdo();
$row = Settings::settingValue('site.main.coverspath');
if ($row !== null) {
Utility::setCoversConstant($row);
} else {
exit("Unable to set Covers' constant!\n");
}
$path2covers = storage_path('covers/games/');
$itr = File::allFiles($path2covers);
+6 -14
View File
@@ -3,9 +3,7 @@
require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
use App\Models\MovieInfo;
use App\Models\Settings;
use Blacklight\ColorCLI;
use Blacklight\utility\Utility;
use Illuminate\Support\Facades\File;
$covers = $updated = $deleted = 0;
@@ -16,12 +14,6 @@ if ($argc === 1 || $argv[1] !== 'true') {
exit();
}
$row = Settings::settingValue('site.main.coverspath');
if ($row !== null) {
Utility::setCoversConstant($row);
} else {
exit("Unable to set Covers' constant!\n");
}
$path2covers = storage_path('covers/movies');
$itr = File::allFiles($path2covers);
@@ -35,7 +27,7 @@ foreach ($itr as $filePath) {
} else {
$run = MovieInfo::query()->where('imdbid', '=', $hit[1])->select(['imdbid'])->get();
if ($run->count() === 0) {
$colorCli->info($filePath.' not found in db.');
$colorCli->climate()->error($filePath.' not found in db.');
}
}
}
@@ -49,7 +41,7 @@ foreach ($itr as $filePath) {
} else {
$run = MovieInfo::query()->where('imdbid', $match1[1])->select(['imdbid'])->get();
if ($run->count() === 0) {
$colorCli->info($filePath->getPathname().' not found in db.');
$colorCli->climate()->error($filePath->getPathname().' not found in db.');
}
}
}
@@ -68,10 +60,10 @@ $qry1 = MovieInfo::query()->where('backdrop', '=', 1)->select(['imdbid'])->get()
foreach ($qry1 as $rows) {
if (! is_file($path2covers.$rows['imdbid'].'-backdrop.jpg')) {
MovieInfo::query()->where('backdrop', '=', 1)->where('imdbid', $rows['imdbid'])->update(['backdrop' => 0]);
$colorCli->info($path2covers.$rows['imdbid'].'-backdrop.jpg does not exist.');
$colorCli->climate()->info($path2covers.$rows['imdbid'].'-backdrop.jpg does not exist.');
$deleted++;
}
}
$colorCli->header($covers.' covers set.');
$colorCli->header($updated.' backdrops set.');
$colorCli->header($deleted.' movies unset.');
$colorCli->climate()->info($covers.' covers set.');
$colorCli->climate()->info($updated.' backdrops set.');
$colorCli->climate()->info($deleted.' movies unset.');