diff --git a/Blacklight/Backfill.php b/Blacklight/Backfill.php
index 36258dcfc..141a752d8 100755
--- a/Blacklight/Backfill.php
+++ b/Blacklight/Backfill.php
@@ -45,33 +45,12 @@ class Backfill
protected ColorCLI $colorCli;
- /**
- * Constructor.
- *
- * @param array $options Class instances / Echo to cli?
- *
- * @throws \Exception
- */
- public function __construct(array $options = [])
+ public function __construct()
{
- $defaults = [
- 'Echo' => true,
- 'Logger' => null,
- 'Groups' => null,
- 'NNTP' => null,
- 'Settings' => null,
- ];
- $options += $defaults;
+ $this->_echoCLI = config('nntmux.echocli');
- $this->_echoCLI = ($options['Echo'] && config('nntmux.echocli'));
-
- $this->_nntp = (
- $options['NNTP'] instanceof NNTP
- ? $options['NNTP'] : new NNTP()
- );
- $this->_binaries = new Binaries(
- ['NNTP' => $this->_nntp, 'Echo' => $this->_echoCLI]
- );
+ $this->_nntp = new NNTP();
+ $this->_binaries = new Binaries();
$this->colorCli = new ColorCLI();
diff --git a/Blacklight/Binaries.php b/Blacklight/Binaries.php
index 668c50f55..85246e22b 100644
--- a/Blacklight/Binaries.php
+++ b/Blacklight/Binaries.php
@@ -175,28 +175,17 @@ class Binaries
*
* @throws \Exception
*/
- public function __construct(array $options = [])
+ public function __construct()
{
- $defaults = [
- 'Echo' => true,
- 'CollectionsCleaning' => null,
- 'ColorCLI' => null,
- 'Logger' => null,
- 'Groups' => null,
- 'NNTP' => null,
- 'Settings' => null,
- ];
- $options += $defaults;
-
$this->startUpdate = now();
$this->timeCleaning = 0;
- $this->_echoCLI = ($options['Echo'] && config('nntmux.echocli'));
+ $this->_echoCLI = config('nntmux.echocli');
$this->_pdo = DB::connection()->getPdo();
- $this->colorCli = ($options['ColorCLI'] instanceof ColorCLI ? $options['ColorCLI'] : new ColorCLI());
- $this->_nntp = ($options['NNTP'] instanceof NNTP ? $options['NNTP'] : new NNTP(['Echo' => $this->colorCli, 'ColorCLI' => $this->colorCli]));
- $this->_collectionsCleaning = ($options['CollectionsCleaning'] instanceof CollectionsCleaning ? $options['CollectionsCleaning'] : new CollectionsCleaning());
+ $this->colorCli = new ColorCLI();
+ $this->_nntp = new NNTP();
+ $this->_collectionsCleaning = new CollectionsCleaning();
$this->messageBuffer = Settings::settingValue('..maxmssgs') !== '' ?
(int) Settings::settingValue('..maxmssgs') : 20000;
diff --git a/Blacklight/Books.php b/Blacklight/Books.php
index e11ea0ca2..e255da94d 100755
--- a/Blacklight/Books.php
+++ b/Blacklight/Books.php
@@ -60,15 +60,9 @@ class Books
*
* @throws \Exception
*/
- public function __construct(array $options = [])
+ public function __construct()
{
- $defaults = [
- 'Echo' => false,
- 'Settings' => null,
- ];
- $options += $defaults;
-
- $this->echooutput = ($options['Echo'] && config('nntmux.echocli'));
+ $this->echooutput = config('nntmux.echocli');
$this->colorCli = new ColorCLI();
diff --git a/Blacklight/Console.php b/Blacklight/Console.php
index b7eb4340e..cec37e9bb 100755
--- a/Blacklight/Console.php
+++ b/Blacklight/Console.php
@@ -84,20 +84,9 @@ class Console
*/
protected $colorCli;
- /**
- * @param array $options Class instances / Echo to cli.
- *
- * @throws \Exception
- */
- public function __construct(array $options = [])
+ public function __construct()
{
- $defaults = [
- 'Echo' => false,
- 'Settings' => null,
- ];
- $options += $defaults;
-
- $this->echooutput = ($options['Echo'] && config('nntmux.echocli'));
+ $this->echooutput = config('nntmux.echocli');
$this->colorCli = new ColorCLI();
diff --git a/Blacklight/Games.php b/Blacklight/Games.php
index 51f58cebe..15a0f0290 100755
--- a/Blacklight/Games.php
+++ b/Blacklight/Games.php
@@ -78,15 +78,9 @@ class Games
*
* @throws \Exception
*/
- public function __construct(array $options = [])
+ public function __construct()
{
- $defaults = [
- 'Echo' => false,
- 'ColorCLI' => null,
- 'Settings' => null,
- ];
- $options += $defaults;
- $this->echoOutput = ($options['Echo'] && config('nntmux.echocli'));
+ $this->echoOutput = config('nntmux.echocli');
$this->colorCli = new ColorCLI();
diff --git a/Blacklight/Genres.php b/Blacklight/Genres.php
index 67b94edc3..080b621fe 100755
--- a/Blacklight/Genres.php
+++ b/Blacklight/Genres.php
@@ -23,17 +23,8 @@ class Genres
public const STATUS_DISABLED = 1;
- /**
- * @param array $options Class instances.
- *
- * @throws \Exception
- */
- public function __construct(array $options = [])
+ public function __construct()
{
- $defaults = [
- 'Settings' => null,
- ];
- $options += $defaults;
}
/**
diff --git a/Blacklight/IRCClient.php b/Blacklight/IRCClient.php
index 844027bea..015972b19 100755
--- a/Blacklight/IRCClient.php
+++ b/Blacklight/IRCClient.php
@@ -14,73 +14,53 @@ class IRCClient
{
/**
* Hostname IRC server used when connecting.
- *
- * @var string
*/
- protected $_remote_host = '';
+ protected string $_remote_host = '';
/**
* Port number IRC server.
- *
- * @var int
*/
- protected $_remote_port = 6667;
+ protected int $_remote_port = 6667;
/**
* Socket transport type for the IRC server.
- *
- * @var string
*/
- protected $_remote_transport = 'tcp';
+ protected string $_remote_transport = 'tcp';
/**
* Hostname the IRC server sent us back.
- *
- * @var string
*/
- protected $_remote_host_received = '';
+ protected string $_remote_host_received = '';
/**
* String used when creating the stream socket.
- *
- * @var string
*/
- protected $_remote_socket_string = '';
+ protected string $_remote_socket_string = '';
/**
* Are we using tls/ssl?
- *
- * @var bool
*/
- protected $_remote_tls = false;
+ protected bool $_remote_tls = false;
/**
* Time in seconds to timeout on connect.
- *
- * @var int
*/
- protected $_remote_connection_timeout = 30;
+ protected int $_remote_connection_timeout = 30;
/**
* Time in seconds before we timeout when sending/receiving a command.
- *
- * @var int
*/
- protected $_socket_timeout = 180;
+ protected int $_socket_timeout = 180;
/**
* How many times to retry when connecting to IRC.
- *
- * @var int
*/
- protected $_reconnectRetries = 3;
+ protected int $_reconnectRetries = 3;
/**
* Seconds to delay when reconnecting fails.
- *
- * @var int
*/
- protected $_reconnectDelay = 5;
+ protected int $_reconnectDelay = 5;
/**
* Stream socket client.
@@ -94,7 +74,7 @@ class IRCClient
*
* @var string
*/
- protected $_buffer = null;
+ protected ?string $_buffer = null;
/**
* When someone types something into a channel, buffer it.
@@ -105,73 +85,53 @@ class IRCClient
* );.
*
* @note Used with the processChannelMessages() function.
- *
- * @var array
*/
- protected $_channelData = [];
+ protected array $_channelData = [];
/**
* Nick name when we log in.
- *
- * @var string
*/
- protected $_nickName;
+ protected string $_nickName;
/**
* User name when we log in.
- *
- * @var string
*/
- protected $_userName;
+ protected string $_userName;
/**
* "Real" name when we log in.
- *
- * @var string
*/
- protected $_realName;
+ protected string $_realName;
/**
* Password when we log in.
- *
- * @var string
*/
- protected $_password;
+ protected string $_password;
/**
* List of channels and passwords to join.
- *
- * @var array
*/
- protected $_channels;
+ protected array $_channels;
/**
* Last time we received a ping or sent a ping to the server.
- *
- * @var int
*/
- protected $_lastPing;
+ protected int $_lastPing;
/**
* How many times we've tried to reconnect to IRC.
- *
- * @var int
*/
- protected $_currentRetries = 0;
+ protected int $_currentRetries = 0;
/**
* Turns on or off debugging.
- *
- * @var bool
*/
- protected $_debug = true;
+ protected bool $_debug = true;
/**
* Are we already logged in to IRC?
- *
- * @var bool
*/
- protected $_alreadyLoggedIn = false;
+ protected bool $_alreadyLoggedIn = false;
/**
* Disconnect from IRC.
diff --git a/Blacklight/Movie.php b/Blacklight/Movie.php
index 25fdc64af..8f6052599 100755
--- a/Blacklight/Movie.php
+++ b/Blacklight/Movie.php
@@ -111,22 +111,12 @@ class Movie
protected ColorCLI $colorCli;
/**
- * @param array $options Class instances / Echo to CLI.
- *
* @throws \Exception
*/
- public function __construct(array $options = [])
+ public function __construct()
{
- $defaults = [
- 'Echo' => false,
- 'Logger' => null,
- 'ReleaseImage' => null,
- 'Settings' => null,
- 'TMDb' => null,
- ];
- $options += $defaults;
- $this->releaseImage = ($options['ReleaseImage'] instanceof ReleaseImage ? $options['ReleaseImage'] : new ReleaseImage());
+ $this->releaseImage = new ReleaseImage();
$this->colorCli = new ColorCLI();
$this->traktcheck = config('nntmux_api.trakttv_api_key');
if ($this->traktcheck !== null) {
@@ -156,7 +146,7 @@ class Movie
$this->movieqty = Settings::settingValue('..maximdbprocessed') !== '' ? (int) Settings::settingValue('..maximdbprocessed') : 100;
$this->showPasswords = (new Releases())->showPasswords();
- $this->echooutput = ($options['Echo'] && config('nntmux.echocli'));
+ $this->echooutput = config('nntmux.echocli');
$this->imgSavePath = storage_path('covers/movies/');
$this->service = '';
}
diff --git a/Blacklight/Music.php b/Blacklight/Music.php
index 8ff872644..c284e33e1 100755
--- a/Blacklight/Music.php
+++ b/Blacklight/Music.php
@@ -74,20 +74,9 @@ class Music
*/
protected $colorCli;
- /**
- * @param array $options Class instances/ echo to CLI.
- *
- * @throws \Exception
- */
- public function __construct(array $options = [])
+ public function __construct()
{
- $defaults = [
- 'Echo' => false,
- 'Settings' => null,
- ];
- $options += $defaults;
-
- $this->echooutput = ($options['Echo'] && config('nntmux.echocli'));
+ $this->echooutput = config('nntmux.echocli');
$this->colorCli = new ColorCLI();
diff --git a/Blacklight/NNTP.php b/Blacklight/NNTP.php
index 4f770ae90..698d49cd6 100755
--- a/Blacklight/NNTP.php
+++ b/Blacklight/NNTP.php
@@ -110,17 +110,11 @@ class NNTP extends \Net_NNTP_Client
*
* @throws \Exception
*/
- public function __construct(array $options = [])
+ public function __construct()
{
- $defaults = [
- 'Echo' => true,
- 'Logger' => null,
- ];
- $options += $defaults;
-
parent::__construct();
- $this->_echo = ($options['Echo'] && config('nntmux.echocli'));
+ $this->_echo = config('nntmux.echocli');
$this->_tmux = new Tmux();
$this->_nntpRetries = Settings::settingValue('..nntpretries') !== '' ? (int) Settings::settingValue('..nntpretries') : 0 + 1;
$this->colorCli = new ColorCLI();
diff --git a/Blacklight/NZBContents.php b/Blacklight/NZBContents.php
index c031131db..7c36248de 100755
--- a/Blacklight/NZBContents.php
+++ b/Blacklight/NZBContents.php
@@ -50,42 +50,14 @@ class NZBContents
*/
protected $alternateNNTP;
- /**
- * Construct.
- *
- * @param array $options
- * array(
- * 'Echo' => bool ; To echo to CLI or not.
- * 'NNTP' => NNTP ; Class NNTP.
- * 'Nfo' => Nfo ; Class Nfo.
- * 'NZB' => NZB ; Class NZB.
- * 'Settings' => DB ; Class Blacklight\db\DB.
- * 'PostProcess' => PostProcess ; Class PostProcess.
- * )
- *
- * @throws \Exception
- */
- public function __construct(array $options = [])
+ public function __construct()
{
- $defaults = [
- 'Echo' => false,
- 'NNTP' => null,
- 'Nfo' => null,
- 'NZB' => null,
- 'Settings' => null,
- 'PostProcess' => null,
- ];
- $options += $defaults;
- $this->echooutput = ($options['Echo'] && config('nntmux.echocli'));
- $this->nntp = ($options['NNTP'] instanceof NNTP ? $options['NNTP'] : new NNTP(['Echo' => $this->echooutput]));
- $this->nfo = ($options['Nfo'] instanceof Nfo ? $options['Nfo'] : new Nfo());
- $this->pp = (
- $options['PostProcess'] instanceof PostProcess
- ? $options['PostProcess']
- : new PostProcess(['Echo' => $this->echooutput, 'Nfo' => $this->nfo])
- );
- $this->nzb = ($options['NZB'] instanceof NZB ? $options['NZB'] : new NZB());
+ $this->echooutput = config('nntmux.echocli');
+ $this->nntp = new NNTP();
+ $this->nfo = new Nfo();
+ $this->pp = new PostProcess();
+ $this->nzb = new NZB();
$this->lookuppar2 = (int) Settings::settingValue('..lookuppar2') === 1;
$this->alternateNNTP = (int) Settings::settingValue('..alternate_nntp') === 1;
}
diff --git a/Blacklight/NZBExport.php b/Blacklight/NZBExport.php
index 59206ac43..910796360 100755
--- a/Blacklight/NZBExport.php
+++ b/Blacklight/NZBExport.php
@@ -28,21 +28,11 @@ class NZBExport
*
* @throws \Exception
*/
- public function __construct(array $options = [])
+ public function __construct()
{
- $defaults = [
- 'Browser' => false, // Started from browser?
- 'Echo' => true, // Echo to CLI?
- 'NZB' => null,
- 'Releases' => null,
- 'Settings' => null,
- ];
- $options += $defaults;
-
- $this->browser = $options['Browser'];
- $this->echoCLI = (! $this->browser && config('nntmux.echocli') && $options['Echo']);
- $this->releases = ($options['Releases'] instanceof Releases ? $options['Releases'] : new Releases());
- $this->nzb = ($options['NZB'] instanceof NZB ? $options['NZB'] : new NZB());
+ $this->echoCLI = config('nntmux.echocli');
+ $this->releases = new Releases();
+ $this->nzb = new NZB();
}
/**
@@ -195,7 +185,7 @@ class NZBExport
*/
protected function returnValue(): bool
{
- return $this->browser ? $this->retVal : true;
+ return true;
}
protected function checkDate($date): bool
@@ -211,9 +201,7 @@ class NZBExport
protected function echoOut($message): void
{
- if ($this->browser) {
- $this->retVal .= $message.'
';
- } elseif ($this->echoCLI) {
+ if ($this->echoCLI) {
echo $message.PHP_EOL;
}
}
diff --git a/Blacklight/NZBImport.php b/Blacklight/NZBImport.php
index bd6f02a2f..69c9af184 100755
--- a/Blacklight/NZBImport.php
+++ b/Blacklight/NZBImport.php
@@ -87,36 +87,15 @@ class NZBImport
*/
protected $colorCli;
- /**
- * Construct.
- *
- * @param array $options Class instances / various options.
- *
- * @throws \Exception
- */
- public function __construct(array $options = [])
+ public function __construct()
{
- $defaults = [
- 'Browser' => false, // Was this started from the browser?
- 'Echo' => true, // Echo to CLI?
- 'Binaries' => null,
- 'Categorize' => null,
- 'NZB' => null,
- 'ReleaseCleaning' => null,
- 'Releases' => null,
- 'Settings' => null,
- ];
- $options += $defaults;
-
- $this->echoCLI = (! $this->browser && config('nntmux.echocli') && $options['Echo']);
- $this->binaries = ($options['Binaries'] instanceof Binaries ? $options['Binaries'] : new Binaries(['Echo' => $this->echoCLI]));
- $this->category = ($options['Categorize'] instanceof Categorize ? $options['Categorize'] : new Categorize());
- $this->nzb = ($options['NZB'] instanceof NZB ? $options['NZB'] : new NZB());
- $this->releaseCleaner = ($options['ReleaseCleaning'] instanceof ReleaseCleaning ? $options['ReleaseCleaning'] : new ReleaseCleaning());
+ $this->echoCLI = config('nntmux.echocli');
+ $this->binaries = new Binaries();
+ $this->category = new Categorize();
+ $this->nzb = new NZB();
+ $this->releaseCleaner = new ReleaseCleaning();
$this->colorCli = new ColorCLI();
-
$this->crossPostt = Settings::settingValue('..crossposttime') !== '' ? Settings::settingValue('..crossposttime') : 2;
- $this->browser = $options['Browser'];
$this->retVal = '';
}
diff --git a/Blacklight/NameFixer.php b/Blacklight/NameFixer.php
index 46bc8f83b..31546c6c4 100755
--- a/Blacklight/NameFixer.php
+++ b/Blacklight/NameFixer.php
@@ -103,9 +103,9 @@ class NameFixer
protected string $fullall;
/**
- * @var \Blacklight\ConsoleTools
+ * @var \Blacklight\ColorCLI
*/
- public mixed $consoletools;
+ public ColorCLI $colorCLI;
/**
* @var \Blacklight\Categorize
@@ -126,25 +126,9 @@ class NameFixer
private ElasticSearchSiteSearch $elasticsearch;
- /**
- * @param array $options Class instances / Echo to cli.
- *
- * @throws \Exception
- */
- public function __construct(array $options = [])
+ public function __construct()
{
- $defaults = [
- 'Echo' => true,
- 'Categorize' => null,
- 'ConsoleTools' => null,
- 'Groups' => null,
- 'Misc' => null,
- 'Settings' => null,
- 'ManticoreSearch' => null,
- ];
- $options += $defaults;
-
- $this->echoOutput = ($options['Echo'] && config('nntmux.echocli'));
+ $this->echoOutput = config('nntmux.echocli');
$this->relid = $this->fixed = $this->checked = 0;
$this->othercats = implode(',', Category::OTHERS_GROUP);
$this->timeother = sprintf(' AND rel.adddate > (NOW() - INTERVAL 6 HOUR) AND rel.categories_id IN (%s) GROUP BY rel.id ORDER BY postdate DESC', $this->othercats);
@@ -153,9 +137,9 @@ class NameFixer
$this->fullall = '';
$this->_fileName = '';
$this->done = $this->matched = false;
- $this->consoletools = ($options['ConsoleTools'] instanceof ConsoleTools ? $options['ConsoleTools'] : new ConsoleTools());
- $this->category = ($options['Categorize'] instanceof Categorize ? $options['Categorize'] : new Categorize(['Settings' => null]));
- $this->manticore = ($options['ManticoreSearch'] instanceof ManticoreSearch ? $options['ManticoreSearch'] : new ManticoreSearch());
+ $this->colorCLI = new ColorCLI();
+ $this->category = new Categorize();
+ $this->manticore = new ManticoreSearch();
$this->elasticsearch = new ElasticSearchSiteSearch();
}
@@ -207,7 +191,7 @@ class NameFixer
if ($total > 0) {
$this->_totalReleases = $total;
- $this->consoletools->primary(number_format($total).' releases to process.');
+ $this->colorCLI->primary(number_format($total).' releases to process.');
foreach ($releases as $rel) {
$releaseRow = Release::fromQuery(
@@ -237,7 +221,7 @@ class NameFixer
}
$this->_echoFoundCount($echo, ' NFO\'s');
} else {
- $this->consoletools->info('Nothing to fix.');
+ $this->colorCLI->info('Nothing to fix.');
}
}
@@ -288,7 +272,7 @@ class NameFixer
$total = $releases->count();
if ($total > 0) {
$this->_totalReleases = $total;
- $this->consoletools->primary(number_format($total).' file names to process.');
+ $this->colorCLI->primary(number_format($total).' file names to process.');
foreach ($releases as $release) {
$this->reset();
@@ -299,7 +283,7 @@ class NameFixer
$this->_echoFoundCount($echo, ' files');
} else {
- $this->consoletools->info('Nothing to fix.');
+ $this->colorCLI->info('Nothing to fix.');
}
}
@@ -350,7 +334,7 @@ class NameFixer
$total = $releases->count();
if ($total > 0) {
$this->_totalReleases = $total;
- $this->consoletools->primary(number_format($total).' CRC32\'s to process.');
+ $this->colorCLI->primary(number_format($total).' CRC32\'s to process.');
foreach ($releases as $release) {
$this->reset();
@@ -361,7 +345,7 @@ class NameFixer
$this->_echoFoundCount($echo, ' crc32\'s');
} else {
- $this->consoletools->info('Nothing to fix.');
+ $this->colorCLI->info('Nothing to fix.');
}
}
@@ -410,7 +394,7 @@ class NameFixer
$total = $releases->count();
if ($total > 0) {
$this->_totalReleases = $total;
- $this->consoletools->primary(number_format($total).' xxx file names to process.');
+ $this->colorCLI->primary(number_format($total).' xxx file names to process.');
foreach ($releases as $release) {
$this->reset();
@@ -420,7 +404,7 @@ class NameFixer
}
$this->_echoFoundCount($echo, ' files');
} else {
- $this->consoletools->info('Nothing to fix.');
+ $this->colorCLI->info('Nothing to fix.');
}
}
@@ -471,7 +455,7 @@ class NameFixer
$total = $releases->count();
if ($total > 0) {
$this->_totalReleases = $total;
- $this->consoletools->primary(number_format($total).' srr file extensions to process.');
+ $this->colorCLI->primary(number_format($total).' srr file extensions to process.');
foreach ($releases as $release) {
$this->reset();
@@ -481,7 +465,7 @@ class NameFixer
}
$this->_echoFoundCount($echo, ' files');
} else {
- $this->consoletools->info('Nothing to fix.');
+ $this->colorCLI->info('Nothing to fix.');
}
}
@@ -530,7 +514,7 @@ class NameFixer
if ($total > 0) {
$this->_totalReleases = $total;
- $this->consoletools->primary(number_format($total).' releases to process.');
+ $this->colorCLI->primary(number_format($total).' releases to process.');
$Nfo = new Nfo();
$nzbContents = new NZBContents(
[
@@ -551,7 +535,7 @@ class NameFixer
}
$this->_echoFoundCount($echo, ' files');
} else {
- $this->consoletools->info('Nothing to fix.');
+ $this->colorCLI->info('Nothing to fix.');
}
}
@@ -611,7 +595,7 @@ class NameFixer
$total = $releases->count();
if ($total > 0) {
$this->_totalReleases = $total;
- $this->consoletools->primary(number_format($total).' unique ids to process.');
+ $this->colorCLI->primary(number_format($total).' unique ids to process.');
foreach ($releases as $rel) {
$this->checked++;
$this->reset();
@@ -620,7 +604,7 @@ class NameFixer
}
$this->_echoFoundCount($echo, ' UID\'s');
} else {
- $this->consoletools->info('Nothing to fix.');
+ $this->colorCLI->info('Nothing to fix.');
}
}
@@ -671,7 +655,7 @@ class NameFixer
$total = $releases->count();
if ($total > 0) {
$this->_totalReleases = $total;
- $this->consoletools->primary(number_format($total).' mediainfo movie names to process.');
+ $this->colorCLI->primary(number_format($total).' mediainfo movie names to process.');
foreach ($releases as $rel) {
$this->checked++;
$this->reset();
@@ -680,7 +664,7 @@ class NameFixer
}
$this->_echoFoundCount($echo, ' MediaInfo\'s');
} else {
- $this->consoletools->info('Nothing to fix.');
+ $this->colorCLI->info('Nothing to fix.');
}
}
@@ -741,7 +725,7 @@ class NameFixer
$total = $releases->count();
if ($total > 0) {
$this->_totalReleases = $total;
- $this->consoletools->primary(number_format($total).' hash_16K to process.');
+ $this->colorCLI->primary(number_format($total).' hash_16K to process.');
foreach ($releases as $rel) {
$this->checked++;
$this->reset();
@@ -750,7 +734,7 @@ class NameFixer
}
$this->_echoFoundCount($echo, ' hashes');
} else {
- $this->consoletools->info('Nothing to fix.');
+ $this->colorCLI->info('Nothing to fix.');
}
}
@@ -787,7 +771,7 @@ class NameFixer
protected function _echoFoundCount(bool|int $echo, string $type): void
{
if ($echo === true) {
- $this->consoletools->header(
+ $this->colorCLI->header(
PHP_EOL.
number_format($this->fixed).
' releases have had their names changed out of: '.
@@ -795,7 +779,7 @@ class NameFixer
$type.'.'
);
} else {
- $this->consoletools->header(
+ $this->colorCLI->header(
PHP_EOL.
number_format($this->fixed).
' releases could have their names changed. '.
@@ -811,7 +795,7 @@ class NameFixer
*/
protected function _echoStartMessage(int $time, string $type): void
{
- $this->consoletools->header(
+ $this->colorCLI->header(
sprintf(
'Fixing search names %s using %s.',
($time === 1 ? 'in the past 6 hours' : 'since the beginning'),
@@ -823,15 +807,15 @@ class NameFixer
protected function _echoRenamed(int $show): void
{
if ($this->checked % 500 === 0 && $show === 1) {
- $this->consoletools->alternate(PHP_EOL.number_format($this->checked).' files processed.'.PHP_EOL);
+ $this->colorCLI->alternate(PHP_EOL.number_format($this->checked).' files processed.'.PHP_EOL);
}
if ($show === 2) {
- $this->consoletools->overWritePrimary(
+ $this->colorCLI->overWritePrimary(
'Renamed Releases: ['.
number_format($this->fixed).
'] '.
- $this->consoletools->percentString($this->checked, $this->_totalReleases)
+ $this->colorCLI->percentString($this->checked, $this->_totalReleases)
);
}
}
@@ -879,25 +863,25 @@ class NameFixer
echo PHP_EOL;
- $this->consoletools->headerOver('New name: ').
- $this->consoletools->primary(substr($newName, 0, 299)).
- $this->consoletools->headerOver('Old name: ').
- $this->consoletools->primary($release->searchname).
- $this->consoletools->headerOver('Use name: ').
- $this->consoletools->primary($release->name).
- $this->consoletools->headerOver('New cat: ').
- $this->consoletools->primary($newCatName).
- $this->consoletools->headerOver('Old cat: ').
- $this->consoletools->primary($oldCatName).
- $this->consoletools->headerOver('Group: ').
- $this->consoletools->primary($groupName).
- $this->consoletools->headerOver('Method: ').
- $this->consoletools->primary($type.$method).
- $this->consoletools->headerOver('Releases ID: ').
- $this->consoletools->primary($release->releases_id);
+ $this->colorCLI->headerOver('New name: ').
+ $this->colorCLI->primary(substr($newName, 0, 299)).
+ $this->colorCLI->headerOver('Old name: ').
+ $this->colorCLI->primary($release->searchname).
+ $this->colorCLI->headerOver('Use name: ').
+ $this->colorCLI->primary($release->name).
+ $this->colorCLI->headerOver('New cat: ').
+ $this->colorCLI->primary($newCatName).
+ $this->colorCLI->headerOver('Old cat: ').
+ $this->colorCLI->primary($oldCatName).
+ $this->colorCLI->headerOver('Group: ').
+ $this->colorCLI->primary($groupName).
+ $this->colorCLI->headerOver('Method: ').
+ $this->colorCLI->primary($type.$method).
+ $this->colorCLI->headerOver('Releases ID: ').
+ $this->colorCLI->primary($release->releases_id);
if (! empty($release->filename)) {
- $this->consoletools->headerOver('Filename: ').
- $this->consoletools->primary($release->filename);
+ $this->colorCLI->headerOver('Filename: ').
+ $this->colorCLI->primary($release->filename);
}
if ($type !== 'PAR2, ') {
@@ -1129,8 +1113,8 @@ class NameFixer
$limit = 'LIMIT 1000000';
}
- $this->consoletools->header(PHP_EOL.'Match PreFiles '.$args[1].' Started at '.now());
- $this->consoletools->primary('Matching predb filename to cleaned release_files.name.');
+ $this->colorCLI->header(PHP_EOL.'Match PreFiles '.$args[1].' Started at '.now());
+ $this->colorCLI->primary('Matching predb filename to cleaned release_files.name.');
$counter = $counted = 0;
$timeStart = now();
@@ -1159,7 +1143,7 @@ class NameFixer
$total = $query->count();
if ($total > 0) {
- $this->consoletools->header(PHP_EOL.number_format($total).' releases to process.');
+ $this->colorCLI->header(PHP_EOL.number_format($total).' releases to process.');
foreach ($query as $row) {
$success = $this->matchPreDbFiles($row, true, 1, $show);
@@ -1167,12 +1151,12 @@ class NameFixer
$counted++;
}
if ($show === 0) {
- $this->consoletools->overWritePrimary('Renamed Releases: ['.number_format($counted).'] '.$this->consoletools->percentString(++$counter, $total));
+ $this->colorCLI->overWritePrimary('Renamed Releases: ['.number_format($counted).'] '.$this->colorCLI->percentString(++$counter, $total));
}
}
- $this->consoletools->header(PHP_EOL.'Renamed '.number_format($counted).' releases in '.now()->diffInSeconds($timeStart).' seconds'.'.');
+ $this->colorCLI->header(PHP_EOL.'Renamed '.number_format($counted).' releases in '.now()->diffInSeconds($timeStart).' seconds'.'.');
} else {
- $this->consoletools->info('Nothing to do.');
+ $this->colorCLI->info('Nothing to do.');
}
}
}
@@ -1313,7 +1297,7 @@ class NameFixer
if ($time === 1) {
$te = ' in the past 3 hours';
}
- $this->consoletools->header('Fixing search names'.$te.' using the predb hash.');
+ $this->colorCLI->header('Fixing search names'.$te.' using the predb hash.');
}
$regex = 'AND (r.ishashed = 1 OR rf.ishashed = 1)';
@@ -1331,7 +1315,7 @@ class NameFixer
$res = Release::fromQuery($query);
$total = $res->count();
- $this->consoletools->primary(number_format($total).' releases to process.');
+ $this->colorCLI->primary(number_format($total).' releases to process.');
foreach ($res as $row) {
if (preg_match('/[a-fA-F0-9]{32,40}/i', $row->name, $hits)) {
$updated += $this->matchPredbHash($hits[0], $row, $echo, $nameStatus, $show);
@@ -1339,13 +1323,13 @@ class NameFixer
$updated += $this->matchPredbHash($hits[0], $row, $echo, $nameStatus, $show);
}
if ($show === 2) {
- $this->consoletools->overWritePrimary('Renamed Releases: ['.number_format($updated).'] '.$this->consoletools->percentString($checked++, $total));
+ $this->colorCLI->overWritePrimary('Renamed Releases: ['.number_format($updated).'] '.$this->colorCLI->percentString($checked++, $total));
}
}
if ($echo === 1) {
- $this->consoletools->header(PHP_EOL.$updated.' releases have had their names changed out of: '.number_format($checked).' files.');
+ $this->colorCLI->header(PHP_EOL.$updated.' releases have had their names changed out of: '.number_format($checked).' files.');
} else {
- $this->consoletools->header(PHP_EOL.$updated.' releases could have their names changed. '.number_format($checked).' files were checked.');
+ $this->colorCLI->header(PHP_EOL.$updated.' releases could have their names changed. '.number_format($checked).' files were checked.');
}
return $updated;
diff --git a/Blacklight/Nfo.php b/Blacklight/Nfo.php
index 4034943e0..ec144cce9 100755
--- a/Blacklight/Nfo.php
+++ b/Blacklight/Nfo.php
@@ -59,7 +59,7 @@ class Nfo
/**
* @var \Blacklight\ColorCLI
*/
- protected $colorCli;
+ protected ColorCLI $colorCli;
/**
* Default constructor.
diff --git a/Blacklight/ReleaseRemover.php b/Blacklight/ReleaseRemover.php
index 509fd806c..241a3a274 100755
--- a/Blacklight/ReleaseRemover.php
+++ b/Blacklight/ReleaseRemover.php
@@ -13,126 +13,71 @@ use Illuminate\Support\Facades\DB;
*/
class ReleaseRemover
{
- /**
- * @var string
- */
- protected $blacklistID;
+ protected string $blacklistID;
- /**
- * Is is run from the browser?
- *
- * @var bool
- */
- protected $browser;
+ protected ColorCLI $colorCLI;
- /**
- * @var \Blacklight\ConsoleTools
- */
- protected $consoleTools;
+ protected string $crapTime = '';
- /**
- * @var string
- */
- protected $crapTime = '';
+ protected bool $delete;
- /**
- * @var bool
- */
- protected $delete;
+ protected int $deletedCount = 0;
- /**
- * @var int
- */
- protected $deletedCount = 0;
-
- /**
- * @var bool
- */
- protected $echoCLI;
+ protected bool $echoCLI;
/**
* If an error occurred, store it here.
- *
- * @var string
*/
- protected $error;
+ protected string $error;
/**
* Ignore user check?
- *
- * @var bool
*/
- protected $ignoreUserCheck;
+ protected bool $ignoreUserCheck;
- /**
- * @var string
- */
- protected $method = '';
+ protected string $method = '';
/**
* The query we will use to select unwanted releases.
- *
- * @var string
*/
- protected $query;
+ protected string $query;
/**
* @var \Blacklight\Releases
*/
- protected $releases;
+ protected Releases $releases;
/**
* Result of the select query.
- *
- * @var array
*/
- protected $result;
+ protected array $result;
/**
* @var \Blacklight\NZB
*/
- private $nzb;
+ private NZB $nzb;
/**
* @var \Blacklight\ReleaseImage
*/
- private $releaseImage;
+ private ReleaseImage $releaseImage;
/**
* @var \Blacklight\ColorCLI
*/
- protected $colorCli;
+ protected ColorCLI $colorCli;
- /**
- * Construct.
- *
- * @param array $options Class instances / various options.
- *
- * @throws \Exception
- */
- public function __construct(array $options = [])
+ public function __construct()
{
- $defaults = [
- 'Browser' => false, // Are we coming from the web script.
- 'ConsoleTools' => null,
- 'Echo' => true, // Echo to CLI?
- 'NZB' => null,
- 'ReleaseImage' => null,
- 'Releases' => null,
- 'Settings' => null,
- ];
- $options += $defaults;
-
- $this->consoleTools = ($options['ConsoleTools'] instanceof ConsoleTools ? $options['ConsoleTools'] : new ConsoleTools());
- $this->releases = ($options['Releases'] instanceof Releases ? $options['Releases'] : new Releases());
- $this->nzb = ($options['NZB'] instanceof NZB ? $options['NZB'] : new NZB());
- $this->releaseImage = ($options['ReleaseImage'] instanceof ReleaseImage ? $options['ReleaseImage'] : new ReleaseImage());
+ $this->colorCLI = new ColorCLI();
+ $this->releases = new Releases();
+ $this->nzb = new NZB();
+ $this->releaseImage = new ReleaseImage();
$this->query = '';
$this->error = '';
$this->ignoreUserCheck = false;
- $this->browser = $options['Browser'];
- $this->echoCLI = (! $this->browser && config('nntmux.echocli') && $options['Echo']);
+ $this->echoCLI = config('nntmux.echocli');
}
/**
@@ -185,19 +130,11 @@ class ReleaseRemover
$this->deleteReleases();
if ($this->echoCLI) {
- $this->consoleTools->headerOver(($this->delete ? 'Deleted ' : 'Would have deleted ').$this->deletedCount.' release(s). This script ran for ');
- $this->consoleTools->header(now()->diffInSeconds($timeStart).' seconds', true);
+ $this->colorCLI->headerOver(($this->delete ? 'Deleted ' : 'Would have deleted ').$this->deletedCount.' release(s). This script ran for ');
+ $this->colorCLI->header(now()->diffInSeconds($timeStart).' seconds', true);
}
- return $this->browser
- ?
- 'Success! '.
- ($this->delete ? 'Deleted ' : 'Would have deleted ').
- $this->deletedCount.
- ' release(s) in '.
- now()->diffInSeconds($timeStart).' seconds'
- :
- true;
+ return true;
}
/**
@@ -228,7 +165,7 @@ class ReleaseRemover
if ($time === 'full') {
if ($this->echoCLI) {
- $this->consoleTools->header('Removing '.($type === '' ? 'All crap releases ' : $type.' crap releases').' - no time limit.', true);
+ $this->colorCLI->header('Removing '.($type === '' ? 'All crap releases ' : $type.' crap releases').' - no time limit.', true);
}
} else {
if (! is_numeric($time)) {
@@ -237,7 +174,7 @@ class ReleaseRemover
return $this->returnError();
}
if ($this->echoCLI) {
- $this->consoleTools->header('Removing '.($type === '' ? 'All crap releases ' : $type.' crap releases').' from the past '.$time.' hour(s).', true);
+ $this->colorCLI->header('Removing '.($type === '' ? 'All crap releases ' : $type.' crap releases').' from the past '.$time.' hour(s).', true);
}
$this->crapTime = ' AND r.adddate > (NOW() - INTERVAL '.$time.' HOUR)';
}
@@ -315,19 +252,11 @@ class ReleaseRemover
}
if ($this->echoCLI) {
- $this->consoleTools->headerOver(($this->delete ? 'Deleted ' : 'Would have deleted ').$this->deletedCount.' release(s). This script ran for ');
- $this->consoleTools->header(now()->diffInSeconds($timeStart).' seconds', true);
+ $this->colorCLI->headerOver(($this->delete ? 'Deleted ' : 'Would have deleted ').$this->deletedCount.' release(s). This script ran for ');
+ $this->colorCLI->header(now()->diffInSeconds($timeStart).' seconds', true);
}
- return $this->browser
- ?
- 'Success! '.
- ($this->delete ? 'Deleted ' : 'Would have deleted ').
- $this->deletedCount.
- ' release(s) in '.
- now()->diffInSeconds($timeStart).' seconds'
- :
- true;
+ return true;
}
/**
@@ -810,7 +739,7 @@ class ReleaseRemover
}
// Provide useful output of operations
- $this->consoleTools->header(
+ $this->colorCLI->header(
sprintf(
'Finding crap releases for %s: Using %s method against release %s.'.
'%s',
@@ -844,7 +773,7 @@ class ReleaseRemover
$this->deleteReleases();
}
} else {
- $this->consoleTools->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);
+ $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);
}
return true;
@@ -914,7 +843,7 @@ class ReleaseRemover
$ftUsing = PHP_EOL;
// Provide useful output of operations
- $this->consoleTools->header(
+ $this->colorCLI->header(
sprintf(
'Finding crap releases for %s: Using %s method against release filenames.'.PHP_EOL.
'%s',
@@ -1047,10 +976,10 @@ class ReleaseRemover
if ($this->delete) {
$this->releases->deleteSingle(['g' => $release->guid, 'i' => $release->id], $this->nzb, $this->releaseImage);
if ($this->echoCLI) {
- $this->consoleTools->primary('Deleting: '.$this->method.': '.$release->searchname, true);
+ $this->colorCLI->primary('Deleting: '.$this->method.': '.$release->searchname, true);
}
} elseif ($this->echoCLI) {
- $this->consoleTools->primary('Would be deleting: '.$this->method.': '.$release->searchname, true);
+ $this->colorCLI->primary('Would be deleting: '.$this->method.': '.$release->searchname, true);
}
$deletedCount++;
}
@@ -1259,12 +1188,12 @@ class ReleaseRemover
*/
protected function checkUserResponse(): bool
{
- if ($this->ignoreUserCheck || $this->browser) {
+ if ($this->ignoreUserCheck) {
return true;
}
// Print the query to the user, ask them if they want to continue using it.
- $this->consoleTools->primary(
+ $this->colorCLI->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.',
@@ -1274,7 +1203,7 @@ class ReleaseRemover
// Check the users response.
$userInput = trim(fgets(fopen('php://stdin', 'rtb')));
if ($userInput !== 'yes') {
- $this->consoleTools->primary('You typed: "'.$userInput.'", the program will exit.', true);
+ $this->colorCLI->primary('You typed: "'.$userInput.'", the program will exit.', true);
return false;
}
@@ -1314,19 +1243,15 @@ class ReleaseRemover
*/
protected function returnError()
{
- if ($this->browser) {
- return $this->error.'
';
- }
-
if ($this->echoCLI && $this->error !== '') {
- $this->consoleTools->error($this->error, true);
+ $this->colorCLI->error($this->error, true);
}
return false;
}
/**
- * @return bool|mixed|string
+ * @return array|string|string[]
*/
protected function extractSrchFromRegx(string $dbRegex = '')
{
diff --git a/Blacklight/Steam.php b/Blacklight/Steam.php
index 1772ffcd6..62341b517 100755
--- a/Blacklight/Steam.php
+++ b/Blacklight/Steam.php
@@ -37,11 +37,8 @@ class Steam
*
* @throws \Exception
*/
- public function __construct(array $options = [])
+ public function __construct()
{
- $defaults = ['DB' => null];
- $options += $defaults;
-
$this->steamFront = new Main(
[
'country_code' => 'us',
diff --git a/Blacklight/XXX.php b/Blacklight/XXX.php
index 6a4c97f85..065f869f9 100755
--- a/Blacklight/XXX.php
+++ b/Blacklight/XXX.php
@@ -50,25 +50,14 @@ class XXX
*/
protected ColorCLI $colorCli;
- /**
- * @param array $options Echo to cli / Class instances.
- *
- * @throws \Exception
- */
- public function __construct(array $options = [])
+ public function __construct()
{
- $defaults = [
- 'Echo' => false,
- 'ReleaseImage' => null,
- 'Settings' => null,
- ];
- $options += $defaults;
- $this->releaseImage = ($options['ReleaseImage'] instanceof ReleaseImage ? $options['ReleaseImage'] : new ReleaseImage());
+ $this->releaseImage = new ReleaseImage();
$this->colorCli = new ColorCLI();
$this->movieQty = Settings::settingValue('..maxxxxprocessed') !== '' ? (int) Settings::settingValue('..maxxxxprocessed') : 100;
$this->showPasswords = (new Releases())->showPasswords();
- $this->echoOutput = ($options['Echo'] && config('nntmux.echocli'));
+ $this->echoOutput = config('nntmux.echocli');
$this->imgSavePath = storage_path('covers/xxx/');
$this->cookie = resource_path('tmp/xxx.cookie');
}
diff --git a/Blacklight/processing/PostProcess.php b/Blacklight/processing/PostProcess.php
index fe837dad6..77d008a84 100755
--- a/Blacklight/processing/PostProcess.php
+++ b/Blacklight/processing/PostProcess.php
@@ -48,33 +48,15 @@ class PostProcess
private Nfo $Nfo;
- /**
- * Constructor.
- *
- * @param array $options Pass in class instances.
- *
- * @throws \Exception
- */
- public function __construct(array $options = [])
+ public function __construct()
{
- $defaults = [
- 'Echo' => true,
- 'Logger' => null,
- 'Groups' => null,
- 'NameFixer' => null,
- 'Nfo' => null,
- 'ReleaseFiles' => null,
- 'Settings' => null,
- ];
- $options += $defaults;
-
// Various.
- $this->echooutput = ($options['Echo'] && config('nntmux.echocli'));
+ $this->echooutput = config('nntmux.echocli');
// Class instances.
$this->_par2Info = new Par2Info();
- $this->nameFixer = (($options['NameFixer'] instanceof NameFixer) ? $options['NameFixer'] : new NameFixer(['Echo' => $this->echooutput, 'Groups' => null]));
- $this->Nfo = (($options['Nfo'] instanceof Nfo) ? $options['Nfo'] : new Nfo());
+ $this->nameFixer = new NameFixer();
+ $this->Nfo = new Nfo();
// Site settings.
$this->addpar2 = (int) Settings::settingValue('..addpar2') !== 0;
diff --git a/Blacklight/processing/ProcessReleases.php b/Blacklight/processing/ProcessReleases.php
index 493eaf076..ddf23b131 100755
--- a/Blacklight/processing/ProcessReleases.php
+++ b/Blacklight/processing/ProcessReleases.php
@@ -12,7 +12,7 @@ use App\Models\ReleasesGroups;
use App\Models\Settings;
use App\Models\UsenetGroup;
use Blacklight\Categorize;
-use Blacklight\ConsoleTools;
+use Blacklight\ColorCLI;
use Blacklight\Genres;
use Blacklight\NNTP;
use Blacklight\NZB;
@@ -58,7 +58,7 @@ class ProcessReleases
public \PDO $pdo;
- public ConsoleTools $consoleTools;
+ public ColorCLI $colorCLI;
public NZB $nzb;
@@ -73,32 +73,15 @@ class ProcessReleases
*/
private int $collectionTimeout;
- /**
- * @param array $options Class instances / Echo to cli ?
- *
- * @throws \Exception
- */
- public function __construct(array $options = [])
+ public function __construct()
{
- $defaults = [
- 'Echo' => true,
- 'ConsoleTools' => null,
- 'Groups' => null,
- 'NZB' => null,
- 'ReleaseCleaning' => null,
- 'ReleaseImage' => null,
- 'Releases' => null,
- 'Settings' => null,
- ];
- $options += $defaults;
+ $this->echoCLI = config('nntmux.echocli');
- $this->echoCLI = ($options['Echo'] && config('nntmux.echocli'));
-
- $this->consoleTools = ($options['ConsoleTools'] instanceof ConsoleTools ? $options['ConsoleTools'] : new ConsoleTools());
- $this->nzb = ($options['NZB'] instanceof NZB ? $options['NZB'] : new NZB());
- $this->releaseCleaning = ($options['ReleaseCleaning'] instanceof ReleaseCleaning ? $options['ReleaseCleaning'] : new ReleaseCleaning());
- $this->releases = ($options['Releases'] instanceof Releases ? $options['Releases'] : new Releases());
- $this->releaseImage = ($options['ReleaseImage'] instanceof ReleaseImage ? $options['ReleaseImage'] : new ReleaseImage());
+ $this->colorCLI = new ColorCLI();
+ $this->nzb = new NZB();
+ $this->releaseCleaning = new ReleaseCleaning();
+ $this->releases = new Releases();
+ $this->releaseImage = new ReleaseImage();
$dummy = Settings::settingValue('..delaytime');
$this->collectionDelayTime = ($dummy !== '' ? (int) $dummy : 2);
@@ -110,7 +93,7 @@ class ProcessReleases
$this->completion = ($dummy !== '' ? (int) $dummy : 0);
if ($this->completion > 100) {
$this->completion = 100;
- $this->consoleTools->error(PHP_EOL.'You have an invalid setting for completion. It cannot be higher than 100.');
+ $this->colorCLI->error(PHP_EOL.'You have an invalid setting for completion. It cannot be higher than 100.');
}
$this->collectionTimeout = (int) Settings::settingValue('indexer.processing.collection_timeout');
}
@@ -122,12 +105,12 @@ class ProcessReleases
*
* @throws \Throwable
*/
- public function processReleases(int $categorize, int $postProcess, string $groupName, NNTP $nntp, bool $echooutput): int
+ public function processReleases(int $categorize, int $postProcess, string $groupName, NNTP $nntp): int
{
- $this->echoCLI = ($echooutput && config('nntmux.echocli'));
+ $this->echoCLI = config('nntmux.echocli');
$groupID = '';
- if (! empty($groupName) && $groupName !== 'mgr') {
+ if (! empty($groupName)) {
$groupInfo = UsenetGroup::getByName($groupName);
if ($groupInfo !== null) {
$groupID = $groupInfo['id'];
@@ -135,12 +118,12 @@ class ProcessReleases
}
if ($this->echoCLI) {
- $this->consoleTools->header('Starting release update process ('.now()->format('Y-m-d H:i:s').')');
+ $this->colorCLI->header('Starting release update process ('.now()->format('Y-m-d H:i:s').')');
}
if (! file_exists(Settings::settingValue('..nzbpath'))) {
if ($this->echoCLI) {
- $this->consoleTools->error('Bad or missing nzb directory - '.Settings::settingValue('..nzbpath'));
+ $this->colorCLI->error('Bad or missing nzb directory - '.Settings::settingValue('..nzbpath'));
}
return 0;
@@ -210,8 +193,8 @@ class ProcessReleases
Release::query()->where('id', $release->id)->update(['categories_id' => $catId['categories_id'], 'iscategorized' => 1]);
$categorized++;
if ($this->echoCLI) {
- $this->consoleTools->overWritePrimary(
- 'Categorizing: '.$this->consoleTools->percentString($categorized, $total)
+ $this->colorCLI->overWritePrimary(
+ 'Categorizing: '.$this->colorCLI->percentString($categorized, $total)
);
}
}
@@ -232,7 +215,7 @@ class ProcessReleases
$startTime = now()->toImmutable();
if ($this->echoCLI) {
- $this->consoleTools->header('Process Releases -> Attempting to find complete collections.');
+ $this->colorCLI->header('Process Releases -> Attempting to find complete collections.');
}
$where = (! empty($groupID) ? ' AND c.groups_id = '.$groupID.' ' : ' ');
@@ -255,7 +238,7 @@ class ProcessReleases
$totalTime = now()->diffInSeconds($startTime);
- $this->consoleTools->primary(
+ $this->colorCLI->primary(
($count ?? 0).' collections were found to be complete. Time: '.
$totalTime.Str::plural(' second', $totalTime),
true
@@ -272,7 +255,7 @@ class ProcessReleases
$startTime = now()->toImmutable();
if ($this->echoCLI) {
- $this->consoleTools->header('Process Releases -> Calculating collection sizes (in bytes).');
+ $this->colorCLI->header('Process Releases -> Calculating collection sizes (in bytes).');
}
// Get the total size in bytes of the collection for collections where filecheck = 2.
DB::transaction(function () use ($groupID, $startTime) {
@@ -295,12 +278,12 @@ class ProcessReleases
)
);
if ($checked > 0 && $this->echoCLI) {
- $this->consoleTools->primary(
+ $this->colorCLI->primary(
$checked.' collections set to filecheck = 3(size calculated)',
true
);
$totalTime = now()->diffInSeconds($startTime);
- $this->consoleTools->primary($totalTime.Str::plural(' second', $totalTime), true);
+ $this->colorCLI->primary($totalTime.Str::plural(' second', $totalTime), true);
}
}, 10);
}
@@ -314,7 +297,7 @@ class ProcessReleases
$startTime = now()->toImmutable();
if ($this->echoCLI) {
- $this->consoleTools->header('Process Releases -> Delete collections smaller/larger than minimum size/file count from group/site setting.');
+ $this->colorCLI->header('Process Releases -> Delete collections smaller/larger than minimum size/file count from group/site setting.');
}
$groupID === '' ? $groupIDs = UsenetGroup::getActiveIDs() : $groupIDs = [['id' => $groupID]];
@@ -386,7 +369,7 @@ class ProcessReleases
$totalTime = now()->diffInSeconds($startTime);
if ($this->echoCLI) {
- $this->consoleTools->primary('Deleted '.($minSizeDeleted + $maxSizeDeleted + $minFilesDeleted).' collections: '.PHP_EOL.$minSizeDeleted.' smaller than, '.$maxSizeDeleted.' bigger than, '.$minFilesDeleted.' with less files than site/group settings in: '.$totalTime.Str::plural(' second', $totalTime), true);
+ $this->colorCLI->primary('Deleted '.($minSizeDeleted + $maxSizeDeleted + $minFilesDeleted).' collections: '.PHP_EOL.$minSizeDeleted.' smaller than, '.$maxSizeDeleted.' bigger than, '.$minFilesDeleted.' with less files than site/group settings in: '.$totalTime.Str::plural(' second', $totalTime), true);
}
}, 10);
}
@@ -407,7 +390,7 @@ class ProcessReleases
$returnCount = $duplicate = 0;
if ($this->echoCLI) {
- $this->consoleTools->header('Process Releases -> Create releases from complete collections.');
+ $this->colorCLI->header('Process Releases -> Create releases from complete collections.');
}
$collectionsQuery = Collection::query()
->where('collections.filecheck', self::COLLFC_SIZED)
@@ -420,7 +403,7 @@ class ProcessReleases
->limit($this->releaseCreationLimit);
$collections = $collectionsQuery->get();
if ($this->echoCLI && $collections->count() > 0) {
- $this->consoleTools->primary(\count($collections).' Collections ready to be converted to releases.', true);
+ $this->colorCLI->primary(\count($collections).' Collections ready to be converted to releases.', true);
}
foreach ($collections as $collection) {
@@ -555,7 +538,7 @@ class ProcessReleases
$totalTime = now()->diffInSeconds($startTime);
if ($this->echoCLI) {
- $this->consoleTools->primary(
+ $this->colorCLI->primary(
PHP_EOL.
number_format($returnCount).
' Releases added and '.
@@ -581,7 +564,7 @@ class ProcessReleases
$startTime = now()->toImmutable();
if ($this->echoCLI) {
- $this->consoleTools->header('Process Releases -> Create the NZB, delete collections/binaries/parts.');
+ $this->colorCLI->header('Process Releases -> Create the NZB, delete collections/binaries/parts.');
}
$releasesQuery = Release::query()->with('category.parent')->where('nzbstatus', '=', 0);
@@ -607,7 +590,7 @@ class ProcessReleases
$totalTime = now()->diffInSeconds($startTime);
if ($this->echoCLI) {
- $this->consoleTools->primary(
+ $this->colorCLI->primary(
number_format($nzbCount).' NZBs created/Collections deleted in '.
$totalTime.Str::plural(' second', $totalTime).PHP_EOL.
'Total time: '.$totalTime.Str::plural(' second', $totalTime),
@@ -631,7 +614,7 @@ class ProcessReleases
{
$startTime = now()->toImmutable();
if ($this->echoCLI) {
- $this->consoleTools->header('Process Releases -> Categorize releases.');
+ $this->colorCLI->header('Process Releases -> Categorize releases.');
}
$type = match ((int) $categorize) {
2 => 'searchname',
@@ -645,7 +628,7 @@ class ProcessReleases
$totalTime = now()->diffInSeconds($startTime);
if ($this->echoCLI) {
- $this->consoleTools->primary($totalTime.Str::plural(' second', $totalTime));
+ $this->colorCLI->primary($totalTime.Str::plural(' second', $totalTime));
}
}
@@ -662,7 +645,7 @@ class ProcessReleases
if ((int) $postProcess === 1) {
(new PostProcess(['Echo' => $this->echoCLI]))->processAll($nntp);
} elseif ($this->echoCLI) {
- $this->consoleTools->info(
+ $this->colorCLI->info(
'Post-processing is not running inside the Process Releases class.'.PHP_EOL.
'If you are using tmux or screen they might have their own scripts running Post-processing.'
);
@@ -681,8 +664,8 @@ class ProcessReleases
// CBP older than retention.
if ($this->echoCLI) {
- echo $this->consoleTools->header('Process Releases -> Delete finished collections.'.PHP_EOL).
- $this->consoleTools->primary(sprintf(
+ echo $this->colorCLI->header('Process Releases -> Delete finished collections.'.PHP_EOL).
+ $this->colorCLI->primary(sprintf(
'Deleting collections/binaries/parts older than %d hours.',
Settings::settingValue('..partretentionhours')
), true);
@@ -702,7 +685,7 @@ class ProcessReleases
$totalTime = $firstQuery->diffInSeconds($startTime);
if ($this->echoCLI) {
- $this->consoleTools->primary(
+ $this->colorCLI->primary(
'Finished deleting '.$deleted.' old collections/binaries/parts in '.
$totalTime.Str::plural(' second', $totalTime),
true
@@ -714,7 +697,7 @@ class ProcessReleases
if (random_int(0, 200) <= 1) {
// CBP collection orphaned with no binaries or parts.
if ($this->echoCLI) {
- echo $this->consoleTools->header('Process Releases -> Remove CBP orphans.'.PHP_EOL).$this->consoleTools->primary('Deleting orphaned collections.');
+ echo $this->colorCLI->header('Process Releases -> Remove CBP orphans.'.PHP_EOL).$this->colorCLI->primary('Deleting orphaned collections.');
}
$deleted = 0;
@@ -728,12 +711,12 @@ class ProcessReleases
$totalTime = now()->diffInSeconds($firstQuery);
if ($this->echoCLI) {
- $this->consoleTools->primary('Finished deleting '.$deleted.' orphaned collections in '.$totalTime.Str::plural(' second', $totalTime), true);
+ $this->colorCLI->primary('Finished deleting '.$deleted.' orphaned collections in '.$totalTime.Str::plural(' second', $totalTime), true);
}
}
if ($this->echoCLI) {
- $this->consoleTools->primary('Deleting collections that were missed after NZB creation.', true);
+ $this->colorCLI->primary('Deleting collections that were missed after NZB creation.', true);
}
$deleted = 0;
@@ -750,7 +733,7 @@ class ProcessReleases
$totalTime = $fourthQuery->diffInSeconds($startTime);
if ($this->echoCLI) {
- $this->consoleTools->primary('Finished deleting '.$deleted.' collections missed after NZB creation in '.$colDelTime.Str::plural(' second', $colDelTime).PHP_EOL.'Removed '.number_format($deletedCount).' parts/binaries/collection rows in '.$totalTime.Str::plural(' second', $totalTime), true);
+ $this->colorCLI->primary('Finished deleting '.$deleted.' collections missed after NZB creation in '.$colDelTime.Str::plural(' second', $colDelTime).PHP_EOL.'Removed '.number_format($deletedCount).' parts/binaries/collection rows in '.$totalTime.Str::plural(' second', $totalTime), true);
}
}, 10);
}
@@ -771,7 +754,7 @@ class ProcessReleases
$minSizeDeleted = $maxSizeDeleted = $minFilesDeleted = 0;
if ($this->echoCLI) {
- $this->consoleTools->header('Process Releases -> Delete releases smaller/larger than minimum size/file count from group/site setting.');
+ $this->colorCLI->header('Process Releases -> Delete releases smaller/larger than minimum size/file count from group/site setting.');
}
$groupIDs = $groupID === '' ? UsenetGroup::getActiveIDs() : [['id' => $groupID]];
@@ -806,7 +789,7 @@ class ProcessReleases
$totalTime = now()->diffInSeconds($startTime);
if ($this->echoCLI) {
- $this->consoleTools->primary(
+ $this->colorCLI->primary(
'Deleted '.($minSizeDeleted + $maxSizeDeleted + $minFilesDeleted).
' releases: '.PHP_EOL.
$minSizeDeleted.' smaller than, '.$maxSizeDeleted.' bigger than, '.$minFilesDeleted.
@@ -834,7 +817,7 @@ class ProcessReleases
// Delete old releases and finished collections.
if ($this->echoCLI) {
- $this->consoleTools->header('Process Releases -> Delete old releases and passworded releases.');
+ $this->colorCLI->header('Process Releases -> Delete old releases and passworded releases.');
}
// Releases past retention.
@@ -934,7 +917,7 @@ class ProcessReleases
}
if ($this->echoCLI) {
- $this->consoleTools->primary(
+ $this->colorCLI->primary(
'Removed releases: '.
number_format($retentionDeleted).
' past retention, '.
@@ -967,7 +950,7 @@ class ProcessReleases
);
if ($totalDeleted > 0) {
$totalTime = now()->diffInSeconds($startTime);
- $this->consoleTools->primary(
+ $this->colorCLI->primary(
'Removed '.number_format($totalDeleted).' releases in '.
$totalTime.Str::plural(' second', $totalTime),
true
@@ -1206,7 +1189,7 @@ class ProcessReleases
}
$obj = $objQuery->delete();
if ($this->echoCLI && $obj > 0) {
- $this->consoleTools->primary('Deleted '.$obj.' broken/stuck collections.', true);
+ $this->colorCLI->primary('Deleted '.$obj.' broken/stuck collections.', true);
}
}, 10);
}
diff --git a/Blacklight/processing/Videos.php b/Blacklight/processing/Videos.php
index 010085638..a66ddc6ea 100755
--- a/Blacklight/processing/Videos.php
+++ b/Blacklight/processing/Videos.php
@@ -51,15 +51,9 @@ abstract class Videos
*/
public array $titleCache;
- public function __construct(array $options = [])
+ public function __construct()
{
- $defaults = [
- 'Echo' => false,
- 'Settings' => null,
- ];
- $options += $defaults;
-
- $this->echooutput = ($options['Echo'] && config('nntmux.echocli'));
+ $this->echooutput = config('nntmux.echocli');
$this->titleCache = [];
}
diff --git a/Blacklight/processing/post/ProcessAdditional.php b/Blacklight/processing/post/ProcessAdditional.php
index 13700304d..f33580a00 100755
--- a/Blacklight/processing/post/ProcessAdditional.php
+++ b/Blacklight/processing/post/ProcessAdditional.php
@@ -261,36 +261,21 @@ class ProcessAdditional
*
* @throws \Exception
*/
- public function __construct(array $options = [])
+ public function __construct()
{
- $defaults = [
- 'Echo' => false,
- 'Categorize' => null,
- 'Groups' => null,
- 'NameFixer' => null,
- 'Nfo' => null,
- 'NNTP' => null,
- 'NZB' => null,
- 'ReleaseExtra' => null,
- 'ReleaseImage' => null,
- 'Settings' => null,
- 'ManticoreSearch' => null,
- ];
- $options += $defaults;
+ $this->_echoCLI = config('nntmux.echocli');
- $this->_echoCLI = ($options['Echo'] && config('nntmux.echocli') && (strtolower(PHP_SAPI) === 'cli'));
+ $this->_nntp = new NNTP();
- $this->_nntp = $options['NNTP'] ?? new NNTP(['Echo' => $this->_echoCLI]);
-
- $this->_nzb = $options['NZB'] ?? new NZB();
+ $this->_nzb = new NZB();
$this->_archiveInfo = new ArchiveInfo();
- $this->_categorize = $options['Categorize'] ?? new Categorize();
- $this->_nameFixer = $options['NameFixer'] ?? new NameFixer(['Echo' => $this->_echoCLI, 'Categorize' => $this->_categorize]);
- $this->_releaseExtra = $options['ReleaseExtra'] ?? new ReleaseExtra();
- $this->_releaseImage = $options['ReleaseImage'] ?? new ReleaseImage();
+ $this->_categorize = new Categorize();
+ $this->_nameFixer = new NameFixer();
+ $this->_releaseExtra = new ReleaseExtra();
+ $this->_releaseImage = new ReleaseImage();
$this->_par2Info = new Par2Info();
- $this->_nfo = $options['Nfo'] ?? new Nfo();
- $this->manticore = $options['ManticoreSearch'] ?? new ManticoreSearch();
+ $this->_nfo = new Nfo();
+ $this->manticore = new ManticoreSearch();
$this->elasticsearch = new ElasticSearchSiteSearch();
$this->ffmpeg = FFMpeg::create(['timeout' => Settings::settingValue('..timeoutseconds')]);
$this->ffprobe = FFProbe::create();
diff --git a/Blacklight/processing/tv/TV.php b/Blacklight/processing/tv/TV.php
index 1e61c0999..4e775da4c 100755
--- a/Blacklight/processing/tv/TV.php
+++ b/Blacklight/processing/tv/TV.php
@@ -75,9 +75,9 @@ abstract class TV extends Videos
*
* @throws \Exception
*/
- public function __construct(array $options = [])
+ public function __construct()
{
- parent::__construct($options);
+ 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;
diff --git a/Blacklight/processing/tv/TVDB.php b/Blacklight/processing/tv/TVDB.php
index cf692feb3..3ec3e9af3 100755
--- a/Blacklight/processing/tv/TVDB.php
+++ b/Blacklight/processing/tv/TVDB.php
@@ -44,9 +44,9 @@ class TVDB extends TV
*
* @throws \Exception
*/
- public function __construct(array $options = [])
+ public function __construct()
{
- parent::__construct($options);
+ parent::__construct();
$this->client = new TheTVDbAPI();
$this->local = false;
diff --git a/Blacklight/processing/tv/TVMaze.php b/Blacklight/processing/tv/TVMaze.php
index 073509083..0272fffad 100644
--- a/Blacklight/processing/tv/TVMaze.php
+++ b/Blacklight/processing/tv/TVMaze.php
@@ -30,9 +30,9 @@ class TVMaze extends TV
*
* @throws \Exception
*/
- public function __construct(array $options = [])
+ public function __construct()
{
- parent::__construct($options);
+ parent::__construct();
$this->client = new Client();
}
diff --git a/Blacklight/processing/tv/TraktTv.php b/Blacklight/processing/tv/TraktTv.php
index 500b2c5c1..3744f113f 100755
--- a/Blacklight/processing/tv/TraktTv.php
+++ b/Blacklight/processing/tv/TraktTv.php
@@ -36,15 +36,11 @@ class TraktTv extends TV
private string $localizedTZ;
/**
- * Construct. Set up API key.
- *
- * @param array $options Class instances.
- *
* @throws \Exception
*/
- public function __construct(array $options = [])
+ public function __construct()
{
- parent::__construct($options);
+ parent::__construct();
$clientId = config('nntmux_api.trakttv_api_key');
$requestHeaders = [
'Content-Type' => 'application/json',