diff --git a/Blacklight/ColorCLI.php b/Blacklight/ColorCLI.php
deleted file mode 100755
index 623e83529..000000000
--- a/Blacklight/ColorCLI.php
+++ /dev/null
@@ -1,279 +0,0 @@
-');
- }
- render("
{$str}
");
- }
-
- public function info(string $str, bool $newline = false): void
- {
- if ($newline) {
- render('
');
- }
- render("{$str}
");
- }
-
- public function notice(string $str, bool $newline = false): void
- {
- if ($newline) {
- render('
');
- }
- render("{$str}
");
- }
-
- public function warning(string $str, bool $newline = false): void
- {
- if ($newline) {
- render('
');
- }
- render("{$str}
");
- }
-
- public function error(string $str, bool $newline = false): void
- {
- if ($newline) {
- render('
');
- }
- render("{$str}
");
- }
-
- public function primary(string $str, bool $newline = false): void
- {
- if ($newline) {
- render('
');
- }
- render("{$str}
");
- }
-
- public function header(string $str, bool $newline = false): void
- {
- if ($newline) {
- render('
');
- }
- render("{$str}
");
- }
-
- public function alternate(string $str, bool $newline = false): void
- {
- if ($newline) {
- render('
');
- }
- render("{$str}
");
- }
-
- public function tmuxOrange(string $str, bool $newline = false): void
- {
- if ($newline) {
- render('
');
- }
- render("{$str}
");
- }
-
- public function primaryOver(string $str): void
- {
- echo "\033[32m{$str}\033[0m";
- }
-
- public function headerOver(string $str): void
- {
- echo "\033[33m{$str}\033[0m";
- }
-
- public function alternateOver(string $str): void
- {
- echo "\033[1;35m{$str}\033[0m";
- }
-
- public function warningOver(string $str): void
- {
- echo "\033[31m{$str}\033[0m";
- }
-
- public function progress(): object
- {
- return new class
- {
- private int $total = 0;
-
- private int $current = 0;
-
- private string $label = '';
-
- public function total(int $total): self
- {
- $this->total = $total;
-
- return $this;
- }
-
- public function current(int $current, ?string $label = null): void
- {
- $this->current = $current;
- if ($label !== null) {
- $this->label = $label;
- }
- $this->display();
- }
-
- public function advance(int $step = 1, ?string $label = null): void
- {
- $this->current += $step;
- if ($label !== null) {
- $this->label = $label;
- }
- $this->display();
- }
-
- private function display(): void
- {
- $percentage = $this->total > 0 ? (int) (($this->current / $this->total) * 100) : 0;
- $bar = str_repeat('=', (int) ($percentage / 2));
- $spaces = str_repeat(' ', 50 - (int) ($percentage / 2));
- $label = $this->label ? " {$this->label}" : '';
- echo "\r[{$bar}{$spaces}] {$percentage}%{$label}";
- if ($this->current >= $this->total) {
- echo "\n";
- }
- }
- };
- }
-
- /**
- * Apply ANSI color code to a string and return it (does not render)
- *
- * @param string $string The string to colorize
- * @param string $color The color name
- * @return string The colored string with ANSI codes
- */
- public function ansiString(string $string, string $color): string
- {
- $colors = [
- 'black' => '0;30',
- 'red' => '0;31',
- 'green' => '0;32',
- 'yellow' => '0;33',
- 'blue' => '0;34',
- 'magenta' => '0;35',
- 'cyan' => '0;36',
- 'white' => '0;37',
- ];
-
- $code = $colors[$color] ?? '0;37';
-
- return "\033[{$code}m{$string}\033[0m";
- }
-
- public function overWriteHeader(string $message, bool $reset = false): void
- {
- if ($reset) {
- $this->lastMessageLength = 0;
- }
-
- echo str_repeat(\chr(8), $this->lastMessageLength);
- echo str_repeat(' ', $this->lastMessageLength);
- echo str_repeat(\chr(8), $this->lastMessageLength);
-
- $this->lastMessageLength = \strlen($message);
- $this->headerOver($message);
- }
-
- public function overWritePrimary(string $message, bool $reset = false): void
- {
- if ($reset) {
- $this->lastMessageLength = 0;
- }
-
- echo str_repeat(\chr(8), $this->lastMessageLength);
- echo str_repeat(' ', $this->lastMessageLength);
- echo str_repeat(\chr(8), $this->lastMessageLength);
-
- $this->lastMessageLength = \strlen($message);
- $this->primaryOver($message);
- }
-
- public function overWrite(string $message, bool $reset = false): void
- {
- if ($reset) {
- $this->lastMessageLength = 0;
- }
-
- echo str_repeat(\chr(8), $this->lastMessageLength);
- echo str_repeat(' ', $this->lastMessageLength);
- echo str_repeat(\chr(8), $this->lastMessageLength);
-
- $this->lastMessageLength = \strlen($message);
- echo $message;
- }
-
- public function appendWrite(string $message): void
- {
- echo $message;
- $this->lastMessageLength += \strlen($message);
- }
-
- public function percentString(int $cur, int $total): string
- {
- $percent = 100 * $cur / $total;
- $formatString = '% '.\strlen($total).'d/%d (% 2d%%)';
-
- return sprintf($formatString, $cur, $total, $percent);
- }
-
- public function percentString2(int $first, int $last, int $total): string
- {
- $percent1 = 100 * ($first - 1) / $total;
- $percent2 = 100 * $last / $total;
- $formatString = '% '.\strlen($total).'d-% '.\strlen($total).'d/%d (% 2d%%-% 3d%%)';
-
- return sprintf($formatString, $first, $last, $total, $percent1, $percent2);
- }
-
- /**
- * Convert seconds to minutes or hours, appending type at the end.
- */
- public function convertTime(int $seconds): string
- {
- if ($seconds > 3600) {
- return round($seconds / 3600).' hour(s)';
- }
- if ($seconds > 60) {
- return round($seconds / 60).' minute(s)';
- }
-
- return $seconds.' second(s)';
- }
-
- /**
- * Convert seconds to a timer, 00h:00m:00s.
- */
- public function convertTimer(int $seconds): string
- {
- return ' '.sprintf('%02dh:%02dm:%02ds', floor($seconds / 3600), floor(($seconds / 60) % 60), $seconds % 60);
- }
-
- /**
- * Sleep for x seconds, printing timer on screen.
- */
- public function showSleep(int $seconds): void
- {
- for ($i = $seconds; $i >= 0; $i--) {
- $this->overWriteHeader('Sleeping for '.$i.' seconds.');
- sleep(1);
- }
- echo PHP_EOL;
- }
-}
diff --git a/Blacklight/Music.php b/Blacklight/Music.php
index d94091b8b..d721da547 100755
--- a/Blacklight/Music.php
+++ b/Blacklight/Music.php
@@ -65,16 +65,10 @@ class Music
*/
public $failCache;
- /**
- * @var ColorCLI
- */
- protected $colorCli;
-
public function __construct()
{
$this->echooutput = config('nntmux.echocli');
- $this->colorCli = new ColorCLI;
$this->pubkey = Settings::settingValue('amazonpubkey');
$this->privkey = Settings::settingValue('amazonprivkey');
@@ -355,7 +349,7 @@ class Music
if ($musicId) {
if ($this->echooutput) {
- $this->colorCli->header(
+ cli()->header(
PHP_EOL.'Added/updated album: '.PHP_EOL.
' Artist: '.
$mus['artist'].PHP_EOL.
@@ -373,7 +367,7 @@ class Music
$artist = 'Artist: '.$mus['artist'].', Album: ';
}
- $this->colorCli->headerOver(
+ cli()->headerOver(
'Nothing to update: '.
$artist.
$mus['title'].
@@ -418,7 +412,7 @@ class Music
$newname = $album['name'].' ('.$album['year'].')';
if ($this->echooutput) {
- $this->colorCli->info('Looking up: '.$newname);
+ cli()->info('Looking up: '.$newname);
}
// Do a local lookup first
@@ -427,7 +421,7 @@ class Music
if ($musicCheck === null && \in_array($album['name'].$album['year'], $this->failCache, false)) {
// Lookup recently failed, no point trying again
if ($this->echooutput) {
- $this->colorCli->headerOver('Cached previous failure. Skipping.');
+ cli()->headerOver('Cached previous failure. Skipping.');
}
$albumId = -2;
} elseif ($musicCheck === null && $local === false) {
@@ -459,7 +453,7 @@ class Music
echo PHP_EOL;
}
} elseif ($this->echooutput) {
- $this->colorCli->header('No music releases to process.');
+ cli()->header('No music releases to process.');
}
}
diff --git a/Blacklight/Nfo.php b/Blacklight/Nfo.php
index b891516f3..69f349b43 100755
--- a/Blacklight/Nfo.php
+++ b/Blacklight/Nfo.php
@@ -139,8 +139,6 @@ class Nfo
public const NFO_FOUND = 1; // Release has an NFO.
- protected ColorCLI $colorCli;
-
/**
* Default constructor.
*
@@ -151,7 +149,6 @@ class Nfo
public function __construct()
{
$this->echo = (bool) config('nntmux.echocli');
- $this->colorCli = new ColorCLI();
// Cache settings to reduce database queries
// Note: Cast after Cache::remember as cached values may be stored as strings
@@ -558,13 +555,13 @@ class Nfo
} catch (\Exception $e) {
DB::rollBack();
if ($this->echo) {
- $this->colorCli->error("Error saving NFO for release {$release['id']}: {$e->getMessage()}");
+ cli()->error("Error saving NFO for release {$release['id']}: {$e->getMessage()}");
}
}
}
} catch (\Exception $e) {
if ($this->echo) {
- $this->colorCli->error("Error processing release {$release['id']}: {$e->getMessage()}");
+ cli()->error("Error processing release {$release['id']}: {$e->getMessage()}");
}
}
}
@@ -579,7 +576,7 @@ class Nfo
echo PHP_EOL;
}
if ($processedCount > 0) {
- $this->colorCli->primary($processedCount.' NFO file(s) found/processed.');
+ cli()->primary($processedCount.' NFO file(s) found/processed.');
}
}
@@ -618,7 +615,7 @@ class Nfo
*/
private function displayProcessingHeader(string $guidChar, string $groupID, int $nfoCount): void
{
- $this->colorCli->primary(
+ cli()->primary(
PHP_EOL.
($guidChar === '' ? '' : '['.$guidChar.'] ').
($groupID === '' ? '' : '['.$groupID.'] ').
@@ -644,7 +641,7 @@ class Nfo
foreach ($nfoStats as $row) {
$outString .= ', '.$row['status'].' = '.number_format($row['count']);
}
- $this->colorCli->header($outString.'.');
+ cli()->header($outString.'.');
}
}
@@ -680,7 +677,7 @@ class Nfo
} catch (\Exception $e) {
DB::rollBack();
if ($this->echo) {
- $this->colorCli->error("Error handling failed NFO attempts: {$e->getMessage()}");
+ cli()->error("Error handling failed NFO attempts: {$e->getMessage()}");
}
}
});
diff --git a/app/Console/Commands/ReprocessMissingEpisodes.php b/app/Console/Commands/ReprocessMissingEpisodes.php
index 8c6b26cc5..5a32f2bdf 100644
--- a/app/Console/Commands/ReprocessMissingEpisodes.php
+++ b/app/Console/Commands/ReprocessMissingEpisodes.php
@@ -5,7 +5,6 @@ namespace App\Console\Commands;
use App\Models\Category;
use App\Models\Release;
use App\Services\TvProcessing\TvProcessingPipeline;
-use Blacklight\ColorCLI;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
@@ -34,12 +33,9 @@ class ReprocessMissingEpisodes extends Command
*/
protected $description = 'Reprocess TV releases with matched shows but missing episode matches (videos_id > 0, tv_episodes_id = 0)';
- protected ColorCLI $colorCli;
-
public function __construct()
{
parent::__construct();
- $this->colorCli = new ColorCLI();
}
/**
@@ -137,7 +133,7 @@ class ReprocessMissingEpisodes extends Command
$matched++;
if ($debug) {
$this->newLine();
- $this->colorCli->primary("Episode matched: {$release->searchname}");
+ cli()->primary("Episode matched: {$release->searchname}");
$this->info(' Provider: ' . ($result['provider'] ?? 'Unknown'));
$this->info(' Video ID: ' . ($result['video_id'] ?? 'N/A'));
$this->info(' Episode ID: ' . ($result['episode_id'] ?? 'N/A'));
@@ -146,7 +142,7 @@ class ReprocessMissingEpisodes extends Command
$failed++;
if ($debug) {
$this->newLine();
- $this->colorCli->warning("Episode not found: {$release->searchname}");
+ cli()->warning("Episode not found: {$release->searchname}");
}
}
} catch (\Throwable $e) {
diff --git a/app/Console/Commands/ReprocessTvRelease.php b/app/Console/Commands/ReprocessTvRelease.php
index b8bd63621..da6f6a759 100644
--- a/app/Console/Commands/ReprocessTvRelease.php
+++ b/app/Console/Commands/ReprocessTvRelease.php
@@ -4,7 +4,6 @@ namespace App\Console\Commands;
use App\Models\Release;
use App\Services\TvProcessing\TvProcessingPipeline;
-use Blacklight\ColorCLI;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
@@ -27,12 +26,9 @@ class ReprocessTvRelease extends Command
*/
protected $description = 'Reprocess a specific TV release by GUID to rematch it against TV databases';
- protected ColorCLI $colorCli;
-
public function __construct()
{
parent::__construct();
- $this->colorCli = new ColorCLI();
}
/**
@@ -84,12 +80,12 @@ class ReprocessTvRelease extends Command
$this->newLine();
if ($result['matched']) {
- $this->colorCli->primary('Successfully matched!');
+ cli()->primary('Successfully matched!');
$this->info('Provider: ' . ($result['provider'] ?? 'Unknown'));
$this->info('Video ID: ' . ($result['video_id'] ?? 'N/A'));
$this->info('Episode ID: ' . ($result['episode_id'] ?? 'N/A'));
} else {
- $this->colorCli->warning('No match found.');
+ cli()->warning('No match found.');
$this->info('Status: ' . ($result['status'] ?? 'Unknown'));
if (isset($result['provider'])) {
$this->info('Last provider tried: ' . $result['provider']);
diff --git a/app/Console/Commands/ReprocessUnmatchedTvReleases.php b/app/Console/Commands/ReprocessUnmatchedTvReleases.php
index 00b7cb580..ab7461244 100644
--- a/app/Console/Commands/ReprocessUnmatchedTvReleases.php
+++ b/app/Console/Commands/ReprocessUnmatchedTvReleases.php
@@ -5,7 +5,6 @@ namespace App\Console\Commands;
use App\Models\Category;
use App\Models\Release;
use App\Services\TvProcessing\TvProcessingPipeline;
-use Blacklight\ColorCLI;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
@@ -29,12 +28,9 @@ class ReprocessUnmatchedTvReleases extends Command
*/
protected $description = 'Reprocess all TV releases that are not matched to any show in the database (videos_id = 0)';
- protected ColorCLI $colorCli;
-
public function __construct()
{
parent::__construct();
- $this->colorCli = new ColorCLI();
}
/**
@@ -123,7 +119,7 @@ class ReprocessUnmatchedTvReleases extends Command
$matched++;
if ($debug) {
$this->newLine();
- $this->colorCli->primary("Matched: {$release->searchname}");
+ cli()->primary("Matched: {$release->searchname}");
$this->info(' Provider: ' . ($result['provider'] ?? 'Unknown'));
$this->info(' Video ID: ' . ($result['video_id'] ?? 'N/A'));
$this->info(' Episode ID: ' . ($result['episode_id'] ?? 'N/A'));
@@ -132,7 +128,7 @@ class ReprocessUnmatchedTvReleases extends Command
$failed++;
if ($debug) {
$this->newLine();
- $this->colorCli->warning("No match: {$release->searchname}");
+ cli()->warning("No match: {$release->searchname}");
}
}
} catch (\Throwable $e) {
diff --git a/app/Console/Commands/TmuxMonitor.php b/app/Console/Commands/TmuxMonitor.php
index 13e38cd80..76bed7fdb 100644
--- a/app/Console/Commands/TmuxMonitor.php
+++ b/app/Console/Commands/TmuxMonitor.php
@@ -8,7 +8,6 @@ use App\Services\Tmux\TmuxMonitorService;
use App\Services\Tmux\TmuxSessionManager;
use App\Services\Tmux\TmuxTaskRunner;
use App\Services\Tmux\TmuxOutput;
-use Blacklight\ColorCLI;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
@@ -38,14 +37,11 @@ class TmuxMonitor extends Command
private TmuxOutput $tmuxOutput;
- private ColorCLI $colorCli;
-
/**
* Execute the console command.
*/
public function handle(): int
{
- $this->colorCli = new ColorCLI;
try {
// Reset old collections if requested
@@ -71,7 +67,7 @@ class TmuxMonitor extends Command
return Command::FAILURE;
}
- $this->colorCli->header('Starting Tmux Monitor');
+ cli()->header('Starting Tmux Monitor');
$this->info("📊 Monitoring session: {$sessionName}");
// Initialize monitor
@@ -124,7 +120,7 @@ class TmuxMonitor extends Command
{
$delayTime = (int) (Settings::settingValue('delaytime') ?? 2);
- $this->colorCli->header('Resetting expired collections...');
+ cli()->header('Resetting expired collections...');
try {
DB::transaction(function () use ($delayTime) {
diff --git a/app/Console/Commands/TmuxMonitorCommand.php b/app/Console/Commands/TmuxMonitorCommand.php
index 5358b5b13..d3e300cb1 100644
--- a/app/Console/Commands/TmuxMonitorCommand.php
+++ b/app/Console/Commands/TmuxMonitorCommand.php
@@ -6,7 +6,6 @@ use App\Models\Collection;
use App\Models\Settings;
use App\Services\Tmux\TmuxMonitorService;
use App\Services\Tmux\TmuxTaskRunner;
-use Blacklight\ColorCLI;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
@@ -31,15 +30,11 @@ class TmuxMonitorCommand extends Command
private TmuxTaskRunner $taskRunner;
- private ColorCLI $colorCli;
-
/**
* Execute the console command.
*/
public function handle(): int
{
- $this->colorCli = new ColorCLI;
-
try {
// Reset old collections
$this->resetOldCollections();
@@ -53,7 +48,7 @@ class TmuxMonitorCommand extends Command
// Initialize monitor
$runVar = $this->monitor->initializeMonitor();
- $this->colorCli->header('Starting Tmux Monitor');
+ cli()->header('Starting Tmux Monitor');
$this->info("Monitoring session: {$sessionName}");
// Main monitoring loop
@@ -94,7 +89,7 @@ class TmuxMonitorCommand extends Command
{
$delayTime = Settings::settingValue('delaytime') ?? 2;
- $this->colorCli->header('Resetting expired collections. This may take some time...');
+ cli()->header('Resetting expired collections. This may take some time...');
try {
DB::transaction(function () use ($delayTime) {
diff --git a/app/Console/Commands/TmuxStart.php b/app/Console/Commands/TmuxStart.php
index 9d18e1df9..04d02a2e9 100644
--- a/app/Console/Commands/TmuxStart.php
+++ b/app/Console/Commands/TmuxStart.php
@@ -6,7 +6,6 @@ use App\Models\Collection;
use App\Models\Settings;
use App\Services\Tmux\TmuxLayoutBuilder;
use App\Services\Tmux\TmuxSessionManager;
-use Blacklight\ColorCLI;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
@@ -33,17 +32,13 @@ class TmuxStart extends Command
private TmuxLayoutBuilder $layoutBuilder;
- private ColorCLI $colorCli;
-
/**
* Execute the console command.
*/
public function handle(): int
{
- $this->colorCli = new ColorCLI;
-
try {
- $this->colorCli->header('Starting Tmux Processing');
+ cli()->header('Starting Tmux Processing');
// Get session name
$sessionName = $this->option('session')
diff --git a/app/Console/Commands/TmuxStop.php b/app/Console/Commands/TmuxStop.php
index 5295c0721..a81435db9 100644
--- a/app/Console/Commands/TmuxStop.php
+++ b/app/Console/Commands/TmuxStop.php
@@ -4,7 +4,6 @@ namespace App\Console\Commands;
use App\Models\Settings;
use App\Services\Tmux\TmuxSessionManager;
-use Blacklight\ColorCLI;
use Illuminate\Console\Command;
class TmuxStop extends Command
@@ -27,14 +26,11 @@ class TmuxStop extends Command
private TmuxSessionManager $sessionManager;
- private ColorCLI $colorCli;
-
/**
* Execute the console command.
*/
public function handle(): int
{
- $this->colorCli = new ColorCLI;
try {
// Get session name
@@ -60,7 +56,7 @@ class TmuxStop extends Command
}
}
- $this->colorCli->header('Stopping Tmux Session');
+ cli()->header('Stopping Tmux Session');
// Set running flag to 0
Settings::query()->where('name', 'running')->update(['value' => 0]);
diff --git a/app/Console/Commands/UpdateBinaries.php b/app/Console/Commands/UpdateBinaries.php
index ec9c3b8dc..6d3704c91 100644
--- a/app/Console/Commands/UpdateBinaries.php
+++ b/app/Console/Commands/UpdateBinaries.php
@@ -8,7 +8,6 @@ use App\Models\Settings;
use App\Models\UsenetGroup;
use App\Services\Binaries\BinariesService;
use App\Services\NNTP\NNTPService;
-use Blacklight\ColorCLI;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
@@ -30,8 +29,6 @@ class UpdateBinaries extends Command
*/
protected $description = 'Update binaries for a specific group or all groups';
- private ColorCLI $colorCLI;
-
private bool $echoCLI;
/**
@@ -39,7 +36,6 @@ class UpdateBinaries extends Command
*/
public function handle(): int
{
- $this->colorCLI = new ColorCLI();
$this->echoCLI = (bool) config('nntmux.echocli');
$groupName = $this->argument('group');
@@ -74,7 +70,7 @@ class UpdateBinaries extends Command
return self::SUCCESS;
} catch (\Throwable $e) {
Log::error($e->getMessage());
- $this->colorCLI->error('Error: ' . $e->getMessage());
+ cli()->error('Error: ' . $e->getMessage());
return self::FAILURE;
}
@@ -124,8 +120,8 @@ class UpdateBinaries extends Command
}
echo PHP_EOL;
- $this->colorCLI->header('NNTmux Binary Update');
- $this->colorCLI->info('Started: ' . now()->format('Y-m-d H:i:s'));
+ cli()->header('NNTmux Binary Update');
+ cli()->info('Started: ' . now()->format('Y-m-d H:i:s'));
}
/**
@@ -138,8 +134,8 @@ class UpdateBinaries extends Command
}
echo PHP_EOL;
- $this->colorCLI->header(strtoupper($title));
- $this->colorCLI->header(str_repeat('-', strlen($title)));
+ cli()->header(strtoupper($title));
+ cli()->header(str_repeat('-', strlen($title)));
}
/**
@@ -151,7 +147,7 @@ class UpdateBinaries extends Command
return;
}
- $this->colorCLI->info(" {$message}");
+ cli()->info(" {$message}");
}
/**
@@ -167,9 +163,9 @@ class UpdateBinaries extends Command
$timeStr = $this->formatElapsedTime($elapsed);
echo PHP_EOL;
- $this->colorCLI->header('COMPLETE');
- $this->colorCLI->header('--------');
- $this->colorCLI->info(" Total time: {$timeStr}");
+ cli()->header('COMPLETE');
+ cli()->header('--------');
+ cli()->info(" Total time: {$timeStr}");
echo PHP_EOL;
}
diff --git a/app/Extensions/helper/helpers.php b/app/Extensions/helper/helpers.php
index 4d42647a0..379ded3b4 100644
--- a/app/Extensions/helper/helpers.php
+++ b/app/Extensions/helper/helpers.php
@@ -985,3 +985,290 @@ if (! function_exists('isValidNewznabNzb')) {
return $hasNzbNamespace || $isNzbRoot;
}
}
+
+if (! function_exists('cli')) {
+ /**
+ * Get the CLI helper instance for colored console output.
+ *
+ * This replaces the Blacklight\ColorCLI class with a helper function approach.
+ * Usage: cli()->primary('message'), cli()->error('message'), etc.
+ *
+ * @return object The CLI helper object with all output methods
+ */
+ function cli(): object
+ {
+ static $instance = null;
+
+ if ($instance === null) {
+ $instance = new class
+ {
+ public int $lastMessageLength = 0;
+
+ public function debug(string $str, bool $newline = false): void
+ {
+ if ($newline) {
+ \Termwind\render('
');
+ }
+ \Termwind\render("{$str}
");
+ }
+
+ public function info(string $str, bool $newline = false): void
+ {
+ if ($newline) {
+ \Termwind\render('
');
+ }
+ \Termwind\render("{$str}
");
+ }
+
+ public function notice(string $str, bool $newline = false): void
+ {
+ if ($newline) {
+ \Termwind\render('
');
+ }
+ \Termwind\render("{$str}
");
+ }
+
+ public function warning(string $str, bool $newline = false): void
+ {
+ if ($newline) {
+ \Termwind\render('
');
+ }
+ \Termwind\render("{$str}
");
+ }
+
+ public function error(string $str, bool $newline = false): void
+ {
+ if ($newline) {
+ \Termwind\render('
');
+ }
+ \Termwind\render("{$str}
");
+ }
+
+ public function primary(string $str, bool $newline = false): void
+ {
+ if ($newline) {
+ \Termwind\render('
');
+ }
+ \Termwind\render("{$str}
");
+ }
+
+ public function header(string $str, bool $newline = false): void
+ {
+ if ($newline) {
+ \Termwind\render('
');
+ }
+ \Termwind\render("{$str}
");
+ }
+
+ public function alternate(string $str, bool $newline = false): void
+ {
+ if ($newline) {
+ \Termwind\render('
');
+ }
+ \Termwind\render("{$str}
");
+ }
+
+ public function tmuxOrange(string $str, bool $newline = false): void
+ {
+ if ($newline) {
+ \Termwind\render('
');
+ }
+ \Termwind\render("{$str}
");
+ }
+
+ public function primaryOver(string $str): void
+ {
+ echo "\033[32m{$str}\033[0m";
+ }
+
+ public function headerOver(string $str): void
+ {
+ echo "\033[33m{$str}\033[0m";
+ }
+
+ public function alternateOver(string $str): void
+ {
+ echo "\033[1;35m{$str}\033[0m";
+ }
+
+ public function warningOver(string $str): void
+ {
+ echo "\033[31m{$str}\033[0m";
+ }
+
+ public function progress(): object
+ {
+ return new class
+ {
+ private int $total = 0;
+
+ private int $current = 0;
+
+ private string $label = '';
+
+ public function total(int $total): self
+ {
+ $this->total = $total;
+
+ return $this;
+ }
+
+ public function current(int $current, ?string $label = null): void
+ {
+ $this->current = $current;
+ if ($label !== null) {
+ $this->label = $label;
+ }
+ $this->display();
+ }
+
+ public function advance(int $step = 1, ?string $label = null): void
+ {
+ $this->current += $step;
+ if ($label !== null) {
+ $this->label = $label;
+ }
+ $this->display();
+ }
+
+ private function display(): void
+ {
+ $percentage = $this->total > 0 ? (int) (($this->current / $this->total) * 100) : 0;
+ $bar = str_repeat('=', (int) ($percentage / 2));
+ $spaces = str_repeat(' ', 50 - (int) ($percentage / 2));
+ $label = $this->label ? " {$this->label}" : '';
+ echo "\r[{$bar}{$spaces}] {$percentage}%{$label}";
+ if ($this->current >= $this->total) {
+ echo "\n";
+ }
+ }
+ };
+ }
+
+ /**
+ * Apply ANSI color code to a string and return it (does not render)
+ */
+ public function ansiString(string $string, string $color): string
+ {
+ $colors = [
+ 'black' => '0;30',
+ 'red' => '0;31',
+ 'green' => '0;32',
+ 'yellow' => '0;33',
+ 'blue' => '0;34',
+ 'magenta' => '0;35',
+ 'cyan' => '0;36',
+ 'white' => '0;37',
+ ];
+
+ $code = $colors[$color] ?? '0;37';
+
+ return "\033[{$code}m{$string}\033[0m";
+ }
+
+ public function overWriteHeader(string $message, bool $reset = false): void
+ {
+ if ($reset) {
+ $this->lastMessageLength = 0;
+ }
+
+ echo str_repeat(\chr(8), $this->lastMessageLength);
+ echo str_repeat(' ', $this->lastMessageLength);
+ echo str_repeat(\chr(8), $this->lastMessageLength);
+
+ $this->lastMessageLength = \strlen($message);
+ $this->headerOver($message);
+ }
+
+ public function overWritePrimary(string $message, bool $reset = false): void
+ {
+ if ($reset) {
+ $this->lastMessageLength = 0;
+ }
+
+ echo str_repeat(\chr(8), $this->lastMessageLength);
+ echo str_repeat(' ', $this->lastMessageLength);
+ echo str_repeat(\chr(8), $this->lastMessageLength);
+
+ $this->lastMessageLength = \strlen($message);
+ $this->primaryOver($message);
+ }
+
+ public function overWrite(string $message, bool $reset = false): void
+ {
+ if ($reset) {
+ $this->lastMessageLength = 0;
+ }
+
+ echo str_repeat(\chr(8), $this->lastMessageLength);
+ echo str_repeat(' ', $this->lastMessageLength);
+ echo str_repeat(\chr(8), $this->lastMessageLength);
+
+ $this->lastMessageLength = \strlen($message);
+ echo $message;
+ }
+
+ public function appendWrite(string $message): void
+ {
+ echo $message;
+ $this->lastMessageLength += \strlen($message);
+ }
+
+ public function percentString(int $cur, int $total): string
+ {
+ $percent = 100 * $cur / $total;
+ $formatString = '% '.\strlen($total).'d/%d (% 2d%%)';
+
+ return sprintf($formatString, $cur, $total, $percent);
+ }
+
+ public function percentString2(int $first, int $last, int $total): string
+ {
+ $percent1 = 100 * ($first - 1) / $total;
+ $percent2 = 100 * $last / $total;
+ $formatString = '% '.\strlen($total).'d-% '.\strlen($total).'d/%d (% 2d%%-% 3d%%)';
+
+ return sprintf($formatString, $first, $last, $total, $percent1, $percent2);
+ }
+
+ /**
+ * Convert seconds to minutes or hours, appending type at the end.
+ */
+ public function convertTime(int $seconds): string
+ {
+ if ($seconds > 3600) {
+ return round($seconds / 3600).' hour(s)';
+ }
+ if ($seconds > 60) {
+ return round($seconds / 60).' minute(s)';
+ }
+
+ return $seconds.' second(s)';
+ }
+
+ /**
+ * Convert seconds to a timer, 00h:00m:00s.
+ */
+ public function convertTimer(int $seconds): string
+ {
+ return ' '.sprintf('%02dh:%02dm:%02ds', floor($seconds / 3600), floor(($seconds / 60) % 60), $seconds % 60);
+ }
+
+ /**
+ * Sleep for x seconds, printing timer on screen.
+ */
+ public function showSleep(int $seconds): void
+ {
+ for ($i = $seconds; $i >= 0; $i--) {
+ $this->overWriteHeader('Sleeping for '.$i.' seconds.');
+ sleep(1);
+ }
+ echo PHP_EOL;
+ }
+ };
+ }
+
+ return $instance;
+ }
+}
+
diff --git a/app/Models/Predb.php b/app/Models/Predb.php
index f3a2eb51f..70f93590a 100644
--- a/app/Models/Predb.php
+++ b/app/Models/Predb.php
@@ -3,7 +3,6 @@
namespace App\Models;
use App\Facades\Search;
-use Blacklight\ColorCLI;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Facades\Cache;
@@ -105,11 +104,10 @@ class Predb extends Model
*/
public static function checkPre(bool|int|string $dateLimit = false): void
{
- $consoleTools = new ColorCLI;
$updated = 0;
if (config('nntmux.echocli')) {
- (new ColorCLI)->header('Querying DB for release search names not matched with PreDB titles.');
+ cli()->header('Querying DB for release search names not matched with PreDB titles.');
}
$query = self::query()
@@ -124,14 +122,14 @@ class Predb extends Model
if ($res !== null) {
$total = \count($res);
- (new ColorCLI)->primary(number_format($total).' releases to match.');
+ cli()->primary(number_format($total).' releases to match.');
foreach ($res as $row) {
Release::query()->where('id', $row['releases_id'])->update(['predb_id' => $row['predb_id']]);
if (config('nntmux.echocli')) {
- $consoleTools->overWritePrimary(
- 'Matching up preDB titles with release searchnames: '.$consoleTools->percentString(++$updated, $total)
+ cli()->overWritePrimary(
+ 'Matching up preDB titles with release searchnames: '.cli()->percentString(++$updated, $total)
);
}
}
@@ -140,7 +138,7 @@ class Predb extends Model
}
if (config('nntmux.echocli')) {
- (new ColorCLI)->header(
+ cli()->header(
'Matched '.number_format(($updated > 0) ? $updated : 0).' PreDB titles to release search names.'
);
}
diff --git a/app/Models/UsenetGroup.php b/app/Models/UsenetGroup.php
index cf3a91ccb..c1b3e1544 100644
--- a/app/Models/UsenetGroup.php
+++ b/app/Models/UsenetGroup.php
@@ -5,7 +5,6 @@ namespace App\Models;
use App\Services\Nzb\NzbService;
use App\Services\ReleaseImageService;
use App\Services\NNTP\NNTPService;
-use Blacklight\ColorCLI;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
@@ -492,6 +491,6 @@ class UsenetGroup extends Model
public static function disableIfNotExist(int $id): void
{
self::updateGroupStatus($id, 'active');
- (new ColorCLI)->error('Group does not exist on server, disabling');
+ cli()->error('Group does not exist on server, disabling');
}
}
diff --git a/app/Services/AdditionalProcessing/ConsoleOutputService.php b/app/Services/AdditionalProcessing/ConsoleOutputService.php
index aa5e38707..f736cd85f 100644
--- a/app/Services/AdditionalProcessing/ConsoleOutputService.php
+++ b/app/Services/AdditionalProcessing/ConsoleOutputService.php
@@ -1,28 +1,26 @@
colorCLI = new ColorCLI();
}
public function echo(string $message, string $type = 'primary'): void
{
if ($this->echoCLI) {
- $this->colorCLI->$type($message);
+ cli()->$type($message);
}
}
public function debug(string $message): void
{
if ($this->echoCLI && config('app.env') === 'local' && config('app.debug') === true) {
- $this->colorCLI->debug('DEBUG: '.$message);
+ cli()->debug('DEBUG: '.$message);
}
}
public function echoDescription(int $totalReleases): void
diff --git a/app/Services/AdultProcessing/AdultProcessingPipeline.php b/app/Services/AdultProcessing/AdultProcessingPipeline.php
index 35d84352d..e449cc707 100644
--- a/app/Services/AdultProcessing/AdultProcessingPipeline.php
+++ b/app/Services/AdultProcessing/AdultProcessingPipeline.php
@@ -16,7 +16,6 @@ use App\Services\AdultProcessing\Pipes\HotmoviesPipe;
use App\Services\AdultProcessing\Pipes\IafdPipe;
use App\Services\AdultProcessing\Pipes\PoppornPipe;
use App\Services\ReleaseImageService;
-use Blacklight\ColorCLI;
use Illuminate\Pipeline\Pipeline;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Concurrency;
@@ -39,7 +38,6 @@ class AdultProcessingPipeline
protected int $movieQty;
protected bool $echoOutput;
- protected ColorCLI $colorCli;
protected ReleaseImageService $releaseImage;
protected string $imgSavePath;
protected string $cookie;
@@ -81,7 +79,6 @@ class AdultProcessingPipeline
}
$this->echoOutput = $echoOutput;
- $this->colorCli = new ColorCLI();
$this->releaseImage = new ReleaseImageService();
$this->imgSavePath = storage_path('covers/xxx/');
$this->cookie = resource_path('tmp/xxx.cookie');
@@ -195,13 +192,13 @@ class AdultProcessingPipeline
if ($releaseCount === 0) {
if ($this->echoOutput) {
- $this->colorCli->header('No XXX releases to process.');
+ cli()->header('No XXX releases to process.');
}
return;
}
if ($this->echoOutput) {
- $this->colorCli->header('Processing ' . $releaseCount . ' XXX releases using pipeline.');
+ cli()->header('Processing ' . $releaseCount . ' XXX releases using pipeline.');
}
// Process releases in batches for parallel processing
@@ -210,7 +207,7 @@ class AdultProcessingPipeline
foreach ($batches as $batchIndex => $batch) {
if ($this->echoOutput) {
- $this->colorCli->info('Processing batch ' . ($batchIndex + 1) . ' of ' . count($batches));
+ cli()->info('Processing batch ' . ($batchIndex + 1) . ' of ' . count($batches));
}
$this->processBatch($batch);
}
@@ -223,7 +220,7 @@ class AdultProcessingPipeline
]);
if ($this->echoOutput) {
- $this->colorCli->error('Error during processing: ' . $e->getMessage());
+ cli()->error('Error during processing: ' . $e->getMessage());
}
}
@@ -400,7 +397,7 @@ class AdultProcessingPipeline
if ($cleanTitle === false) {
if ($this->echoOutput) {
- $this->colorCli->primary('.');
+ cli()->primary('.');
}
$this->updateReleaseXxxId($releaseId, $idCheck);
$this->stats['skipped']++;
@@ -412,13 +409,13 @@ class AdultProcessingPipeline
if ($existingInfo !== null) {
if ($this->echoOutput) {
- $this->colorCli->info('Local match found for XXX Movie: ' . $cleanTitle);
+ cli()->info('Local match found for XXX Movie: ' . $cleanTitle);
}
$idCheck = (int) $existingInfo['id'];
} else {
if ($this->echoOutput) {
- $this->colorCli->info('Looking up: ' . $cleanTitle);
- $this->colorCli->info('Local match not found, checking web!');
+ cli()->info('Looking up: ' . $cleanTitle);
+ cli()->info('Local match not found, checking web!');
}
$idCheck = $this->updateXXXInfo($cleanTitle, $release);
@@ -480,7 +477,7 @@ class AdultProcessingPipeline
'hotm' => 'HotMovies',
default => $providerName,
};
- $this->colorCli->primary('Fetching XXX info from: ' . $fromStr);
+ cli()->primary('Fetching XXX info from: ' . $fromStr);
}
// Track provider usage
@@ -574,7 +571,7 @@ class AdultProcessingPipeline
}
if ($this->echoOutput) {
- $this->colorCli->primary(
+ cli()->primary(
($xxxID !== false ? 'Added/updated XXX movie: ' . $mov['title'] : 'Nothing to update for XXX movie: ' . $mov['title']),
true
);
@@ -729,17 +726,17 @@ class AdultProcessingPipeline
*/
protected function outputStats(): void
{
- $this->colorCli->header("\n=== Adult Processing Statistics ===");
- $this->colorCli->primary('Processed: ' . $this->stats['processed']);
- $this->colorCli->primary('Matched: ' . $this->stats['matched']);
- $this->colorCli->primary('Failed: ' . $this->stats['failed']);
- $this->colorCli->primary('Skipped: ' . $this->stats['skipped']);
- $this->colorCli->primary(sprintf('Duration: %.2f seconds', $this->stats['duration']));
+ cli()->header("\n=== Adult Processing Statistics ===");
+ cli()->primary('Processed: ' . $this->stats['processed']);
+ cli()->primary('Matched: ' . $this->stats['matched']);
+ cli()->primary('Failed: ' . $this->stats['failed']);
+ cli()->primary('Skipped: ' . $this->stats['skipped']);
+ cli()->primary(sprintf('Duration: %.2f seconds', $this->stats['duration']));
if (!empty($this->stats['providers'])) {
- $this->colorCli->header("\nProvider Statistics:");
+ cli()->header("\nProvider Statistics:");
foreach ($this->stats['providers'] as $provider => $count) {
- $this->colorCli->primary(" {$provider}: {$count} matches");
+ cli()->primary(" {$provider}: {$count} matches");
}
}
}
diff --git a/app/Services/AdultProcessing/Pipes/AbstractAdultProviderPipe.php b/app/Services/AdultProcessing/Pipes/AbstractAdultProviderPipe.php
index 72750f5d8..a7360bf65 100644
--- a/app/Services/AdultProcessing/Pipes/AbstractAdultProviderPipe.php
+++ b/app/Services/AdultProcessing/Pipes/AbstractAdultProviderPipe.php
@@ -5,7 +5,6 @@ namespace App\Services\AdultProcessing\Pipes;
use App\Services\AdultProcessing\AdultProcessingPassable;
use App\Services\AdultProcessing\AdultProcessingResult;
use App\Services\AdultProcessing\AgeVerificationManager;
-use Blacklight\ColorCLI;
use Closure;
use GuzzleHttp\Client;
use GuzzleHttp\Cookie\CookieJar;
@@ -33,7 +32,6 @@ abstract class AbstractAdultProviderPipe
{
protected int $priority = 50;
protected bool $echoOutput = true;
- protected ?ColorCLI $colorCli = null;
protected ?HtmlDomParser $html = null;
protected ?string $cookie = null;
@@ -89,18 +87,7 @@ abstract class AbstractAdultProviderPipe
public function __construct()
{
- // Lazy load ColorCLI and HtmlDomParser to avoid serialization issues
- }
-
- /**
- * Get the ColorCLI instance (lazy loaded).
- */
- protected function getColorCli(): ColorCLI
- {
- if ($this->colorCli === null) {
- $this->colorCli = new ColorCLI();
- }
- return $this->colorCli;
+ // Lazy load HtmlDomParser to avoid serialization issues
}
/**
diff --git a/app/Services/AnimeProcessor.php b/app/Services/AnimeProcessor.php
index 1d0b535ec..503aecf5e 100644
--- a/app/Services/AnimeProcessor.php
+++ b/app/Services/AnimeProcessor.php
@@ -10,7 +10,6 @@ use App\Models\Category;
use App\Models\Release;
use App\Models\Settings;
use App\Services\PopulateAniListService as PaList;
-use Blacklight\ColorCLI;
class AnimeProcessor
{
@@ -29,8 +28,6 @@ class AnimeProcessor
/** @var int|null The status of the release being processed */
private ?int $status;
- protected ColorCLI $colorCli;
-
/**
* Simple cache of looked up titles -> anidbid to reduce repeat queries within one run.
*
@@ -52,7 +49,6 @@ class AnimeProcessor
{
$this->echooutput = $echooutput && (bool) config('nntmux.echocli');
$this->palist = new PaList;
- $this->colorCli = new ColorCLI;
$quantity = (int) Settings::settingValue('maxanidbprocessed');
$this->aniqty = $quantity > 0 ? $quantity : 100;
@@ -113,7 +109,7 @@ class AnimeProcessor
}
}
} else {
- $this->colorCli->info('No anidb releases to process.');
+ cli()->info('No anidb releases to process.');
}
}
@@ -350,7 +346,7 @@ class AnimeProcessor
}
} catch (\Exception $e) {
if ($this->echooutput) {
- $this->colorCli->error('AniList search failed: '.$e->getMessage());
+ cli()->error('AniList search failed: '.$e->getMessage());
}
}
@@ -376,7 +372,7 @@ class AnimeProcessor
$title = $cleanArr['title'];
if ($this->echooutput) {
- $this->colorCli->info('Looking Up: Title: '.$title);
+ cli()->info('Looking Up: Title: '.$title);
}
$anidbTitle = $this->getAnidbByName($title);
@@ -404,7 +400,7 @@ class AnimeProcessor
}
} catch (\Exception $e) {
if ($this->echooutput) {
- $this->colorCli->warning('AniList search failed: '.$e->getMessage());
+ cli()->warning('AniList search failed: '.$e->getMessage());
}
}
}
@@ -419,10 +415,10 @@ class AnimeProcessor
$this->updateRelease($anidbId, (int) $release->id);
if ($this->echooutput) {
- $this->colorCli->headerOver('Matched '.$type.' AniList ID: ');
- $this->colorCli->primary((string) $anidbId);
- $this->colorCli->alternateOver(' Title: ');
- $this->colorCli->primary($anidbTitle->title);
+ cli()->headerOver('Matched '.$type.' AniList ID: ');
+ cli()->primary((string) $anidbId);
+ cli()->alternateOver(' Title: ');
+ cli()->primary($anidbTitle->title);
}
$matched = true;
} else {
diff --git a/app/Services/Backfill/BackfillService.php b/app/Services/Backfill/BackfillService.php
index 61a1daaa6..bac1b6dc6 100644
--- a/app/Services/Backfill/BackfillService.php
+++ b/app/Services/Backfill/BackfillService.php
@@ -7,7 +7,6 @@ namespace App\Services\Backfill;
use App\Models\UsenetGroup;
use App\Services\Binaries\BinariesService;
use App\Services\NNTP\NNTPService;
-use Blacklight\ColorCLI;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
@@ -30,18 +29,14 @@ final class BackfillService
private NNTPService $nntp;
- private ColorCLI $colorCli;
-
public function __construct(
?BackfillConfig $config = null,
?BinariesService $binaries = null,
?NNTPService $nntp = null,
- ?ColorCLI $colorCli = null,
) {
$this->config = $config ?? BackfillConfig::fromSettings();
$this->binaries = $binaries ?? new BinariesService;
$this->nntp = $nntp ?? new NNTPService;
- $this->colorCli = $colorCli ?? new ColorCLI;
}
/**
@@ -302,11 +297,11 @@ final class BackfillService
}
match ($type) {
- 'header' => $this->colorCli->header($message),
- 'warning' => $this->colorCli->warning($message),
- 'error' => $this->colorCli->error($message),
- 'notice' => $this->colorCli->notice($message),
- default => $this->colorCli->primary($message),
+ 'header' => cli()->header($message),
+ 'warning' => cli()->warning($message),
+ 'error' => cli()->error($message),
+ 'notice' => cli()->notice($message),
+ default => cli()->primary($message),
};
}
diff --git a/app/Services/Binaries/BinariesService.php b/app/Services/Binaries/BinariesService.php
index eeded940d..caa64674b 100644
--- a/app/Services/Binaries/BinariesService.php
+++ b/app/Services/Binaries/BinariesService.php
@@ -7,7 +7,6 @@ namespace App\Services\Binaries;
use App\Models\Settings;
use App\Models\UsenetGroup;
use App\Services\NNTP\NNTPService;
-use Blacklight\ColorCLI;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
@@ -32,8 +31,6 @@ class BinariesService
private MissedPartHandler $missedPartHandler;
- private ColorCLI $colorCli;
-
private ?NNTPService $nntp = null;
// Timing metrics
@@ -69,7 +66,6 @@ class BinariesService
?HeaderParser $headerParser = null,
?HeaderStorageService $headerStorage = null,
?MissedPartHandler $missedPartHandler = null,
- ?ColorCLI $colorCli = null,
?NNTPService $nntp = null
) {
$this->config = $config ?? BinariesConfig::fromSettings();
@@ -79,7 +75,6 @@ class BinariesService
$this->config->partRepairLimit,
$this->config->partRepairMaxTries
);
- $this->colorCli = $colorCli ?? new ColorCLI;
$this->nntp = $nntp;
$this->startUpdate = now();
}
@@ -207,17 +202,17 @@ class BinariesService
}
if ($this->config->echoCli) {
- $this->colorCli->primary('Processing '.$groupMySQL['name']);
+ cli()->primary('Processing '.$groupMySQL['name']);
}
// Attempt to repair any missing parts before grabbing new ones
if ((int) $groupMySQL['last_record'] !== 0 && $this->config->partRepair) {
if ($this->config->echoCli) {
- $this->colorCli->primary('Part repair enabled. Checking for missing parts.');
+ cli()->primary('Part repair enabled. Checking for missing parts.');
}
$this->partRepair($groupMySQL);
} elseif ($this->config->echoCli && (int) $groupMySQL['last_record'] !== 0) {
- $this->colorCli->primary('Part repair disabled by user.');
+ cli()->primary('Part repair disabled by user.');
}
// Generate postdate for first record, for those that upgraded
@@ -242,7 +237,7 @@ class BinariesService
if ($this->config->echoCli) {
$endGroup = now()->diffInSeconds($startGroup, true);
- $this->colorCli->primary(
+ cli()->primary(
PHP_EOL.'Group '.$groupMySQL['name'].' processed in '.$endGroup.Str::plural(' second', $endGroup)
);
}
@@ -364,7 +359,7 @@ class BinariesService
}
if ($this->config->echoCli) {
- $this->colorCli->primary('Attempting to repair '.number_format($missingCount).' parts.');
+ cli()->primary('Attempting to repair '.number_format($missingCount).' parts.');
}
// Group into continuous ranges
@@ -390,7 +385,7 @@ class BinariesService
}
if ($this->config->echoCli) {
- $this->colorCli->primary(PHP_EOL.number_format($partsRepaired).' parts repaired.');
+ cli()->primary(PHP_EOL.number_format($partsRepaired).' parts repaired.');
}
// Remove articles that exceeded max tries
@@ -474,7 +469,7 @@ class BinariesService
}
if ($this->config->echoCli) {
- $this->colorCli->primary(
+ cli()->primary(
'Searching for an approximate article number for group '.$data['group'].' '.$days.' days back.'
);
}
@@ -596,7 +591,7 @@ class BinariesService
$first++;
if ($this->config->echoCli) {
- $this->colorCli->header(
+ cli()->header(
PHP_EOL.'Getting '.number_format($last - $first + 1).' articles ('.number_format($first).
' to '.number_format($last).') from '.$groupMySQL['name'].' - ('.
number_format($groupLast - $last).' articles in queue).'
@@ -708,7 +703,7 @@ class BinariesService
$this->missedPartHandler->addMissingParts($rangeNotReceived, $this->groupMySQL['id']);
if ($this->config->echoCli) {
- $this->colorCli->alternate(
+ cli()->alternate(
'Server did not return '.$notReceivedCount.' articles from '.$this->groupMySQL['name'].'.'
);
}
@@ -814,7 +809,7 @@ class BinariesService
$goalCarbon = Carbon::createFromTimestamp($goalTime, date_default_timezone_get());
$articleCarbon = Carbon::createFromTimestamp($articleTime, date_default_timezone_get());
$diffDays = $goalCarbon->diffInDays($articleCarbon, true);
- $this->colorCli->primary(
+ cli()->primary(
PHP_EOL.'Found article #'.$wantedArticle.' which has a date of '.date('r', $articleTime).
', vs wanted date of '.date('r', $goalTime).'. Difference from goal is '.$diffDays.' days.'
);
@@ -828,7 +823,7 @@ class BinariesService
private function outputNoNewArticles(array $groupMySQL, array $groupNNTP, array $range): void
{
if ($this->config->echoCli) {
- $this->colorCli->primary(
+ cli()->primary(
'No new articles for '.$groupMySQL['name'].' (first '.number_format((int) $range['first']).
', last '.number_format((int) $range['last']).', grouplast '.number_format((int) $groupMySQL['last_record']).
', total '.number_format((int) $range['total']).")\n".'Server oldest: '.number_format((int) $groupNNTP['first']).
@@ -850,7 +845,7 @@ class BinariesService
: number_format($this->config->newGroupMessagesToScan).' messages').' worth.'
: 'Group '.$groupNNTP['group'].' has '.number_format((int) $range['realTotal']).' new articles.';
- $this->colorCli->primary(
+ cli()->primary(
$message.
' Leaving '.number_format((int) $range['leaveOver']).
" for next pass.\nServer oldest: ".number_format((int) $groupNNTP['first']).
@@ -861,7 +856,7 @@ class BinariesService
private function outputHeaderInitial(): void
{
- $this->colorCli->primary(
+ cli()->primary(
'Received '.\count($this->headersReceived).
' articles of '.number_format($this->last - $this->first + 1).' requested, '.
$this->headersBlackListed.' blacklisted, '.$this->notYEnc.' not yEnc.'
@@ -875,16 +870,16 @@ class BinariesService
}
$currentMicroTime = now();
- $this->colorCli->alternateOver(number_format($this->timeHeaders, 2).'s').
- $this->colorCli->primaryOver(' to download articles, ').
- $this->colorCli->alternateOver(number_format($this->timeCleaning, 2).'s').
- $this->colorCli->primaryOver(' to process collections, ').
- $this->colorCli->alternateOver(number_format($this->timeInsert, 2).'s').
- $this->colorCli->primaryOver(' to insert binaries/parts, ').
- $this->colorCli->alternateOver(number_format($currentMicroTime->diffInSeconds($this->startPR, true), 2).'s').
- $this->colorCli->primaryOver(' for part repair, ').
- $this->colorCli->alternateOver(number_format($currentMicroTime->diffInSeconds($this->startLoop, true), 2).'s').
- $this->colorCli->primary(' total.');
+ cli()->alternateOver(number_format($this->timeHeaders, 2).'s').
+ cli()->primaryOver(' to download articles, ').
+ cli()->alternateOver(number_format($this->timeCleaning, 2).'s').
+ cli()->primaryOver(' to process collections, ').
+ cli()->alternateOver(number_format($this->timeInsert, 2).'s').
+ cli()->primaryOver(' to insert binaries/parts, ').
+ cli()->alternateOver(number_format($currentMicroTime->diffInSeconds($this->startPR, true), 2).'s').
+ cli()->primaryOver(' for part repair, ').
+ cli()->alternateOver(number_format($currentMicroTime->diffInSeconds($this->startLoop, true), 2).'s').
+ cli()->primary(' total.');
}
// ==================== Logging Methods ====================
@@ -892,14 +887,14 @@ class BinariesService
private function log(string $message, string $method, string $color): void
{
if ($this->config->echoCli) {
- $this->colorCli->$color($message.' ['.__CLASS__."::$method]");
+ cli()->$color($message.' ['.__CLASS__."::$method]");
}
}
private function logError(string $message): void
{
if ($this->config->echoCli) {
- $this->colorCli->error($message);
+ cli()->error($message);
}
if (config('app.debug')) {
Log::error($message);
diff --git a/app/Services/BookService.php b/app/Services/BookService.php
index dc4f026f2..2b21f4721 100644
--- a/app/Services/BookService.php
+++ b/app/Services/BookService.php
@@ -6,7 +6,6 @@ use App\Models\BookInfo;
use App\Models\Category;
use App\Models\Release;
use App\Models\Settings;
-use Blacklight\ColorCLI;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
@@ -36,15 +35,12 @@ class BookService
public array $failCache;
- protected ColorCLI $colorCli;
-
/**
* @throws \Exception
*/
public function __construct()
{
$this->echooutput = config('nntmux.echocli');
- $this->colorCli = new ColorCLI;
$this->pubkey = Settings::settingValue('amazonpubkey');
$this->privkey = Settings::settingValue('amazonprivkey');
@@ -321,7 +317,7 @@ class BookService
{
if ($res->count() > 0) {
if ($this->echooutput) {
- $this->colorCli->header('Processing '.$res->count().' book release(s) for categories id '.$categoryID);
+ cli()->header('Processing '.$res->count().' book release(s) for categories id '.$categoryID);
}
$bookId = -2;
@@ -339,7 +335,7 @@ class BookService
if ($bookInfo !== false) {
if ($this->echooutput) {
- $this->colorCli->info('Looking up: '.$bookInfo);
+ cli()->info('Looking up: '.$bookInfo);
}
// Do a local lookup first
@@ -348,7 +344,7 @@ class BookService
if ($bookCheck === null && \in_array($bookInfo, $this->failCache, false)) {
// Lookup recently failed, no point trying again
if ($this->echooutput) {
- $this->colorCli->info('Cached previous failure. Skipping.');
+ cli()->info('Cached previous failure. Skipping.');
}
$bookId = -2;
} elseif ($bookCheck === null) {
@@ -376,7 +372,7 @@ class BookService
}
}
} elseif ($this->echooutput) {
- $this->colorCli->header('No book releases to process for categories id '.$categoryID);
+ cli()->header('No book releases to process for categories id '.$categoryID);
}
}
@@ -401,7 +397,7 @@ class BookService
if ($releasetype === 'ebook') {
if (preg_match('/^([a-z0-9] )+$|ArtofUsenet|ekiosk|(ebook|mobi).+collection|erotica|Full Video|ImwithJamie|linkoff org|Mega.+pack|^[a-z0-9]+ (?!((January|February|March|April|May|June|July|August|September|O([ck])tober|November|De([cz])ember)))[a-z]+( (ebooks?|The))?$|NY Times|(Book|Massive) Dump|Sexual/i', $releasename)) {
if ($this->echooutput) {
- $this->colorCli->headerOver('Changing category to misc books: ').$this->colorCli->primary($releasename);
+ cli()->headerOver('Changing category to misc books: ').cli()->primary($releasename);
}
Release::query()->where('id', $releaseID)->update(['categories_id' => Category::BOOKS_UNKNOWN]);
@@ -410,7 +406,7 @@ class BookService
if (preg_match('/^([a-z0-9ü!]+ ){1,2}(N|Vol)?\d{1,4}([abc])?$|^([a-z0-9]+ ){1,2}(Jan( |unar|$)|Feb( |ruary|$)|Mar( |ch|$)|Apr( |il|$)|May(?![a-z0-9])|Jun([ e$])|Jul([ y$])|Aug( |ust|$)|Sep( |tember|$)|O([ck])t( |ober|$)|Nov( |ember|$)|De([cz])( |ember|$))/ui', $releasename) && ! preg_match('/Part \d+/i', $releasename)) {
if ($this->echooutput) {
- $this->colorCli->headerOver('Changing category to magazines: ').$this->colorCli->primary($releasename);
+ cli()->headerOver('Changing category to magazines: ').cli()->primary($releasename);
}
Release::query()->where('id', $releaseID)->update(['categories_id' => Category::BOOKS_MAGAZINES]);
@@ -450,7 +446,7 @@ class BookService
$book = false;
if ($bookInfo !== '') {
if (! $book) {
- $this->colorCli->info('Fetching data from iTunes for '.$bookInfo);
+ cli()->info('Fetching data from iTunes for '.$bookInfo);
$book = $this->fetchItunesBookProperties($bookInfo);
} elseif ($amazdata !== null) {
$book = $amazdata;
@@ -507,20 +503,20 @@ class BookService
if ($bookId && $bookId !== -2) {
if ($this->echooutput) {
- $this->colorCli->header('Added/updated book: ');
+ cli()->header('Added/updated book: ');
if ($book['author'] !== '') {
- $this->colorCli->alternateOver(' Author: ').$this->colorCli->primary($book['author']);
+ cli()->alternateOver(' Author: ').cli()->primary($book['author']);
}
- $this->colorCli->alternateOver(' Title: ').$this->colorCli->primary(' '.$book['title']);
+ cli()->alternateOver(' Title: ').cli()->primary(' '.$book['title']);
if ($book['genre'] !== 'null') {
- $this->colorCli->alternateOver(' Genre: ').$this->colorCli->primary(' '.$book['genre']);
+ cli()->alternateOver(' Genre: ').cli()->primary(' '.$book['genre']);
}
}
$book['cover'] = $ri->saveImage($bookId, $book['coverurl'], $this->imgSavePath, 250, 250);
} elseif ($this->echooutput) {
- $this->colorCli->header('Nothing to update: ').
- $this->colorCli->header($book['author'].
+ cli()->header('Nothing to update: ').
+ cli()->header($book['author'].
' - '.
$book['title']);
}
@@ -539,12 +535,12 @@ class BookService
$iTunesBook = $itunes->findEbook($bookInfo);
if ($iTunesBook === null) {
- $this->colorCli->notice('Could not find a match on iTunes!');
+ cli()->notice('Could not find a match on iTunes!');
return false;
}
- $this->colorCli->info('Found matching title: '.$iTunesBook['name']);
+ cli()->info('Found matching title: '.$iTunesBook['name']);
$book = [
'title' => $iTunesBook['name'],
diff --git a/app/Services/CollectionCleanupService.php b/app/Services/CollectionCleanupService.php
index 2b1894dfb..6e00ea29a 100644
--- a/app/Services/CollectionCleanupService.php
+++ b/app/Services/CollectionCleanupService.php
@@ -4,15 +4,13 @@ namespace App\Services;
use App\Models\Collection;
use App\Models\Settings;
-use Blacklight\ColorCLI;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
class CollectionCleanupService
{
- public function __construct(
- private readonly ColorCLI $colorCLI
- ) {}
+ public function __construct()
+ {}
/**
* Deletes finished/old collections, cleans orphans, and removes collections missed after NZB creation.
@@ -26,8 +24,8 @@ class CollectionCleanupService
$deletedCount = 0;
if ($echoCLI) {
- echo $this->colorCLI->header('Process Releases -> Delete finished collections.'.PHP_EOL).
- $this->colorCLI->primary(sprintf(
+ echo cli()->header('Process Releases -> Delete finished collections.'.PHP_EOL).
+ cli()->primary(sprintf(
'Deleting collections/binaries/parts older than %d hours.',
Settings::settingValue('partretentionhours')
), true);
@@ -57,7 +55,7 @@ class CollectionCleanupService
$attempt++;
if ($attempt >= $maxRetries) {
if ($echoCLI) {
- $this->colorCLI->error('Cleanup delete failed after retries: '.$e->getMessage());
+ cli()->error('Cleanup delete failed after retries: '.$e->getMessage());
}
break;
}
@@ -77,7 +75,7 @@ class CollectionCleanupService
if ($echoCLI) {
$elapsed = now()->diffInSeconds($startTime, true);
- $this->colorCLI->primary(
+ cli()->primary(
'Finished deleting '.$batchDeleted.' old collections/binaries/parts in '.
$elapsed.Str::plural(' second', $elapsed),
true
@@ -87,8 +85,8 @@ class CollectionCleanupService
// Occasionally prune CBP orphans (low frequency to avoid heavy load).
if (random_int(0, 200) <= 1) {
if ($echoCLI) {
- echo $this->colorCLI->header('Process Releases -> Remove CBP orphans.'.PHP_EOL).
- $this->colorCLI->primary('Deleting orphaned collections.');
+ echo cli()->header('Process Releases -> Remove CBP orphans.'.PHP_EOL).
+ cli()->primary('Deleting orphaned collections.');
}
$deleted = 0;
@@ -108,12 +106,12 @@ class CollectionCleanupService
$totalTime = now()->diffInSeconds($startTime);
if ($echoCLI) {
- $this->colorCLI->primary('Finished deleting '.$deleted.' orphaned collections in '.$totalTime.Str::plural(' second', $totalTime), true);
+ cli()->primary('Finished deleting '.$deleted.' orphaned collections in '.$totalTime.Str::plural(' second', $totalTime), true);
}
}
if ($echoCLI) {
- $this->colorCLI->primary('Deleting collections that were missed after NZB creation.', true);
+ cli()->primary('Deleting collections that were missed after NZB creation.', true);
}
$deleted = 0;
@@ -132,7 +130,7 @@ class CollectionCleanupService
$totalTime = now()->diffInSeconds($startTime, true);
if ($echoCLI) {
- $this->colorCLI->primary(
+ cli()->primary(
'Finished deleting '.$deleted.' collections missed after NZB creation in '.($totalTime).Str::plural(' second', $totalTime).
PHP_EOL.'Removed '.number_format($deletedCount).' parts/binaries/collection rows in '.$totalTime.Str::plural(' second', $totalTime),
true
diff --git a/app/Services/ConsoleService.php b/app/Services/ConsoleService.php
index c8c2830e2..dd09ae59b 100644
--- a/app/Services/ConsoleService.php
+++ b/app/Services/ConsoleService.php
@@ -9,7 +9,6 @@ use App\Models\ConsoleInfo;
use App\Models\Genre;
use App\Models\Release;
use App\Models\Settings;
-use Blacklight\ColorCLI;
use Blacklight\Genres;
use GuzzleHttp\Exception\ClientException;
use Illuminate\Database\Eloquent\Model;
@@ -55,8 +54,6 @@ class ConsoleService
public array $failCache;
- protected ColorCLI $colorCli;
-
protected ReleaseImageService $imageService;
protected $igdbSleep;
@@ -64,7 +61,6 @@ class ConsoleService
public function __construct(?ReleaseImageService $imageService = null)
{
$this->echoOutput = config('nntmux.echocli');
- $this->colorCli = new ColorCLI;
$this->imageService = $imageService ?? new ReleaseImageService;
$this->pubkey = Settings::settingValue('amazonpubkey');
@@ -356,13 +352,13 @@ class ConsoleService
$consoleId = $this->updateConsoleTable($igdb);
if ($this->echoOutput && $consoleId !== -2) {
- $this->colorCli->header('Added/updated game: ') .
- $this->colorCli->alternateOver(' Title: ') .
- $this->colorCli->primary($igdb['title']) .
- $this->colorCli->alternateOver(' Platform: ') .
- $this->colorCli->primary($igdb['platform']) .
- $this->colorCli->alternateOver(' Genre: ') .
- $this->colorCli->primary($igdb['consolegenre']);
+ cli()->header('Added/updated game: ') .
+ cli()->alternateOver(' Title: ') .
+ cli()->primary($igdb['title']) .
+ cli()->alternateOver(' Platform: ') .
+ cli()->primary($igdb['platform']) .
+ cli()->alternateOver(' Genre: ') .
+ cli()->primary($igdb['consolegenre']);
}
}
@@ -452,12 +448,12 @@ class ConsoleService
];
}
- $this->colorCli->notice('IGDB returned no valid results');
+ cli()->notice('IGDB returned no valid results');
return false;
}
- $this->colorCli->notice('IGDB found no valid results');
+ cli()->notice('IGDB found no valid results');
return false;
} catch (ClientException $e) {
@@ -465,7 +461,7 @@ class ConsoleService
$this->igdbSleep = now()->endOfMonth();
}
} catch (\Exception $e) {
- $this->colorCli->error('Error fetching IGDB properties: ' . $e->getMessage());
+ cli()->error('Error fetching IGDB properties: ' . $e->getMessage());
return false;
}
@@ -499,7 +495,7 @@ class ConsoleService
$releaseCount = $res->count();
if ($res instanceof \Traversable && $releaseCount > 0) {
if ($this->echoOutput) {
- $this->colorCli->header('Processing ' . $releaseCount . ' console release(s).');
+ cli()->header('Processing ' . $releaseCount . ' console release(s).');
}
foreach ($res as $arr) {
@@ -510,7 +506,7 @@ class ConsoleService
if ($gameInfo !== false) {
if ($this->echoOutput) {
- $this->colorCli->info('Looking up: ' . $gameInfo['title'] . ' (' . $gameInfo['platform'] . ')');
+ cli()->info('Looking up: ' . $gameInfo['title'] . ' (' . $gameInfo['platform'] . ')');
}
// Check for existing console entry.
@@ -519,7 +515,7 @@ class ConsoleService
if ($gameCheck === false && \in_array($gameInfo['title'] . $gameInfo['platform'], $this->failCache, false)) {
// Lookup recently failed, no point trying again
if ($this->echoOutput) {
- $this->colorCli->info('Cached previous failure. Skipping.');
+ cli()->info('Cached previous failure. Skipping.');
}
$gameId = -2;
} elseif ($gameCheck === false) {
@@ -531,8 +527,8 @@ class ConsoleService
}
} else {
if ($this->echoOutput) {
- $this->colorCli->headerOver('Found Local: ') .
- $this->colorCli->primary("{$gameInfo['title']} - {$gameInfo['platform']}");
+ cli()->headerOver('Found Local: ') .
+ cli()->primary("{$gameInfo['title']} - {$gameInfo['platform']}");
}
$gameId = $gameCheck['id'] ?? -2;
}
@@ -550,7 +546,7 @@ class ConsoleService
}
}
} elseif ($this->echoOutput) {
- $this->colorCli->header('No console releases to process.');
+ cli()->header('No console releases to process.');
}
}
diff --git a/app/Services/ForkingService.php b/app/Services/ForkingService.php
index 50b42775a..1af388fc4 100644
--- a/app/Services/ForkingService.php
+++ b/app/Services/ForkingService.php
@@ -7,7 +7,6 @@ use App\Services\Runners\BackfillRunner;
use App\Services\Runners\BinariesRunner;
use App\Services\Runners\PostProcessRunner;
use App\Services\Runners\ReleasesRunner;
-use Blacklight\ColorCLI;
use Blacklight\Nfo;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
@@ -21,8 +20,6 @@ use Symfony\Component\Process\Process;
*/
class ForkingService
{
- protected ColorCLI $colorCli;
-
protected BackfillRunner $backfillRunner;
protected BinariesRunner $binariesRunner;
@@ -37,10 +34,8 @@ class ForkingService
protected int $maxRetries;
- public function __construct(?ColorCLI $colorCli = null)
+ public function __construct()
{
- $this->colorCli = $colorCli ?? new ColorCLI;
-
$this->maxSize = (int) Settings::settingValue('maxsizetoprocessnfo');
$this->minSize = (int) Settings::settingValue('minsizetoprocessnfo');
$this->maxRetries = (int) Settings::settingValue('maxnforetries') >= 0
@@ -49,10 +44,10 @@ class ForkingService
$this->maxRetries = max($this->maxRetries, -8);
// Initialize runners
- $this->backfillRunner = new BackfillRunner($this->colorCli);
- $this->binariesRunner = new BinariesRunner($this->colorCli);
- $this->releasesRunner = new ReleasesRunner($this->colorCli);
- $this->postProcessRunner = new PostProcessRunner($this->colorCli);
+ $this->backfillRunner = new BackfillRunner();
+ $this->binariesRunner = new BinariesRunner();
+ $this->releasesRunner = new ReleasesRunner();
+ $this->postProcessRunner = new PostProcessRunner();
}
/**
@@ -220,7 +215,7 @@ class ForkingService
}
if (config('nntmux.echocli')) {
- $this->colorCli->header(
+ cli()->header(
"Multi-processing for {$taskName} finished in " . (now()->timestamp - $startTime) .
' seconds at ' . now()->toRfc2822String() . '.' . PHP_EOL
);
diff --git a/app/Services/GamesService.php b/app/Services/GamesService.php
index a027797cd..cd5d9b711 100644
--- a/app/Services/GamesService.php
+++ b/app/Services/GamesService.php
@@ -9,7 +9,6 @@ use App\Models\GamesInfo;
use App\Models\Genre;
use App\Models\Release;
use App\Models\Settings;
-use Blacklight\ColorCLI;
use Blacklight\Genres;
use GuzzleHttp\Exception\ClientException;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
@@ -47,7 +46,6 @@ class GamesService
protected IGDBService $igdbService;
protected GamesTitleParser $titleParser;
protected ReleaseImageService $imageService;
- protected ColorCLI $colorCli;
// Processing stats
protected int $processedCount = 0;
@@ -68,7 +66,6 @@ class GamesService
?ReleaseImageService $imageService = null
) {
$this->echoOutput = config('nntmux.echocli');
- $this->colorCli = new ColorCLI;
$this->steamService = $steamService ?? new SteamService;
$this->igdbService = $igdbService ?? new IGDBService;
$this->titleParser = $titleParser ?? new GamesTitleParser;
@@ -541,11 +538,11 @@ class GamesService
if (!empty($gamesId)) {
if ($this->echoOutput) {
- $this->colorCli->header('Added/updated game: ') .
- $this->colorCli->alternateOver(' Title: ') .
- $this->colorCli->primary($game['title']) .
- $this->colorCli->alternateOver(' Source: ') .
- $this->colorCli->primary($this->_classUsed);
+ cli()->header('Added/updated game: ') .
+ cli()->alternateOver(' Title: ') .
+ cli()->primary($game['title']) .
+ cli()->alternateOver(' Source: ') .
+ cli()->primary($this->_classUsed);
}
// Save cover image
@@ -558,8 +555,8 @@ class GamesService
$game['backdrop'] = $this->imageService->saveImage($gamesId . '-backdrop', $game['backdropurl'], $this->imgSavePath, 1920, 1024);
}
} elseif ($this->echoOutput) {
- $this->colorCli->headerOver('Nothing to update: ') .
- $this->colorCli->primary($game['title'] . ' (PC)');
+ cli()->headerOver('Nothing to update: ') .
+ cli()->primary($game['title'] . ' (PC)');
}
return $gamesId !== false ? $gamesId : false;
@@ -626,7 +623,7 @@ class GamesService
if ($res->count() > 0) {
if ($this->echoOutput) {
- $this->colorCli->header('Processing ' . $res->count() . ' games release(s).');
+ cli()->header('Processing ' . $res->count() . ' games release(s).');
}
Log::info('GamesService: Starting processing', ['count' => $res->count()]);
@@ -641,7 +638,7 @@ class GamesService
if ($gameInfo !== false) {
if ($this->echoOutput) {
- $this->colorCli->info('Looking up: ' . $gameInfo['title'] . ' (PC)');
+ cli()->info('Looking up: ' . $gameInfo['title'] . ' (PC)');
}
// Check for existing games entry
@@ -687,7 +684,7 @@ class GamesService
]);
if ($this->echoOutput) {
- $this->colorCli->header(sprintf(
+ cli()->header(sprintf(
'Games processing complete: %d processed, %d matched, %d cached, %d failed (%.2fs)',
$this->processedCount,
$this->matchedCount,
@@ -697,7 +694,7 @@ class GamesService
));
}
} elseif ($this->echoOutput) {
- $this->colorCli->header('No games releases to process.');
+ cli()->header('No games releases to process.');
}
}
diff --git a/app/Services/MovieService.php b/app/Services/MovieService.php
index 8e3949397..a76cf5166 100644
--- a/app/Services/MovieService.php
+++ b/app/Services/MovieService.php
@@ -8,7 +8,6 @@ use App\Models\MovieInfo;
use App\Models\Release;
use App\Models\Settings;
use App\Services\TvProcessing\Providers\TraktProvider;
-use Blacklight\ColorCLI;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Support\Carbon;
@@ -62,15 +61,12 @@ class MovieService
protected ?string $traktcheck;
- protected ColorCLI $colorCli;
-
/**
* @throws \Exception
*/
public function __construct()
{
$this->releaseImage = new ReleaseImageService;
- $this->colorCli = new ColorCLI;
$this->traktcheck = config('nntmux_api.trakttv_api_key');
if ($this->traktcheck !== null) {
$this->traktTv = new TraktProvider();
@@ -281,7 +277,7 @@ class MovieService
public function updateMovieInfo(string $imdbId): bool
{
if ($this->echooutput && $this->service !== '') {
- $this->colorCli->primary('Fetching IMDB info from TMDB/IMDB/Trakt/OMDB/iTunes using IMDB id: '.$imdbId);
+ cli()->primary('Fetching IMDB info from TMDB/IMDB/Trakt/OMDB/iTunes using IMDB id: '.$imdbId);
}
// Check TMDB for IMDB info.
@@ -464,8 +460,8 @@ class MovieService
}
if ($this->echooutput && $this->service !== '') {
- PHP_EOL.$this->colorCli->headerOver('Added/updated movie: ').
- $this->colorCli->primary(
+ PHP_EOL.cli()->headerOver('Added/updated movie: ').
+ cli()->primary(
$mov['title'].
' ('.
$mov['year'].
@@ -491,7 +487,7 @@ class MovieService
if ($result !== null) {
if ($this->echooutput) {
- $this->colorCli->info('Fanart found '.$result['title']);
+ cli()->info('Fanart found '.$result['title']);
}
return $result;
@@ -630,7 +626,7 @@ class MovieService
}
if ($this->echooutput) {
- $this->colorCli->info('TMDb found '.$ret['title']);
+ cli()->info('TMDb found '.$ret['title']);
}
Cache::put($cacheKey, $ret, $expiresAt);
@@ -681,7 +677,7 @@ class MovieService
}
Cache::put($cacheKey, $scraped, $expiresAt);
if ($this->echooutput) {
- $this->colorCli->info('IMDb scraped '.$scraped['title']);
+ cli()->info('IMDb scraped '.$scraped['title']);
}
return $scraped;
@@ -753,7 +749,7 @@ class MovieService
];
if ($this->echooutput) {
- $this->colorCli->info('Trakt found '.$movieData['title']);
+ cli()->info('Trakt found '.$movieData['title']);
}
Cache::put($cacheKey, $movieData, $expiresAt);
@@ -836,7 +832,7 @@ class MovieService
];
if ($this->echooutput) {
- $this->colorCli->info('OMDbAPI Found '.$movieData['title']);
+ cli()->info('OMDbAPI Found '.$movieData['title']);
}
Cache::put($cacheKey, $movieData, $expiresAt);
@@ -872,7 +868,7 @@ class MovieService
try {
$this->service = $service;
if ($this->echooutput && $this->service !== '') {
- $this->colorCli->info($this->service.' found IMDBid: tt'.$imdbId);
+ cli()->info($this->service.' found IMDBid: tt'.$imdbId);
}
$movieInfoId = MovieInfo::query()->where('imdbid', $imdbId)->first(['id']);
@@ -951,7 +947,7 @@ class MovieService
if ($movieCount > 0) {
if ($this->echooutput && $movieCount > 1) {
- $this->colorCli->header('Processing '.$movieCount.' movie releases.');
+ cli()->header('Processing '.$movieCount.' movie releases.');
}
foreach ($res as $arr) {
@@ -965,7 +961,7 @@ class MovieService
$movieName = $this->formatMovieName();
if ($this->echooutput) {
- $this->colorCli->info('Looking up: '.$movieName);
+ cli()->info('Looking up: '.$movieName);
}
$foundIMDB = $this->searchLocalDatabase($arr['id']) ||
@@ -976,7 +972,7 @@ class MovieService
if ($foundIMDB) {
if ($this->echooutput) {
- $this->colorCli->primary('Successfully updated release with IMDB ID');
+ cli()->primary('Successfully updated release with IMDB ID');
}
continue;
@@ -984,7 +980,7 @@ class MovieService
$releaseCheck = Release::query()->where('id', $arr['id'])->whereNotNull('imdbid')->exists();
if ($releaseCheck) {
if ($this->echooutput) {
- $this->colorCli->info('Release already has IMDB ID, skipping');
+ cli()->info('Release already has IMDB ID, skipping');
}
continue;
@@ -1001,9 +997,9 @@ class MovieService
->whereIn('id', $failedIDs)
->get();
- $this->colorCli->header('Failed to find IMDB IDs for '.count($failedIDs).' releases:');
+ cli()->header('Failed to find IMDB IDs for '.count($failedIDs).' releases:');
foreach ($failedReleases as $release) {
- $this->colorCli->error("ID: {$release->id} - {$release->searchname}");
+ cli()->error("ID: {$release->id} - {$release->searchname}");
}
}
@@ -1218,7 +1214,7 @@ class MovieService
Cache::put($cacheKey, $match['imdbid'], now()->addDays(7));
if ($this->echooutput) {
- $this->colorCli->info("Found local match: {$match['title']} ({$match['imdbid']})");
+ cli()->info("Found local match: {$match['title']} ({$match['imdbid']})");
}
return $match['imdbid'];
diff --git a/app/Services/NNTP/NNTPService.php b/app/Services/NNTP/NNTPService.php
index 7a797bca7..b2fee7618 100644
--- a/app/Services/NNTP/NNTPService.php
+++ b/app/Services/NNTP/NNTPService.php
@@ -5,7 +5,6 @@ namespace App\Services\NNTP;
use App\Extensions\util\PhpYenc;
use App\Models\Settings;
use App\Services\Tmux\Tmux;
-use Blacklight\ColorCLI;
/*
* Response codes not defined in Net_NNTP
@@ -23,8 +22,6 @@ defined('NET_NNTP_PROTOCOL_RESPONSECODE_TLS_FAILED_NEGOTIATION') || define('NET_
*/
class NNTPService extends \Net_NNTP_Client
{
- protected ColorCLI $colorCli;
-
protected bool $_debugBool;
protected bool $_echo;
@@ -140,14 +137,13 @@ class NNTPService extends \Net_NNTP_Client
/**
* Create a new NNTP service instance.
*/
- public function __construct(?ColorCLI $colorCli = null, ?Tmux $tmux = null)
+ public function __construct(?Tmux $tmux = null)
{
parent::__construct();
$this->_echo = config('nntmux.echocli');
$this->_tmux = $tmux ?? new Tmux;
$this->_nntpRetries = Settings::settingValue('nntpretries') !== '' ? (int) Settings::settingValue('nntpretries') : 0 + 1;
- $this->colorCli = $colorCli ?? new ColorCLI;
$this->initializeConfig();
}
@@ -275,7 +271,7 @@ class NNTPService extends \Net_NNTP_Client
': '.
$cError;
- return $this->throwError($this->colorCli->error($message));
+ return $this->throwError(cli()->error($message));
}
// If we are connected, try to authenticate.
@@ -313,7 +309,7 @@ class NNTPService extends \Net_NNTP_Client
$userName.
' ('.$aError.')';
- return $this->throwError($this->colorCli->error($message));
+ return $this->throwError(cli()->error($message));
}
}
}
@@ -337,7 +333,7 @@ class NNTPService extends \Net_NNTP_Client
// If we somehow got out of the loop, return an error.
$message = 'Unable to connect to '.$this->_currentServer.$enc;
- return $this->throwError($this->colorCli->error($message));
+ return $this->throwError(cli()->error($message));
}
/**
@@ -660,7 +656,7 @@ class NNTPService extends \Net_NNTP_Client
} else {
$message = 'Wrong Identifier type, array, int or string accepted. This type of var was passed: '.gettype($identifiers);
- return $this->throwError($this->colorCli->error($message));
+ return $this->throwError(cli()->error($message));
}
if ($aConnected === true) {
@@ -815,7 +811,7 @@ class NNTPService extends \Net_NNTP_Client
$message = "Code {$data->code}: {$data->message}\nSkipping group: {$group}";
if ($this->_echo) {
- $this->colorCli->error($message);
+ cli()->error($message);
}
$nntp->doQuit();
}
@@ -961,7 +957,7 @@ class NNTPService extends \Net_NNTP_Client
if (! empty($deComp)) {
$bytesReceived = \strlen($data);
if ($this->_echo && $bytesReceived > 10240) {
- $this->colorCli->primaryOver(
+ cli()->primaryOver(
'Received '.round($bytesReceived / 1024).
'KB from group ('.$this->group().').'
);
@@ -974,7 +970,7 @@ class NNTPService extends \Net_NNTP_Client
}
$message = 'Decompression of OVER headers failed.';
- return $this->throwError($this->colorCli->error($message), 1000);
+ return $this->throwError(cli()->error($message), 1000);
}
// The buffer was not empty, so we know this was not the real ending, so reset $possibleTerm.
$possibleTerm = false;
@@ -993,7 +989,7 @@ class NNTPService extends \Net_NNTP_Client
if (empty($buffer)) {
$message = 'Error fetching data from usenet server while downloading OVER headers.';
- return $this->throwError($this->colorCli->error($message), 1000);
+ return $this->throwError(cli()->error($message), 1000);
}
}
@@ -1010,7 +1006,7 @@ class NNTPService extends \Net_NNTP_Client
$message = 'Unspecified error while downloading OVER headers.';
- return $this->throwError($this->colorCli->error($message), 1000);
+ return $this->throwError(cli()->error($message), 1000);
}
/**
diff --git a/app/Services/NameFixing/NameFixingService.php b/app/Services/NameFixing/NameFixingService.php
index 7ccc0c18b..0f4652017 100644
--- a/app/Services/NameFixing/NameFixingService.php
+++ b/app/Services/NameFixing/NameFixingService.php
@@ -12,7 +12,6 @@ use App\Services\NameFixing\DTO\NameFixResult;
use App\Services\NameFixing\Extractors\NfoNameExtractor;
use App\Services\NameFixing\Extractors\FileNameExtractor;
use App\Services\NNTP\NNTPService;
-use Blacklight\ColorCLI;
use Illuminate\Support\Arr;
/**
@@ -49,7 +48,6 @@ class NameFixingService
protected FileNameExtractor $fileExtractor;
protected FileNameCleaner $fileNameCleaner;
protected FilePrioritizer $filePrioritizer;
- protected ColorCLI $colorCLI;
protected bool $echoOutput;
protected string $othercats;
@@ -66,8 +64,7 @@ class NameFixingService
?NfoNameExtractor $nfoExtractor = null,
?FileNameExtractor $fileExtractor = null,
?FileNameCleaner $fileNameCleaner = null,
- ?FilePrioritizer $filePrioritizer = null,
- ?ColorCLI $colorCLI = null
+ ?FilePrioritizer $filePrioritizer = null
) {
$this->updateService = $updateService ?? new ReleaseUpdateService();
$this->checkerService = $checkerService ?? new NameCheckerService();
@@ -75,7 +72,6 @@ class NameFixingService
$this->fileExtractor = $fileExtractor ?? new FileNameExtractor();
$this->fileNameCleaner = $fileNameCleaner ?? new FileNameCleaner();
$this->filePrioritizer = $filePrioritizer ?? new FilePrioritizer();
- $this->colorCLI = $colorCLI ?? new ColorCLI();
$this->echoOutput = config('nntmux.echocli');
$this->othercats = implode(',', Category::OTHERS_GROUP);
@@ -123,7 +119,7 @@ class NameFixingService
if ($total > 0) {
$this->_totalReleases = $total;
- $this->colorCLI->info(number_format($total) . ' releases to process.');
+ cli()->info(number_format($total) . ' releases to process.');
foreach ($releases as $rel) {
$releaseRow = Release::fromQuery(
@@ -170,7 +166,7 @@ class NameFixingService
}
$this->echoFoundCount($echo, ' NFO\'s');
} else {
- $this->colorCLI->info('Nothing to fix.');
+ cli()->info('Nothing to fix.');
}
}
@@ -214,7 +210,7 @@ class NameFixingService
if ($total > 0) {
$this->_totalReleases = $total;
- $this->colorCLI->info(number_format($total) . ' file names to process.');
+ cli()->info(number_format($total) . ' file names to process.');
// Group files by release
$releaseFiles = [];
@@ -273,7 +269,7 @@ class NameFixingService
$this->echoFoundCount($echo, ' files');
} else {
- $this->colorCLI->info('Nothing to fix.');
+ cli()->info('Nothing to fix.');
}
}
@@ -321,7 +317,7 @@ class NameFixingService
if ($total > 0) {
$this->_totalReleases = $total;
- $this->colorCLI->info(number_format($total) . ' srr file extensions to process.');
+ cli()->info(number_format($total) . ' srr file extensions to process.');
foreach ($releases as $release) {
$this->updateService->reset();
@@ -333,7 +329,7 @@ class NameFixingService
$this->echoFoundCount($echo, ' files');
} else {
- $this->colorCLI->info('Nothing to fix.');
+ cli()->info('Nothing to fix.');
}
}
@@ -381,7 +377,7 @@ class NameFixingService
if ($total > 0) {
$this->_totalReleases = $total;
- $this->colorCLI->info(number_format($total) . ' CRC32\'s to process.');
+ cli()->info(number_format($total) . ' CRC32\'s to process.');
// Group by release
$releasesCrc = [];
@@ -422,7 +418,7 @@ class NameFixingService
$this->echoFoundCount($echo, ' crc32\'s');
} else {
- $this->colorCLI->info('Nothing to fix.');
+ cli()->info('Nothing to fix.');
}
}
@@ -468,7 +464,7 @@ class NameFixingService
if ($total > 0) {
$this->_totalReleases = $total;
- $this->colorCLI->info(number_format($total) . ' unique ids to process.');
+ cli()->info(number_format($total) . ' unique ids to process.');
foreach ($releases as $rel) {
$this->updateService->reset();
@@ -479,7 +475,7 @@ class NameFixingService
$this->echoFoundCount($echo, ' UID\'s');
} else {
- $this->colorCLI->info('Nothing to fix.');
+ cli()->info('Nothing to fix.');
}
}
@@ -525,7 +521,7 @@ class NameFixingService
if ($total > 0) {
$this->_totalReleases = $total;
- $this->colorCLI->info(number_format($total) . ' hash_16K to process.');
+ cli()->info(number_format($total) . ' hash_16K to process.');
foreach ($releases as $rel) {
$this->updateService->reset();
@@ -536,7 +532,7 @@ class NameFixingService
$this->echoFoundCount($echo, ' hashes');
} else {
- $this->colorCLI->info('Nothing to fix.');
+ cli()->info('Nothing to fix.');
}
}
@@ -833,7 +829,7 @@ class NameFixingService
*/
protected function echoStartMessage(int $time, string $type): void
{
- $this->colorCLI->info(
+ cli()->info(
sprintf(
'Fixing search names %s using %s.',
($time === 1 ? 'in the past 6 hours' : 'since the beginning'),
@@ -849,7 +845,7 @@ class NameFixingService
{
$stats = $this->updateService->getStats();
if ($echo === true) {
- $this->colorCLI->info(
+ cli()->info(
PHP_EOL .
number_format($stats['fixed']) .
' releases have had their names changed out of: ' .
@@ -857,7 +853,7 @@ class NameFixingService
$type . '.'
);
} else {
- $this->colorCLI->info(
+ cli()->info(
PHP_EOL .
number_format($stats['fixed']) .
' releases could have their names changed. ' .
@@ -876,7 +872,7 @@ class NameFixingService
// Show milestone message every 500 releases
if ($stats['checked'] % 500 === 0 && $stats['checked'] > 0) {
- $this->colorCLI->alternate(PHP_EOL . number_format($stats['checked']) . ' files processed.' . PHP_EOL);
+ cli()->alternate(PHP_EOL . number_format($stats['checked']) . ' files processed.' . PHP_EOL);
}
// Show active counter on the same line (overwrites previous)
@@ -942,7 +938,7 @@ class NameFixingService
if ($total > 0) {
$this->_totalReleases = $total;
- $this->colorCLI->info(number_format($total) . ' releases to process.');
+ cli()->info(number_format($total) . ' releases to process.');
$nzbContentsService = app(\App\Services\Nzb\NzbContentsService::class);
foreach ($releases as $release) {
@@ -955,7 +951,7 @@ class NameFixingService
}
$this->echoFoundCount($echo, ' files');
} else {
- $this->colorCLI->info('Nothing to fix.');
+ cli()->info('Nothing to fix.');
}
}
@@ -997,7 +993,7 @@ class NameFixingService
if ($total > 0) {
$this->_totalReleases = $total;
- $this->colorCLI->info(number_format($total) . ' xxx file names to process.');
+ cli()->info(number_format($total) . ' xxx file names to process.');
foreach ($releases as $release) {
$this->updateService->reset();
@@ -1007,7 +1003,7 @@ class NameFixingService
}
$this->echoFoundCount($echo, ' files');
} else {
- $this->colorCLI->info('Nothing to fix.');
+ cli()->info('Nothing to fix.');
}
}
@@ -1046,7 +1042,7 @@ class NameFixingService
if ($total > 0) {
$this->_totalReleases = $total;
- $this->colorCLI->info(number_format($total) . ' mediainfo movie names to process.');
+ cli()->info(number_format($total) . ' mediainfo movie names to process.');
foreach ($releases as $rel) {
$this->updateService->incrementChecked();
@@ -1056,7 +1052,7 @@ class NameFixingService
}
$this->echoFoundCount($echo, ' MediaInfo\'s');
} else {
- $this->colorCLI->info('Nothing to fix.');
+ cli()->info('Nothing to fix.');
}
}
@@ -1288,8 +1284,8 @@ class NameFixingService
$limit = 'LIMIT 1000000';
}
- $this->colorCLI->info(PHP_EOL . 'Match PreFiles ' . ($args[1] ?? 'all') . ' Started at ' . now());
- $this->colorCLI->info('Matching predb filename to cleaned release_files.name.');
+ cli()->info(PHP_EOL . 'Match PreFiles ' . ($args[1] ?? 'all') . ' Started at ' . now());
+ cli()->info('Matching predb filename to cleaned release_files.name.');
$counter = $counted = 0;
$timeStart = now();
@@ -1317,7 +1313,7 @@ class NameFixingService
$total = $query->count();
if ($total > 0) {
- $this->colorCLI->info(PHP_EOL . number_format($total) . ' releases to process.');
+ cli()->info(PHP_EOL . number_format($total) . ' releases to process.');
foreach ($query as $row) {
$success = $this->matchPreDbFiles($row, true, true, $show);
@@ -1325,12 +1321,12 @@ class NameFixingService
$counted++;
}
if ($show === false) {
- $this->colorCLI->info('Renamed Releases: [' . number_format($counted) . '] ' . (new ColorCLI())->percentString(++$counter, $total));
+ cli()->info('Renamed Releases: [' . number_format($counted) . '] ' . (new ColorCLI())->percentString(++$counter, $total));
}
}
- $this->colorCLI->info(PHP_EOL . 'Renamed ' . number_format($counted) . ' releases in ' . now()->diffInSeconds($timeStart, true) . ' seconds.');
+ cli()->info(PHP_EOL . 'Renamed ' . number_format($counted) . ' releases in ' . now()->diffInSeconds($timeStart, true) . ' seconds.');
} else {
- $this->colorCLI->info('Nothing to do.');
+ cli()->info('Nothing to do.');
}
}
}
diff --git a/app/Services/NameFixing/ReleaseUpdateService.php b/app/Services/NameFixing/ReleaseUpdateService.php
index 9827c362e..290ef50ce 100644
--- a/app/Services/NameFixing/ReleaseUpdateService.php
+++ b/app/Services/NameFixing/ReleaseUpdateService.php
@@ -11,7 +11,6 @@ use App\Models\Release;
use App\Models\UsenetGroup;
use App\Services\Categorization\CategorizationService;
use App\Services\ReleaseCleaningService;
-use Blacklight\ColorCLI;
use Illuminate\Support\Arr;
/**
@@ -49,7 +48,6 @@ class ReleaseUpdateService
protected CategorizationService $category;
protected FileNameCleaner $fileNameCleaner;
- protected ColorCLI $colorCLI;
protected bool $echoOutput;
/**
@@ -79,12 +77,10 @@ class ReleaseUpdateService
public function __construct(
?CategorizationService $category = null,
- ?FileNameCleaner $fileNameCleaner = null,
- ?ColorCLI $colorCLI = null
+ ?FileNameCleaner $fileNameCleaner = null
) {
$this->category = $category ?? new CategorizationService();
$this->fileNameCleaner = $fileNameCleaner ?? new FileNameCleaner();
- $this->colorCLI = $colorCLI ?? new ColorCLI();
$this->echoOutput = config('nntmux.echocli');
}
@@ -212,23 +208,23 @@ class ReleaseUpdateService
echo PHP_EOL;
- $this->colorCLI->primary('Release Information:');
+ cli()->primary('Release Information:');
- echo ' ' . $this->colorCLI->headerOver('New name: ') . $this->colorCLI->primary(substr($newName, 0, 100)) . PHP_EOL;
- echo ' ' . $this->colorCLI->headerOver('Old name: ') . $this->colorCLI->primary(substr((string) $release->searchname, 0, 100)) . PHP_EOL;
- echo ' ' . $this->colorCLI->headerOver('Use name: ') . $this->colorCLI->primary(substr((string) $release->name, 0, 100)) . PHP_EOL;
+ echo ' ' . cli()->headerOver('New name: ') . cli()->primary(substr($newName, 0, 100)) . PHP_EOL;
+ echo ' ' . cli()->headerOver('Old name: ') . cli()->primary(substr((string) $release->searchname, 0, 100)) . PHP_EOL;
+ echo ' ' . cli()->headerOver('Use name: ') . cli()->primary(substr((string) $release->name, 0, 100)) . PHP_EOL;
echo PHP_EOL;
- echo ' ' . $this->colorCLI->headerOver('New cat: ') . $this->colorCLI->primary($newCatName) . PHP_EOL;
- echo ' ' . $this->colorCLI->headerOver('Old cat: ') . $this->colorCLI->primary($oldCatName) . PHP_EOL;
- echo ' ' . $this->colorCLI->headerOver('Group: ') . $this->colorCLI->primary($groupName) . PHP_EOL;
+ echo ' ' . cli()->headerOver('New cat: ') . cli()->primary($newCatName) . PHP_EOL;
+ echo ' ' . cli()->headerOver('Old cat: ') . cli()->primary($oldCatName) . PHP_EOL;
+ echo ' ' . cli()->headerOver('Group: ') . cli()->primary($groupName) . PHP_EOL;
echo PHP_EOL;
- echo ' ' . $this->colorCLI->headerOver('Method: ') . $this->colorCLI->primary($type . $method) . PHP_EOL;
- echo ' ' . $this->colorCLI->headerOver('Release ID: ') . $this->colorCLI->primary((string) $release->releases_id) . PHP_EOL;
+ echo ' ' . cli()->headerOver('Method: ') . cli()->primary($type . $method) . PHP_EOL;
+ echo ' ' . cli()->headerOver('Release ID: ') . cli()->primary((string) $release->releases_id) . PHP_EOL;
if (!empty($release->filename)) {
- echo ' ' . $this->colorCLI->headerOver('Filename: ') . $this->colorCLI->primary(substr((string) $release->filename, 0, 100)) . PHP_EOL;
+ echo ' ' . cli()->headerOver('Filename: ') . cli()->primary(substr((string) $release->filename, 0, 100)) . PHP_EOL;
}
if ($type !== 'PAR2, ') {
diff --git a/app/Services/Nzb/NzbImportService.php b/app/Services/Nzb/NzbImportService.php
index b6388aa76..ff90b104b 100644
--- a/app/Services/Nzb/NzbImportService.php
+++ b/app/Services/Nzb/NzbImportService.php
@@ -10,7 +10,6 @@ use App\Models\UsenetGroup;
use App\Services\BlacklistService;
use App\Services\Categorization\CategorizationService;
use App\Services\ReleaseCleaningService;
-use Blacklight\ColorCLI;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
@@ -59,8 +58,6 @@ class NzbImportService
*/
protected string $nzbGuid;
- protected ColorCLI $colorCli;
-
public function __construct(array $options = [])
{
$this->echoCLI = config('nntmux.echocli');
@@ -68,7 +65,6 @@ class NzbImportService
$this->category = new CategorizationService();
$this->nzb = app(NzbService::class);
$this->releaseCleaner = new ReleaseCleaningService;
- $this->colorCli = new ColorCLI;
$this->crossPostt = Settings::settingValue('crossposttime') !== '' ? Settings::settingValue('crossposttime') : 2;
// Set properties from options
@@ -448,7 +444,7 @@ class NzbImportService
if ($this->browser) {
$this->retVal .= $message.'
';
} elseif ($this->echoCLI) {
- $this->colorCli->notice($message);
+ cli()->notice($message);
}
}
diff --git a/app/Services/PopulateAniListService.php b/app/Services/PopulateAniListService.php
index e8f36ea36..cd24b9fbf 100644
--- a/app/Services/PopulateAniListService.php
+++ b/app/Services/PopulateAniListService.php
@@ -6,7 +6,6 @@ namespace App\Services;
use App\Models\AnidbInfo;
use App\Models\AnidbTitle;
-use Blacklight\ColorCLI;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\ClientException;
use GuzzleHttp\Exception\GuzzleException;
@@ -49,15 +48,12 @@ class PopulateAniListService
*/
private static ?array $rateLimitPause = null;
- protected ColorCLI $colorCli;
-
/**
* @throws \Exception
*/
public function __construct()
{
$this->echooutput = config('nntmux.echocli');
- $this->colorCli = new ColorCLI;
// Use storage_path directly to match CoverController expectations
$this->imgSavePath = storage_path('covers/anime/');
@@ -305,7 +301,7 @@ class PopulateAniListService
if ($now < $pausedUntil) {
$remainingSeconds = $pausedUntil - $now;
if ($this->echooutput) {
- $this->colorCli->warning("API calls paused due to 429 error. Resuming in {$remainingSeconds} seconds...");
+ cli()->warning("API calls paused due to 429 error. Resuming in {$remainingSeconds} seconds...");
}
// Throw exception to stop processing
@@ -339,7 +335,7 @@ class PopulateAniListService
];
if ($this->echooutput) {
- $this->colorCli->error('AniList API returned 429 (Too Many Requests). Pausing all API calls for 15 minutes.');
+ cli()->error('AniList API returned 429 (Too Many Requests). Pausing all API calls for 15 minutes.');
}
return false;
@@ -367,7 +363,7 @@ class PopulateAniListService
if (isset($body['errors'])) {
if ($this->echooutput) {
- $this->colorCli->error('AniList API Error: '.json_encode($body['errors']));
+ cli()->error('AniList API Error: '.json_encode($body['errors']));
}
return false;
@@ -385,20 +381,20 @@ class PopulateAniListService
];
if ($this->echooutput) {
- $this->colorCli->error('AniList API returned 429 (Too Many Requests). Pausing all API calls for 15 minutes.');
+ cli()->error('AniList API returned 429 (Too Many Requests). Pausing all API calls for 15 minutes.');
}
throw new \Exception("AniList API rate limit exceeded (429). Paused until " . date('Y-m-d H:i:s', $pauseUntil));
}
if ($this->echooutput) {
- $this->colorCli->error('AniList API Request Failed: '.$e->getMessage());
+ cli()->error('AniList API Request Failed: '.$e->getMessage());
}
return false;
} catch (GuzzleException $e) {
if ($this->echooutput) {
- $this->colorCli->error('AniList API Request Failed: '.$e->getMessage());
+ cli()->error('AniList API Request Failed: '.$e->getMessage());
}
return false;
@@ -428,7 +424,7 @@ class PopulateAniListService
if ($waitTime > 0 && $waitTime <= 60) {
if ($this->echooutput) {
- $this->colorCli->warning("Rate limit approaching. Waiting {$waitTime} seconds...");
+ cli()->warning("Rate limit approaching. Waiting {$waitTime} seconds...");
}
sleep($waitTime);
}
@@ -659,15 +655,15 @@ class PopulateAniListService
chmod($coverPath, 0644);
if ($this->echooutput) {
- $this->colorCli->info("Downloaded cover image for ID {$anidbid} from AniList to {$coverPath}");
+ cli()->info("Downloaded cover image for ID {$anidbid} from AniList to {$coverPath}");
}
} catch (GuzzleException $e) {
if ($this->echooutput) {
- $this->colorCli->warning("Failed to download cover image for ID {$anidbid}: ".$e->getMessage());
+ cli()->warning("Failed to download cover image for ID {$anidbid}: ".$e->getMessage());
}
} catch (\Exception $e) {
if ($this->echooutput) {
- $this->colorCli->error("Error saving cover image for ID {$anidbid}: ".$e->getMessage());
+ cli()->error("Error saving cover image for ID {$anidbid}: ".$e->getMessage());
}
}
}
@@ -713,7 +709,7 @@ class PopulateAniListService
if ($anilistData === false) {
if ($this->echooutput) {
- $this->colorCli->info("Anime with AniList ID: {$anilistId} not found.");
+ cli()->info("Anime with AniList ID: {$anilistId} not found.");
}
return;
diff --git a/app/Services/ReleaseCreationService.php b/app/Services/ReleaseCreationService.php
index 6bc645153..78f71eda5 100644
--- a/app/Services/ReleaseCreationService.php
+++ b/app/Services/ReleaseCreationService.php
@@ -13,14 +13,12 @@ use App\Models\UsenetGroup;
use App\Services\Categorization\CategorizationService;
use App\Services\Nzb\NzbService;
use App\Services\ReleaseCleaningService;
-use Blacklight\ColorCLI;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
class ReleaseCreationService
{
public function __construct(
- private readonly ColorCLI $colorCLI,
private readonly ReleaseCleaningService $releaseCleaning
) {}
@@ -38,7 +36,7 @@ class ReleaseCreationService
$duplicate = 0;
if ($echoCLI) {
- $this->colorCLI->header('Process Releases -> Create releases from complete collections.');
+ cli()->header('Process Releases -> Create releases from complete collections.');
}
$collectionsQuery = Collection::query()
@@ -53,7 +51,7 @@ class ReleaseCreationService
$collections = $collectionsQuery->get();
if ($echoCLI && $collections->count() > 0) {
- $this->colorCLI->primary(\count($collections).' Collections ready to be converted to releases.', true);
+ cli()->primary(\count($collections).' Collections ready to be converted to releases.', true);
}
foreach ($collections as $collection) {
@@ -181,7 +179,7 @@ class ReleaseCreationService
$totalTime = now()->diffInSeconds($startTime, true);
if ($echoCLI) {
- $this->colorCLI->primary(
+ cli()->primary(
PHP_EOL.
number_format($returnCount).
' Releases added and '.
diff --git a/app/Services/ReleaseImageService.php b/app/Services/ReleaseImageService.php
index 6e4cc496e..7c556fa80 100644
--- a/app/Services/ReleaseImageService.php
+++ b/app/Services/ReleaseImageService.php
@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace App\Services;
-use Blacklight\ColorCLI;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Log;
use Intervention\Image\Drivers\Imagick\Driver;
@@ -45,14 +44,11 @@ class ReleaseImageService
*/
public string $vidSavePath;
- protected ColorCLI $colorCli;
-
/**
* ReleaseImageService constructor.
*/
public function __construct()
{
- $this->colorCli = new ColorCLI;
$this->audSavePath = storage_path('covers/audiosample/');
$this->imgSavePath = storage_path('covers/preview/');
$this->jpgSavePath = storage_path('covers/sample/');
@@ -88,7 +84,7 @@ class ReleaseImageService
$httpCode = (int) $matches[1];
if ($httpCode >= 400) {
Log::debug('HTTP error fetching image from '.$imgLoc.': '.$statusLine);
- $this->colorCli->notice('HTTP error fetching image: '.$statusLine);
+ cli()->notice('HTTP error fetching image: '.$statusLine);
return false;
}
@@ -99,14 +95,14 @@ class ReleaseImageService
$error = error_get_last();
$errorMsg = $error !== null && isset($error['message']) ? $error['message'] : 'Unknown error fetching image';
Log::debug('Failed to fetch image from '.$imgLoc.': '.$errorMsg);
- $this->colorCli->notice('Failed to fetch image from '.$imgLoc.': '.$errorMsg);
+ cli()->notice('Failed to fetch image from '.$imgLoc.': '.$errorMsg);
return false;
}
if (empty($imageData)) {
Log::debug('Empty image data received from '.$imgLoc);
- $this->colorCli->notice('Empty image data received from '.$imgLoc);
+ cli()->notice('Empty image data received from '.$imgLoc);
return false;
}
@@ -115,18 +111,18 @@ class ReleaseImageService
$img = $manager->read($imageData);
} catch (\Exception $e) {
if ($e->getCode() === 404) {
- $this->colorCli->notice('Data not available on server');
+ cli()->notice('Data not available on server');
} elseif ($e->getCode() === 503) {
- $this->colorCli->notice('Service unavailable');
+ cli()->notice('Service unavailable');
} else {
Log::debug('Exception fetching image from '.$imgLoc.': '.$e->getMessage());
- $this->colorCli->notice('Unable to fetch image: '.$e->getMessage());
+ cli()->notice('Unable to fetch image: '.$e->getMessage());
}
$img = false;
} catch (\Error $e) {
Log::debug('Error fetching image from '.$imgLoc.': '.$e->getMessage());
- $this->colorCli->info($e->getMessage());
+ cli()->info($e->getMessage());
$img = false;
}
diff --git a/app/Services/ReleaseProcessingService.php b/app/Services/ReleaseProcessingService.php
index bfa0ddf74..02ac8513e 100644
--- a/app/Services/ReleaseProcessingService.php
+++ b/app/Services/ReleaseProcessingService.php
@@ -19,7 +19,6 @@ use App\Support\DTOs\ProcessReleasesSettings;
use App\Support\DTOs\ReleaseCreationResult;
use App\Support\DTOs\ReleaseDeleteStats;
use App\Services\NNTP\NNTPService;
-use Blacklight\ColorCLI;
use Blacklight\Genres;
use DateTimeInterface;
use Illuminate\Support\Carbon;
@@ -48,7 +47,6 @@ final class ReleaseProcessingService
private bool $echoCLI;
private readonly ProcessReleasesSettings $settings;
- private readonly ColorCLI $colorCLI;
private readonly NzbService $nzb;
private readonly ReleaseCleaningService $releaseCleaning;
private readonly ReleaseManagementService $releaseManagement;
@@ -58,7 +56,6 @@ final class ReleaseProcessingService
private readonly ?PostProcessService $postProcessService;
public function __construct(
- ?ColorCLI $colorCLI = null,
?NzbService $nzb = null,
?ReleaseCleaningService $releaseCleaning = null,
?ReleaseManagementService $releaseManagement = null,
@@ -69,16 +66,15 @@ final class ReleaseProcessingService
) {
$this->echoCLI = (bool) config('nntmux.echocli');
- $this->colorCLI = $colorCLI ?? new ColorCLI();
$this->nzb = $nzb ?? app(NzbService::class);
$this->releaseCleaning = $releaseCleaning ?? new ReleaseCleaningService();
$this->releaseManagement = $releaseManagement ?? app(ReleaseManagementService::class);
$this->releaseImage = $releaseImage ?? new ReleaseImageService();
$this->releaseCreationService = $releaseCreationService
- ?? new ReleaseCreationService($this->colorCLI, $this->releaseCleaning);
+ ?? new ReleaseCreationService($this->releaseCleaning);
$this->collectionCleanupService = $collectionCleanupService
- ?? new CollectionCleanupService($this->colorCLI);
+ ?? new CollectionCleanupService();
$this->postProcessService = $postProcessService;
$this->settings = $this->loadSettings();
@@ -112,7 +108,7 @@ final class ReleaseProcessingService
private function validateSettings(): void
{
if (!$this->settings->hasValidCompletion()) {
- $this->colorCLI->error(
+ cli()->error(
PHP_EOL . 'Invalid completion setting. Value must be between 0 and 100.'
);
}
@@ -570,7 +566,7 @@ final class ReleaseProcessingService
$stats = ['minSize' => 0, 'maxSize' => 0, 'minFiles' => 0];
if ($this->echoCLI) {
- $this->colorCLI->header(
+ cli()->header(
'Process Releases -> Delete releases smaller/larger than minimum size/file count from group/site setting.'
);
}
@@ -622,7 +618,7 @@ final class ReleaseProcessingService
if (!file_exists($nzbPath)) {
if ($this->echoCLI) {
- $this->colorCLI->error("Bad or missing NZB directory - {$nzbPath}");
+ cli()->error("Bad or missing NZB directory - {$nzbPath}");
}
return false;
}
@@ -882,7 +878,7 @@ final class ReleaseProcessingService
} while (true);
if ($this->echoCLI && $totalDeleted > 0) {
- $this->colorCLI->primary("Deleted {$totalDeleted} broken/stuck collections.", true);
+ cli()->primary("Deleted {$totalDeleted} broken/stuck collections.", true);
}
}
@@ -928,7 +924,7 @@ final class ReleaseProcessingService
$attempt++;
if ($attempt >= self::MAX_RETRIES) {
if ($this->echoCLI) {
- $this->colorCLI->error(
+ cli()->error(
'Stuck collections delete failed after retries: ' . $e->getMessage()
);
}
@@ -1233,8 +1229,8 @@ final class ReleaseProcessingService
}
echo PHP_EOL;
- $this->colorCLI->header('NNTmux Release Processing');
- $this->colorCLI->info('Started: ' . now()->format('Y-m-d H:i:s'));
+ cli()->header('NNTmux Release Processing');
+ cli()->info('Started: ' . now()->format('Y-m-d H:i:s'));
}
private function outputHeader(string $title): void
@@ -1244,8 +1240,8 @@ final class ReleaseProcessingService
}
echo PHP_EOL;
- $this->colorCLI->header(strtoupper($title));
- $this->colorCLI->header(str_repeat('-', strlen($title)));
+ cli()->header(strtoupper($title));
+ cli()->header(str_repeat('-', strlen($title)));
}
private function outputSubHeader(string $title): void
@@ -1254,7 +1250,7 @@ final class ReleaseProcessingService
return;
}
- $this->colorCLI->notice(" {$title}");
+ cli()->notice(" {$title}");
}
private function outputSuccess(string $message): void
@@ -1263,7 +1259,7 @@ final class ReleaseProcessingService
return;
}
- $this->colorCLI->primary(" {$message}");
+ cli()->primary(" {$message}");
}
private function outputInfo(string $message): void
@@ -1272,7 +1268,7 @@ final class ReleaseProcessingService
return;
}
- $this->colorCLI->info(" {$message}");
+ cli()->info(" {$message}");
}
private function outputStat(string $label, string|int $value, string $suffix = ''): void
@@ -1282,7 +1278,7 @@ final class ReleaseProcessingService
}
$formattedValue = is_int($value) ? number_format($value) : $value;
- $this->colorCLI->primary(" {$label}: {$formattedValue}{$suffix}");
+ cli()->primary(" {$label}: {$formattedValue}{$suffix}");
}
private function outputElapsedTime(DateTimeInterface $startTime, string $prefix = 'Time'): void
@@ -1293,7 +1289,7 @@ final class ReleaseProcessingService
$elapsed = now()->diffInSeconds($startTime, true);
$timeStr = $this->formatElapsedTime($elapsed);
- $this->colorCLI->info(" {$prefix}: {$timeStr}");
+ cli()->info(" {$prefix}: {$timeStr}");
}
private function formatElapsedTime(int|float $seconds): string
@@ -1347,15 +1343,15 @@ final class ReleaseProcessingService
$elapsed = now()->diffInSeconds($startTime, true);
echo PHP_EOL;
- $this->colorCLI->header('SUMMARY');
- $this->colorCLI->header('-------');
- $this->colorCLI->primary(' Releases added: ' . number_format($releasesAdded));
- $this->colorCLI->primary(' NZBs created: ' . number_format($nzbsCreated));
+ cli()->header('SUMMARY');
+ cli()->header('-------');
+ cli()->primary(' Releases added: ' . number_format($releasesAdded));
+ cli()->primary(' NZBs created: ' . number_format($nzbsCreated));
if ($dupes > 0) {
- $this->colorCLI->warning(' Duplicates skipped: ' . number_format($dupes));
+ cli()->warning(' Duplicates skipped: ' . number_format($dupes));
}
- $this->colorCLI->info(' Processing cycles: ' . number_format($iterations));
- $this->colorCLI->info(' Total time: ' . $this->formatElapsedTime($elapsed));
+ cli()->info(' Processing cycles: ' . number_format($iterations));
+ cli()->info(' Total time: ' . $this->formatElapsedTime($elapsed));
echo PHP_EOL;
}
diff --git a/app/Services/ReleaseRemoverService.php b/app/Services/ReleaseRemoverService.php
index 60ae4bf97..5929b9ae8 100644
--- a/app/Services/ReleaseRemoverService.php
+++ b/app/Services/ReleaseRemoverService.php
@@ -9,7 +9,6 @@ use App\Models\Category;
use App\Models\Settings;
use App\Services\Nzb\NzbService;
use App\Services\Releases\ReleaseManagementService;
-use Blacklight\ColorCLI;
use Exception;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
@@ -37,7 +36,6 @@ class ReleaseRemoverService
private const string TYPE_WMV_ALL = 'wmv_all';
protected string $blacklistID = '';
- protected ColorCLI $colorCLI;
protected string $crapTime = '';
protected bool $delete = false;
protected int $deletedCount = 0;
@@ -57,12 +55,10 @@ class ReleaseRemoverService
private array $removalHandlers;
public function __construct(
- ?ColorCLI $colorCLI = null,
?ReleaseManagementService $releaseManagement = null,
?NzbService $nzb = null,
?ReleaseImageService $releaseImage = null
) {
- $this->colorCLI = $colorCLI ?? new ColorCLI;
$this->releaseManagement = $releaseManagement ?? app(ReleaseManagementService::class);
$this->nzb = $nzb ?? app(NzbService::class);
$this->releaseImage = $releaseImage ?? new ReleaseImageService;
@@ -261,8 +257,8 @@ class ReleaseRemoverService
private function logCompletion(\Carbon\Carbon $timeStart): void
{
if ($this->echoCLI) {
- $this->colorCLI->headerOver(($this->delete ? 'Deleted ' : 'Would have deleted ').$this->deletedCount.' release(s). This script ran for ');
- $this->colorCLI->header(now()->diffInSeconds($timeStart, true).' seconds', true);
+ cli()->headerOver(($this->delete ? 'Deleted ' : 'Would have deleted ').$this->deletedCount.' release(s). This script ran for ');
+ cli()->header(now()->diffInSeconds($timeStart, true).' seconds', true);
}
}
@@ -272,7 +268,7 @@ class ReleaseRemoverService
private function logHeader(string $message): void
{
if ($this->echoCLI) {
- $this->colorCLI->header($message, true);
+ cli()->header($message, true);
}
}
@@ -612,7 +608,7 @@ class ReleaseRemoverService
));
if (empty($regexList)) {
- $this->colorCLI->error("No regular expressions were selected for blacklist removal. Make sure you have activated REGEXPs in Site Edit and you're specifying a valid ID.", true);
+ cli()->error("No regular expressions were selected for blacklist removal. Make sure you have activated REGEXPs in Site Edit and you're specifying a valid ID.", true);
return true;
}
@@ -680,7 +676,7 @@ class ReleaseRemoverService
*/
private function logBlacklistOperation(string $opTypeName, string $regexMatch): void
{
- $this->colorCLI->header(sprintf(
+ cli()->header(sprintf(
'Finding crap releases for %s: Using only REGEXP method against release %s.%s',
$this->method,
$opTypeName,
@@ -737,7 +733,7 @@ class ReleaseRemoverService
$this->method = 'Blacklist Files '.$regex->id;
- $this->colorCLI->header(sprintf(
+ cli()->header(sprintf(
'Finding crap releases for %s: Using only REGEXP method against release filenames.%s',
$this->method,
PHP_EOL
@@ -849,10 +845,10 @@ class ReleaseRemoverService
if ($this->delete) {
$this->releaseManagement->deleteSingleWithService(['g' => $release->guid, 'i' => $release->id], $this->nzb, $this->releaseImage);
if ($this->echoCLI) {
- $this->colorCLI->primary('Deleting: '.$this->method.': '.$release->searchname, true);
+ cli()->primary('Deleting: '.$this->method.': '.$release->searchname, true);
}
} elseif ($this->echoCLI) {
- $this->colorCLI->primary('Would be deleting: '.$this->method.': '.$release->searchname, true);
+ cli()->primary('Would be deleting: '.$this->method.': '.$release->searchname, true);
}
$deletedCount++;
}
@@ -1060,7 +1056,7 @@ class ReleaseRemoverService
return true;
}
- $this->colorCLI->primary(
+ cli()->primary(
'This is the query we have formatted using your criteria, you can run it in SQL to see if you like the results:'.
PHP_EOL.$this->query.';'.PHP_EOL.
'If you are satisfied, type yes and press enter. Anything else will exit.',
@@ -1069,7 +1065,7 @@ class ReleaseRemoverService
$userInput = trim(fgets(fopen('php://stdin', 'rtb')));
if ($userInput !== 'yes') {
- $this->colorCLI->primary('You typed: "'.$userInput.'", the program will exit.', true);
+ cli()->primary('You typed: "'.$userInput.'", the program will exit.', true);
return false;
}
@@ -1104,7 +1100,7 @@ class ReleaseRemoverService
protected function returnError(): bool
{
if ($this->echoCLI && $this->error !== '') {
- $this->colorCLI->error($this->error, true);
+ cli()->error($this->error, true);
}
return false;
diff --git a/app/Services/Runners/BackfillRunner.php b/app/Services/Runners/BackfillRunner.php
index 1ed9b29d7..5ef776eb8 100644
--- a/app/Services/Runners/BackfillRunner.php
+++ b/app/Services/Runners/BackfillRunner.php
@@ -50,7 +50,7 @@ class BackfillRunner extends BaseRunner
foreach ($results as $groupName => $output) {
echo $output;
- $this->colorCli->primary('Backfilled group '.$groupName);
+ cli()->primary('Backfilled group '.$groupName);
}
}
@@ -111,7 +111,7 @@ class BackfillRunner extends BaseRunner
if ($count <= 0) {
$this->headerNone();
if (config('nntmux.echocli') && $groupName !== '') {
- $this->colorCli->primary('No backfill needed for group '.$groupName);
+ cli()->primary('No backfill needed for group '.$groupName);
}
return;
@@ -150,7 +150,7 @@ class BackfillRunner extends BaseRunner
foreach ($results as $idx => $output) {
echo $output;
- $this->colorCli->primary('Backfilled group '.$groupName);
+ cli()->primary('Backfilled group '.$groupName);
}
}
}
diff --git a/app/Services/Runners/BaseRunner.php b/app/Services/Runners/BaseRunner.php
index c4ea36ef4..8dac77837 100644
--- a/app/Services/Runners/BaseRunner.php
+++ b/app/Services/Runners/BaseRunner.php
@@ -2,16 +2,12 @@
namespace App\Services\Runners;
-use Blacklight\ColorCLI;
use Symfony\Component\Process\Process;
abstract class BaseRunner
{
- protected ColorCLI $colorCli;
-
- public function __construct(?ColorCLI $colorCli = null)
+ public function __construct()
{
- $this->colorCli = $colorCli ?? new ColorCLI;
}
protected function buildDnrCommand(string $args): string
@@ -147,7 +143,7 @@ abstract class BaseRunner
protected function headerStart(string $workType, int $count, int $maxProcesses): void
{
if (config('nntmux.echocli')) {
- $this->colorCli->header(
+ cli()->header(
'Multi-processing started at '.now()->toRfc2822String().' for '.$workType.' with '.$count.
' job(s) to do using a max of '.max(1, $maxProcesses).' child process(es).'
);
@@ -157,7 +153,7 @@ abstract class BaseRunner
protected function headerNone(): void
{
if (config('nntmux.echocli')) {
- $this->colorCli->header('No work to do!');
+ cli()->header('No work to do!');
}
}
@@ -349,7 +345,7 @@ abstract class BaseRunner
unset($running[$key]);
$finished++;
if (config('nntmux.echocli')) {
- $this->colorCli->primary('Finished task #'.($total - $finished + 1).' for '.$desc);
+ cli()->primary('Finished task #'.($total - $finished + 1).' for '.$desc);
}
// Start next from queue if available
if (! empty($queue)) {
diff --git a/app/Services/Runners/BinariesRunner.php b/app/Services/Runners/BinariesRunner.php
index 34e69de70..87156bd99 100644
--- a/app/Services/Runners/BinariesRunner.php
+++ b/app/Services/Runners/BinariesRunner.php
@@ -49,7 +49,7 @@ class BinariesRunner extends BaseRunner
foreach ($results as $groupName => $output) {
echo $output;
- $this->colorCli->primary('Updated group '.$groupName);
+ cli()->primary('Updated group '.$groupName);
}
}
@@ -64,7 +64,7 @@ class BinariesRunner extends BaseRunner
// Prevent division by zero - ensure maxmssgs is at least 1
if ($maxMessages < 1) {
$defaultMaxMessages = 20000;
- $this->colorCli->warning('maxmssgs setting is invalid or not set, using default of '.$defaultMaxMessages);
+ cli()->warning('maxmssgs setting is invalid or not set, using default of '.$defaultMaxMessages);
$maxMessages = $defaultMaxMessages;
}
@@ -144,7 +144,7 @@ class BinariesRunner extends BaseRunner
$group = $groupMapping[$idx] ?? '';
if (!empty($group)) {
echo $output;
- $this->colorCli->primary('Updated group '.$group);
+ cli()->primary('Updated group '.$group);
}
}
}
diff --git a/app/Services/Runners/PostProcessRunner.php b/app/Services/Runners/PostProcessRunner.php
index 78b33b670..3d67fb97c 100644
--- a/app/Services/Runners/PostProcessRunner.php
+++ b/app/Services/Runners/PostProcessRunner.php
@@ -51,11 +51,11 @@ class PostProcessRunner extends BaseRunner
foreach ($results as $taskIdx => $output) {
echo $output;
- $this->colorCli->primary('Finished task for '.$desc);
+ cli()->primary('Finished task for '.$desc);
}
} catch (\Throwable $e) {
Log::error('Postprocess batch failed: '.$e->getMessage());
- $this->colorCli->error('Batch '.($batchIndex + 1).' failed: '.$e->getMessage());
+ cli()->error('Batch '.($batchIndex + 1).' failed: '.$e->getMessage());
}
}
}
@@ -241,11 +241,11 @@ class PostProcessRunner extends BaseRunner
foreach ($results as $taskIdx => $output) {
echo $output;
- $this->colorCli->primary('Finished task for '.$desc);
+ cli()->primary('Finished task for '.$desc);
}
} catch (\Throwable $e) {
Log::error('TV pipeline batch failed: '.$e->getMessage());
- $this->colorCli->error('Batch '.($batchIndex + 1).' failed: '.$e->getMessage());
+ cli()->error('Batch '.($batchIndex + 1).' failed: '.$e->getMessage());
}
}
}
diff --git a/app/Services/Runners/ReleasesRunner.php b/app/Services/Runners/ReleasesRunner.php
index 85a5d5998..4b94bc829 100644
--- a/app/Services/Runners/ReleasesRunner.php
+++ b/app/Services/Runners/ReleasesRunner.php
@@ -64,11 +64,11 @@ class ReleasesRunner extends BaseRunner
foreach ($results as $groupId => $output) {
echo $output;
- $this->colorCli->primary('Finished performing release processing for group ID: '.$groupId);
+ cli()->primary('Finished performing release processing for group ID: '.$groupId);
}
} catch (\Throwable $e) {
Log::error('Release processing batch failed: '.$e->getMessage());
- $this->colorCli->error('Batch '.($batchIndex + 1).' failed: '.$e->getMessage());
+ cli()->error('Batch '.($batchIndex + 1).' failed: '.$e->getMessage());
}
}
}
@@ -114,11 +114,11 @@ class ReleasesRunner extends BaseRunner
foreach ($results as $groupId => $output) {
echo $output;
$name = UsenetGroup::getNameByID($groupId);
- $this->colorCli->primary('Finished updating binaries, processing releases and additional postprocessing for group: '.$name);
+ cli()->primary('Finished updating binaries, processing releases and additional postprocessing for group: '.$name);
}
} catch (\Throwable $e) {
Log::error('Update per group batch failed: '.$e->getMessage());
- $this->colorCli->error('Batch '.($batchIndex + 1).' failed: '.$e->getMessage());
+ cli()->error('Batch '.($batchIndex + 1).' failed: '.$e->getMessage());
}
}
}
@@ -186,11 +186,11 @@ class ReleasesRunner extends BaseRunner
foreach ($results as $taskIdx => $output) {
echo $output;
- $this->colorCli->primary('Task #'.$taskIdx.' Finished fixing releases names');
+ cli()->primary('Task #'.$taskIdx.' Finished fixing releases names');
}
} catch (\Throwable $e) {
Log::error('Fix rel names batch failed: '.$e->getMessage());
- $this->colorCli->error('Batch '.($batchIndex + 1).' failed: '.$e->getMessage());
+ cli()->error('Batch '.($batchIndex + 1).' failed: '.$e->getMessage());
}
}
}
diff --git a/app/Services/Search/Drivers/ManticoreSearchDriver.php b/app/Services/Search/Drivers/ManticoreSearchDriver.php
index 124102672..90e036b18 100644
--- a/app/Services/Search/Drivers/ManticoreSearchDriver.php
+++ b/app/Services/Search/Drivers/ManticoreSearchDriver.php
@@ -4,7 +4,6 @@ namespace App\Services\Search\Drivers;
use App\Models\Release;
use App\Services\Search\Contracts\SearchDriverInterface;
-use Blacklight\ColorCLI;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
@@ -26,8 +25,6 @@ class ManticoreSearchDriver implements SearchDriverInterface
public Search $search;
- private ColorCLI $cli;
-
/**
* Establishes a connection to ManticoreSearch HTTP port.
*/
@@ -37,7 +34,6 @@ class ManticoreSearchDriver implements SearchDriverInterface
$this->connection = ['host' => $this->config['host'], 'port' => $this->config['port']];
$this->manticoreSearch = new Client($this->connection);
$this->search = new Search($this->manticoreSearch);
- $this->cli = new ColorCLI;
}
/**
diff --git a/app/Services/Tmux/Scripts/groupfixrelnames.php b/app/Services/Tmux/Scripts/groupfixrelnames.php
index 427557022..6149187c9 100644
--- a/app/Services/Tmux/Scripts/groupfixrelnames.php
+++ b/app/Services/Tmux/Scripts/groupfixrelnames.php
@@ -12,12 +12,8 @@
require_once __DIR__.'/../../../../bootstrap/autoload.php';
-use Blacklight\ColorCLI;
-
-$colorCli = new ColorCLI;
-
if (! isset($argv[1])) {
- $colorCli->error('This script is not intended to be run manually, it is called from Multiprocessing.');
+ cli()->error('This script is not intended to be run manually, it is called from Multiprocessing.');
exit(1);
}
@@ -30,7 +26,7 @@ $artisan = base_path('artisan');
switch ($type) {
case 'standard':
if ($guidChar === null || $maxPerRun === null || ! is_numeric($maxPerRun)) {
- $colorCli->error('Invalid arguments for standard type');
+ cli()->error('Invalid arguments for standard type');
exit(1);
}
@@ -39,7 +35,7 @@ switch ($type) {
case 'predbft':
if (! isset($maxPerRun) || ! is_numeric($maxPerRun) || ! isset($thread) || ! is_numeric($thread)) {
- $colorCli->error('Invalid arguments for predbft type');
+ cli()->error('Invalid arguments for predbft type');
exit(1);
}
@@ -47,7 +43,7 @@ switch ($type) {
break;
default:
- $colorCli->error("Unknown type: {$type}");
+ cli()->error("Unknown type: {$type}");
exit(1);
}
diff --git a/app/Services/Tmux/Scripts/monitor.php b/app/Services/Tmux/Scripts/monitor.php
index 38391acdb..79bf2c589 100644
--- a/app/Services/Tmux/Scripts/monitor.php
+++ b/app/Services/Tmux/Scripts/monitor.php
@@ -19,9 +19,6 @@ use App\Models\Settings;
use App\Services\Tmux\TmuxMonitorService;
use App\Services\Tmux\TmuxTaskRunner;
use App\Services\Tmux\TmuxOutput;
-use Blacklight\ColorCLI;
-
-$colorCli = new ColorCLI;
try {
// Get session name
@@ -42,7 +39,7 @@ try {
logger()->error('Failed to spawn IRC scraper: '.$e->getMessage());
}
- $colorCli->header('Tmux Monitor Started');
+ cli()->header('Tmux Monitor Started');
echo "Session: {$sessionName}\n";
echo "Press Ctrl+C to stop (or set exit flag in settings)\n\n";
@@ -81,10 +78,10 @@ try {
sleep(10);
}
- $colorCli->info('Monitor stopped by exit flag');
+ cli()->info('Monitor stopped by exit flag');
} catch (Exception $e) {
- $colorCli->error('Monitor failed: '.$e->getMessage());
+ cli()->error('Monitor failed: '.$e->getMessage());
logger()->error('Tmux monitor error', [
'message' => $e->getMessage(),
'trace' => $e->getTraceAsString(),
diff --git a/app/Services/Tmux/Tmux.php b/app/Services/Tmux/Tmux.php
index d507ee772..614e89c8a 100644
--- a/app/Services/Tmux/Tmux.php
+++ b/app/Services/Tmux/Tmux.php
@@ -5,7 +5,6 @@ namespace App\Services\Tmux;
use App\Models\Category;
use App\Models\Settings;
use App\Services\NameFixing\NameFixingService;
-use Blacklight\ColorCLI;
use Blacklight\Nfo;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
@@ -22,15 +21,12 @@ class Tmux
public $tmux_session;
- protected ColorCLI $colorCli;
-
/**
* Tmux constructor.
*/
public function __construct()
{
$this->pdo = DB::connection()->getPdo();
- $this->colorCli = new ColorCLI;
}
/**
@@ -417,12 +413,12 @@ class Tmux
if ($this->isRunning()) {
Settings::query()->where(['name' => 'running'])->update(['value' => 0]);
$sleep = Settings::settingValue('monitor_delay');
- $this->colorCli->header('Stopping tmux scripts and waiting '.$sleep.' seconds for all panes to shutdown');
+ cli()->header('Stopping tmux scripts and waiting '.$sleep.' seconds for all panes to shutdown');
sleep($sleep);
return true;
}
- $this->colorCli->info('Tmux scripts are not running!');
+ cli()->info('Tmux scripts are not running!');
return false;
}
diff --git a/app/Services/Tmux/TmuxOutput.php b/app/Services/Tmux/TmuxOutput.php
index 94844e9d6..6be8b1d0c 100644
--- a/app/Services/Tmux/TmuxOutput.php
+++ b/app/Services/Tmux/TmuxOutput.php
@@ -2,7 +2,6 @@
namespace App\Services\Tmux;
-use Blacklight\ColorCLI;
use Illuminate\Support\Facades\Process;
/**
@@ -482,8 +481,8 @@ class TmuxOutput extends Tmux
['Slow', '/.*\bSlow[^:]*?: (\d+)\b.*/'],
['QPS', '/.*\bQueries[^:]*?: (\d+)\b.*/'],
] as $v) {
- $pieces[] = $this->colorCli->ansiString($v[0].' = ', 'green').
- $this->colorCli->ansiString(preg_replace($v[1], '$1', $info), 'yellow');
+ $pieces[] = cli()->ansiString($v[0].' = ', 'green').
+ cli()->ansiString(preg_replace($v[1], '$1', $info), 'yellow');
}
$buffer .= PHP_EOL.implode(', ', $pieces).PHP_EOL;
@@ -516,12 +515,12 @@ class TmuxOutput extends Tmux
protected function _setColourMasks(): void
{
- $this->_colourMasks[1] = $this->colorCli->ansiString('%-18s', 'yellow').' '.$this->colorCli->ansiString('%-60.60s', 'yellow').PHP_EOL;
- $this->_colourMasks['2.0'] = $this->colorCli->ansiString('%-20s', 'magenta').' '.$this->colorCli->ansiString('%-33.33s', 'yellow').PHP_EOL;
- $this->_colourMasks['2.1'] = $this->colorCli->ansiString('%-20s', 'yellow').' '.$this->colorCli->ansiString('%-33.33s', 'yellow').PHP_EOL;
- $this->_colourMasks[3] = $this->colorCli->ansiString('%-16.16s %25.25s %25.25s', 'yellow').PHP_EOL;
- $this->_colourMasks[4] = $this->colorCli->ansiString('%-16.16s', 'green').' '.$this->colorCli->ansiString('%25.25s %25.25s', 'yellow').PHP_EOL;
- $this->_colourMasks[5] = $this->colorCli->ansiString('%-16.16s %25.25s %25.25s', 'yellow').PHP_EOL;
+ $this->_colourMasks[1] = cli()->ansiString('%-18s', 'yellow').' '.cli()->ansiString('%-60.60s', 'yellow').PHP_EOL;
+ $this->_colourMasks['2.0'] = cli()->ansiString('%-20s', 'magenta').' '.cli()->ansiString('%-33.33s', 'yellow').PHP_EOL;
+ $this->_colourMasks['2.1'] = cli()->ansiString('%-20s', 'yellow').' '.cli()->ansiString('%-33.33s', 'yellow').PHP_EOL;
+ $this->_colourMasks[3] = cli()->ansiString('%-16.16s %25.25s %25.25s', 'yellow').PHP_EOL;
+ $this->_colourMasks[4] = cli()->ansiString('%-16.16s', 'green').' '.cli()->ansiString('%25.25s %25.25s', 'yellow').PHP_EOL;
+ $this->_colourMasks[5] = cli()->ansiString('%-16.16s %25.25s %25.25s', 'yellow').PHP_EOL;
}
}
diff --git a/app/Services/Tmux/TmuxTaskRunner.php b/app/Services/Tmux/TmuxTaskRunner.php
index a48c4d38d..9e52b2b08 100644
--- a/app/Services/Tmux/TmuxTaskRunner.php
+++ b/app/Services/Tmux/TmuxTaskRunner.php
@@ -3,7 +3,6 @@
namespace App\Services\Tmux;
use App\Models\Settings;
-use Blacklight\ColorCLI;
/**
* Service for running tasks in tmux panes
@@ -12,15 +11,12 @@ class TmuxTaskRunner
{
protected TmuxPaneManager $paneManager;
- protected ColorCLI $colorCli;
-
protected string $sessionName;
public function __construct(string $sessionName)
{
$this->sessionName = $sessionName;
$this->paneManager = new TmuxPaneManager($sessionName);
- $this->colorCli = new ColorCLI;
}
/**
@@ -601,7 +597,7 @@ class TmuxTaskRunner
} else {
// Log that TV processing was skipped due to no work
if ($this->echooutput ?? true) {
- $this->colorCli->notice('Skipping TV processing - no work available');
+ cli()->notice('Skipping TV processing - no work available');
}
}
}
diff --git a/app/Services/TvProcessing/Pipes/AbstractTvProviderPipe.php b/app/Services/TvProcessing/Pipes/AbstractTvProviderPipe.php
index 16bef133c..598677811 100644
--- a/app/Services/TvProcessing/Pipes/AbstractTvProviderPipe.php
+++ b/app/Services/TvProcessing/Pipes/AbstractTvProviderPipe.php
@@ -5,7 +5,6 @@ namespace App\Services\TvProcessing\Pipes;
use App\Services\TvProcessing\TvProcessingPassable;
use App\Services\TvProcessing\TvProcessingResult;
use App\Services\TvProcessing\TvReleaseContext;
-use Blacklight\ColorCLI;
use Closure;
/**
@@ -17,12 +16,10 @@ abstract class AbstractTvProviderPipe
{
protected int $priority = 50;
protected bool $echoOutput = true;
- protected ColorCLI $colorCli;
protected array $titleCache = [];
public function __construct()
{
- $this->colorCli = new ColorCLI();
}
/**
@@ -143,21 +140,21 @@ abstract class AbstractTvProviderPipe
return;
}
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->headerOver($this->truncateTitle($title));
+ cli()->primaryOver(' → ');
+ cli()->headerOver($this->truncateTitle($title));
if ($airdate !== null) {
- $this->colorCli->primaryOver(' | ');
- $this->colorCli->warningOver($airdate);
+ cli()->primaryOver(' | ');
+ cli()->warningOver($airdate);
} elseif ($season !== null && $episode !== null) {
- $this->colorCli->primaryOver(' S');
- $this->colorCli->warningOver(sprintf('%02d', $season));
- $this->colorCli->primaryOver('E');
- $this->colorCli->warningOver(sprintf('%02d', $episode));
+ cli()->primaryOver(' S');
+ cli()->warningOver(sprintf('%02d', $season));
+ cli()->primaryOver('E');
+ cli()->warningOver(sprintf('%02d', $episode));
}
- $this->colorCli->primaryOver(' ✓ ');
- $this->colorCli->primary('MATCHED (' . $this->getName() . ')');
+ cli()->primaryOver(' ✓ ');
+ cli()->primary('MATCHED (' . $this->getName() . ')');
}
/**
@@ -169,10 +166,10 @@ abstract class AbstractTvProviderPipe
return;
}
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->alternateOver($this->truncateTitle($title));
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->alternate('Not found in ' . $this->getName());
+ cli()->primaryOver(' → ');
+ cli()->alternateOver($this->truncateTitle($title));
+ cli()->primaryOver(' → ');
+ cli()->alternate('Not found in ' . $this->getName());
}
/**
@@ -184,10 +181,10 @@ abstract class AbstractTvProviderPipe
return;
}
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->alternateOver($this->truncateTitle($title));
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->alternate('Skipped (previously failed)');
+ cli()->primaryOver(' → ');
+ cli()->alternateOver($this->truncateTitle($title));
+ cli()->primaryOver(' → ');
+ cli()->alternate('Skipped (previously failed)');
}
/**
@@ -199,10 +196,10 @@ abstract class AbstractTvProviderPipe
return;
}
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->headerOver($this->truncateTitle($title));
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->info('Searching ' . $this->getName() . '...');
+ cli()->primaryOver(' → ');
+ cli()->headerOver($this->truncateTitle($title));
+ cli()->primaryOver(' → ');
+ cli()->info('Searching ' . $this->getName() . '...');
}
/**
@@ -214,10 +211,10 @@ abstract class AbstractTvProviderPipe
return;
}
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->headerOver($this->truncateTitle($title));
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->info('Found in DB');
+ cli()->primaryOver(' → ');
+ cli()->headerOver($this->truncateTitle($title));
+ cli()->primaryOver(' → ');
+ cli()->info('Found in DB');
}
}
diff --git a/app/Services/TvProcessing/Pipes/LocalDbPipe.php b/app/Services/TvProcessing/Pipes/LocalDbPipe.php
index 5a578c07c..6a6c089f1 100644
--- a/app/Services/TvProcessing/Pipes/LocalDbPipe.php
+++ b/app/Services/TvProcessing/Pipes/LocalDbPipe.php
@@ -99,23 +99,23 @@ class LocalDbPipe extends AbstractTvProviderPipe
$localDb->setVideoIdFound($videoId, $context->releaseId, 0);
if ($this->echoOutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->headerOver($this->truncateTitle($cleanName));
+ cli()->primaryOver(' → ');
+ cli()->headerOver($this->truncateTitle($cleanName));
if ($hasAirdate) {
- $this->colorCli->primaryOver(' | ');
- $this->colorCli->warningOver($parsedInfo['airdate']);
- $this->colorCli->headerOver(' → ');
- $this->colorCli->notice('Series matched, airdate not in local DB');
+ cli()->primaryOver(' | ');
+ cli()->warningOver($parsedInfo['airdate']);
+ cli()->headerOver(' → ');
+ cli()->notice('Series matched, airdate not in local DB');
} elseif ($hasEpisodeNumbers) {
- $this->colorCli->primaryOver(' S');
- $this->colorCli->warningOver(sprintf('%02d', (int) $parsedInfo['season']));
- $this->colorCli->primaryOver('E');
- $this->colorCli->warningOver(sprintf('%02d', (int) $parsedInfo['episode']));
- $this->colorCli->headerOver(' → ');
- $this->colorCli->notice('Series matched, episode not in local DB');
+ cli()->primaryOver(' S');
+ cli()->warningOver(sprintf('%02d', (int) $parsedInfo['season']));
+ cli()->primaryOver('E');
+ cli()->warningOver(sprintf('%02d', (int) $parsedInfo['episode']));
+ cli()->headerOver(' → ');
+ cli()->notice('Series matched, episode not in local DB');
} else {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->notice('Series matched (no episode info)');
+ cli()->primaryOver(' → ');
+ cli()->notice('Series matched (no episode info)');
}
}
diff --git a/app/Services/TvProcessing/Pipes/ParseInfoPipe.php b/app/Services/TvProcessing/Pipes/ParseInfoPipe.php
index 939d528ef..65c0c16bf 100644
--- a/app/Services/TvProcessing/Pipes/ParseInfoPipe.php
+++ b/app/Services/TvProcessing/Pipes/ParseInfoPipe.php
@@ -53,7 +53,7 @@ class ParseInfoPipe extends AbstractTvProviderPipe
);
if ($this->echoOutput) {
- $this->colorCli->error(sprintf(
+ cli()->error(sprintf(
' ✗ Parse failed: %s',
mb_substr($passable->context->searchName, 0, 50)
));
diff --git a/app/Services/TvProcessing/Pipes/TmdbPipe.php b/app/Services/TvProcessing/Pipes/TmdbPipe.php
index 15ad35a18..3a11d71ff 100644
--- a/app/Services/TvProcessing/Pipes/TmdbPipe.php
+++ b/app/Services/TvProcessing/Pipes/TmdbPipe.php
@@ -168,14 +168,14 @@ class TmdbPipe extends AbstractTvProviderPipe
$tmdb->setVideoIdFound($videoId, $context->releaseId, 0);
if ($this->echoOutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->alternateOver($this->truncateTitle($cleanName));
+ cli()->primaryOver(' → ');
+ cli()->alternateOver($this->truncateTitle($cleanName));
if ($hasAirdate) {
- $this->colorCli->primaryOver(' | ');
- $this->colorCli->warningOver($parsedInfo['airdate']);
+ cli()->primaryOver(' | ');
+ cli()->warningOver($parsedInfo['airdate']);
}
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->warning('Episode not found');
+ cli()->primaryOver(' → ');
+ cli()->warning('Episode not found');
}
return TvProcessingResult::notFound($this->getName(), [
@@ -193,10 +193,10 @@ class TmdbPipe extends AbstractTvProviderPipe
return;
}
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->headerOver($this->truncateTitle($title));
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->primary('Full Season matched');
+ cli()->primaryOver(' → ');
+ cli()->headerOver($this->truncateTitle($title));
+ cli()->primaryOver(' → ');
+ cli()->primary('Full Season matched');
}
/**
@@ -241,14 +241,14 @@ class TmdbPipe extends AbstractTvProviderPipe
$tmdb->setVideoIdFound($videoId, $context->releaseId, 0);
if ($this->echoOutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->alternateOver($this->truncateTitle($cleanName));
+ cli()->primaryOver(' → ');
+ cli()->alternateOver($this->truncateTitle($cleanName));
if ($hasAirdate) {
- $this->colorCli->primaryOver(' | ');
- $this->colorCli->warningOver($parsedInfo['airdate']);
+ cli()->primaryOver(' | ');
+ cli()->warningOver($parsedInfo['airdate']);
}
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->warning('Episode not in local DB');
+ cli()->primaryOver(' → ');
+ cli()->warning('Episode not in local DB');
}
return TvProcessingResult::notFound($this->getName(), [
diff --git a/app/Services/TvProcessing/Pipes/TraktPipe.php b/app/Services/TvProcessing/Pipes/TraktPipe.php
index 687be5b13..db5e69384 100644
--- a/app/Services/TvProcessing/Pipes/TraktPipe.php
+++ b/app/Services/TvProcessing/Pipes/TraktPipe.php
@@ -160,14 +160,14 @@ class TraktPipe extends AbstractTvProviderPipe
$trakt->setVideoIdFound($videoId, $context->releaseId, 0);
if ($this->echoOutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->alternateOver($this->truncateTitle($cleanName));
+ cli()->primaryOver(' → ');
+ cli()->alternateOver($this->truncateTitle($cleanName));
if ($hasAirdate) {
- $this->colorCli->primaryOver(' | ');
- $this->colorCli->warningOver($parsedInfo['airdate']);
+ cli()->primaryOver(' | ');
+ cli()->warningOver($parsedInfo['airdate']);
}
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->warning('Episode not found');
+ cli()->primaryOver(' → ');
+ cli()->warning('Episode not found');
}
return TvProcessingResult::notFound($this->getName(), [
@@ -185,10 +185,10 @@ class TraktPipe extends AbstractTvProviderPipe
return;
}
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->headerOver($this->truncateTitle($title));
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->primary('Full Season matched');
+ cli()->primaryOver(' → ');
+ cli()->headerOver($this->truncateTitle($title));
+ cli()->primaryOver(' → ');
+ cli()->primary('Full Season matched');
}
/**
@@ -233,14 +233,14 @@ class TraktPipe extends AbstractTvProviderPipe
$trakt->setVideoIdFound($videoId, $context->releaseId, 0);
if ($this->echoOutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->alternateOver($this->truncateTitle($cleanName));
+ cli()->primaryOver(' → ');
+ cli()->alternateOver($this->truncateTitle($cleanName));
if ($hasAirdate) {
- $this->colorCli->primaryOver(' | ');
- $this->colorCli->warningOver($parsedInfo['airdate']);
+ cli()->primaryOver(' | ');
+ cli()->warningOver($parsedInfo['airdate']);
}
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->warning('Episode not in local DB');
+ cli()->primaryOver(' → ');
+ cli()->warning('Episode not in local DB');
}
return TvProcessingResult::notFound($this->getName(), [
diff --git a/app/Services/TvProcessing/Pipes/TvMazePipe.php b/app/Services/TvProcessing/Pipes/TvMazePipe.php
index 1d5cf7c9b..138f94958 100644
--- a/app/Services/TvProcessing/Pipes/TvMazePipe.php
+++ b/app/Services/TvProcessing/Pipes/TvMazePipe.php
@@ -169,14 +169,14 @@ class TvMazePipe extends AbstractTvProviderPipe
$tvmaze->setVideoIdFound($videoId, $context->releaseId, 0);
if ($this->echoOutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->alternateOver($this->truncateTitle($cleanName));
+ cli()->primaryOver(' → ');
+ cli()->alternateOver($this->truncateTitle($cleanName));
if ($hasAirdate) {
- $this->colorCli->primaryOver(' | ');
- $this->colorCli->warningOver($parsedInfo['airdate']);
+ cli()->primaryOver(' | ');
+ cli()->warningOver($parsedInfo['airdate']);
}
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->warning('Episode not found');
+ cli()->primaryOver(' → ');
+ cli()->warning('Episode not found');
}
return TvProcessingResult::notFound($this->getName(), [
@@ -194,10 +194,10 @@ class TvMazePipe extends AbstractTvProviderPipe
return;
}
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->headerOver($this->truncateTitle($title));
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->primary('Full Season matched');
+ cli()->primaryOver(' → ');
+ cli()->headerOver($this->truncateTitle($title));
+ cli()->primaryOver(' → ');
+ cli()->primary('Full Season matched');
}
/**
@@ -242,14 +242,14 @@ class TvMazePipe extends AbstractTvProviderPipe
$tvmaze->setVideoIdFound($videoId, $context->releaseId, 0);
if ($this->echoOutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->alternateOver($this->truncateTitle($cleanName));
+ cli()->primaryOver(' → ');
+ cli()->alternateOver($this->truncateTitle($cleanName));
if ($hasAirdate) {
- $this->colorCli->primaryOver(' | ');
- $this->colorCli->warningOver($parsedInfo['airdate']);
+ cli()->primaryOver(' | ');
+ cli()->warningOver($parsedInfo['airdate']);
}
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->warning('Episode not in local DB');
+ cli()->primaryOver(' → ');
+ cli()->warning('Episode not in local DB');
}
return TvProcessingResult::notFound($this->getName(), [
diff --git a/app/Services/TvProcessing/Pipes/TvdbPipe.php b/app/Services/TvProcessing/Pipes/TvdbPipe.php
index 59841a322..ff3a0455c 100644
--- a/app/Services/TvProcessing/Pipes/TvdbPipe.php
+++ b/app/Services/TvProcessing/Pipes/TvdbPipe.php
@@ -178,14 +178,14 @@ class TvdbPipe extends AbstractTvProviderPipe
$tvdb->setVideoIdFound($videoId, $context->releaseId, 0);
if ($this->echoOutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->alternateOver($this->truncateTitle($cleanName));
+ cli()->primaryOver(' → ');
+ cli()->alternateOver($this->truncateTitle($cleanName));
if ($hasAirdate) {
- $this->colorCli->primaryOver(' | ');
- $this->colorCli->warningOver($parsedInfo['airdate']);
+ cli()->primaryOver(' | ');
+ cli()->warningOver($parsedInfo['airdate']);
}
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->warning('Episode not found');
+ cli()->primaryOver(' → ');
+ cli()->warning('Episode not found');
}
return TvProcessingResult::notFound($this->getName(), [
@@ -223,10 +223,10 @@ class TvdbPipe extends AbstractTvProviderPipe
return;
}
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->headerOver($this->truncateTitle($title));
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->primary('Full Season matched');
+ cli()->primaryOver(' → ');
+ cli()->headerOver($this->truncateTitle($title));
+ cli()->primaryOver(' → ');
+ cli()->primary('Full Season matched');
}
/**
@@ -271,14 +271,14 @@ class TvdbPipe extends AbstractTvProviderPipe
$tvdb->setVideoIdFound($videoId, $context->releaseId, 0);
if ($this->echoOutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->alternateOver($this->truncateTitle($cleanName));
+ cli()->primaryOver(' → ');
+ cli()->alternateOver($this->truncateTitle($cleanName));
if ($hasAirdate) {
- $this->colorCli->primaryOver(' | ');
- $this->colorCli->warningOver($parsedInfo['airdate']);
+ cli()->primaryOver(' | ');
+ cli()->warningOver($parsedInfo['airdate']);
}
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->warning('Episode not in local DB');
+ cli()->primaryOver(' → ');
+ cli()->warning('Episode not in local DB');
}
return TvProcessingResult::notFound($this->getName(), [
diff --git a/app/Services/TvProcessing/Providers/AbstractTvProvider.php b/app/Services/TvProcessing/Providers/AbstractTvProvider.php
index 25f10e095..351feda52 100644
--- a/app/Services/TvProcessing/Providers/AbstractTvProvider.php
+++ b/app/Services/TvProcessing/Providers/AbstractTvProvider.php
@@ -9,7 +9,6 @@ use App\Models\TvEpisode;
use App\Models\TvInfo;
use App\Models\Video;
use App\Services\Releases\ReleaseBrowseService;
-use Blacklight\ColorCLI;
use Illuminate\Support\Facades\DB;
/**
@@ -66,8 +65,6 @@ abstract class AbstractTvProvider extends BaseVideoProvider
*/
public string $catWhere;
- protected ColorCLI $colorCli;
-
/**
* AbstractTvProvider constructor.
*
@@ -76,7 +73,6 @@ abstract class AbstractTvProvider extends BaseVideoProvider
public function __construct()
{
parent::__construct();
- $this->colorCli = new ColorCLI;
$this->catWhere = 'categories_id BETWEEN '.Category::TV_ROOT.' AND '.Category::TV_OTHER.' AND categories_id != '.Category::TV_ANIME;
$this->tvqty = Settings::settingValue('maxrageprocessed') !== '' ? (int) Settings::settingValue('maxrageprocessed') : 75;
$this->imgSavePath = storage_path('covers/tvshows/');
diff --git a/app/Services/TvProcessing/Providers/LocalDbProvider.php b/app/Services/TvProcessing/Providers/LocalDbProvider.php
index b617944ea..fd89746c4 100644
--- a/app/Services/TvProcessing/Providers/LocalDbProvider.php
+++ b/app/Services/TvProcessing/Providers/LocalDbProvider.php
@@ -65,19 +65,19 @@ class LocalDbProvider extends AbstractTvProvider
$matchedCount++;
if ($this->echooutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->headerOver($showInfo['cleanname']);
+ cli()->primaryOver(' → ');
+ cli()->headerOver($showInfo['cleanname']);
if ($hasAirdate) {
- $this->colorCli->primaryOver(' | ');
- $this->colorCli->warningOver($showInfo['airdate']);
+ cli()->primaryOver(' | ');
+ cli()->warningOver($showInfo['airdate']);
} else {
- $this->colorCli->primaryOver(' S');
- $this->colorCli->warningOver(sprintf('%02d', (int) ($showInfo['season'] ?? 0)));
- $this->colorCli->primaryOver('E');
- $this->colorCli->warningOver(sprintf('%02d', (int) ($showInfo['episode'] ?? 0)));
+ cli()->primaryOver(' S');
+ cli()->warningOver(sprintf('%02d', (int) ($showInfo['season'] ?? 0)));
+ cli()->primaryOver('E');
+ cli()->warningOver(sprintf('%02d', (int) ($showInfo['episode'] ?? 0)));
}
- $this->colorCli->primaryOver(' ✓ ');
- $this->colorCli->primary('MATCHED (Local DB)');
+ cli()->primaryOver(' ✓ ');
+ cli()->primary('MATCHED (Local DB)');
}
} else {
// Series matched but no specific episode located
@@ -88,25 +88,25 @@ class LocalDbProvider extends AbstractTvProvider
if ($hasEpisodeNumbers || $hasAirdate) {
$episodeMissingCount++;
if ($this->echooutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->headerOver($showInfo['cleanname']);
+ cli()->primaryOver(' → ');
+ cli()->headerOver($showInfo['cleanname']);
if ($hasAirdate) {
- $this->colorCli->primaryOver(' | ');
- $this->colorCli->warningOver($showInfo['airdate']);
+ cli()->primaryOver(' | ');
+ cli()->warningOver($showInfo['airdate']);
} else {
- $this->colorCli->primaryOver(' S');
- $this->colorCli->warningOver(sprintf('%02d', (int) ($showInfo['season'] ?? 0)));
- $this->colorCli->primaryOver('E');
- $this->colorCli->warningOver(sprintf('%02d', (int) ($showInfo['episode'] ?? 0)));
+ cli()->primaryOver(' S');
+ cli()->warningOver(sprintf('%02d', (int) ($showInfo['season'] ?? 0)));
+ cli()->primaryOver('E');
+ cli()->warningOver(sprintf('%02d', (int) ($showInfo['episode'] ?? 0)));
}
- $this->colorCli->headerOver(' → ');
- $this->colorCli->notice($hasAirdate ? 'Series matched, airdate not in local DB' : 'Series matched, episode not in local DB');
+ cli()->headerOver(' → ');
+ cli()->notice($hasAirdate ? 'Series matched, airdate not in local DB' : 'Series matched, episode not in local DB');
}
} elseif ($this->echooutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->headerOver($showInfo['cleanname']);
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->notice('Series matched (no episode info)');
+ cli()->primaryOver(' → ');
+ cli()->headerOver($showInfo['cleanname']);
+ cli()->primaryOver(' → ');
+ cli()->notice('Series matched (no episode info)');
}
}
}
@@ -114,27 +114,27 @@ class LocalDbProvider extends AbstractTvProvider
if (! $matched && $videoId === false || $videoId === 0) {
$notFoundCount++;
if ($this->echooutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->alternateOver($showInfo['cleanname']);
+ cli()->primaryOver(' → ');
+ cli()->alternateOver($showInfo['cleanname']);
if (! empty($showInfo['airdate'])) {
- $this->colorCli->primaryOver(' | ');
- $this->colorCli->warningOver($showInfo['airdate']);
+ cli()->primaryOver(' | ');
+ cli()->warningOver($showInfo['airdate']);
} elseif (isset($showInfo['season'], $showInfo['episode'])) {
- $this->colorCli->primaryOver(' S');
- $this->colorCli->warningOver(sprintf('%02d', $showInfo['season'] ?? 0));
- $this->colorCli->primaryOver('E');
- $this->colorCli->warningOver(sprintf('%02d', $showInfo['episode'] ?? 0));
+ cli()->primaryOver(' S');
+ cli()->warningOver(sprintf('%02d', $showInfo['season'] ?? 0));
+ cli()->primaryOver('E');
+ cli()->warningOver(sprintf('%02d', $showInfo['episode'] ?? 0));
}
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->alternate('Not in local DB');
+ cli()->primaryOver(' → ');
+ cli()->alternate('Not in local DB');
}
}
}
if ($this->echooutput && ($matchedCount > 0 || $seriesMatchedCount > 0)) {
echo "\n";
- $this->colorCli->primaryOver(' ✓ Local DB: ');
- $this->colorCli->primary(sprintf(
+ cli()->primaryOver(' ✓ Local DB: ');
+ cli()->primary(sprintf(
'%d episode matches, %d series matches, %d missing episodes, %d not found',
$matchedCount,
$seriesMatchedCount,
diff --git a/app/Services/TvProcessing/Providers/TmdbProvider.php b/app/Services/TvProcessing/Providers/TmdbProvider.php
index 1573a72f1..f979bfca5 100644
--- a/app/Services/TvProcessing/Providers/TmdbProvider.php
+++ b/app/Services/TvProcessing/Providers/TmdbProvider.php
@@ -60,10 +60,10 @@ class TmdbProvider extends AbstractTvProvider
if (is_array($release) && $release['name'] !== '') {
if (in_array($release['cleanname'], $this->titleCache, false)) {
if ($this->echooutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->alternateOver($this->truncateTitle($release['cleanname']));
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->alternate('Skipped (previously failed)');
+ cli()->primaryOver(' → ');
+ cli()->alternateOver($this->truncateTitle($release['cleanname']));
+ cli()->primaryOver(' → ');
+ cli()->alternate('Skipped (previously failed)');
}
$this->setVideoNotFound(parent::PROCESS_TRAKT, $row['id']);
$skipped++;
@@ -82,10 +82,10 @@ class TmdbProvider extends AbstractTvProvider
// If lookups are allowed lets try to get it.
if ($videoId === 0 && $lookupSetting) {
if ($this->echooutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->headerOver($this->truncateTitle($release['cleanname']));
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->info('Searching TMDB...');
+ cli()->primaryOver(' → ');
+ cli()->headerOver($this->truncateTitle($release['cleanname']));
+ cli()->primaryOver(' → ');
+ cli()->info('Searching TMDB...');
}
// Get the show from TMDB
@@ -106,10 +106,10 @@ class TmdbProvider extends AbstractTvProvider
}
} else {
if ($this->echooutput && $videoId > 0) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->headerOver($this->truncateTitle($release['cleanname']));
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->info('Found in DB');
+ cli()->primaryOver(' → ');
+ cli()->headerOver($this->truncateTitle($release['cleanname']));
+ cli()->primaryOver(' → ');
+ cli()->info('Found in DB');
}
$siteId = $this->getSiteIDFromVideoID('tmdb', $videoId);
}
@@ -126,10 +126,10 @@ class TmdbProvider extends AbstractTvProvider
// Set the video ID and leave episode 0
$this->setVideoIdFound($videoId, $row['id'], 0);
if ($this->echooutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->headerOver($this->truncateTitle($release['cleanname']));
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->primary('Full Season matched');
+ cli()->primaryOver(' → ');
+ cli()->headerOver($this->truncateTitle($release['cleanname']));
+ cli()->primaryOver(' → ');
+ cli()->primary('Full Season matched');
}
$matched++;
@@ -170,19 +170,19 @@ class TmdbProvider extends AbstractTvProvider
// Mark the releases video and episode IDs
$this->setVideoIdFound($videoId, $row['id'], $episode);
if ($this->echooutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->headerOver($this->truncateTitle($release['cleanname']));
+ cli()->primaryOver(' → ');
+ cli()->headerOver($this->truncateTitle($release['cleanname']));
if ($seriesNo !== '' && $episodeNo !== '') {
- $this->colorCli->primaryOver(' S');
- $this->colorCli->warningOver(sprintf('%02d', $seriesNo));
- $this->colorCli->primaryOver('E');
- $this->colorCli->warningOver(sprintf('%02d', $episodeNo));
+ cli()->primaryOver(' S');
+ cli()->warningOver(sprintf('%02d', $seriesNo));
+ cli()->primaryOver('E');
+ cli()->warningOver(sprintf('%02d', $episodeNo));
} elseif ($hasAirdate) {
- $this->colorCli->primaryOver(' | ');
- $this->colorCli->warningOver($release['airdate']);
+ cli()->primaryOver(' | ');
+ cli()->warningOver($release['airdate']);
}
- $this->colorCli->primaryOver(' ✓ ');
- $this->colorCli->primary('MATCHED (TMDB)');
+ cli()->primaryOver(' ✓ ');
+ cli()->primary('MATCHED (TMDB)');
}
$matched++;
} else {
@@ -190,14 +190,14 @@ class TmdbProvider extends AbstractTvProvider
$this->setVideoIdFound($videoId, $row['id'], 0);
$this->setVideoNotFound(parent::PROCESS_TRAKT, $row['id']);
if ($this->echooutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->alternateOver($this->truncateTitle($release['cleanname']));
+ cli()->primaryOver(' → ');
+ cli()->alternateOver($this->truncateTitle($release['cleanname']));
if ($hasAirdate) {
- $this->colorCli->primaryOver(' | ');
- $this->colorCli->warningOver($release['airdate']);
+ cli()->primaryOver(' | ');
+ cli()->warningOver($release['airdate']);
}
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->warning('Episode not found');
+ cli()->primaryOver(' → ');
+ cli()->warning('Episode not found');
}
}
} else {
@@ -205,10 +205,10 @@ class TmdbProvider extends AbstractTvProvider
$this->setVideoNotFound(parent::PROCESS_TRAKT, $row['id']);
$this->titleCache[] = $release['cleanname'] ?? null;
if ($this->echooutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->alternateOver($this->truncateTitle($release['cleanname']));
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->warning('Not found');
+ cli()->primaryOver(' → ');
+ cli()->alternateOver($this->truncateTitle($release['cleanname']));
+ cli()->primaryOver(' → ');
+ cli()->warning('Not found');
}
}
} else {
@@ -216,10 +216,10 @@ class TmdbProvider extends AbstractTvProvider
$this->setVideoNotFound(parent::PROCESS_TRAKT, $row['id']);
$this->titleCache[] = $release['cleanname'] ?? null;
if ($this->echooutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->alternateOver(mb_substr($row['searchname'], 0, 50));
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->error('Parse failed');
+ cli()->primaryOver(' → ');
+ cli()->alternateOver(mb_substr($row['searchname'], 0, 50));
+ cli()->primaryOver(' → ');
+ cli()->error('Parse failed');
}
}
}
@@ -227,8 +227,8 @@ class TmdbProvider extends AbstractTvProvider
// Display summary
if ($this->echooutput && $matched > 0) {
echo "\n";
- $this->colorCli->primaryOver(' ✓ TMDB: ');
- $this->colorCli->primary(sprintf('%d matched, %d skipped', $matched, $skipped));
+ cli()->primaryOver(' ✓ TMDB: ');
+ cli()->primary(sprintf('%d matched, %d skipped', $matched, $skipped));
}
}
}
diff --git a/app/Services/TvProcessing/Providers/TraktProvider.php b/app/Services/TvProcessing/Providers/TraktProvider.php
index a4492b0d5..157bf6e80 100644
--- a/app/Services/TvProcessing/Providers/TraktProvider.php
+++ b/app/Services/TvProcessing/Providers/TraktProvider.php
@@ -73,10 +73,10 @@ class TraktProvider extends AbstractTvProvider
if (\is_array($release) && $release['name'] !== '') {
if (\in_array($release['cleanname'], $this->titleCache, false)) {
if ($this->echooutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->alternateOver($this->truncateTitle($release['cleanname']));
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->alternate('Skipped (previously failed)');
+ cli()->primaryOver(' → ');
+ cli()->alternateOver($this->truncateTitle($release['cleanname']));
+ cli()->primaryOver(' → ');
+ cli()->alternate('Skipped (previously failed)');
}
$this->setVideoNotFound(parent::PROCESS_IMDB, $row['id']);
$skipped++;
@@ -97,10 +97,10 @@ class TraktProvider extends AbstractTvProvider
if ($videoId === 0 && $lookupSetting) {
// If it doesn't exist locally and lookups are allowed lets try to get it.
if ($this->echooutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->headerOver($this->truncateTitle($release['cleanname']));
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->info('Searching Trakt...');
+ cli()->primaryOver(' → ');
+ cli()->headerOver($this->truncateTitle($release['cleanname']));
+ cli()->primaryOver(' → ');
+ cli()->info('Searching Trakt...');
}
// Get the show from TRAKT
@@ -112,10 +112,10 @@ class TraktProvider extends AbstractTvProvider
}
} else {
if ($this->echooutput && $videoId > 0) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->headerOver($this->truncateTitle($release['cleanname']));
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->info('Found in DB');
+ cli()->primaryOver(' → ');
+ cli()->headerOver($this->truncateTitle($release['cleanname']));
+ cli()->primaryOver(' → ');
+ cli()->info('Found in DB');
}
$traktid = $this->getSiteIDFromVideoID('trakt', $videoId);
$this->localizedTZ = $this->getLocalZoneFromVideoID($videoId);
@@ -132,10 +132,10 @@ class TraktProvider extends AbstractTvProvider
// Set the video ID and leave episode 0
$this->setVideoIdFound($videoId, $row['id'], 0);
if ($this->echooutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->headerOver($this->truncateTitle($release['cleanname']));
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->primary('Full Season matched');
+ cli()->primaryOver(' → ');
+ cli()->headerOver($this->truncateTitle($release['cleanname']));
+ cli()->primaryOver(' → ');
+ cli()->primary('Full Season matched');
}
$matched++;
@@ -162,14 +162,14 @@ class TraktProvider extends AbstractTvProvider
// Mark the releases video and episode IDs
$this->setVideoIdFound($videoId, $row['id'], $episode);
if ($this->echooutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->headerOver($this->truncateTitle($release['cleanname']));
- $this->colorCli->primaryOver(' S');
- $this->colorCli->warningOver(sprintf('%02d', $seasonNo));
- $this->colorCli->primaryOver('E');
- $this->colorCli->warningOver(sprintf('%02d', $episodeNo));
- $this->colorCli->primaryOver(' ✓ ');
- $this->colorCli->primary('MATCHED (Trakt)');
+ cli()->primaryOver(' → ');
+ cli()->headerOver($this->truncateTitle($release['cleanname']));
+ cli()->primaryOver(' S');
+ cli()->warningOver(sprintf('%02d', $seasonNo));
+ cli()->primaryOver('E');
+ cli()->warningOver(sprintf('%02d', $episodeNo));
+ cli()->primaryOver(' ✓ ');
+ cli()->primary('MATCHED (Trakt)');
}
$matched++;
} else {
@@ -177,10 +177,10 @@ class TraktProvider extends AbstractTvProvider
$this->setVideoIdFound($videoId, $row['id'], 0);
$this->setVideoNotFound(parent::PROCESS_IMDB, $row['id']);
if ($this->echooutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->alternateOver($this->truncateTitle($release['cleanname']));
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->warning('Episode not found');
+ cli()->primaryOver(' → ');
+ cli()->alternateOver($this->truncateTitle($release['cleanname']));
+ cli()->primaryOver(' → ');
+ cli()->warning('Episode not found');
}
}
} else {
@@ -188,10 +188,10 @@ class TraktProvider extends AbstractTvProvider
$this->setVideoNotFound(parent::PROCESS_IMDB, $row['id']);
$this->titleCache[] = $release['cleanname'] ?? null;
if ($this->echooutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->alternateOver($this->truncateTitle($release['cleanname']));
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->warning('Not found');
+ cli()->primaryOver(' → ');
+ cli()->alternateOver($this->truncateTitle($release['cleanname']));
+ cli()->primaryOver(' → ');
+ cli()->warning('Not found');
}
}
} else {
@@ -199,10 +199,10 @@ class TraktProvider extends AbstractTvProvider
$this->setVideoNotFound(parent::PROCESS_IMDB, $row['id']);
$this->titleCache[] = $release['cleanname'] ?? null;
if ($this->echooutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->alternateOver(mb_substr($row['searchname'], 0, 50));
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->error('Parse failed');
+ cli()->primaryOver(' → ');
+ cli()->alternateOver(mb_substr($row['searchname'], 0, 50));
+ cli()->primaryOver(' → ');
+ cli()->error('Parse failed');
}
}
}
@@ -210,8 +210,8 @@ class TraktProvider extends AbstractTvProvider
// Display summary
if ($this->echooutput && $matched > 0) {
echo "\n";
- $this->colorCli->primaryOver(' ✓ Trakt: ');
- $this->colorCli->primary(sprintf('%d matched, %d skipped', $matched, $skipped));
+ cli()->primaryOver(' ✓ Trakt: ');
+ cli()->primary(sprintf('%d matched, %d skipped', $matched, $skipped));
}
}
}
diff --git a/app/Services/TvProcessing/Providers/TvMazeProvider.php b/app/Services/TvProcessing/Providers/TvMazeProvider.php
index 05220e5a5..50fbcb830 100644
--- a/app/Services/TvProcessing/Providers/TvMazeProvider.php
+++ b/app/Services/TvProcessing/Providers/TvMazeProvider.php
@@ -75,10 +75,10 @@ class TvMazeProvider extends AbstractTvProvider
if (\is_array($release) && $release['name'] !== '') {
if (\in_array($release['cleanname'], $this->titleCache, false)) {
if ($this->echooutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->alternateOver($this->truncateTitle($release['cleanname']));
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->alternate('Skipped (previously failed)');
+ cli()->primaryOver(' → ');
+ cli()->alternateOver($this->truncateTitle($release['cleanname']));
+ cli()->primaryOver(' → ');
+ cli()->alternate('Skipped (previously failed)');
}
$this->setVideoNotFound(parent::PROCESS_TMDB, $row['id']);
$skipped++;
@@ -96,10 +96,10 @@ class TvMazeProvider extends AbstractTvProvider
if ($videoId === 0 && $lookupSetting) {
// If lookups are allowed lets try to get it.
if ($this->echooutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->headerOver($this->truncateTitle($release['cleanname']));
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->info('Searching TVMaze...');
+ cli()->primaryOver(' → ');
+ cli()->headerOver($this->truncateTitle($release['cleanname']));
+ cli()->primaryOver(' → ');
+ cli()->info('Searching TVMaze...');
}
// Get the show from TVMaze
@@ -125,10 +125,10 @@ class TvMazeProvider extends AbstractTvProvider
}
} else {
if ($this->echooutput && $videoId > 0) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->headerOver($this->truncateTitle($release['cleanname']));
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->info('Found in DB');
+ cli()->primaryOver(' → ');
+ cli()->headerOver($this->truncateTitle($release['cleanname']));
+ cli()->primaryOver(' → ');
+ cli()->info('Found in DB');
}
$siteId = $this->getSiteIDFromVideoID('tvmaze', $videoId);
}
@@ -144,10 +144,10 @@ class TvMazeProvider extends AbstractTvProvider
// Set the video ID and leave episode 0
$this->setVideoIdFound($videoId, $row['id'], 0);
if ($this->echooutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->headerOver($this->truncateTitle($release['cleanname']));
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->primary('Full Season matched');
+ cli()->primaryOver(' → ');
+ cli()->headerOver($this->truncateTitle($release['cleanname']));
+ cli()->primaryOver(' → ');
+ cli()->primary('Full Season matched');
}
$matched++;
@@ -180,14 +180,14 @@ class TvMazeProvider extends AbstractTvProvider
// Mark the releases video and episode IDs
$this->setVideoIdFound($videoId, $row['id'], $episode);
if ($this->echooutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->headerOver($this->truncateTitle($release['cleanname']));
- $this->colorCli->primaryOver(' S');
- $this->colorCli->warningOver(sprintf('%02d', $seriesNo));
- $this->colorCli->primaryOver('E');
- $this->colorCli->warningOver(sprintf('%02d', $episodeNo));
- $this->colorCli->primaryOver(' ✓ ');
- $this->colorCli->primary('MATCHED (TVMaze)');
+ cli()->primaryOver(' → ');
+ cli()->headerOver($this->truncateTitle($release['cleanname']));
+ cli()->primaryOver(' S');
+ cli()->warningOver(sprintf('%02d', $seriesNo));
+ cli()->primaryOver('E');
+ cli()->warningOver(sprintf('%02d', $episodeNo));
+ cli()->primaryOver(' ✓ ');
+ cli()->primary('MATCHED (TVMaze)');
}
$matched++;
} else {
@@ -195,10 +195,10 @@ class TvMazeProvider extends AbstractTvProvider
$this->setVideoIdFound($videoId, $row['id'], 0);
$this->setVideoNotFound(parent::PROCESS_TMDB, $row['id']);
if ($this->echooutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->alternateOver($this->truncateTitle($release['cleanname']));
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->warning('Episode not found');
+ cli()->primaryOver(' → ');
+ cli()->alternateOver($this->truncateTitle($release['cleanname']));
+ cli()->primaryOver(' → ');
+ cli()->warning('Episode not found');
}
}
} else {
@@ -206,10 +206,10 @@ class TvMazeProvider extends AbstractTvProvider
$this->setVideoNotFound(parent::PROCESS_TMDB, $row['id']);
$this->titleCache[] = $release['cleanname'] ?? null;
if ($this->echooutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->alternateOver($this->truncateTitle($release['cleanname']));
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->warning('Not found');
+ cli()->primaryOver(' → ');
+ cli()->alternateOver($this->truncateTitle($release['cleanname']));
+ cli()->primaryOver(' → ');
+ cli()->warning('Not found');
}
}
} else {
@@ -217,10 +217,10 @@ class TvMazeProvider extends AbstractTvProvider
$this->setVideoNotFound(parent::PROCESS_TMDB, $row['id']);
$this->titleCache[] = $release['cleanname'] ?? null;
if ($this->echooutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->alternateOver(mb_substr($row['searchname'], 0, 50));
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->error('Parse failed');
+ cli()->primaryOver(' → ');
+ cli()->alternateOver(mb_substr($row['searchname'], 0, 50));
+ cli()->primaryOver(' → ');
+ cli()->error('Parse failed');
}
}
}
@@ -228,8 +228,8 @@ class TvMazeProvider extends AbstractTvProvider
// Display summary
if ($this->echooutput && $matched > 0) {
echo "\n";
- $this->colorCli->primaryOver(' ✓ TVMaze: ');
- $this->colorCli->primary(sprintf('%d matched, %d skipped', $matched, $skipped));
+ cli()->primaryOver(' ✓ TVMaze: ');
+ cli()->primary(sprintf('%d matched, %d skipped', $matched, $skipped));
}
}
}
diff --git a/app/Services/TvProcessing/Providers/TvdbProvider.php b/app/Services/TvProcessing/Providers/TvdbProvider.php
index d419a4213..06f2d7b9f 100644
--- a/app/Services/TvProcessing/Providers/TvdbProvider.php
+++ b/app/Services/TvProcessing/Providers/TvdbProvider.php
@@ -82,10 +82,10 @@ class TvdbProvider extends AbstractTvProvider
if (\is_array($release) && $release['name'] !== '') {
if (\in_array($release['cleanname'], $this->titleCache, false)) {
if ($this->echooutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->alternateOver($this->truncateTitle($release['cleanname']));
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->alternate('Skipped (previously failed)');
+ cli()->primaryOver(' → ');
+ cli()->alternateOver($this->truncateTitle($release['cleanname']));
+ cli()->primaryOver(' → ');
+ cli()->alternate('Skipped (previously failed)');
}
$this->setVideoNotFound(parent::PROCESS_TVMAZE, $row['id']);
$skipped++;
@@ -105,10 +105,10 @@ class TvdbProvider extends AbstractTvProvider
if ($siteId === false && $lookupSetting) {
if ($this->echooutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->headerOver($this->truncateTitle($release['cleanname']));
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->info('Searching TVDB...');
+ cli()->primaryOver(' → ');
+ cli()->headerOver($this->truncateTitle($release['cleanname']));
+ cli()->primaryOver(' → ');
+ cli()->info('Searching TVDB...');
}
$country = (
@@ -125,10 +125,10 @@ class TvdbProvider extends AbstractTvProvider
$siteId = (int) $tvdbShow['tvdb'];
}
} elseif ($this->echooutput && $siteId !== false) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->headerOver($this->truncateTitle($release['cleanname']));
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->info('Found in DB');
+ cli()->primaryOver(' → ');
+ cli()->headerOver($this->truncateTitle($release['cleanname']));
+ cli()->primaryOver(' → ');
+ cli()->info('Found in DB');
}
if ((int) $videoId > 0 && (int) $siteId > 0) {
@@ -149,10 +149,10 @@ class TvdbProvider extends AbstractTvProvider
if ($episodeNo === 'all') {
$this->setVideoIdFound($videoId, $row['id'], 0);
if ($this->echooutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->headerOver($this->truncateTitle($release['cleanname']));
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->primary('Full Season matched');
+ cli()->primaryOver(' → ');
+ cli()->headerOver($this->truncateTitle($release['cleanname']));
+ cli()->primaryOver(' → ');
+ cli()->primary('Full Season matched');
}
$matched++;
continue;
@@ -181,50 +181,50 @@ class TvdbProvider extends AbstractTvProvider
if ($episode !== false && is_numeric($episode) && $episode > 0) {
$this->setVideoIdFound($videoId, $row['id'], $episode);
if ($this->echooutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->headerOver($this->truncateTitle($release['cleanname']));
+ cli()->primaryOver(' → ');
+ cli()->headerOver($this->truncateTitle($release['cleanname']));
if ($seriesNo !== '' && $episodeNo !== '') {
- $this->colorCli->primaryOver(' S');
- $this->colorCli->warningOver(sprintf('%02d', $seriesNo));
- $this->colorCli->primaryOver('E');
- $this->colorCli->warningOver(sprintf('%02d', $episodeNo));
+ cli()->primaryOver(' S');
+ cli()->warningOver(sprintf('%02d', $seriesNo));
+ cli()->primaryOver('E');
+ cli()->warningOver(sprintf('%02d', $episodeNo));
} elseif ($hasAirdate) {
- $this->colorCli->primaryOver(' | ');
- $this->colorCli->warningOver($release['airdate']);
+ cli()->primaryOver(' | ');
+ cli()->warningOver($release['airdate']);
}
- $this->colorCli->primaryOver(' ✓ ');
- $this->colorCli->primary('MATCHED (TVDB)');
+ cli()->primaryOver(' ✓ ');
+ cli()->primary('MATCHED (TVDB)');
}
$matched++;
} else {
$this->setVideoIdFound($videoId, $row['id'], 0);
$this->setVideoNotFound(parent::PROCESS_TVMAZE, $row['id']);
if ($this->echooutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->alternateOver($this->truncateTitle($release['cleanname']));
+ cli()->primaryOver(' → ');
+ cli()->alternateOver($this->truncateTitle($release['cleanname']));
if ($hasAirdate) {
- $this->colorCli->primaryOver(' | ');
- $this->colorCli->warningOver($release['airdate']);
+ cli()->primaryOver(' | ');
+ cli()->warningOver($release['airdate']);
}
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->warning('Episode not found');
+ cli()->primaryOver(' → ');
+ cli()->warning('Episode not found');
}
}
} else {
$this->setVideoNotFound(parent::PROCESS_TVMAZE, $row['id']);
$this->titleCache[] = $release['cleanname'] ?? null;
if ($this->echooutput) {
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->alternateOver($this->truncateTitle($release['cleanname']));
- $this->colorCli->primaryOver(' → ');
- $this->colorCli->warning('Not found');
+ cli()->primaryOver(' → ');
+ cli()->alternateOver($this->truncateTitle($release['cleanname']));
+ cli()->primaryOver(' → ');
+ cli()->warning('Not found');
}
}
} else {
$this->setVideoNotFound(parent::FAILED_PARSE, $row['id']);
$this->titleCache[] = $release['cleanname'] ?? null;
if ($this->echooutput) {
- $this->colorCli->error(sprintf(
+ cli()->error(sprintf(
' ✗ [%d/%d] Parse failed: %s',
$processed,
$tvCount,
@@ -236,8 +236,8 @@ class TvdbProvider extends AbstractTvProvider
if ($this->echooutput && $matched > 0) {
echo "\n";
- $this->colorCli->primaryOver(' ✓ TVDB: ');
- $this->colorCli->primary(sprintf('%d matched, %d skipped', $matched, $skipped));
+ cli()->primaryOver(' ✓ TVDB: ');
+ cli()->primary(sprintf('%d matched, %d skipped', $matched, $skipped));
}
}
@@ -259,12 +259,12 @@ class TvdbProvider extends AbstractTvProvider
$response = $this->client->search()->search($name, ['type' => 'series']);
} catch (ResourceNotFoundException $e) {
$response = false;
- $this->colorCli->error('Show not found on TVDB');
+ cli()->error('Show not found on TVDB');
} catch (UnauthorizedException $e) {
try {
$this->authorizeTvdb();
} catch (UnauthorizedException $error) {
- $this->colorCli->error('Not authorized to access TVDB');
+ cli()->error('Not authorized to access TVDB');
}
}
@@ -338,7 +338,7 @@ class TvdbProvider extends AbstractTvProvider
try {
$this->authorizeTvdb();
} catch (UnauthorizedException $error) {
- $this->colorCli->error('Not authorized to access TVDB');
+ cli()->error('Not authorized to access TVDB');
}
}
} else {
@@ -382,12 +382,12 @@ class TvdbProvider extends AbstractTvProvider
$poster = collect($poster)->where('type', 2)->sortByDesc('score')->first();
$this->posterUrl = ! empty($poster->image) ? $poster->image : '';
} catch (ResourceNotFoundException $e) {
- $this->colorCli->error('Poster image not found on TVDB');
+ cli()->error('Poster image not found on TVDB');
} catch (UnauthorizedException $error) {
try {
$this->authorizeTvdb();
} catch (UnauthorizedException $error) {
- $this->colorCli->error('Not authorized to access TVDB');
+ cli()->error('Not authorized to access TVDB');
}
}
@@ -395,9 +395,9 @@ class TvdbProvider extends AbstractTvProvider
$imdbId = $this->client->series()->extended($show->tvdb_id);
preg_match('/tt(?P\d{6,9})$/i', $imdbId->getIMDBId(), $imdb);
} catch (ResourceNotFoundException $e) {
- $this->colorCli->error('Show ImdbId not found on TVDB');
+ cli()->error('Show ImdbId not found on TVDB');
} catch (\Exception) {
- $this->colorCli->error('Error on TVDB, aborting');
+ cli()->error('Error on TVDB, aborting');
}
return [
@@ -435,13 +435,13 @@ class TvdbProvider extends AbstractTvProvider
{
$this->token = '';
if (config('tvdb.api_key') === null || config('tvdb.user_pin') === null) {
- $this->colorCli->warning('TVDB API key or user pin not set. Running in local mode only!', true);
+ cli()->warning('TVDB API key or user pin not set. Running in local mode only!', true);
$this->local = true;
} else {
try {
$this->token = $this->client->authentication()->login(config('tvdb.api_key'), config('tvdb.user_pin'));
} catch (UnauthorizedException $error) {
- $this->colorCli->warning('Could not reach TVDB API. Running in local mode only!', true);
+ cli()->warning('Could not reach TVDB API. Running in local mode only!', true);
$this->local = true;
}
diff --git a/app/Services/TvProcessing/TvProcessingPipeline.php b/app/Services/TvProcessing/TvProcessingPipeline.php
index fcd0bdefd..d7ede6ec2 100644
--- a/app/Services/TvProcessing/TvProcessingPipeline.php
+++ b/app/Services/TvProcessing/TvProcessingPipeline.php
@@ -12,7 +12,6 @@ use App\Services\TvProcessing\Pipes\TmdbPipe;
use App\Services\TvProcessing\Pipes\TraktPipe;
use App\Services\TvProcessing\Pipes\TvdbPipe;
use App\Services\TvProcessing\Pipes\TvMazePipe;
-use Blacklight\ColorCLI;
use Illuminate\Pipeline\Pipeline;
use Illuminate\Support\Collection;
@@ -31,7 +30,6 @@ class TvProcessingPipeline
protected int $tvqty;
protected bool $echoOutput;
- protected ColorCLI $colorCli;
protected array $stats = [
'processed' => 0,
@@ -55,7 +53,6 @@ class TvProcessingPipeline
: 75;
$this->echoOutput = $echoOutput;
- $this->colorCli = new ColorCLI();
}
/**
@@ -118,13 +115,13 @@ class TvProcessingPipeline
if ($totalCount === 0) {
if ($this->echoOutput) {
- $this->colorCli->header('No TV releases to process.');
+ cli()->header('No TV releases to process.');
}
return;
}
if ($this->echoOutput) {
- $this->colorCli->header('Processing '.$totalCount.' TV release(s).');
+ cli()->header('Processing '.$totalCount.' TV release(s).');
}
foreach ($releases as $release) {
@@ -254,7 +251,7 @@ class TvProcessingPipeline
return;
}
- $this->colorCli->header(sprintf(
+ cli()->header(sprintf(
'TV processing complete: %d processed, %d matched, %d failed (%.2fs)',
$this->stats['processed'],
$this->stats['matched'],
@@ -267,7 +264,7 @@ class TvProcessingPipeline
foreach ($this->stats['providers'] as $provider => $count) {
$providerSummary[] = "$provider: $count";
}
- $this->colorCli->primary('Matches by provider: '.implode(', ', $providerSummary));
+ cli()->primary('Matches by provider: '.implode(', ', $providerSummary));
}
}
diff --git a/app/Services/TvProcessor.php b/app/Services/TvProcessor.php
index 1aa33b980..1d84f9691 100644
--- a/app/Services/TvProcessor.php
+++ b/app/Services/TvProcessor.php
@@ -9,7 +9,6 @@ use App\Services\TvProcessing\Providers\TmdbProvider;
use App\Services\TvProcessing\Providers\TraktProvider;
use App\Services\TvProcessing\Providers\TvdbProvider;
use App\Services\TvProcessing\Providers\TvMazeProvider;
-use Blacklight\ColorCLI;
class TvProcessor
{
@@ -20,8 +19,6 @@ class TvProcessor
private bool $echooutput;
- private ColorCLI $colorCli;
-
/**
* @var array
*/
@@ -36,7 +33,6 @@ class TvProcessor
public function __construct(bool $echooutput)
{
$this->echooutput = $echooutput;
- $this->colorCli = new ColorCLI;
$this->providers = $this->buildProviderPipeline();
}
@@ -287,7 +283,7 @@ class TvProcessor
return;
}
- $this->colorCli->header('Processing '.$total.' TV release(s) via '.$providerName.'.');
+ cli()->header('Processing '.$total.' TV release(s) via '.$providerName.'.');
}
/**
diff --git a/misc/testing/DB/mark_as_passworded.php b/misc/testing/DB/mark_as_passworded.php
index 12ee8f70a..8c382281e 100644
--- a/misc/testing/DB/mark_as_passworded.php
+++ b/misc/testing/DB/mark_as_passworded.php
@@ -2,7 +2,7 @@
use App\Models\Release;
use App\Models\ReleaseFile;
-use Blacklight\ColorCLI;
+
use Blacklight\Releases;
require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
@@ -22,4 +22,4 @@ if ($passFiles->isNotEmpty()) {
}
}
}
-(new ColorCLI)->info($count2.' releases marked as passworded');
+cli()->info($count2.' releases marked as passworded');
diff --git a/misc/testing/DB/reset_postprocessing.php b/misc/testing/DB/reset_postprocessing.php
index d7c30ef93..526a294eb 100755
--- a/misc/testing/DB/reset_postprocessing.php
+++ b/misc/testing/DB/reset_postprocessing.php
@@ -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
diff --git a/misc/testing/Dev/clean_nzbs.php b/misc/testing/Dev/clean_nzbs.php
index 6eec9b333..118a85d07 100644
--- a/misc/testing/Dev/clean_nzbs.php
+++ b/misc/testing/Dev/clean_nzbs.php
@@ -6,15 +6,15 @@ use App\Models\Release;
use App\Services\Nzb\NzbParserService;
use App\Services\Nzb\NzbService;
use App\Services\ReleaseImageService;
-use Blacklight\ColorCLI;
+
use Blacklight\Releases;
use Illuminate\Support\Facades\File;
$dir = resource_path().'/movednzbs/';
-$colorCli = new ColorCLI;
+
if (! isset($argv[1]) || ! in_array($argv[1], ['true', 'move'])) {
- $colorCli->error("This script can remove all nzbs not found in the db and all releases with no nzbs found. It can also move invalid nzbs.\n\n"
+ cli()->error("This script can remove all nzbs not found in the db and all releases with no nzbs found. It can also move invalid nzbs.\n\n"
."php $argv[0] true ...: For a dry run, to see how many would be moved.\n"
."php $argv[0] move ...: Move NZBs that are possibly bad or have no release. They are moved into this folder: $dir");
exit();
@@ -33,8 +33,8 @@ $timestart = now()->toRfc2822String();
$checked = $moved = 0;
$couldbe = ($argv[1] === 'true') ? 'could be ' : '';
-$colorCli->header('Getting List of nzbs to check against db.');
-$colorCli->header("Checked / {$couldbe}moved\n");
+cli()->header('Getting List of nzbs to check against db.');
+cli()->header("Checked / {$couldbe}moved\n");
$dirItr = new RecursiveDirectoryIterator(config('nntux_settings.path_to_nzbs'));
$itr = new RecursiveIteratorIterator($dirItr, RecursiveIteratorIterator::LEAVES_ONLY);
@@ -56,9 +56,9 @@ foreach ($itr as $filePath) {
}
}
-$colorCli->header("\n".number_format($checked).' nzbs checked, '.number_format($moved).' nzbs '.$couldbe.'moved.');
-$colorCli->header('Getting List of releases to check against nzbs.');
-$colorCli->header("Checked / releases deleted\n");
+cli()->header("\n".number_format($checked).' nzbs checked, '.number_format($moved).' nzbs '.$couldbe.'moved.');
+cli()->header('Getting List of releases to check against nzbs.');
+cli()->header("Checked / releases deleted\n");
$checked = $deleted = 0;
@@ -74,5 +74,5 @@ foreach ($res as $row) {
$checked++;
echo "$checked / $deleted\r";
}
-$colorCli->header("\n".number_format($checked).' releases checked, '.number_format($deleted).' releases deleted.');
-$colorCli->header("Script started at [$timestart], finished at [".now()->toRfc2822String().']');
+cli()->header("\n".number_format($checked).' releases checked, '.number_format($deleted).' releases deleted.');
+cli()->header("Script started at [$timestart], finished at [".now()->toRfc2822String().']');
diff --git a/misc/testing/NZB/nzb-reorg.php b/misc/testing/NZB/nzb-reorg.php
index 31f607465..768906234 100755
--- a/misc/testing/NZB/nzb-reorg.php
+++ b/misc/testing/NZB/nzb-reorg.php
@@ -4,14 +4,14 @@ require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
use App\Models\Settings;
use App\Services\Nzb\NzbService;
-use Blacklight\ColorCLI;
+
if (! isset($argv[1]) || ! isset($argv[2])) {
exit("ERROR: You must supply the level you want to reorganize it to, and the source directory (You would use: 3 .../newznab/resources/nzb/ to move it to 3 levels deep)\n");
}
$nzb = app(NzbService::class);
-$consoleTools = new ColorCLI;
+
$newLevel = $argv[1];
$sourcePath = $argv[2];
@@ -39,9 +39,9 @@ foreach ($objects as $filestoprocess => $nzbFile) {
}
$iFilesProcessed++;
if ($iFilesProcessed % 100 == 0) {
- $consoleTools->overWrite("Reorganized $iFilesProcessed");
+ cli()->overWrite("Reorganized $iFilesProcessed");
}
}
Settings::query()->where(['name' => 'nzbsplitlevel'])->update(['value' => $argv[1]]);
-$consoleTools->overWrite("Processed $iFilesProcessed nzbs in ".$time->diffForHumans()."\n");
+cli()->overWrite("Processed $iFilesProcessed nzbs in ".$time->diffForHumans()."\n");
diff --git a/misc/testing/PostProc/check_covers.php b/misc/testing/PostProc/check_covers.php
index c3730cd3b..a1ec6b798 100644
--- a/misc/testing/PostProc/check_covers.php
+++ b/misc/testing/PostProc/check_covers.php
@@ -6,12 +6,12 @@
require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
use App\Services\MovieService;
-use Blacklight\ColorCLI;
+
use Illuminate\Support\Facades\DB;
$movie = new MovieService();
$movie->echooutput = true;
-$colorCli = new ColorCLI;
+
$path2cover = storage_path('covers/movies/');
@@ -21,7 +21,7 @@ if (isset($argv[1]) && ($argv[1] === 'true' || $argv[1] === 'check')) {
if (isset($argv[2]) && is_numeric($argv[2])) {
$limit = $argv[2];
}
- $colorCli->header('Scanning for releases missing covers');
+ cli()->header('Scanning for releases missing covers');
$res = DB::select('SELECT r.imdbid
FROM releases r
LEFT JOIN movieinfo m ON m.imdbid = r.imdbid
@@ -31,7 +31,7 @@ if (isset($argv[1]) && ($argv[1] === 'true' || $argv[1] === 'check')) {
$nzbpath = $path2cover.$row->imdbid.'-cover.jpg';
if (! file_exists($nzbpath)) {
$counterfixed++;
- $colorCli->warning('Missing cover '.$nzbpath);
+ cli()->warning('Missing cover '.$nzbpath);
if ($argv[1] === 'true') {
$cover = $movie->updateMovieInfo($row->imdbid);
if ($cover === false || ! file_exists($nzbpath)) {
@@ -44,9 +44,9 @@ if (isset($argv[1]) && ($argv[1] === 'true' || $argv[1] === 'check')) {
break;
}
}
- $colorCli->header('Total releases missing covers that '.$couldbe.'their covers fixed = '.number_format($counterfixed));
+ cli()->header('Total releases missing covers that '.$couldbe.'their covers fixed = '.number_format($counterfixed));
} else {
- $colorCli->header("\nThis script checks if release covers actually exist on disk.\n\n"
+ cli()->header("\nThis script checks if release covers actually exist on disk.\n\n"
."Releases without covers 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"
diff --git a/misc/testing/PostProc/check_previews.php b/misc/testing/PostProc/check_previews.php
index dbe0c30f8..7755bf729 100644
--- a/misc/testing/PostProc/check_previews.php
+++ b/misc/testing/PostProc/check_previews.php
@@ -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"
diff --git a/misc/testing/PostProc/getConsole.php b/misc/testing/PostProc/getConsole.php
index 943a9b639..5ab9af5ba 100644
--- a/misc/testing/PostProc/getConsole.php
+++ b/misc/testing/PostProc/getConsole.php
@@ -6,12 +6,12 @@ require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
use App\Models\Category;
use App\Services\ConsoleService;
-use Blacklight\ColorCLI;
+
use Illuminate\Support\Facades\DB;
$pdo = DB::connection()->getPdo();
$console = new ConsoleService;
-$colorCli = new ColorCLI;
+
$res = $pdo->query(
sprintf(
@@ -22,7 +22,7 @@ $res = $pdo->query(
)
);
if ($res instanceof Traversable) {
- $colorCli->header('Updating console info for '.number_format($res->rowCount()).' releases.');
+ cli()->header('Updating console info for '.number_format($res->rowCount()).' releases.');
foreach ($res as $arr) {
$starttime = now()->timestamp;
@@ -30,14 +30,14 @@ if ($res instanceof Traversable) {
if ($gameInfo !== false) {
$game = $console->updateConsoleInfo($gameInfo);
if ($game === false) {
- $colorCli->primary($gameInfo['release'].' not found');
+ cli()->primary($gameInfo['release'].' not found');
}
}
// amazon limits are 1 per 1 sec
$diff = floor((now()->timestamp - $starttime) * 1000000);
if (1000000 - $diff > 0) {
- $colorCli->alternate('Sleeping');
+ cli()->alternate('Sleeping');
usleep(1000000 - $diff);
}
}
diff --git a/misc/testing/PostProc/getGameCovers.php b/misc/testing/PostProc/getGameCovers.php
index a7bb99e23..b4d7e82a5 100644
--- a/misc/testing/PostProc/getGameCovers.php
+++ b/misc/testing/PostProc/getGameCovers.php
@@ -5,28 +5,28 @@
require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
use App\Services\GamesService;
-use Blacklight\ColorCLI;
+
use Illuminate\Support\Facades\DB;
$pdo = DB::connection()->getPdo();
$game = new GamesService;
-$colorCli = new ColorCLI;
+
$res = $pdo->query(
sprintf('SELECT id, title FROM gamesinfo WHERE cover = 0 ORDER BY id DESC LIMIT 100')
);
$total = $res->rowCount();
if ($total > 0) {
- $colorCli->header('Updating game covers for '.number_format($total).' releases.');
+ cli()->header('Updating game covers for '.number_format($total).' releases.');
foreach ($res as $arr) {
$starttime = now()->timestamp;
$gameInfo = $game->parseTitle($arr['title']);
if ($gameInfo !== false) {
- $colorCli->primary('Looking up: '.$gameInfo['release']);
+ cli()->primary('Looking up: '.$gameInfo['release']);
$gameData = $game->updateGamesInfo($gameInfo);
if ($gameData === false) {
- $colorCli->primary($gameInfo['release'].' not found');
+ cli()->primary($gameInfo['release'].' not found');
} else {
if (file_exists(storage_path('covers/games/').$gameData.'.jpg')) {
$pdo->exec(sprintf('UPDATE gamesinfo SET cover = 1 WHERE id = %d', $arr['id']));
@@ -37,7 +37,7 @@ if ($total > 0) {
// Rate limiting - 1 per second
$diff = floor((now()->timestamp - $starttime) * 1000000);
if (1000000 - $diff > 0) {
- $colorCli->alternate('Sleeping');
+ cli()->alternate('Sleeping');
usleep(1000000 - $diff);
}
}
diff --git a/misc/testing/PostProc/getImdb.php b/misc/testing/PostProc/getImdb.php
index c7e5192ed..3a0623af6 100644
--- a/misc/testing/PostProc/getImdb.php
+++ b/misc/testing/PostProc/getImdb.php
@@ -4,19 +4,19 @@
require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
use App\Services\MovieService;
-use Blacklight\ColorCLI;
+
use Illuminate\Support\Facades\DB;
$pdo = DB::connection()->getPdo();
$movie = new MovieService();
$movie->echooutput = true;
-$colorCli = new ColorCLI;
+
$movies = $pdo->query('SELECT imdbid FROM movieinfo WHERE tmdbid = 0 ORDER BY id ASC');
if ($movies instanceof Traversable) {
$count = $movies->rowCount();
if ($count > 0) {
- $colorCli->header('Updating movie info for '.number_format($count).' movies.');
+ cli()->header('Updating movie info for '.number_format($count).' movies.');
foreach ($movies as $mov) {
$startTime = now()->timestamp;
@@ -30,6 +30,6 @@ if ($movies instanceof Traversable) {
}
}
} else {
- $colorCli->header('No movies to update');
+ cli()->header('No movies to update');
}
}
diff --git a/misc/testing/PostProc/getMovieCovers.php b/misc/testing/PostProc/getMovieCovers.php
index e31418e82..4862f990c 100644
--- a/misc/testing/PostProc/getMovieCovers.php
+++ b/misc/testing/PostProc/getMovieCovers.php
@@ -5,20 +5,20 @@ require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
use App\Models\MovieInfo;
use App\Services\MovieService;
-use Blacklight\ColorCLI;
+
$movie = new MovieService();
$movie->echooutput = true;
-$colorCli = new ColorCLI;
+
$movies = MovieInfo::query()->where('cover', '=', 0)->orderBy('year')->orderByDesc('id')->get(['imdbid']);
$count = $movies->count();
if ($count > 0) {
- $colorCli->primary('Updating '.number_format($count).' movie covers.');
+ cli()->primary('Updating '.number_format($count).' movie covers.');
foreach ($movies as $mov) {
$startTime = now()->timestamp;
$mov = $movie->updateMovieInfo($mov['imdbid']);
}
} else {
- $colorCli->header('No movie covers to update');
+ cli()->header('No movie covers to update');
}
diff --git a/misc/testing/PostProc/getTraktData.php b/misc/testing/PostProc/getTraktData.php
index a8856a993..e041a19ec 100644
--- a/misc/testing/PostProc/getTraktData.php
+++ b/misc/testing/PostProc/getTraktData.php
@@ -6,29 +6,29 @@ require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
use App\Models\MovieInfo;
use App\Services\MovieService;
use App\Services\TvProcessing\Providers\TraktProvider;
-use Blacklight\ColorCLI;
+
$movie = new MovieService();
$movie->echooutput = true;
-$colorCli = new ColorCLI;
+
$movies = MovieInfo::query()->where('imdbid', '<>', 0)->where('traktid', '=', 0)->get(['imdbid']);
$count = $movies->count();
if ($count > 0) {
- $colorCli->primary('Updating '.number_format($count).' movies for TraktTV id.');
+ cli()->primary('Updating '.number_format($count).' movies for TraktTV id.');
foreach ($movies as $mov) {
$traktTv = new TraktProvider();
$traktmovie = $traktTv->client->getMovieSummary('tt'.$mov['imdbid'], 'full');
if ($traktmovie !== false) {
- $colorCli->info('Updating IMDb id: tt'.$mov['imdbid']);
+ cli()->info('Updating IMDb id: tt'.$mov['imdbid']);
$trakt = $movie->parseTraktTv($traktmovie);
if ($trakt === true) {
- $colorCli->info('Added traktid: '.$traktmovie['ids']['trakt']);
+ cli()->info('Added traktid: '.$traktmovie['ids']['trakt']);
} else {
- $colorCli->info('No traktid found.');
+ cli()->info('No traktid found.');
}
}
}
} else {
- $colorCli->header('No movies to update');
+ cli()->header('No movies to update');
}
diff --git a/misc/testing/PostProc/getXXXCovers.php b/misc/testing/PostProc/getXXXCovers.php
index 50670fe74..0d4306e87 100644
--- a/misc/testing/PostProc/getXXXCovers.php
+++ b/misc/testing/PostProc/getXXXCovers.php
@@ -4,23 +4,23 @@
require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
use App\Services\AdultProcessing\AdultProcessingPipeline;
-use Blacklight\ColorCLI;
+
use Illuminate\Support\Facades\DB;
$pipeline = new AdultProcessingPipeline([], true);
-$c = new ColorCLI;
+
$movies = DB::select('SELECT title FROM xxxinfo WHERE cover = 0');
-echo $c->primary('Updating '.number_format(\count($movies)).' XXX movie covers.');
+echo cli()->primary('Updating '.number_format(\count($movies)).' XXX movie covers.');
foreach ($movies as $mov) {
$starttime = now()->timestamp;
$result = $pipeline->processMovie($mov->title);
if ($result['status'] === 'matched') {
- echo $c->primary('Updated: '.$mov->title);
+ echo cli()->primary('Updated: '.$mov->title);
} else {
- echo $c->warning('No match found for: '.$mov->title);
+ echo cli()->warning('No match found for: '.$mov->title);
}
// sleep so that it's not ddos' the site
diff --git a/misc/testing/PostProc/getXXXSamples.php b/misc/testing/PostProc/getXXXSamples.php
index 755aa31f8..fdbf54c53 100644
--- a/misc/testing/PostProc/getXXXSamples.php
+++ b/misc/testing/PostProc/getXXXSamples.php
@@ -4,11 +4,11 @@ require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
use App\Models\Category;
use App\Services\ReleaseImageService;
-use Blacklight\ColorCLI;
+
use Illuminate\Support\Facades\DB;
$pdo = DB::connection()->getPdo();
-$colorCli = new ColorCLI;
+
$path2cover = storage_path('covers/sample/');
@@ -20,7 +20,7 @@ if (isset($argv[1]) && ($argv[1] === 'true' || $argv[1] === 'check')) {
$limit = $argv[2];
}
- $colorCli->header('Scanning for XXX UHD/HD/SD releases missing sample images');
+ cli()->header('Scanning for XXX UHD/HD/SD releases missing sample images');
$res = $pdo->query(sprintf('SELECT r.id, r.guid AS guid, r.searchname AS searchname
FROM releases r
WHERE r.jpgstatus = 0 AND r.categories_id IN (%s, %s, %s) ORDER BY r.adddate DESC', Category::XXX_CLIPHD, Category::XXX_CLIPSD, Category::XXX_UHD));
@@ -37,10 +37,10 @@ if (isset($argv[1]) && ($argv[1] === 'true' || $argv[1] === 'check')) {
}
$sample = $releaseImage->saveImage($row['guid'].'_thumb', $imgpath, $releaseImage->jpgSavePath, 650, 650);
if ($sample !== 0) {
- $colorCli->info('Downloaded sample for '.$row['searchname']);
+ cli()->info('Downloaded sample for '.$row['searchname']);
$pdo->exec(sprintf('UPDATE releases SET jpgstatus = 1 WHERE id = %d', $row['id']));
} else {
- $colorCli->notice('Sample download failed!');
+ cli()->notice('Sample download failed!');
$pdo->exec(sprintf('UPDATE releases SET jpgstatus = -2 WHERE id = %d', $row['id']));
}
}
@@ -50,9 +50,9 @@ if (isset($argv[1]) && ($argv[1] === 'true' || $argv[1] === 'check')) {
break;
}
}
- $colorCli->header('Total releases missing samples that '.$couldbe.'their samples updated = '.number_format($counterfixed));
+ cli()->header('Total releases missing samples that '.$couldbe.'their samples updated = '.number_format($counterfixed));
} else {
- $colorCli->header("\nThis script checks if XXX release samples actually exist on disk.\n\n"
+ cli()->header("\nThis script checks if XXX release samples actually exist on disk.\n\n"
."php $argv[0] check ...: Dry run, displays missing samples.\n"
."php $argv[0] true ...: Update XXX releases missing samples.\n");
exit();
diff --git a/misc/testing/PostProc/updateBookImages.php b/misc/testing/PostProc/updateBookImages.php
index cd01ba2d7..914021b8b 100644
--- a/misc/testing/PostProc/updateBookImages.php
+++ b/misc/testing/PostProc/updateBookImages.php
@@ -1,16 +1,16 @@
error("\nThis script will check all images in covers/book and compare to db->bookinfo.\nTo run:\nphp $argv[0] true\n");
+ cli()->error("\nThis script will check all images in covers/book and compare to db->bookinfo.\nTo run:\nphp $argv[0] true\n");
exit();
}
@@ -27,7 +27,7 @@ foreach ($itr as $filePath) {
} else {
$run = BookInfo::query()->where('id', $hit[1])->select(['id'])->get();
if ($run->count() === 0) {
- $colorCli->info($filePath.' not found in db.');
+ cli()->info($filePath.' not found in db.');
}
}
}
@@ -38,9 +38,9 @@ $qry = BookInfo::query()->where('cover', '=', 1)->select(['id'])->get();
foreach ($qry as $rows) {
if (! is_file($path2covers.$rows['id'].'.jpg')) {
BookInfo::query()->where(['cover' => 1, 'id' => $rows['id']])->update(['cover' => 0]);
- $colorCli->info($path2covers.$rows['id'].'.jpg does not exist.');
+ cli()->info($path2covers.$rows['id'].'.jpg does not exist.');
$deleted++;
}
}
-$colorCli->header($covers.' covers set.');
-$colorCli->header($deleted.' books unset.');
+cli()->header($covers.' covers set.');
+cli()->header($deleted.' books unset.');
diff --git a/misc/testing/PostProc/updateConsoleImages.php b/misc/testing/PostProc/updateConsoleImages.php
index 0975a194e..22e589fd3 100644
--- a/misc/testing/PostProc/updateConsoleImages.php
+++ b/misc/testing/PostProc/updateConsoleImages.php
@@ -3,14 +3,14 @@
require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
use App\Models\ConsoleInfo;
-use Blacklight\ColorCLI;
+
use Illuminate\Support\Facades\File;
$covers = $updated = $deleted = 0;
-$colorCli = new ColorCLI;
+
if ($argc === 1 || $argv[1] !== 'true') {
- $colorCli->error("\nThis script will check all images in covers/console and compare to db->consoleinfo.\nTo run:\nphp $argv[0] true\n");
+ cli()->error("\nThis script will check all images in covers/console and compare to db->consoleinfo.\nTo run:\nphp $argv[0] true\n");
exit();
}
@@ -32,7 +32,7 @@ foreach ($itr as $filePath) {
} else {
$run = ConsoleInfo::query()->where('id', $hit[1])->value('id');
if ($run === 0) {
- $colorCli->info($filePath.' not found in db.');
+ cli()->info($filePath.' not found in db.');
}
}
}
@@ -48,9 +48,9 @@ foreach ($qry as $rows) {
['id' => $rows['id']],
]
)->update(['cover' => 0]);
- $colorCli->info($path2covers.$rows['id'].'.jpg does not exist.');
+ cli()->info($path2covers.$rows['id'].'.jpg does not exist.');
$deleted++;
}
}
-$colorCli->header($covers.' covers set.');
-$colorCli->header($deleted.' consoles unset.');
+cli()->header($covers.' covers set.');
+cli()->header($deleted.' consoles unset.');
diff --git a/misc/testing/PostProc/updateGamesImages.php b/misc/testing/PostProc/updateGamesImages.php
index 8a710555d..a65863455 100644
--- a/misc/testing/PostProc/updateGamesImages.php
+++ b/misc/testing/PostProc/updateGamesImages.php
@@ -3,14 +3,14 @@
require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
use App\Models\GamesInfo;
-use Blacklight\ColorCLI;
+
use Illuminate\Support\Facades\File;
$covers = $updated = $deleted = 0;
-$colorCli = new ColorCLI;
+
if ($argc === 1 || $argv[1] !== 'true') {
- $colorCli->error("\nThis script will check all images in covers/games and compare to db->gamesinfo.\nTo run:\nphp $argv[0] true\n");
+ cli()->error("\nThis script will check all images in covers/games and compare to db->gamesinfo.\nTo run:\nphp $argv[0] true\n");
exit();
}
@@ -28,7 +28,7 @@ foreach ($itr as $filePath) {
} else {
$run = GamesInfo::query()->where('id', $hit[1])->select(['id'])->get();
if ($run !== null && $run === 0) {
- $colorCli->info($filePath->getPathname().' not found in db.');
+ cli()->info($filePath->getPathname().' not found in db.');
}
}
}
@@ -40,9 +40,9 @@ $qry = GamesInfo::query()->where('cover', '=', 1)->select(['id'])->get();
foreach ($qry as $rows) {
if (! is_file($path2covers.$rows['id'].'.jpg')) {
GamesInfo::query()->where(['cover' => 1, 'id' => $rows['id']])->update(['cover' => 0]);
- $colorCli->info($path2covers.$rows['id'].'.jpg does not exist.');
+ cli()->info($path2covers.$rows['id'].'.jpg does not exist.');
$deleted++;
}
}
-$colorCli->header($covers.' covers set.');
-$colorCli->header($deleted.' games unset.');
+cli()->header($covers.' covers set.');
+cli()->header($deleted.' games unset.');
diff --git a/misc/testing/PostProc/updateMovieImages.php b/misc/testing/PostProc/updateMovieImages.php
index 92506c00f..2b7a5b0a8 100644
--- a/misc/testing/PostProc/updateMovieImages.php
+++ b/misc/testing/PostProc/updateMovieImages.php
@@ -3,14 +3,14 @@
require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
use App\Models\MovieInfo;
-use Blacklight\ColorCLI;
+
use Illuminate\Support\Facades\File;
$covers = $updated = $deleted = 0;
-$colorCli = new ColorCLI;
+
if ($argc === 1 || $argv[1] !== 'true') {
- $colorCli->error("\nThis script will check all images in covers/movies and compare to db->movieinfo.\nTo run:\nphp $argv[0] true\n");
+ cli()->error("\nThis script will check all images in covers/movies and compare to db->movieinfo.\nTo run:\nphp $argv[0] true\n");
exit();
}
@@ -27,7 +27,7 @@ foreach ($itr as $filePath) {
} else {
$run = MovieInfo::query()->where('imdbid', '=', $hit[1])->select(['imdbid'])->get();
if ($run->count() === 0) {
- $colorCli->error($filePath.' not found in db.');
+ cli()->error($filePath.' not found in db.');
}
}
}
@@ -41,7 +41,7 @@ foreach ($itr as $filePath) {
} else {
$run = MovieInfo::query()->where('imdbid', $match1[1])->select(['imdbid'])->get();
if ($run->count() === 0) {
- $colorCli->error($filePath->getPathname().' not found in db.');
+ cli()->error($filePath->getPathname().' not found in db.');
}
}
}
@@ -52,7 +52,7 @@ $qry = MovieInfo::query()->where('cover', '=', 1)->select(['imdbid'])->get();
foreach ($qry as $rows) {
if (! is_file($path2covers.$rows['imdbid'].'-cover.jpg')) {
MovieInfo::query()->where('cover', '=', 1)->where('imdbid', $rows['imdbid'])->update(['cover' => 0]);
- $colorCli->info($path2covers.$rows['imdbid'].'-cover.jpg does not exist.');
+ cli()->info($path2covers.$rows['imdbid'].'-cover.jpg does not exist.');
$deleted++;
}
}
@@ -60,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.');
+ cli()->info($path2covers.$rows['imdbid'].'-backdrop.jpg does not exist.');
$deleted++;
}
}
-$colorCli->info($covers.' covers set.');
-$colorCli->info($updated.' backdrops set.');
-$colorCli->info($deleted.' movies unset.');
+cli()->info($covers.' covers set.');
+cli()->info($updated.' backdrops set.');
+cli()->info($deleted.' movies unset.');
diff --git a/misc/testing/PostProc/updateMusicImages.php b/misc/testing/PostProc/updateMusicImages.php
index f867ed0c8..8dcae9f87 100644
--- a/misc/testing/PostProc/updateMusicImages.php
+++ b/misc/testing/PostProc/updateMusicImages.php
@@ -3,14 +3,14 @@
require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
use App\Models\MusicInfo;
-use Blacklight\ColorCLI;
+
use Illuminate\Support\Facades\File;
$covers = $updated = $deleted = 0;
-$colorCli = new ColorCLI;
+
if ($argc === 1 || $argv[1] !== 'true') {
- $colorCli->error("\nThis script will check all images in covers/music and compare to db->musicinfo.\nTo run:\nphp $argv[0] true\n");
+ cli()->error("\nThis script will check all images in covers/music and compare to db->musicinfo.\nTo run:\nphp $argv[0] true\n");
exit();
}
@@ -27,7 +27,7 @@ foreach ($itr as $filePath) {
} else {
$run = MusicInfo::query()->where('id', $hit[1])->select(['id'])->get();
if ($run->count() === 0) {
- $colorCli->info($filePath->getPathname().' not found in db.');
+ cli()->info($filePath->getPathname().' not found in db.');
}
}
}
@@ -38,9 +38,9 @@ $qry = MusicInfo::query()->where('cover', '=', 1)->select(['id'])->get();
foreach ($qry as $rows) {
if (! is_file($path2covers.$rows['id'].'.jpg')) {
MusicInfo::query()->where(['cover' => 1, 'id' => $rows['id']])->update(['cover' => 0]);
- $colorCli->info($path2covers.$rows['id'].'.jpg does not exist.');
+ cli()->info($path2covers.$rows['id'].'.jpg does not exist.');
$deleted++;
}
}
-$colorCli->header($covers.' covers set.');
-$colorCli->header($deleted.' music unset.');
+cli()->header($covers.' covers set.');
+cli()->header($deleted.' music unset.');
diff --git a/misc/testing/PostProc/updateXXXImages.php b/misc/testing/PostProc/updateXXXImages.php
index bc61646ae..446eeeada 100644
--- a/misc/testing/PostProc/updateXXXImages.php
+++ b/misc/testing/PostProc/updateXXXImages.php
@@ -3,14 +3,14 @@
require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
use App\Models\XxxInfo;
-use Blacklight\ColorCLI;
+
use Illuminate\Support\Facades\File;
$covers = $updated = $deleted = 0;
-$colorCli = new ColorCLI;
+
if ($argc === 1 || $argv[1] !== 'true') {
- $colorCli->error("\nThis script will check all images in covers/xxx and compare to db->xxxinfo.\nTo run:\nphp $argv[0] true\n");
+ cli()->error("\nThis script will check all images in covers/xxx and compare to db->xxxinfo.\nTo run:\nphp $argv[0] true\n");
exit();
}
@@ -27,7 +27,7 @@ foreach ($itr as $filePath) {
} else {
$run = XxxInfo::query()->where('id', $hit[1])->select(['id'])->get();
if ($run->count() === 0) {
- $colorCli->info($filePath->getPathname().' not found in db.');
+ cli()->info($filePath->getPathname().' not found in db.');
}
}
}
@@ -41,7 +41,7 @@ foreach ($itr as $filePath) {
} else {
$run = XxxInfo::query()->where('id', $match1[1])->select(['id'])->get();
if ($run->count() === 0) {
- $colorCli->info($filePath->getPathname().' not found in db.');
+ cli()->info($filePath->getPathname().' not found in db.');
}
}
}
@@ -52,7 +52,7 @@ $qry = XxxInfo::query()->where('cover', '=', 1)->select(['id'])->get();
foreach ($qry as $rows) {
if (! is_file($path2covers.$rows['id'].'-cover.jpg')) {
XxxInfo::query()->where(['cover' => 1, 'id' => $rows['id']])->update(['cover' => 0]);
- $colorCli->info($path2covers.$rows['id'].'-cover.jpg does not exist.');
+ cli()->info($path2covers.$rows['id'].'-cover.jpg does not exist.');
$deleted++;
}
}
@@ -60,10 +60,10 @@ $qry1 = XxxInfo::query()->where('backdrop', '=', 1)->select(['id'])->get();
foreach ($qry1 as $rows) {
if (! is_file($path2covers.$rows['id'].'-backdrop.jpg')) {
XxxInfo::query()->where(['backdrop' => 1, 'id' => $rows['id']])->update(['backdrop' => 0]);
- $colorCli->info($path2covers.$rows['id'].'-backdrop.jpg does not exist.');
+ cli()->info($path2covers.$rows['id'].'-backdrop.jpg does not exist.');
$deleted++;
}
}
-$colorCli->header($covers.' covers set.');
-$colorCli->header($updated.' backdrops set.');
-$colorCli->header($deleted.' movies unset.');
+cli()->header($covers.' covers set.');
+cli()->header($updated.' backdrops set.');
+cli()->header($deleted.' movies unset.');
diff --git a/misc/testing/Releases/delete_releases.php b/misc/testing/Releases/delete_releases.php
index 48a997d65..21690a02d 100644
--- a/misc/testing/Releases/delete_releases.php
+++ b/misc/testing/Releases/delete_releases.php
@@ -2,7 +2,7 @@
require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
-use Blacklight\ColorCLI;
+
use Blacklight\ReleaseRemover;
// New line for CLI.
@@ -11,12 +11,12 @@ $n = PHP_EOL;
// Include config.php
// ColorCLI class.
-$cli = new ColorCLI;
+
// Print arguments/usage.
$totalArgs = count($argv);
if ($totalArgs < 2) {
- exit($cli->info(
+ exit(cli()->info(
$n.
'This deletes releases based on a list of criteria you pass.'.$n.
'Usage:'.$n.$n.
diff --git a/misc/testing/Releases/recategorize.php b/misc/testing/Releases/recategorize.php
index 603153545..6143b3067 100644
--- a/misc/testing/Releases/recategorize.php
+++ b/misc/testing/Releases/recategorize.php
@@ -5,12 +5,12 @@ require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
use App\Models\Category;
use App\Models\Release;
use App\Services\Categorization\CategorizationService;
-use Blacklight\ColorCLI;
-$colorCli = new ColorCLI;
+
+
if (! (isset($argv[1]) && ($argv[1] === 'all' || $argv[1] === 'misc' || preg_match('/\([\d, ]+\)/', $argv[1]) || is_numeric($argv[1])))) {
- $colorCli->error(
+ cli()->error(
"\nThis script will attempt to re-categorize releases and is useful if changes have been made to Category.php.\n"
."No updates will be done unless the category changes\n"
."An optional last argument, false, will display the number of category changes that would be made\n"
@@ -27,22 +27,22 @@ reCategorize($argv);
function reCategorize($argv): void
{
- $colorCli = new ColorCLI;
+
if (isset($argv[1]) && (is_numeric($argv[1]) || preg_match('/\([\d, ]+\)/', $argv[1]))) {
- $colorCli->header('Categorizing all releases in '.$argv[1].' using searchname. This can take a while, be patient.');
+ cli()->header('Categorizing all releases in '.$argv[1].' using searchname. This can take a while, be patient.');
} elseif (isset($argv[1]) && $argv[1] === 'misc') {
- $colorCli->header('Categorizing all releases in misc categories using searchname. This can take a while, be patient.');
+ cli()->header('Categorizing all releases in misc categories using searchname. This can take a while, be patient.');
} else {
- $colorCli->header('Categorizing all releases using searchname. This can take a while, be patient.');
+ cli()->header('Categorizing all releases using searchname. This can take a while, be patient.');
}
$timeStart = now();
$chgCount = categorizeRelease($argv, true);
$time = now()->diffInSeconds($timeStart, true);
if (! isset($argv[2])) {
- $colorCli->header('Finished re-categorizing '.number_format($chgCount).' releases in '.$time.' seconds, using the searchname.').PHP_EOL;
+ cli()->header('Finished re-categorizing '.number_format($chgCount).' releases in '.$time.' seconds, using the searchname.').PHP_EOL;
} else {
- $colorCli->header('Finished re-categorizing in '.$time.' seconds , using the searchname.'.PHP_EOL
+ cli()->header('Finished re-categorizing in '.$time.' seconds , using the searchname.'.PHP_EOL
.'This would have changed '.number_format($chgCount).' releases but no updates were done.').PHP_EOL;
}
}
@@ -62,9 +62,9 @@ function categorizeRelease($argv, $echoOutput = false): int
$update = false;
}
$total = $query->count();
- $colorCli = new ColorCLI;
- $colorCli->header('Categorizing ['.$total.'] releases. This can take a while, be patient.');
- $consoleTools = new ColorCLI;
+
+ cli()->header('Categorizing ['.$total.'] releases. This can take a while, be patient.');
+
$relCount = $chgCount = 0;
if ($total > 0) {
$query->chunk('100', function ($results) use ($update, $relCount, $chgCount) {
@@ -104,7 +104,7 @@ function categorizeRelease($argv, $echoOutput = false): int
});
if ($echoOutput) {
- $consoleTools->overWritePrimary('Re-Categorized: ['.number_format($chgCount).'] '.$consoleTools->percentString($relCount, $total).PHP_EOL);
+ cli()->overWritePrimary('Re-Categorized: ['.number_format($chgCount).'] '.cli()->percentString($relCount, $total).PHP_EOL);
}
}
diff --git a/misc/testing/Releases/removeCrapReleases.php b/misc/testing/Releases/removeCrapReleases.php
index 6a09a6e2f..a77b8c273 100755
--- a/misc/testing/Releases/removeCrapReleases.php
+++ b/misc/testing/Releases/removeCrapReleases.php
@@ -3,17 +3,17 @@
/* This script deletes releases that match certain criteria, type php removeCrapReleases.php false for details. */
require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
-use Blacklight\ColorCLI;
+
use Blacklight\ReleaseRemover;
-$cli = new ColorCLI;
+
$n = PHP_EOL;
$argCnt = count($argv);
if ($argCnt === 1) {
exit(
- $cli->error(
+ cli()->error(
$n.
'Run fixReleaseNames.php first to attempt to fix release names.'.$n.
'This will miss some releases if you have not set fixReleaseNames to set the release as checked.'.$n.$n.
@@ -54,11 +54,11 @@ if ($argCnt === 2) {
"php $argv[0] true full blacklist 1 = Remove releases matching blacklist id 1.".$n
);
} else {
- exit($cli->error("Wrong usage! Type php $argv[0] false"));
+ exit(cli()->error("Wrong usage! Type php $argv[0] false"));
}
}
if ($argCnt < 3) {
- exit($cli->error("Wrong usage! Type php $argv[0] false"));
+ exit(cli()->error("Wrong usage! Type php $argv[0] false"));
}
if (isset($argv[3]) && $argv[3] === 'blacklist' && isset($argv[4])) {
diff --git a/misc/testing/Tests/test_fanarttv_API.php b/misc/testing/Tests/test_fanarttv_API.php
index 4f23725f9..8b89d4dc9 100644
--- a/misc/testing/Tests/test_fanarttv_API.php
+++ b/misc/testing/Tests/test_fanarttv_API.php
@@ -3,10 +3,10 @@
require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
use App\Services\FanartTvService;
-use Blacklight\ColorCLI;
+
$fanart = new FanartTvService();
-$colorCli = new ColorCLI;
+
if (! empty($argv[1])) {
// Test if you can fetch Fanart.TV images
@@ -16,10 +16,10 @@ if (! empty($argv[1])) {
if ($moviefanart) {
dump($moviefanart);
} else {
- $colorCli->error('Error retrieving Fanart.TV data.');
+ cli()->error('Error retrieving Fanart.TV data.');
exit();
}
} else {
- $colorCli->error('Invalid arguments. This script requires a number or string (TMDB or IMDb ID.');
+ cli()->error('Invalid arguments. This script requires a number or string (TMDB or IMDb ID.');
exit();
}
diff --git a/misc/testing/Tests/test_omdb_API.php b/misc/testing/Tests/test_omdb_API.php
index 16a350307..a6425fdba 100644
--- a/misc/testing/Tests/test_omdb_API.php
+++ b/misc/testing/Tests/test_omdb_API.php
@@ -3,10 +3,10 @@
require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
use aharen\OMDbAPI;
-use Blacklight\ColorCLI;
+
$omdb = new OMDbAPI(config('nntmux_api.omdb_api_key'));
-$colorCli = new ColorCLI;
+
if (! empty($argv[1]) && ! empty($argv[2]) && ($argv[2] !== 'series' || $argv[2] !== 'movie')) {
// Test if your OMDb API key and configuration are working
@@ -24,10 +24,10 @@ if (! empty($argv[1]) && ! empty($argv[2]) && ($argv[2] !== 'series' || $argv[2]
dump($search);
} else {
- $colorCli->error('Error retrieving OMDb API data.');
+ cli()->error('Error retrieving OMDb API data.');
exit();
}
} else {
- $colorCli->error('Invalid arguments. This script requires a text string (show name), and a second argument, movie or series.');
+ cli()->error('Invalid arguments. This script requires a text string (show name), and a second argument, movie or series.');
exit();
}
diff --git a/misc/testing/Tests/test_tmdb_API.php b/misc/testing/Tests/test_tmdb_API.php
index 06039376a..baf283336 100755
--- a/misc/testing/Tests/test_tmdb_API.php
+++ b/misc/testing/Tests/test_tmdb_API.php
@@ -3,9 +3,9 @@
require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
use App\Services\TmdbClient;
-use Blacklight\ColorCLI;
-$colorCli = new ColorCLI;
+
+
if (! empty($argv[1]) && is_numeric($argv[2]) && is_numeric($argv[3])) {
// Test if your TMDB API configuration is working
@@ -14,7 +14,7 @@ if (! empty($argv[1]) && is_numeric($argv[2]) && is_numeric($argv[3])) {
$tmdbClient = app(TmdbClient::class);
if (! $tmdbClient->isConfigured()) {
- exit($colorCli->error('TMDB API key is not configured. Please set your API key in the configuration.'));
+ exit(cli()->error('TMDB API key is not configured. Please set your API key in the configuration.'));
}
$season = (int) $argv[2];
@@ -31,7 +31,7 @@ if (! empty($argv[1]) && is_numeric($argv[2]) && is_numeric($argv[3])) {
$showId = TmdbClient::getInt($results[0], 'id');
if ($showId === 0) {
- exit($colorCli->error('Invalid show ID returned from TMDB API.'));
+ exit(cli()->error('Invalid show ID returned from TMDB API.'));
}
// Get TV show details with networks
@@ -57,7 +57,7 @@ if (! empty($argv[1]) && is_numeric($argv[2]) && is_numeric($argv[3])) {
echo "Season: $season, Episode: $episode\n";
print_r($episodeObj);
} else {
- exit($colorCli->error('Episode not found on TMDB API.'));
+ exit(cli()->error('Episode not found on TMDB API.'));
}
} elseif ($season === 0 && $episode === 0) {
$tvShowFull = $tmdbClient->getTvShow($showId);
@@ -65,11 +65,11 @@ if (! empty($argv[1]) && is_numeric($argv[2]) && is_numeric($argv[3])) {
print_r($tvShowFull);
}
} else {
- exit($colorCli->error('Invalid episode data returned from TMDB API.'));
+ exit(cli()->error('Invalid episode data returned from TMDB API.'));
}
} else {
- exit($colorCli->error('Invalid show data returned from TMDB API.'));
+ exit(cli()->error('Invalid show data returned from TMDB API.'));
}
} else {
- exit($colorCli->error('Invalid arguments. This script requires a text string (show name) followed by a season and episode number.'));
+ exit(cli()->error('Invalid arguments. This script requires a text string (show name) followed by a season and episode number.'));
}
diff --git a/misc/testing/Tests/test_trakt_API.php b/misc/testing/Tests/test_trakt_API.php
index ab941f255..b9086a987 100755
--- a/misc/testing/Tests/test_trakt_API.php
+++ b/misc/testing/Tests/test_trakt_API.php
@@ -4,7 +4,7 @@ require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
use App\Services\TraktService;
-$c = new Blacklight\ColorCLI;
+
$trakt = new TraktService;
if (! empty($argv[1]) && is_numeric($argv[2]) && is_numeric($argv[3])) {
@@ -22,8 +22,8 @@ if (! empty($argv[1]) && is_numeric($argv[2]) && is_numeric($argv[3])) {
print_r($series);
print_r($episode);
} else {
- exit($c->error('Error retrieving Trakt data.'));
+ exit(cli()->error('Error retrieving Trakt data.'));
}
} else {
- exit($c->error('Invalid arguments. This script requires a text string (show name) followed by a season and episode number.'));
+ exit(cli()->error('Invalid arguments. This script requires a text string (show name) followed by a season and episode number.'));
}
diff --git a/misc/testing/Tests/test_tvdb_API.php b/misc/testing/Tests/test_tvdb_API.php
index 53926de5a..6dadc25ab 100755
--- a/misc/testing/Tests/test_tvdb_API.php
+++ b/misc/testing/Tests/test_tvdb_API.php
@@ -4,7 +4,7 @@ require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
use App\Services\TvProcessing\Providers\TvdbProvider;
-$c = new Blacklight\ColorCLI;
+
$tvDB = new TvdbProvider;
if (! empty($argv[1]) && isset($argv[2], $argv[3]) && is_numeric($argv[2]) && is_numeric($argv[3])) {
@@ -57,12 +57,12 @@ if (! empty($argv[1]) && isset($argv[2], $argv[3]) && is_numeric($argv[2]) && is
}
}
} else {
- exit($c->error('Invalid episode data returned from TVDB API.'));
+ exit(cli()->error('Invalid episode data returned from TVDB API.'));
}
} else {
- exit($c->error('Invalid show data returned from TVDB API.'));
+ exit(cli()->error('Invalid show data returned from TVDB API.'));
}
} else {
- exit($c->error('Invalid arguments. This script requires a text string (show name) followed by a season and episode number.')
+ exit(cli()->error('Invalid arguments. This script requires a text string (show name) followed by a season and episode number.')
);
}
diff --git a/misc/testing/Tests/test_tvmaze_API.php b/misc/testing/Tests/test_tvmaze_API.php
index 9679d7a95..d7355e6a2 100755
--- a/misc/testing/Tests/test_tvmaze_API.php
+++ b/misc/testing/Tests/test_tvmaze_API.php
@@ -4,7 +4,7 @@ require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
use App\Services\TvProcessing\Providers\TvMazeProvider;
-$c = new Blacklight\ColorCLI;
+
$tvmaze = new TvMazeProvider;
if (! empty($argv[1]) && is_numeric($argv[2]) && is_numeric($argv[3])) {
@@ -19,7 +19,7 @@ if (! empty($argv[1]) && is_numeric($argv[2]) && is_numeric($argv[3])) {
// Use the first show found (highest match) and get the requested season/episode from $argv
if ($series) {
- echo PHP_EOL.$c->info('Server Time: '.$serverTime).PHP_EOL;
+ echo PHP_EOL.cli()->info('Server Time: '.$serverTime).PHP_EOL;
print_r($series[0]);
if ($season > 0 and $episode > 0) {
@@ -36,11 +36,11 @@ if (! empty($argv[1]) && is_numeric($argv[2]) && is_numeric($argv[3])) {
}
}
} else {
- exit($c->error('Invalid episode data returned from TVMaze API.'));
+ exit(cli()->error('Invalid episode data returned from TVMaze API.'));
}
} else {
- exit($c->error('Invalid show data returned from TVMaze API.'));
+ exit(cli()->error('Invalid show data returned from TVMaze API.'));
}
} else {
- exit($c->error('Invalid arguments. This script requires a text string (show name) followed by a season and episode number.'));
+ exit(cli()->error('Invalid arguments. This script requires a text string (show name) followed by a season and episode number.'));
}
diff --git a/misc/testing/resend_activation_email.php b/misc/testing/resend_activation_email.php
index a1b670eb0..cf5503008 100644
--- a/misc/testing/resend_activation_email.php
+++ b/misc/testing/resend_activation_email.php
@@ -1,20 +1,17 @@
info('Email has been sent');
+ cli()->info('Email has been sent');
} else {
- $colorCli->error('You need to provide user id as argument');
+ cli()->error('You need to provide user id as argument');
}