mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:01:24 +00:00
Move colorcli class to helpers
This commit is contained in:
@@ -3,11 +3,11 @@
|
||||
require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
|
||||
|
||||
use App\Models\Category;
|
||||
use Blacklight\ColorCLI;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
$consoletools = new ColorCLI;
|
||||
$colorCli = new ColorCLI;
|
||||
|
||||
|
||||
$ran = false;
|
||||
|
||||
if (isset($argv[1]) && $argv[1] === 'all' && isset($argv[2]) && $argv[2] === 'true') {
|
||||
@@ -29,7 +29,7 @@ if (isset($argv[1]) && $argv[1] === 'all' && isset($argv[2]) && $argv[2] === 'tr
|
||||
DB::select('TRUNCATE TABLE tv_episodes');
|
||||
DB::select('TRUNCATE TABLE anidb_info');
|
||||
}
|
||||
$colorCli->header('Resetting all postprocessing');
|
||||
cli()->header('Resetting all postprocessing');
|
||||
$qry = DB::select('SELECT id FROM releases');
|
||||
$affected = 0;
|
||||
$total = \count($qry);
|
||||
@@ -45,7 +45,7 @@ if (isset($argv[1]) && $argv[1] === 'all' && isset($argv[2]) && $argv[2] === 'tr
|
||||
$releases->id
|
||||
)
|
||||
);
|
||||
$consoletools->overWritePrimary('Resetting Releases: '.$consoletools->percentString(++$affected, $total));
|
||||
cli()->overWritePrimary('Resetting Releases: '.cli()->percentString(++$affected, $total));
|
||||
}
|
||||
}
|
||||
if (isset($argv[1]) && ($argv[1] === 'consoles' || $argv[1] === 'all')) {
|
||||
@@ -54,10 +54,10 @@ if (isset($argv[1]) && ($argv[1] === 'consoles' || $argv[1] === 'all')) {
|
||||
DB::select('TRUNCATE TABLE consoleinfo');
|
||||
}
|
||||
if (isset($argv[2]) && $argv[2] === 'true') {
|
||||
$colorCli->header('Resetting all Console postprocessing');
|
||||
cli()->header('Resetting all Console postprocessing');
|
||||
$where = ' WHERE consoleinfo_id IS NOT NULL AND categories_id BETWEEN '.Category::GAME_ROOT.' AND '.Category::GAME_OTHER;
|
||||
} else {
|
||||
$colorCli->header('Resetting all failed Console postprocessing');
|
||||
cli()->header('Resetting all failed Console postprocessing');
|
||||
$where = ' WHERE consoleinfo_id IN (-2, 0) AND categories_id BETWEEN '.Category::GAME_ROOT.' AND '.Category::GAME_OTHER;
|
||||
}
|
||||
|
||||
@@ -70,9 +70,9 @@ if (isset($argv[1]) && ($argv[1] === 'consoles' || $argv[1] === 'all')) {
|
||||
$concount = 0;
|
||||
foreach ($qry as $releases) {
|
||||
DB::update('UPDATE releases SET consoleinfo_id = NULL WHERE id = '.$releases->id);
|
||||
$consoletools->overWritePrimary('Resetting Console Releases: '.$consoletools->percentString(++$concount, $total));
|
||||
cli()->overWritePrimary('Resetting Console Releases: '.cli()->percentString(++$concount, $total));
|
||||
}
|
||||
$colorCli->header(PHP_EOL.number_format($concount).' consoleinfoIDs reset.');
|
||||
cli()->header(PHP_EOL.number_format($concount).' consoleinfoIDs reset.');
|
||||
}
|
||||
if (isset($argv[1]) && ($argv[1] === 'games' || $argv[1] === 'all')) {
|
||||
$ran = true;
|
||||
@@ -80,10 +80,10 @@ if (isset($argv[1]) && ($argv[1] === 'games' || $argv[1] === 'all')) {
|
||||
DB::select('TRUNCATE TABLE gamesinfo');
|
||||
}
|
||||
if (isset($argv[2]) && $argv[2] === 'true') {
|
||||
$colorCli->header('Resetting all Games postprocessing');
|
||||
cli()->header('Resetting all Games postprocessing');
|
||||
$where = ' WHERE gamesinfo_id != 0 AND categories_id = 4050';
|
||||
} else {
|
||||
$colorCli->header('Resetting all failed Games postprocessing');
|
||||
cli()->header('Resetting all failed Games postprocessing');
|
||||
$where = ' WHERE gamesinfo_id IN (-2, 0) AND categories_id = 4050';
|
||||
}
|
||||
|
||||
@@ -97,9 +97,9 @@ if (isset($argv[1]) && ($argv[1] === 'games' || $argv[1] === 'all')) {
|
||||
$concount = 0;
|
||||
foreach ($qry as $releases) {
|
||||
DB::update('UPDATE releases SET gamesinfo_id = 0 WHERE id = '.$releases->id);
|
||||
$consoletools->overWritePrimary('Resetting Games Releases: '.$consoletools->percentString(++$concount, $total));
|
||||
cli()->overWritePrimary('Resetting Games Releases: '.cli()->percentString(++$concount, $total));
|
||||
}
|
||||
$colorCli->header(PHP_EOL.number_format($concount).' gameinfo_IDs reset.');
|
||||
cli()->header(PHP_EOL.number_format($concount).' gameinfo_IDs reset.');
|
||||
}
|
||||
if (isset($argv[1]) && ($argv[1] === 'movies' || $argv[1] === 'all')) {
|
||||
$ran = true;
|
||||
@@ -107,10 +107,10 @@ if (isset($argv[1]) && ($argv[1] === 'movies' || $argv[1] === 'all')) {
|
||||
DB::select('TRUNCATE TABLE movieinfo');
|
||||
}
|
||||
if (isset($argv[2]) && $argv[2] === 'true') {
|
||||
$colorCli->header('Resetting all Movie postprocessing');
|
||||
cli()->header('Resetting all Movie postprocessing');
|
||||
$where = ' WHERE imdbid IS NOT NULL AND categories_id BETWEEN '.Category::MOVIE_ROOT.' AND '.Category::MOVIE_OTHER;
|
||||
} else {
|
||||
$colorCli->header('Resetting all failed Movie postprocessing');
|
||||
cli()->header('Resetting all failed Movie postprocessing');
|
||||
$where = ' WHERE imdbid IN (-2, 0) AND categories_id BETWEEN '.Category::MOVIE_ROOT.' AND '.Category::MOVIE_OTHER;
|
||||
}
|
||||
|
||||
@@ -123,9 +123,9 @@ if (isset($argv[1]) && ($argv[1] === 'movies' || $argv[1] === 'all')) {
|
||||
$concount = 0;
|
||||
foreach ($qry as $releases) {
|
||||
DB::update('UPDATE releases SET imdbid = NULL WHERE id = '.$releases->id);
|
||||
$consoletools->overWritePrimary('Resetting Movie Releases: '.$consoletools->percentString(++$concount, $total));
|
||||
cli()->overWritePrimary('Resetting Movie Releases: '.cli()->percentString(++$concount, $total));
|
||||
}
|
||||
$colorCli->header(PHP_EOL.number_format($concount).' imdbIDs reset.');
|
||||
cli()->header(PHP_EOL.number_format($concount).' imdbIDs reset.');
|
||||
}
|
||||
if (isset($argv[1]) && ($argv[1] === 'music' || $argv[1] === 'all')) {
|
||||
$ran = true;
|
||||
@@ -133,10 +133,10 @@ if (isset($argv[1]) && ($argv[1] === 'music' || $argv[1] === 'all')) {
|
||||
DB::select('TRUNCATE TABLE musicinfo');
|
||||
}
|
||||
if (isset($argv[2]) && $argv[2] === 'true') {
|
||||
$colorCli->header('Resetting all Music postprocessing');
|
||||
cli()->header('Resetting all Music postprocessing');
|
||||
$where = ' WHERE musicinfo_id IS NOT NULL AND categories_id BETWEEN '.Category::MUSIC_ROOT.' AND '.Category::MUSIC_OTHER;
|
||||
} else {
|
||||
$colorCli->header('Resetting all failed Music postprocessing');
|
||||
cli()->header('Resetting all failed Music postprocessing');
|
||||
$where = ' WHERE musicinfo_id IN (-2, 0) AND categories_id BETWEEN '.Category::MUSIC_ROOT.' AND '.Category::MUSIC_OTHER;
|
||||
}
|
||||
|
||||
@@ -145,23 +145,23 @@ if (isset($argv[1]) && ($argv[1] === 'music' || $argv[1] === 'all')) {
|
||||
$concount = 0;
|
||||
foreach ($qry as $releases) {
|
||||
DB::update(sprintf('UPDATE releases SET musicinfo_id = NULL WHERE id = %s ', $releases->id));
|
||||
$consoletools->overWritePrimary('Resetting Music Releases: '.$consoletools->percentString(++$concount, $total));
|
||||
cli()->overWritePrimary('Resetting Music Releases: '.cli()->percentString(++$concount, $total));
|
||||
}
|
||||
$colorCli->header(PHP_EOL.number_format($concount).' musicinfo_ids reset.');
|
||||
cli()->header(PHP_EOL.number_format($concount).' musicinfo_ids reset.');
|
||||
}
|
||||
if (isset($argv[1]) && ($argv[1] === 'misc' || $argv[1] === 'all')) {
|
||||
$ran = true;
|
||||
if (isset($argv[2]) && $argv[2] === 'true') {
|
||||
$colorCli->header('Resetting all Additional postprocessing');
|
||||
cli()->header('Resetting all Additional postprocessing');
|
||||
$where = ' WHERE ((haspreview != -1 AND haspreview != 0) OR (passwordstatus != -1 AND passwordstatus != 0) OR jpgstatus != 0 OR videostatus != 0 OR audiostatus != 0)';
|
||||
} else {
|
||||
$colorCli->header('Resetting all failed Additional postprocessing');
|
||||
cli()->header('Resetting all failed Additional postprocessing');
|
||||
$where = ' WHERE ((haspreview < -1 OR haspreview = 0) OR (passwordstatus < -1 OR passwordstatus = 0) OR jpgstatus < 0 OR videostatus < 0 OR audiostatus < 0)';
|
||||
}
|
||||
|
||||
$where .= ' AND categories_id IN ('.Category::OTHER_MISC.','.Category::OTHER_HASHED.')';
|
||||
|
||||
$colorCli->primary('SELECT id FROM releases'.$where);
|
||||
cli()->primary('SELECT id FROM releases'.$where);
|
||||
$qry = DB::select('SELECT id FROM releases'.$where);
|
||||
if (! empty($qry)) {
|
||||
$total = \count($qry);
|
||||
@@ -171,9 +171,9 @@ if (isset($argv[1]) && ($argv[1] === 'misc' || $argv[1] === 'all')) {
|
||||
$concount = 0;
|
||||
foreach ($qry as $releases) {
|
||||
DB::update('UPDATE releases SET passwordstatus = -1, haspreview = -1, jpgstatus = 0, videostatus = 0, audiostatus = 0 WHERE id = '.$releases->id);
|
||||
$consoletools->overWritePrimary('Resetting Releases: '.$consoletools->percentString(++$concount, $total));
|
||||
cli()->overWritePrimary('Resetting Releases: '.cli()->percentString(++$concount, $total));
|
||||
}
|
||||
$colorCli->header(PHP_EOL.number_format($concount).' Releases reset.');
|
||||
cli()->header(PHP_EOL.number_format($concount).' Releases reset.');
|
||||
}
|
||||
if (isset($argv[1]) && ($argv[1] === 'tv' || $argv[1] === 'all')) {
|
||||
$ran = true;
|
||||
@@ -183,10 +183,10 @@ if (isset($argv[1]) && ($argv[1] === 'tv' || $argv[1] === 'all')) {
|
||||
DB::select('TRUNCATE TABLE tv_episodes');
|
||||
}
|
||||
if (isset($argv[2]) && $argv[2] === 'true') {
|
||||
$colorCli->header('Resetting all TV postprocessing');
|
||||
cli()->header('Resetting all TV postprocessing');
|
||||
$where = ' WHERE videos_id != 0 AND tv_episodes_id != 0 AND categories_id BETWEEN '.Category::TV_ROOT.' AND '.Category::TV_OTHER;
|
||||
} else {
|
||||
$colorCli->header('Resetting all failed TV postprocessing');
|
||||
cli()->header('Resetting all failed TV postprocessing');
|
||||
$where = ' WHERE tv_episodes_id < 0 AND categories_id BETWEEN '.Category::TV_ROOT.' AND '.Category::TV_OTHER;
|
||||
}
|
||||
|
||||
@@ -199,9 +199,9 @@ if (isset($argv[1]) && ($argv[1] === 'tv' || $argv[1] === 'all')) {
|
||||
$concount = 0;
|
||||
foreach ($qry as $releases) {
|
||||
DB::update('UPDATE releases SET videos_id = 0, tv_episodes_id = 0 WHERE id = '.$releases->id);
|
||||
$consoletools->overWritePrimary('Resetting TV Releases: '.$consoletools->percentString(++$concount, $total));
|
||||
cli()->overWritePrimary('Resetting TV Releases: '.cli()->percentString(++$concount, $total));
|
||||
}
|
||||
$colorCli->header(PHP_EOL.number_format($concount).' Video IDs reset.');
|
||||
cli()->header(PHP_EOL.number_format($concount).' Video IDs reset.');
|
||||
}
|
||||
if (isset($argv[1]) && ($argv[1] === 'anime' || $argv[1] === 'all')) {
|
||||
$ran = true;
|
||||
@@ -209,10 +209,10 @@ if (isset($argv[1]) && ($argv[1] === 'anime' || $argv[1] === 'all')) {
|
||||
DB::select('TRUNCATE TABLE anidb_info');
|
||||
}
|
||||
if (isset($argv[2]) && $argv[2] === 'true') {
|
||||
$colorCli->header('Resetting all Anime postprocessing');
|
||||
cli()->header('Resetting all Anime postprocessing');
|
||||
$where = ' WHERE categories_id = '.Category::TV_ANIME;
|
||||
} else {
|
||||
$colorCli->header('Resetting all failed Anime postprocessing');
|
||||
cli()->header('Resetting all failed Anime postprocessing');
|
||||
$where = ' WHERE anidbid BETWEEN -2 AND -1 AND categories_id = '.Category::TV_ANIME;
|
||||
}
|
||||
|
||||
@@ -225,9 +225,9 @@ if (isset($argv[1]) && ($argv[1] === 'anime' || $argv[1] === 'all')) {
|
||||
$concount = 0;
|
||||
foreach ($qry as $releases) {
|
||||
DB::update('UPDATE releases SET anidbid = NULL WHERE id = '.$releases->id);
|
||||
$consoletools->overWritePrimary('Resetting Anime Releases: '.$consoletools->percentString(++$concount, $total));
|
||||
cli()->overWritePrimary('Resetting Anime Releases: '.cli()->percentString(++$concount, $total));
|
||||
}
|
||||
$colorCli->header(PHP_EOL.number_format($concount).' anidbIDs reset.');
|
||||
cli()->header(PHP_EOL.number_format($concount).' anidbIDs reset.');
|
||||
}
|
||||
if (isset($argv[1]) && ($argv[1] === 'books' || $argv[1] === 'all')) {
|
||||
$ran = true;
|
||||
@@ -235,10 +235,10 @@ if (isset($argv[1]) && ($argv[1] === 'books' || $argv[1] === 'all')) {
|
||||
DB::select('TRUNCATE TABLE bookinfo');
|
||||
}
|
||||
if (isset($argv[2]) && $argv[2] === 'true') {
|
||||
$colorCli->header('Resetting all Book postprocessing');
|
||||
cli()->header('Resetting all Book postprocessing');
|
||||
$where = ' WHERE bookinfo_id IS NOT NULL AND categories_id BETWEEN '.Category::BOOKS_ROOT.' AND '.Category::BOOKS_UNKNOWN;
|
||||
} else {
|
||||
$colorCli->header('Resetting all failed Book postprocessing');
|
||||
cli()->header('Resetting all failed Book postprocessing');
|
||||
$where = ' WHERE bookinfo_id IN (-2, 0) AND categories_id BETWEEN '.Category::BOOKS_ROOT.' AND '.Category::BOOKS_UNKNOWN;
|
||||
}
|
||||
|
||||
@@ -247,9 +247,9 @@ if (isset($argv[1]) && ($argv[1] === 'books' || $argv[1] === 'all')) {
|
||||
$concount = 0;
|
||||
foreach ($qry as $releases) {
|
||||
DB::update('UPDATE releases SET bookinfo_id = NULL WHERE id = '.$releases->id);
|
||||
$consoletools->overWritePrimary('Resetting Book Releases: '.$consoletools->percentString(++$concount, $total));
|
||||
cli()->overWritePrimary('Resetting Book Releases: '.cli()->percentString(++$concount, $total));
|
||||
}
|
||||
$colorCli->header(PHP_EOL.number_format($concount).' bookinfoIDs reset.');
|
||||
cli()->header(PHP_EOL.number_format($concount).' bookinfoIDs reset.');
|
||||
}
|
||||
if (isset($argv[1]) && ($argv[1] === 'xxx' || $argv[1] === 'all')) {
|
||||
$ran = true;
|
||||
@@ -257,10 +257,10 @@ if (isset($argv[1]) && ($argv[1] === 'xxx' || $argv[1] === 'all')) {
|
||||
DB::select('TRUNCATE TABLE xxxinfo');
|
||||
}
|
||||
if (isset($argv[2]) && $argv[2] === 'true') {
|
||||
$colorCli->header('Resetting all XXX postprocessing');
|
||||
cli()->header('Resetting all XXX postprocessing');
|
||||
$where = ' WHERE xxxinfo_id != 0 AND categories_id BETWEEN '.Category::XXX_ROOT.' AND '.Category::XXX_X264;
|
||||
} else {
|
||||
$colorCli->header('Resetting all failed XXX postprocessing');
|
||||
cli()->header('Resetting all failed XXX postprocessing');
|
||||
$where = ' WHERE xxxinfo_id IN (-2, 0) AND categories_id BETWEEN '.Category::XXX_ROOT.' AND '.Category::XXX_X264;
|
||||
}
|
||||
|
||||
@@ -269,12 +269,12 @@ if (isset($argv[1]) && ($argv[1] === 'xxx' || $argv[1] === 'all')) {
|
||||
$total = \count($qry);
|
||||
foreach ($qry as $releases) {
|
||||
DB::update('UPDATE releases SET xxxinfo_id = 0 WHERE id = '.$releases->id);
|
||||
$consoletools->overWritePrimary('Resetting XXX Releases: '.$consoletools->percentString(
|
||||
cli()->overWritePrimary('Resetting XXX Releases: '.cli()->percentString(
|
||||
++$concount,
|
||||
$total
|
||||
));
|
||||
}
|
||||
$colorCli->header(PHP_EOL.number_format($concount).' xxxinfo_IDs reset.');
|
||||
cli()->header(PHP_EOL.number_format($concount).' xxxinfo_IDs reset.');
|
||||
}
|
||||
if (isset($argv[1]) && ($argv[1] === 'nfos' || $argv[1] === 'all')) {
|
||||
$ran = true;
|
||||
@@ -282,10 +282,10 @@ if (isset($argv[1]) && ($argv[1] === 'nfos' || $argv[1] === 'all')) {
|
||||
DB::select('TRUNCATE TABLE release_nfos');
|
||||
}
|
||||
if (isset($argv[2]) && $argv[2] === 'true') {
|
||||
$colorCli->header('Resetting all NFO postprocessing');
|
||||
cli()->header('Resetting all NFO postprocessing');
|
||||
$where = ' WHERE nfostatus != -1';
|
||||
} else {
|
||||
$colorCli->header('Resetting all failed NFO postprocessing');
|
||||
cli()->header('Resetting all failed NFO postprocessing');
|
||||
$where = ' WHERE nfostatus < -1';
|
||||
}
|
||||
|
||||
@@ -294,13 +294,13 @@ if (isset($argv[1]) && ($argv[1] === 'nfos' || $argv[1] === 'all')) {
|
||||
$total = \count($qry);
|
||||
foreach ($qry as $releases) {
|
||||
DB::update('UPDATE releases SET nfostatus = -1 WHERE id = '.$releases->id);
|
||||
$consoletools->overWritePrimary('Resetting NFO Releases: '.$consoletools->percentString(++$concount, $total));
|
||||
cli()->overWritePrimary('Resetting NFO Releases: '.cli()->percentString(++$concount, $total));
|
||||
}
|
||||
$colorCli->header(PHP_EOL.number_format($concount).' NFOs reset.');
|
||||
cli()->header(PHP_EOL.number_format($concount).' NFOs reset.');
|
||||
}
|
||||
|
||||
if ($ran === false) {
|
||||
$colorCli->error(
|
||||
cli()->error(
|
||||
'This script will reset postprocessing per category.'.PHP_EOL
|
||||
.'It can also truncate the associated tables.'.PHP_EOL
|
||||
.'To reset only those that have previously failed, those without covers, samples, previews, etc. use the second argument false.'.PHP_EOL
|
||||
|
||||
Reference in New Issue
Block a user