mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 02:01:33 +00:00
Refactor ColorCLI class
This commit is contained in:
+17
-10
@@ -54,6 +54,11 @@ class Backfill
|
||||
*/
|
||||
protected $_disableBackfillGroup;
|
||||
|
||||
/**
|
||||
* @var \Blacklight\ColorCLI
|
||||
*/
|
||||
protected $colorCli;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
@@ -82,6 +87,8 @@ class Backfill
|
||||
['NNTP' => $this->_nntp, 'Echo' => $this->_echoCLI]
|
||||
);
|
||||
|
||||
$this->colorCli = new ColorCLI();
|
||||
|
||||
$this->_compressedHeaders = (int) Settings::settingValue('..compressedheaders') === 1;
|
||||
$this->_safeBackFillDate = Settings::settingValue('..safebackfilldate') !== '' ? (string) Settings::settingValue('safebackfilldate') : '2008-08-14';
|
||||
$this->_safePartRepair = (int) Settings::settingValue('..safepartrepair') === 1 ? 'update' : 'backfill';
|
||||
@@ -114,7 +121,7 @@ class Backfill
|
||||
);
|
||||
|
||||
if ($this->_echoCLI) {
|
||||
ColorCLI::header($dMessage);
|
||||
$this->colorCli->header($dMessage);
|
||||
}
|
||||
|
||||
if ($articles !== '' && ! is_numeric($articles)) {
|
||||
@@ -127,7 +134,7 @@ class Backfill
|
||||
$dMessage = 'Starting group '.$counter.' of '.$groupCount;
|
||||
|
||||
if ($this->_echoCLI) {
|
||||
ColorCLI::header($dMessage);
|
||||
$this->colorCli->header($dMessage);
|
||||
}
|
||||
}
|
||||
$this->backfillGroup($groupArr, $groupCount - $counter, $articles);
|
||||
@@ -137,13 +144,13 @@ class Backfill
|
||||
$dMessage = 'Backfilling completed in '.now()->diffInSeconds($allTime).' seconds.';
|
||||
|
||||
if ($this->_echoCLI) {
|
||||
ColorCLI::primary($dMessage);
|
||||
$this->colorCli->primary($dMessage);
|
||||
}
|
||||
} else {
|
||||
$dMessage = 'No groups specified. Ensure groups are added to database for updating.';
|
||||
|
||||
if ($this->_echoCLI) {
|
||||
ColorCLI::warning($dMessage);
|
||||
$this->colorCli->warning($dMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -175,7 +182,7 @@ class Backfill
|
||||
'. Otherwise the group is dead, you must disable it.';
|
||||
|
||||
if ($this->_echoCLI) {
|
||||
ColorCLI::error($dMessage);
|
||||
$this->colorCli->error($dMessage);
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -191,7 +198,7 @@ class Backfill
|
||||
}
|
||||
|
||||
if ($this->_echoCLI) {
|
||||
ColorCLI::primary('Processing '.$groupName);
|
||||
$this->colorCli->primary('Processing '.$groupName);
|
||||
}
|
||||
|
||||
// Check if this is days or post backfill.
|
||||
@@ -224,14 +231,14 @@ class Backfill
|
||||
}
|
||||
|
||||
if ($this->_echoCLI) {
|
||||
ColorCLI::notice($dMessage);
|
||||
$this->colorCli->notice($dMessage);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->_echoCLI) {
|
||||
ColorCLI::primary(
|
||||
$this->colorCli->primary(
|
||||
'Group '.
|
||||
$groupName.
|
||||
"'s oldest article is ".
|
||||
@@ -259,7 +266,7 @@ class Backfill
|
||||
$done = false;
|
||||
while ($done === false) {
|
||||
if ($this->_echoCLI) {
|
||||
ColorCLI::header('Getting '.
|
||||
$this->colorCli->header('Getting '.
|
||||
number_format($last - $first + 1).
|
||||
' articles from '.
|
||||
$groupName.
|
||||
@@ -306,7 +313,7 @@ class Backfill
|
||||
}
|
||||
|
||||
if ($this->_echoCLI) {
|
||||
ColorCLI::primary(
|
||||
$this->colorCli->primary(
|
||||
PHP_EOL.
|
||||
'Group '.
|
||||
$groupName.
|
||||
|
||||
+31
-31
@@ -45,7 +45,7 @@ class Binaries
|
||||
/**
|
||||
* @var \Blacklight\ColorCLI
|
||||
*/
|
||||
protected $_colorCLI;
|
||||
protected $colorCli;
|
||||
|
||||
/**
|
||||
* @var \Blacklight\CollectionsCleaning
|
||||
@@ -241,8 +241,8 @@ class Binaries
|
||||
$this->_echoCLI = ($options['Echo'] && 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->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->messageBuffer = Settings::settingValue('..maxmssgs') !== '' ?
|
||||
@@ -346,14 +346,14 @@ class Binaries
|
||||
}
|
||||
|
||||
if ($this->_echoCLI) {
|
||||
ColorCLI::primary('Processing '.$groupMySQL['name']);
|
||||
$this->colorCli->primary('Processing '.$groupMySQL['name']);
|
||||
}
|
||||
|
||||
// Attempt to repair any missing parts before grabbing new ones.
|
||||
if ((int) $groupMySQL['last_record'] !== 0) {
|
||||
if ($this->_partRepair) {
|
||||
if ($this->_echoCLI) {
|
||||
ColorCLI::primary('Part repair enabled. Checking for missing parts.');
|
||||
$this->colorCli->primary('Part repair enabled. Checking for missing parts.');
|
||||
}
|
||||
$this->partRepair($groupMySQL);
|
||||
|
||||
@@ -363,7 +363,7 @@ class Binaries
|
||||
$this->partRepair($groupMySQL, $tableNames);
|
||||
}
|
||||
} elseif ($this->_echoCLI) {
|
||||
ColorCLI::primary('Part repair disabled by user.');
|
||||
$this->colorCli->primary('Part repair disabled by user.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -431,7 +431,7 @@ class Binaries
|
||||
// If total is bigger than 0 it means we have new parts in the newsgroup.
|
||||
if ($total > 0) {
|
||||
if ($this->_echoCLI) {
|
||||
ColorCLI::primary(
|
||||
$this->colorCli->primary(
|
||||
(
|
||||
(int) $groupMySQL['last_record'] === 0
|
||||
? 'New group '.$groupNNTP['group'].' starting with '.
|
||||
@@ -465,7 +465,7 @@ class Binaries
|
||||
$first++;
|
||||
|
||||
if ($this->_echoCLI) {
|
||||
ColorCLI::header(
|
||||
$this->colorCli->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).'
|
||||
@@ -534,13 +534,13 @@ class Binaries
|
||||
}
|
||||
|
||||
if ($this->_echoCLI) {
|
||||
ColorCLI::primary(
|
||||
$this->colorCli->primary(
|
||||
PHP_EOL.'Group '.$groupMySQL['name'].' processed in '.
|
||||
number_format(microtime(true) - $startGroup, 2).' seconds.'
|
||||
);
|
||||
}
|
||||
} elseif ($this->_echoCLI) {
|
||||
ColorCLI::primary(
|
||||
$this->colorCli->primary(
|
||||
'No new articles for '.$groupMySQL['name'].' (first '.number_format($first).
|
||||
', last '.number_format($last).', grouplast '.number_format($groupMySQL['last_record']).
|
||||
', total '.number_format($total).")\n".'Server oldest: '.number_format($groupNNTP['first']).
|
||||
@@ -771,7 +771,7 @@ class Binaries
|
||||
$this->addMissingParts($rangeNotReceived, $this->tableNames['prname'], $this->groupMySQL['id']);
|
||||
|
||||
if ($this->_echoCLI) {
|
||||
ColorCLI::alternate(
|
||||
$this->colorCli->alternate(
|
||||
'Server did not return '.$notReceivedCount.
|
||||
' articles from '.$this->groupMySQL['name'].'.'
|
||||
);
|
||||
@@ -1008,7 +1008,7 @@ class Binaries
|
||||
*/
|
||||
protected function outputHeaderInitial(): void
|
||||
{
|
||||
ColorCLI::primary(
|
||||
$this->colorCli->primary(
|
||||
'Received '.\count($this->headersReceived).
|
||||
' articles of '.number_format($this->last - $this->first + 1).' requested, '.
|
||||
$this->headersBlackListed.' blacklisted, '.$this->notYEnc.' not yEnc.'
|
||||
@@ -1022,16 +1022,16 @@ class Binaries
|
||||
{
|
||||
$currentMicroTime = microtime(true);
|
||||
if ($this->_echoCLI) {
|
||||
ColorCLI::alternateOver($this->timeHeaders.'s').
|
||||
ColorCLI::primaryOver(' to download articles, ').
|
||||
ColorCLI::alternateOver($this->timeCleaning.'s').
|
||||
ColorCLI::primaryOver(' to process collections, ').
|
||||
ColorCLI::alternateOver($this->timeInsert.'s').
|
||||
ColorCLI::primaryOver(' to insert binaries/parts, ').
|
||||
ColorCLI::alternateOver(number_format($currentMicroTime - $this->startPR, 2).'s').
|
||||
ColorCLI::primaryOver(' for part repair, ').
|
||||
ColorCLI::alternateOver(number_format($currentMicroTime - $this->startLoop, 2).'s').
|
||||
ColorCLI::primary(' total.');
|
||||
$this->colorCli->alternateOver($this->timeHeaders.'s').
|
||||
$this->colorCli->primaryOver(' to download articles, ').
|
||||
$this->colorCli->alternateOver($this->timeCleaning.'s').
|
||||
$this->colorCli->primaryOver(' to process collections, ').
|
||||
$this->colorCli->alternateOver($this->timeInsert.'s').
|
||||
$this->colorCli->primaryOver(' to insert binaries/parts, ').
|
||||
$this->colorCli->alternateOver(number_format($currentMicroTime - $this->startPR, 2).'s').
|
||||
$this->colorCli->primaryOver(' for part repair, ').
|
||||
$this->colorCli->alternateOver(number_format($currentMicroTime - $this->startLoop, 2).'s').
|
||||
$this->colorCli->primary(' total.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1086,7 +1086,7 @@ class Binaries
|
||||
DB::commit();
|
||||
}
|
||||
if ($e->getMessage() === 'SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction') {
|
||||
ColorCLI::notice('Deadlock occurred');
|
||||
$this->colorCli->notice('Deadlock occurred');
|
||||
DB::rollBack();
|
||||
}
|
||||
}
|
||||
@@ -1094,7 +1094,7 @@ class Binaries
|
||||
$missingCount = \count($missingParts);
|
||||
if ($missingCount > 0) {
|
||||
if ($this->_echoCLI) {
|
||||
ColorCLI::primary(
|
||||
$this->colorCli->primary(
|
||||
'Attempting to repair '.
|
||||
number_format($missingCount).
|
||||
' parts.'
|
||||
@@ -1176,7 +1176,7 @@ class Binaries
|
||||
}
|
||||
|
||||
if ($this->_echoCLI) {
|
||||
ColorCLI::primary(
|
||||
$this->colorCli->primary(
|
||||
PHP_EOL.
|
||||
number_format($partsRepaired).
|
||||
' parts repaired.'
|
||||
@@ -1308,7 +1308,7 @@ class Binaries
|
||||
}
|
||||
|
||||
if ($this->_echoCLI) {
|
||||
ColorCLI::primary(
|
||||
$this->colorCli->primary(
|
||||
'Searching for an approximate article number for group '.$data['group'].' '.$days.' days back.'
|
||||
);
|
||||
}
|
||||
@@ -1366,7 +1366,7 @@ class Binaries
|
||||
|
||||
$wantedArticle = (int) $wantedArticle;
|
||||
if ($this->_echoCLI) {
|
||||
ColorCLI::primary(
|
||||
$this->colorCli->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 '.Carbon::createFromTimestamp($goalTime)->diffInDays(Carbon::createFromTimestamp($articleTime)).'days.'
|
||||
);
|
||||
@@ -1623,7 +1623,7 @@ class Binaries
|
||||
private function log($message, $method, $color): void
|
||||
{
|
||||
if ($this->_echoCLI) {
|
||||
ColorCLI::$color($message.' ['.__CLASS__."::$method]");
|
||||
$this->colorCli->$color($message.' ['.__CLASS__."::$method]");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1679,11 +1679,11 @@ class Binaries
|
||||
try {
|
||||
return DB::insert($query);
|
||||
} catch (QueryException $e) {
|
||||
ColorCLI::debug('Query error occurred.');
|
||||
$this->colorCli->debug('Query error occurred.');
|
||||
} catch (\PDOException $e) {
|
||||
ColorCLI::debug('Query error occurred.');
|
||||
$this->colorCli->debug('Query error occurred.');
|
||||
} catch (\Throwable $e) {
|
||||
ColorCLI::debug('Query error occurred.');
|
||||
$this->colorCli->debug('Query error occurred.');
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
+22
-15
@@ -68,6 +68,11 @@ class Books
|
||||
*/
|
||||
public $failCache;
|
||||
|
||||
/**
|
||||
* @var \Blacklight\ColorCLI
|
||||
*/
|
||||
protected $colorCli;
|
||||
|
||||
/**
|
||||
* @param array $options Class instances / Echo to cli.
|
||||
*
|
||||
@@ -83,6 +88,8 @@ class Books
|
||||
|
||||
$this->echooutput = ($options['Echo'] && config('nntmux.echocli'));
|
||||
|
||||
$this->colorCli = new ColorCLI();
|
||||
|
||||
$this->pubkey = Settings::settingValue('APIs..amazonpubkey');
|
||||
$this->privkey = Settings::settingValue('APIs..amazonprivkey');
|
||||
$this->asstag = Settings::settingValue('APIs..amazonassociatetag');
|
||||
@@ -349,12 +356,12 @@ class Books
|
||||
}
|
||||
|
||||
if (isset($response->Items->Item->ItemAttributes->Title)) {
|
||||
ColorCLI::info('Found matching title: '.$response->Items->Item->ItemAttributes->Title);
|
||||
$this->colorCli->info('Found matching title: '.$response->Items->Item->ItemAttributes->Title);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
ColorCLI::notice('Could not find a match on Amazon!');
|
||||
$this->colorCli->notice('Could not find a match on Amazon!');
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -399,7 +406,7 @@ class Books
|
||||
{
|
||||
if ($res->count() > 0) {
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::header('Processing '.$res->count().' book release(s) for categories id '.$categoryID);
|
||||
$this->colorCli->header('Processing '.$res->count().' book release(s) for categories id '.$categoryID);
|
||||
}
|
||||
|
||||
$bookId = -2;
|
||||
@@ -417,7 +424,7 @@ class Books
|
||||
|
||||
if ($bookInfo !== false) {
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::headerOver('Looking up: ').ColorCLI::primary($bookInfo);
|
||||
$this->colorCli->headerOver('Looking up: ').$this->colorCli->primary($bookInfo);
|
||||
}
|
||||
|
||||
// Do a local lookup first
|
||||
@@ -426,7 +433,7 @@ class Books
|
||||
if ($bookCheck === null && \in_array($bookInfo, $this->failCache, false)) {
|
||||
// Lookup recently failed, no point trying again
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::headerOver('Cached previous failure. Skipping.');
|
||||
$this->colorCli->headerOver('Cached previous failure. Skipping.');
|
||||
}
|
||||
$bookId = -2;
|
||||
} elseif ($bookCheck === null) {
|
||||
@@ -454,7 +461,7 @@ class Books
|
||||
}
|
||||
}
|
||||
} elseif ($this->echooutput) {
|
||||
ColorCLI::header('No book releases to process for categories id '.$categoryID);
|
||||
$this->colorCli->header('No book releases to process for categories id '.$categoryID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -481,7 +488,7 @@ class Books
|
||||
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) {
|
||||
ColorCLI::headerOver('Changing category to misc books: ').ColorCLI::primary($releasename);
|
||||
$this->colorCli->headerOver('Changing category to misc books: ').$this->colorCli->primary($releasename);
|
||||
}
|
||||
Release::query()->where('id', $releaseID)->update(['categories_id' => Category::BOOKS_UNKNOWN]);
|
||||
|
||||
@@ -490,7 +497,7 @@ class Books
|
||||
|
||||
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) {
|
||||
ColorCLI::headerOver('Changing category to magazines: ').ColorCLI::primary($releasename);
|
||||
$this->colorCli->headerOver('Changing category to magazines: ').$this->colorCli->primary($releasename);
|
||||
}
|
||||
Release::query()->where('id', $releaseID)->update(['categories_id' => Category::BOOKS_MAGAZINES]);
|
||||
|
||||
@@ -530,7 +537,7 @@ class Books
|
||||
|
||||
$amaz = false;
|
||||
if ($bookInfo !== '') {
|
||||
ColorCLI::info('Fetching data from Amazon for '.$bookInfo);
|
||||
$this->colorCli->info('Fetching data from Amazon for '.$bookInfo);
|
||||
|
||||
$amaz = $this->fetchAmazonProperties($bookInfo);
|
||||
} elseif ($amazdata !== null) {
|
||||
@@ -648,20 +655,20 @@ class Books
|
||||
|
||||
if ($bookId && $bookId !== -2) {
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::header('Added/updated book: ');
|
||||
$this->colorCli->header('Added/updated book: ');
|
||||
if ($book['author'] !== '') {
|
||||
ColorCLI::alternateOver(' Author: ').ColorCLI::primary($book['author']);
|
||||
$this->colorCli->alternateOver(' Author: ').$this->colorCli->primary($book['author']);
|
||||
}
|
||||
ColorCLI::alternateOver(' Title: ').ColorCLI::primary(' '.$book['title']);
|
||||
$this->colorCli->alternateOver(' Title: ').$this->colorCli->primary(' '.$book['title']);
|
||||
if ($book['genre'] !== 'null') {
|
||||
ColorCLI::alternateOver(' Genre: ').ColorCLI::primary(' '.$book['genre']);
|
||||
$this->colorCli->alternateOver(' Genre: ').$this->colorCli->primary(' '.$book['genre']);
|
||||
}
|
||||
}
|
||||
|
||||
$book['cover'] = $ri->saveImage($bookId, $book['coverurl'], $this->imgSavePath, 250, 250);
|
||||
} elseif ($this->echooutput) {
|
||||
ColorCLI::header('Nothing to update: ').
|
||||
ColorCLI::header($book['author'].
|
||||
$this->colorCli->header('Nothing to update: ').
|
||||
$this->colorCli->header($book['author'].
|
||||
' - '.
|
||||
$book['title']);
|
||||
}
|
||||
|
||||
+83
-42
@@ -7,114 +7,155 @@ use League\CLImate\CLImate;
|
||||
class ColorCLI
|
||||
{
|
||||
/**
|
||||
* @return \League\CLImate\CLImate
|
||||
* @var \League\CLImate\CLImate
|
||||
*/
|
||||
protected static function climate()
|
||||
protected $climate;
|
||||
|
||||
/**
|
||||
* ColorCLI constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
return new CLImate();
|
||||
$this->climate = new CLImate();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $str
|
||||
* @param string $str
|
||||
* @param bool $newline
|
||||
*/
|
||||
public static function debug($str): void
|
||||
public function debug(string $str, bool $newline = false): void
|
||||
{
|
||||
self::climate()->lightGray()->out($str);
|
||||
if ($newline) {
|
||||
$this->climate->br();
|
||||
}
|
||||
$this->climate->lightGray()->out($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $str
|
||||
* @param string $str
|
||||
* @param bool $newline
|
||||
*/
|
||||
public static function info($str): void
|
||||
public function info(string $str, bool $newline = false): void
|
||||
{
|
||||
self::climate()->magenta()->out($str);
|
||||
if ($newline) {
|
||||
$this->climate->br();
|
||||
}
|
||||
$this->climate->magenta()->out($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $str
|
||||
* @param string $str
|
||||
* @param bool $newline
|
||||
*/
|
||||
public static function notice($str): void
|
||||
public function notice(string $str, bool $newline = false): void
|
||||
{
|
||||
self::climate()->blue()->out($str);
|
||||
if ($newline) {
|
||||
$this->climate->br();
|
||||
}
|
||||
$this->climate->blue()->out($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $str
|
||||
* @param string $str
|
||||
* @param bool $newline
|
||||
*/
|
||||
public static function warning($str): void
|
||||
public function warning(string $str, bool $newline = false): void
|
||||
{
|
||||
self::climate()->yellow()->out($str);
|
||||
if ($newline) {
|
||||
$this->climate->br();
|
||||
}
|
||||
$this->climate->yellow()->out($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $str
|
||||
* @param string $str
|
||||
* @param bool $newline
|
||||
*/
|
||||
public static function error($str): void
|
||||
public function error(string $str, bool $newline = false): void
|
||||
{
|
||||
self::climate()->red()->out($str);
|
||||
if ($newline) {
|
||||
$this->climate->br();
|
||||
}
|
||||
$this->climate->red()->out($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $str
|
||||
* @param string $str
|
||||
* @param bool $newline
|
||||
*/
|
||||
public static function primary($str): void
|
||||
public function primary(string $str, bool $newline = false): void
|
||||
{
|
||||
self::climate()->green()->out($str);
|
||||
if ($newline) {
|
||||
$this->climate->br();
|
||||
}
|
||||
$this->climate->green()->out($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $str
|
||||
* @param string $str
|
||||
* @param bool $newline
|
||||
*/
|
||||
public static function header($str): void
|
||||
public function header(string $str, bool $newline = false): void
|
||||
{
|
||||
self::climate()->yellow()->out($str);
|
||||
if ($newline) {
|
||||
$this->climate->br();
|
||||
}
|
||||
$this->climate->yellow()->out($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $str
|
||||
* @param string $str
|
||||
* @param bool $newline
|
||||
*/
|
||||
public static function alternate($str): void
|
||||
public function alternate(string $str, bool $newline = false): void
|
||||
{
|
||||
self::climate()->magenta()->bold()->out($str);
|
||||
if ($newline) {
|
||||
$this->climate->br();
|
||||
}
|
||||
$this->climate->magenta()->bold()->out($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $str
|
||||
* @param string $str
|
||||
* @param bool $newline
|
||||
*/
|
||||
public static function tmuxOrange($str): void
|
||||
public function tmuxOrange(string $str, bool $newline = false): void
|
||||
{
|
||||
self::climate()->yellow()->bold()->out($str);
|
||||
if ($newline) {
|
||||
$this->climate->br();
|
||||
}
|
||||
$this->climate->yellow()->bold()->out($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $str
|
||||
* @param string $str
|
||||
*/
|
||||
public static function primaryOver($str): void
|
||||
public function primaryOver(string $str): void
|
||||
{
|
||||
self::climate()->green()->inline($str);
|
||||
$this->climate->green()->inline($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $str
|
||||
* @param string $str
|
||||
*/
|
||||
public static function headerOver($str): void
|
||||
public function headerOver(string $str): void
|
||||
{
|
||||
self::climate()->yellow()->inline($str);
|
||||
$this->climate->yellow()->inline($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $str
|
||||
* @param string $str
|
||||
*/
|
||||
public static function alternateOver($str): void
|
||||
public function alternateOver(string $str): void
|
||||
{
|
||||
self::climate()->magenta()->bold()->inline($str);
|
||||
$this->climate->magenta()->bold()->inline($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $str
|
||||
* @param string $str
|
||||
*/
|
||||
public static function warningOver($str): void
|
||||
public function warningOver(string $str): void
|
||||
{
|
||||
self::climate()->red()->inline($str);
|
||||
$this->climate->red()->inline($str);
|
||||
}
|
||||
}
|
||||
|
||||
+27
-20
@@ -86,6 +86,11 @@ class Console
|
||||
*/
|
||||
public $failCache;
|
||||
|
||||
/**
|
||||
* @var \Blacklight\ColorCLI
|
||||
*/
|
||||
protected $colorCli;
|
||||
|
||||
/**
|
||||
* @param array $options Class instances / Echo to cli.
|
||||
* @throws \Exception
|
||||
@@ -100,6 +105,8 @@ class Console
|
||||
|
||||
$this->echooutput = ($options['Echo'] && config('nntmux.echocli'));
|
||||
|
||||
$this->colorCli = new ColorCLI();
|
||||
|
||||
$this->pubkey = Settings::settingValue('APIs..amazonpubkey');
|
||||
$this->privkey = Settings::settingValue('APIs..amazonprivkey');
|
||||
$this->asstag = Settings::settingValue('APIs..amazonassociatetag');
|
||||
@@ -392,13 +399,13 @@ class Console
|
||||
$consoleId = $this->_updateConsoleTable($con);
|
||||
|
||||
if ($this->echooutput && $consoleId !== -2) {
|
||||
ColorCLI::header('Added/updated game: ').
|
||||
ColorCLI::alternateOver(' Title: ').
|
||||
ColorCLI::primary($con['title']).
|
||||
ColorCLI::alternateOver(' Platform: ').
|
||||
ColorCLI::primary($con['platform']).
|
||||
ColorCLI::alternateOver(' Genre: ').
|
||||
ColorCLI::primary($con['consolegenre']);
|
||||
$this->colorCli->header('Added/updated game: ').
|
||||
$this->colorCli->alternateOver(' Title: ').
|
||||
$this->colorCli->primary($con['title']).
|
||||
$this->colorCli->alternateOver(' Platform: ').
|
||||
$this->colorCli->primary($con['platform']).
|
||||
$this->colorCli->alternateOver(' Genre: ').
|
||||
$this->colorCli->primary($con['consolegenre']);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -413,7 +420,7 @@ class Console
|
||||
$consoleId = $this->_updateConsoleTable($igdb);
|
||||
|
||||
if ($this->echooutput && $consoleId !== -2) {
|
||||
ColorCLI::header('Added/updated game: ').ColorCLI::alternateOver(' Title: ').ColorCLI::primary($igdb['title']).ColorCLI::alternateOver(' Platform: ').ColorCLI::primary($igdb['platform']).ColorCLI::alternateOver(' Genre: ').ColorCLI::primary($igdb['consolegenre']);
|
||||
$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']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -773,7 +780,7 @@ class Console
|
||||
|
||||
$apaiIo = new ApaiIO($conf);
|
||||
|
||||
ColorCLI::info('Trying to find info on Amazon');
|
||||
$this->colorCli->info('Trying to find info on Amazon');
|
||||
$responses = $apaiIo->runOperation($search);
|
||||
|
||||
if ($responses === false) {
|
||||
@@ -783,13 +790,13 @@ class Console
|
||||
foreach ($responses->Items->Item as $response) {
|
||||
similar_text($title, $response->ItemAttributes->Title, $percent);
|
||||
if ($percent > self::MATCH_PERCENT && isset($response->ItemAttributes->Title)) {
|
||||
ColorCLI::info('Found matching info on Amazon: '.$response->ItemAttributes->Title);
|
||||
$this->colorCli->info('Found matching info on Amazon: '.$response->ItemAttributes->Title);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
ColorCLI::info('Could not find match on Amazon');
|
||||
$this->colorCli->info('Could not find match on Amazon');
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -882,12 +889,12 @@ class Console
|
||||
return $game;
|
||||
}
|
||||
|
||||
ColorCLI::notice('IGDB returned no valid results');
|
||||
$this->colorCli->notice('IGDB returned no valid results');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
ColorCLI::notice('IGDB found no valid results');
|
||||
$this->colorCli->notice('IGDB found no valid results');
|
||||
|
||||
return false;
|
||||
} catch (ClientException $e) {
|
||||
@@ -914,7 +921,7 @@ class Console
|
||||
$releaseCount = $res->count();
|
||||
if ($res instanceof \Traversable && $releaseCount > 0) {
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::header('Processing '.$releaseCount.' console release(s).');
|
||||
$this->colorCli->header('Processing '.$releaseCount.' console release(s).');
|
||||
}
|
||||
|
||||
foreach ($res as $arr) {
|
||||
@@ -925,8 +932,8 @@ class Console
|
||||
|
||||
if ($gameInfo !== false) {
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::headerOver('Looking up: ').
|
||||
ColorCLI::primary(
|
||||
$this->colorCli->headerOver('Looking up: ').
|
||||
$this->colorCli->primary(
|
||||
$gameInfo['title'].
|
||||
' ('.
|
||||
$gameInfo['platform'].')'
|
||||
@@ -939,7 +946,7 @@ class Console
|
||||
if ($gameCheck === false && \in_array($gameInfo['title'].$gameInfo['platform'], $this->failCache, false)) {
|
||||
// Lookup recently failed, no point trying again
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::headerOver('Cached previous failure. Skipping.');
|
||||
$this->colorCli->headerOver('Cached previous failure. Skipping.');
|
||||
}
|
||||
$gameId = -2;
|
||||
} elseif ($gameCheck === false) {
|
||||
@@ -951,8 +958,8 @@ class Console
|
||||
}
|
||||
} else {
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::headerOver('Found Local: ').
|
||||
ColorCLI::primary("{$gameCheck['title']} - {$gameCheck['platform']}");
|
||||
$this->colorCli->headerOver('Found Local: ').
|
||||
$this->colorCli->primary("{$gameCheck['title']} - {$gameCheck['platform']}");
|
||||
}
|
||||
$gameId = $gameCheck['id'];
|
||||
}
|
||||
@@ -970,7 +977,7 @@ class Console
|
||||
}
|
||||
}
|
||||
} elseif ($this->echooutput) {
|
||||
ColorCLI::header('No console releases to process.');
|
||||
$this->colorCli->header('No console releases to process.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ class ConsoleTools
|
||||
/**
|
||||
* @var \Blacklight\ColorCLI
|
||||
*/
|
||||
public $cli;
|
||||
public $colorCli;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
@@ -23,6 +23,8 @@ class ConsoleTools
|
||||
public function __construct()
|
||||
{
|
||||
$this->lastMessageLength = 0;
|
||||
|
||||
$this->colorCli = new ColorCLI();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,7 +42,7 @@ class ConsoleTools
|
||||
echo str_repeat(\chr(8), $this->lastMessageLength);
|
||||
|
||||
$this->lastMessageLength = \strlen($message);
|
||||
ColorCLI::headerOver($message);
|
||||
$this->colorCli->headerOver($message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,7 +60,7 @@ class ConsoleTools
|
||||
echo str_repeat(\chr(8), $this->lastMessageLength);
|
||||
|
||||
$this->lastMessageLength = \strlen($message);
|
||||
ColorCLI::primaryOver($message);
|
||||
$this->colorCli->primaryOver($message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+17
-15
@@ -120,6 +120,8 @@ class Games
|
||||
$options += $defaults;
|
||||
$this->echoOutput = ($options['Echo'] && config('nntmux.echocli'));
|
||||
|
||||
$this->colorCli = new ColorCLI();
|
||||
|
||||
$this->publicKey = Settings::settingValue('APIs..giantbombkey');
|
||||
$this->gameQty = Settings::settingValue('..maxgamesprocessed') !== '' ? (int) Settings::settingValue('..maxgamesprocessed') : 150;
|
||||
$this->imgSavePath = NN_COVERS.'games'.DS;
|
||||
@@ -552,12 +554,12 @@ class Games
|
||||
$game['review'] = (string) $this->_gameResults->deck;
|
||||
}
|
||||
} else {
|
||||
ColorCLI::notice('GiantBomb returned no valid results');
|
||||
$this->colorCli->notice('GiantBomb returned no valid results');
|
||||
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
ColorCLI::notice('GiantBomb found no valid results');
|
||||
$this->colorCli->notice('GiantBomb found no valid results');
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -623,12 +625,12 @@ class Games
|
||||
'publisher' => ! empty($publishers) ? implode(',', $publishers) : 'Unknown',
|
||||
];
|
||||
} else {
|
||||
ColorCLI::notice('IGDB returned no valid results');
|
||||
$this->colorCli->notice('IGDB returned no valid results');
|
||||
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
ColorCLI::notice('IGDB found no valid results');
|
||||
$this->colorCli->notice('IGDB found no valid results');
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -732,11 +734,11 @@ class Games
|
||||
|
||||
if (! empty($gamesId)) {
|
||||
if ($this->echoOutput) {
|
||||
ColorCLI::header('Added/updated game: ').
|
||||
ColorCLI::alternateOver(' Title: ').
|
||||
ColorCLI::primary($game['title']).
|
||||
ColorCLI::alternateOver(' Source: ').
|
||||
ColorCLI::primary($this->_classUsed);
|
||||
$this->colorCli->header('Added/updated game: ').
|
||||
$this->colorCli->alternateOver(' Title: ').
|
||||
$this->colorCli->primary($game['title']).
|
||||
$this->colorCli->alternateOver(' Source: ').
|
||||
$this->colorCli->primary($this->_classUsed);
|
||||
}
|
||||
if ($game['cover'] === 1) {
|
||||
$game['cover'] = $ri->saveImage($gamesId, $game['coverurl'], $this->imgSavePath, 250, 250);
|
||||
@@ -745,8 +747,8 @@ class Games
|
||||
$game['backdrop'] = $ri->saveImage($gamesId.'-backdrop', $game['backdropurl'], $this->imgSavePath, 1920, 1024);
|
||||
}
|
||||
} elseif ($this->echoOutput) {
|
||||
ColorCLI::headerOver('Nothing to update: ').
|
||||
ColorCLI::primary($game['title'].' (PC)');
|
||||
$this->colorCli->headerOver('Nothing to update: ').
|
||||
$this->colorCli->primary($game['title'].' (PC)');
|
||||
}
|
||||
|
||||
return ! empty($gamesId) ? $gamesId : false;
|
||||
@@ -774,7 +776,7 @@ class Games
|
||||
|
||||
if ($res->count() > 0) {
|
||||
if ($this->echoOutput) {
|
||||
ColorCLI::header('Processing '.$res->count().' games release(s).');
|
||||
$this->colorCli->header('Processing '.$res->count().' games release(s).');
|
||||
}
|
||||
|
||||
foreach ($res as $arr) {
|
||||
@@ -785,8 +787,8 @@ class Games
|
||||
$gameInfo = $this->parseTitle($arr['searchname']);
|
||||
if ($gameInfo !== false) {
|
||||
if ($this->echoOutput) {
|
||||
ColorCLI::headerOver('Looking up: ').
|
||||
ColorCLI::primary($gameInfo['title'].' (PC)');
|
||||
$this->colorCli->headerOver('Looking up: ').
|
||||
$this->colorCli->primary($gameInfo['title'].' (PC)');
|
||||
}
|
||||
|
||||
// Check for existing games entry.
|
||||
@@ -817,7 +819,7 @@ class Games
|
||||
}
|
||||
}
|
||||
} elseif ($this->echoOutput) {
|
||||
ColorCLI::header('No games releases to process.');
|
||||
$this->colorCli->header('No games releases to process.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+18
-12
@@ -167,6 +167,11 @@ class Movie
|
||||
*/
|
||||
protected $tmdbtokencheck;
|
||||
|
||||
/**
|
||||
* @var \Blacklight\ColorCLI
|
||||
*/
|
||||
protected $colorCli;
|
||||
|
||||
/**
|
||||
* @param array $options Class instances / Echo to CLI.
|
||||
* @throws \Exception
|
||||
@@ -184,6 +189,7 @@ class Movie
|
||||
|
||||
$this->pdo = DB::connection()->getPdo();
|
||||
$this->releaseImage = ($options['ReleaseImage'] instanceof ReleaseImage ? $options['ReleaseImage'] : new ReleaseImage());
|
||||
$this->colorCli = new ColorCLI();
|
||||
$this->traktcheck = Settings::settingValue('APIs..trakttvclientkey');
|
||||
if ($this->traktcheck !== null) {
|
||||
$this->traktTv = new TraktTv(['Settings' => null]);
|
||||
@@ -609,7 +615,7 @@ class Movie
|
||||
public function updateMovieInfo($imdbId): bool
|
||||
{
|
||||
if ($this->echooutput && $this->service !== '' && Utility::isCLI()) {
|
||||
ColorCLI::primary('Fetching IMDB info from TMDB/IMDB/Trakt/OMDB using IMDB id: '.$imdbId);
|
||||
$this->colorCli->primary('Fetching IMDB info from TMDB/IMDB/Trakt/OMDB using IMDB id: '.$imdbId);
|
||||
}
|
||||
|
||||
// Check TMDB for IMDB info.
|
||||
@@ -731,8 +737,8 @@ class Movie
|
||||
]);
|
||||
|
||||
if ($this->echooutput && $this->service !== '' && Utility::isCLI()) {
|
||||
ColorCLI::headerOver('Added/updated movie: ').
|
||||
ColorCLI::primary(
|
||||
$this->colorCli->headerOver('Added/updated movie: ').
|
||||
$this->colorCli->primary(
|
||||
$mov['title'].
|
||||
' ('.
|
||||
$mov['year'].
|
||||
@@ -779,7 +785,7 @@ class Movie
|
||||
$ret['title'] = $art['name'];
|
||||
}
|
||||
if ($this->echooutput && Utility::isCLI()) {
|
||||
ColorCLI::alternateOver('Fanart Found ').ColorCLI::headerOver($ret['title']);
|
||||
$this->colorCli->alternateOver('Fanart Found ').$this->colorCli->headerOver($ret['title']);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
@@ -807,7 +813,7 @@ class Movie
|
||||
$tmdbLookup = $this->tmdbclient->getMoviesApi()->getMovie($lookupId, ['append_to_response' => 'credits']);
|
||||
} catch (TmdbApiException $error) {
|
||||
if (Utility::isCLI()) {
|
||||
ColorCLI::error($error->getMessage());
|
||||
$this->colorCli->error($error->getMessage());
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -893,7 +899,7 @@ class Movie
|
||||
$ret['backdrop'] = '';
|
||||
}
|
||||
if ($this->echooutput && Utility::isCLI()) {
|
||||
ColorCLI::primaryOver('TMDb Found ').ColorCLI::headerOver($ret['title']);
|
||||
$this->colorCli->primaryOver('TMDb Found ').$this->colorCli->headerOver($ret['title']);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
@@ -928,7 +934,7 @@ class Movie
|
||||
];
|
||||
|
||||
if ($this->echooutput && Utility::isCLI()) {
|
||||
ColorCLI::headerOver('IMDb Found ').ColorCLI::primaryOver($result->orig_title());
|
||||
$this->colorCli->headerOver('IMDb Found ').$this->colorCli->primaryOver($result->orig_title());
|
||||
}
|
||||
|
||||
return $ret;
|
||||
@@ -971,7 +977,7 @@ class Movie
|
||||
return false;
|
||||
}
|
||||
if ($this->echooutput && Utility::isCLI()) {
|
||||
ColorCLI::alternateOver('Trakt Found ').ColorCLI::headerOver($ret['title']);
|
||||
$this->colorCli->alternateOver('Trakt Found ').$this->colorCli->headerOver($ret['title']);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
@@ -1022,7 +1028,7 @@ class Movie
|
||||
];
|
||||
|
||||
if ($this->echooutput && Utility::isCLI()) {
|
||||
ColorCLI::alternateOver('OMDbAPI Found ').ColorCLI::headerOver($ret['title']);
|
||||
$this->colorCli->alternateOver('OMDbAPI Found ').$this->colorCli->headerOver($ret['title']);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
@@ -1061,7 +1067,7 @@ class Movie
|
||||
if ($imdbID !== false) {
|
||||
$this->service = $service;
|
||||
if ($this->echooutput && $this->service !== '' && Utility::isCLI()) {
|
||||
ColorCLI::headerOver($service.' found IMDBid: ').ColorCLI::primary('tt'.$imdbID);
|
||||
$this->colorCli->headerOver($service.' found IMDBid: ').$this->colorCli->primary('tt'.$imdbID);
|
||||
}
|
||||
|
||||
$movieInfoId = MovieInfo::query()->where('imdbid', $imdbID)->first(['id']);
|
||||
@@ -1126,7 +1132,7 @@ class Movie
|
||||
|
||||
if ($movieCount > 0) {
|
||||
if ($this->echooutput && $movieCount > 1) {
|
||||
ColorCLI::header('Processing '.$movieCount.' movie releases.');
|
||||
$this->colorCli->header('Processing '.$movieCount.' movie releases.');
|
||||
}
|
||||
|
||||
// Loop over releases.
|
||||
@@ -1145,7 +1151,7 @@ class Movie
|
||||
}
|
||||
|
||||
if ($this->echooutput && Utility::isCLI()) {
|
||||
ColorCLI::primaryOver('Looking up: ').ColorCLI::headerOver($movieName);
|
||||
$this->colorCli->primaryOver('Looking up: ').$this->colorCli->headerOver($movieName);
|
||||
}
|
||||
|
||||
$movieUpdated = false;
|
||||
|
||||
+12
-5
@@ -69,6 +69,11 @@ class Music
|
||||
*/
|
||||
public $failCache;
|
||||
|
||||
/**
|
||||
* @var \Blacklight\ColorCLI
|
||||
*/
|
||||
protected $colorCli;
|
||||
|
||||
/**
|
||||
* @param array $options Class instances/ echo to CLI.
|
||||
* @throws \Exception
|
||||
@@ -83,6 +88,8 @@ class Music
|
||||
|
||||
$this->echooutput = ($options['Echo'] && config('nntmux.echocli'));
|
||||
|
||||
$this->colorCli = new ColorCLI();
|
||||
|
||||
$this->pubkey = Settings::settingValue('APIs..amazonpubkey');
|
||||
$this->privkey = Settings::settingValue('APIs..amazonprivkey');
|
||||
$this->asstag = Settings::settingValue('APIs..amazonassociatetag');
|
||||
@@ -498,7 +505,7 @@ class Music
|
||||
|
||||
if ($musicId) {
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::header(PHP_EOL.'Added/updated album: '.
|
||||
$this->colorCli->header(PHP_EOL.'Added/updated album: '.
|
||||
' Artist: '.
|
||||
$mus['artist'].
|
||||
' Title: '.
|
||||
@@ -516,7 +523,7 @@ class Music
|
||||
$artist = 'Artist: '.$mus['artist'].', Album: ';
|
||||
}
|
||||
|
||||
ColorCLI::headerOver('Nothing to update: '.
|
||||
$this->colorCli->headerOver('Nothing to update: '.
|
||||
$artist.
|
||||
$mus['title'].
|
||||
' ('.
|
||||
@@ -651,7 +658,7 @@ class Music
|
||||
$newname = $album['name'].' ('.$album['year'].')';
|
||||
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::headerOver('Looking up: '.$newname);
|
||||
$this->colorCli->headerOver('Looking up: '.$newname);
|
||||
}
|
||||
|
||||
// Do a local lookup first
|
||||
@@ -660,7 +667,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) {
|
||||
ColorCLI::headerOver('Cached previous failure. Skipping.');
|
||||
$this->colorCli->headerOver('Cached previous failure. Skipping.');
|
||||
}
|
||||
$albumId = -2;
|
||||
} elseif ($musicCheck === null && $local === false) {
|
||||
@@ -692,7 +699,7 @@ class Music
|
||||
echo PHP_EOL;
|
||||
}
|
||||
} elseif ($this->echooutput) {
|
||||
ColorCLI::header('No music releases to process.');
|
||||
$this->colorCli->header('No music releases to process.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+15
-14
@@ -13,9 +13,9 @@ use App\Extensions\util\Yenc;
|
||||
class NNTP extends \Net_NNTP_Client
|
||||
{
|
||||
/**
|
||||
* @var
|
||||
* @var \Blacklight\ColorCLI
|
||||
*/
|
||||
protected $_colorCLI;
|
||||
protected $colorCli;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
@@ -89,6 +89,7 @@ class NNTP extends \Net_NNTP_Client
|
||||
$this->_echo = ($options['Echo'] && config('nntmux.echocli'));
|
||||
|
||||
$this->_nntpRetries = Settings::settingValue('..nntpretries') !== '' ? (int) Settings::settingValue('..nntpretries') : 0 + 1;
|
||||
$this->colorCli = new ColorCLI();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,7 +182,7 @@ class NNTP extends \Net_NNTP_Client
|
||||
': '.
|
||||
$cError;
|
||||
|
||||
return $this->throwError(ColorCLI::error($message));
|
||||
return $this->throwError($this->colorCli->error($message));
|
||||
}
|
||||
|
||||
// If we are connected, try to authenticate.
|
||||
@@ -220,7 +221,7 @@ class NNTP extends \Net_NNTP_Client
|
||||
$userName.
|
||||
' ('.$aError.')';
|
||||
|
||||
return $this->throwError(ColorCLI::error($message));
|
||||
return $this->throwError($this->colorCli->error($message));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -245,7 +246,7 @@ class NNTP 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(ColorCLI::error($message));
|
||||
return $this->throwError($this->colorCli->error($message));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -569,7 +570,7 @@ class NNTP 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(ColorCLI::error($message));
|
||||
return $this->throwError($this->colorCli->error($message));
|
||||
}
|
||||
|
||||
if ($aConnected === true) {
|
||||
@@ -741,7 +742,7 @@ class NNTP extends \Net_NNTP_Client
|
||||
if (! $this->_postingAllowed) {
|
||||
$message = 'You do not have the right to post articles on server '.$this->_currentServer;
|
||||
|
||||
return $this->throwError(ColorCLI::error($message));
|
||||
return $this->throwError($this->colorCli->error($message));
|
||||
}
|
||||
|
||||
$connected = $this->_checkConnection();
|
||||
@@ -753,13 +754,13 @@ class NNTP extends \Net_NNTP_Client
|
||||
if (\strlen($subject) > 510) {
|
||||
$message = 'Max length of subject is 510 chars.';
|
||||
|
||||
return $this->throwError(ColorCLI::error($message));
|
||||
return $this->throwError($this->colorCli->error($message));
|
||||
}
|
||||
|
||||
if (\strlen($from) > 510) {
|
||||
$message = 'Max length of from is 510 chars.';
|
||||
|
||||
return $this->throwError(ColorCLI::error($message));
|
||||
return $this->throwError($this->colorCli->error($message));
|
||||
}
|
||||
|
||||
// Check if the group is string or array.
|
||||
@@ -813,7 +814,7 @@ class NNTP extends \Net_NNTP_Client
|
||||
$message = "Code {$data->code}: {$data->message}\nSkipping group: {$group}";
|
||||
|
||||
if ($this->_echo) {
|
||||
ColorCLI::error($message);
|
||||
$this->colorCli->error($message);
|
||||
}
|
||||
$nntp->doQuit();
|
||||
}
|
||||
@@ -985,7 +986,7 @@ class NNTP extends \Net_NNTP_Client
|
||||
if (! empty($deComp)) {
|
||||
$bytesReceived = \strlen($data);
|
||||
if ($this->_echo && $bytesReceived > 10240) {
|
||||
ColorCLI::primaryOver(
|
||||
$this->colorCli->primaryOver(
|
||||
'Received '.round($bytesReceived / 1024).
|
||||
'KB from group ('.$this->group().').'
|
||||
);
|
||||
@@ -998,7 +999,7 @@ class NNTP extends \Net_NNTP_Client
|
||||
}
|
||||
$message = 'Decompression of OVER headers failed.';
|
||||
|
||||
$message = $this->throwError(ColorCLI::error($message), 1000);
|
||||
$message = $this->throwError($this->colorCli->error($message), 1000);
|
||||
|
||||
return $message;
|
||||
}
|
||||
@@ -1018,7 +1019,7 @@ class NNTP extends \Net_NNTP_Client
|
||||
if (empty($buffer)) {
|
||||
$message = 'Error fetching data from usenet server while downloading OVER headers.';
|
||||
|
||||
$message = $this->throwError(ColorCLI::error($message), 1000);
|
||||
$message = $this->throwError($this->colorCli->error($message), 1000);
|
||||
|
||||
return $message;
|
||||
}
|
||||
@@ -1035,7 +1036,7 @@ class NNTP extends \Net_NNTP_Client
|
||||
}
|
||||
|
||||
$message = 'Unspecified error while downloading OVER headers.';
|
||||
$message = $this->throwError(ColorCLI::error($message), 1000);
|
||||
$message = $this->throwError($this->colorCli->error($message), 1000);
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
@@ -77,6 +77,11 @@ class NZBImport
|
||||
*/
|
||||
protected $nzbGuid;
|
||||
|
||||
/**
|
||||
* @var \Blacklight\ColorCLI
|
||||
*/
|
||||
protected $colorCli;
|
||||
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
@@ -102,6 +107,7 @@ class NZBImport
|
||||
$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->colorCli = new ColorCLI();
|
||||
|
||||
$this->crossPostt = Settings::settingValue('..crossposttime') !== '' ? Settings::settingValue('..crossposttime') : 2;
|
||||
$this->browser = $options['Browser'];
|
||||
@@ -458,7 +464,7 @@ class NZBImport
|
||||
if ($this->browser) {
|
||||
$this->retVal .= $message.'<br />';
|
||||
} elseif ($this->echoCLI) {
|
||||
ColorCLI::notice($message);
|
||||
$this->colorCli->notice($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+66
-59
@@ -136,6 +136,11 @@ class NameFixer
|
||||
*/
|
||||
public $sphinx;
|
||||
|
||||
/**
|
||||
* @var \Blacklight\ColorCLI
|
||||
*/
|
||||
protected $colorCli;
|
||||
|
||||
/**
|
||||
* @param array $options Class instances / Echo to cli.
|
||||
* @throws \Exception
|
||||
@@ -166,6 +171,7 @@ class NameFixer
|
||||
$this->category = ($options['Categorize'] instanceof Categorize ? $options['Categorize'] : new Categorize(['Settings' => null]));
|
||||
$this->text = ($options['Misc'] instanceof Utility ? $options['Misc'] : new Utility());
|
||||
$this->sphinx = ($options['SphinxSearch'] instanceof SphinxSearch ? $options['SphinxSearch'] : new SphinxSearch());
|
||||
$this->colorCli = new ColorCLI();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -219,7 +225,7 @@ class NameFixer
|
||||
|
||||
if ($total > 0) {
|
||||
$this->_totalReleases = $total;
|
||||
ColorCLI::primary(number_format($total).' releases to process.');
|
||||
$this->colorCli->primary(number_format($total).' releases to process.');
|
||||
|
||||
foreach ($releases as $rel) {
|
||||
$releaseRow = DB::select(
|
||||
@@ -248,7 +254,7 @@ class NameFixer
|
||||
}
|
||||
$this->_echoFoundCount($echo, ' NFO\'s');
|
||||
} else {
|
||||
ColorCLI::info('Nothing to fix.');
|
||||
$this->colorCli->info('Nothing to fix.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,7 +309,7 @@ class NameFixer
|
||||
$total = \count($releases);
|
||||
if ($total > 0) {
|
||||
$this->_totalReleases = $total;
|
||||
ColorCLI::primary(number_format($total).' file names to process.');
|
||||
$this->colorCli->primary(number_format($total).' file names to process.');
|
||||
|
||||
foreach ($releases as $release) {
|
||||
$this->reset();
|
||||
@@ -314,7 +320,7 @@ class NameFixer
|
||||
|
||||
$this->_echoFoundCount($echo, ' files');
|
||||
} else {
|
||||
ColorCLI::info('Nothing to fix.');
|
||||
$this->colorCli->info('Nothing to fix.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,7 +373,7 @@ class NameFixer
|
||||
$total = \count($releases);
|
||||
if ($total > 0) {
|
||||
$this->_totalReleases = $total;
|
||||
ColorCLI::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();
|
||||
@@ -377,7 +383,7 @@ class NameFixer
|
||||
}
|
||||
$this->_echoFoundCount($echo, ' files');
|
||||
} else {
|
||||
ColorCLI::info('Nothing to fix.');
|
||||
$this->colorCli->info('Nothing to fix.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -432,7 +438,7 @@ class NameFixer
|
||||
$total = \count($releases);
|
||||
if ($total > 0) {
|
||||
$this->_totalReleases = $total;
|
||||
ColorCLI::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();
|
||||
@@ -442,7 +448,7 @@ class NameFixer
|
||||
}
|
||||
$this->_echoFoundCount($echo, ' files');
|
||||
} else {
|
||||
ColorCLI::info('Nothing to fix.');
|
||||
$this->colorCli->info('Nothing to fix.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -490,7 +496,7 @@ class NameFixer
|
||||
if ($total > 0) {
|
||||
$this->_totalReleases = $total;
|
||||
|
||||
ColorCLI::primary(number_format($total).' releases to process.');
|
||||
$this->colorCli->primary(number_format($total).' releases to process.');
|
||||
$Nfo = new Nfo();
|
||||
$nzbContents = new NZBContents(
|
||||
[
|
||||
@@ -512,7 +518,7 @@ class NameFixer
|
||||
}
|
||||
$this->_echoFoundCount($echo, ' files');
|
||||
} else {
|
||||
ColorCLI::info('Nothing to fix.');
|
||||
$this->colorCli->info('Nothing to fix.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -577,7 +583,7 @@ class NameFixer
|
||||
$total = \count($releases);
|
||||
if ($total > 0) {
|
||||
$this->_totalReleases = $total;
|
||||
ColorCLI::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();
|
||||
@@ -586,7 +592,7 @@ class NameFixer
|
||||
}
|
||||
$this->_echoFoundCount($echo, ' UID\'s');
|
||||
} else {
|
||||
ColorCLI::info('Nothing to fix.');
|
||||
$this->colorCli->info('Nothing to fix.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -642,7 +648,7 @@ class NameFixer
|
||||
$total = \count($releases);
|
||||
if ($total > 0) {
|
||||
$this->_totalReleases = $total;
|
||||
ColorCLI::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();
|
||||
@@ -651,7 +657,7 @@ class NameFixer
|
||||
}
|
||||
$this->_echoFoundCount($echo, ' MediaInfo\'s');
|
||||
} else {
|
||||
ColorCLI::info('Nothing to fix.');
|
||||
$this->colorCli->info('Nothing to fix.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -715,7 +721,7 @@ class NameFixer
|
||||
$total = \count($releases);
|
||||
if ($total > 0) {
|
||||
$this->_totalReleases = $total;
|
||||
ColorCLI::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();
|
||||
@@ -724,7 +730,7 @@ class NameFixer
|
||||
}
|
||||
$this->_echoFoundCount($echo, ' hashes');
|
||||
} else {
|
||||
ColorCLI::info('Nothing to fix.');
|
||||
$this->colorCli->info('Nothing to fix.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -742,19 +748,19 @@ class NameFixer
|
||||
$queryLimit = ($limit === '') ? '' : ' LIMIT '.$limit;
|
||||
// 24 hours, other cats
|
||||
if ($time === 1 && $cats === 1) {
|
||||
ColorCLI::header($query.$this->timeother.$queryLimit.';');
|
||||
$this->colorCli->header($query.$this->timeother.$queryLimit.';');
|
||||
$releases = DB::select($query.$this->timeother.$queryLimit);
|
||||
} // 24 hours, all cats
|
||||
if ($time === 1 && $cats === 2) {
|
||||
ColorCLI::header($query.$this->timeall.$queryLimit.';');
|
||||
$this->colorCli->header($query.$this->timeall.$queryLimit.';');
|
||||
$releases = DB::select($query.$this->timeall.$queryLimit);
|
||||
} //other cats
|
||||
if ($time === 2 && $cats === 1) {
|
||||
ColorCLI::header($query.$this->fullother.$queryLimit.';');
|
||||
$this->colorCli->header($query.$this->fullother.$queryLimit.';');
|
||||
$releases = DB::select($query.$this->fullother.$queryLimit);
|
||||
} // all cats
|
||||
if ($time === 2 && $cats === 2) {
|
||||
ColorCLI::header($query.$this->fullall.$queryLimit.';');
|
||||
$this->colorCli->header($query.$this->fullall.$queryLimit.';');
|
||||
$releases = DB::select($query.$this->fullall.$queryLimit);
|
||||
}
|
||||
|
||||
@@ -770,7 +776,7 @@ class NameFixer
|
||||
protected function _echoFoundCount($echo, $type): void
|
||||
{
|
||||
if ($echo === true) {
|
||||
ColorCLI::header(
|
||||
$this->colorCli->header(
|
||||
PHP_EOL.
|
||||
number_format($this->fixed).
|
||||
' releases have had their names changed out of: '.
|
||||
@@ -778,7 +784,7 @@ class NameFixer
|
||||
$type.'.'
|
||||
);
|
||||
} else {
|
||||
ColorCLI::header(
|
||||
$this->colorCli->header(
|
||||
PHP_EOL.
|
||||
number_format($this->fixed).
|
||||
' releases could have their names changed. '.
|
||||
@@ -794,7 +800,7 @@ class NameFixer
|
||||
*/
|
||||
protected function _echoStartMessage($time, $type): void
|
||||
{
|
||||
ColorCLI::header(
|
||||
$this->colorCli->header(
|
||||
sprintf(
|
||||
'Fixing search names %s using %s.',
|
||||
($time === 1 ? 'in the past 6 hours' : 'since the beginning'),
|
||||
@@ -809,7 +815,7 @@ class NameFixer
|
||||
protected function _echoRenamed($show): void
|
||||
{
|
||||
if ($this->checked % 500 === 0 && $show === 1) {
|
||||
ColorCLI::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) {
|
||||
@@ -874,25 +880,25 @@ class NameFixer
|
||||
|
||||
echo PHP_EOL;
|
||||
|
||||
ColorCLI::headerOver('New name: ').
|
||||
ColorCLI::primary(substr($newName, 0, 299)).
|
||||
ColorCLI::headerOver('Old name: ').
|
||||
ColorCLI::primary($release->searchname).
|
||||
ColorCLI::headerOver('Use name: ').
|
||||
ColorCLI::primary($release->name).
|
||||
ColorCLI::headerOver('New cat: ').
|
||||
ColorCLI::primary($newCatName).
|
||||
ColorCLI::headerOver('Old cat: ').
|
||||
ColorCLI::primary($oldCatName).
|
||||
ColorCLI::headerOver('Group: ').
|
||||
ColorCLI::primary($groupName).
|
||||
ColorCLI::headerOver('Method: ').
|
||||
ColorCLI::primary($type.$method).
|
||||
ColorCLI::headerOver('Releases ID: ').
|
||||
ColorCLI::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)) {
|
||||
ColorCLI::headerOver('Filename: ').
|
||||
ColorCLI::primary($release->filename);
|
||||
$this->colorCli->headerOver('Filename: ').
|
||||
$this->colorCli->primary($release->filename);
|
||||
}
|
||||
|
||||
if ($type !== 'PAR2, ') {
|
||||
@@ -1018,15 +1024,16 @@ class NameFixer
|
||||
'method' => '',
|
||||
]
|
||||
): void {
|
||||
$colorCLI = new ColorCLI();
|
||||
echo PHP_EOL;
|
||||
|
||||
ColorCLI::headerOver('New name: ').ColorCLI::primaryOver($data['new_name']).
|
||||
ColorCLI::headerOver('Old name: ').ColorCLI::primaryOver($data['old_name']).
|
||||
ColorCLI::headerOver('New category: ').ColorCLI::primaryOver($data['new_category']).
|
||||
ColorCLI::headerOver('Old category: ').ColorCLI::primaryOver($data['old_category']).
|
||||
ColorCLI::headerOver('Group: ').ColorCLI::primaryOver($data['group']).
|
||||
ColorCLI::headerOver('Releases ID: ').ColorCLI::primaryOver($data['releases_id']).
|
||||
ColorCLI::headerOver('Method: ').ColorCLI::primaryOver($data['method']);
|
||||
$colorCLI->headerOver('New name: ').$colorCLI->primaryOver($data['new_name']).
|
||||
$colorCLI->headerOver('Old name: ').$colorCLI->primaryOver($data['old_name']).
|
||||
$colorCLI->headerOver('New category: ').$colorCLI->primaryOver($data['new_category']).
|
||||
$colorCLI->headerOver('Old category: ').$colorCLI->primaryOver($data['old_category']).
|
||||
$colorCLI->headerOver('Group: ').$colorCLI->primaryOver($data['group']).
|
||||
$colorCLI->headerOver('Releases ID: ').$colorCLI->primaryOver($data['releases_id']).
|
||||
$colorCLI->headerOver('Method: ').$colorCLI->primaryOver($data['method']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1127,8 +1134,8 @@ class NameFixer
|
||||
$limit = 'LIMIT 1000000';
|
||||
}
|
||||
|
||||
ColorCLI::header(PHP_EOL.'Match PreFiles '.$args[1].' Started at '.now());
|
||||
ColorCLI::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();
|
||||
@@ -1157,7 +1164,7 @@ class NameFixer
|
||||
$total = \count($query);
|
||||
|
||||
if ($total > 0) {
|
||||
ColorCLI::header(PHP_EOL.number_format($total).' releases to process.');
|
||||
$this->colorCli->header(PHP_EOL.number_format($total).' releases to process.');
|
||||
|
||||
foreach (collect($query)->chunk(100) as $chunked) {
|
||||
foreach ($chunked as $row) {
|
||||
@@ -1170,9 +1177,9 @@ class NameFixer
|
||||
}
|
||||
}
|
||||
}
|
||||
ColorCLI::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 {
|
||||
ColorCLI::info('Nothing to do.');
|
||||
$this->colorCli->info('Nothing to do.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1349,7 +1356,7 @@ class NameFixer
|
||||
if ($time === 1) {
|
||||
$te = ' in the past 3 hours';
|
||||
}
|
||||
ColorCLI::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)';
|
||||
|
||||
@@ -1367,7 +1374,7 @@ class NameFixer
|
||||
|
||||
$res = DB::select($query);
|
||||
$total = \count($res);
|
||||
ColorCLI::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, $matches)) {
|
||||
$updated += $this->matchPredbHash($matches[0], $row, $echo, $nameStatus, $show);
|
||||
@@ -1375,13 +1382,13 @@ class NameFixer
|
||||
$updated += $this->matchPredbHash($matches[0], $row, $echo, $nameStatus, $show);
|
||||
}
|
||||
if ($show === 2) {
|
||||
ColorCLI::overWritePrimary('Renamed Releases: ['.number_format($updated).'] '.$this->consoletools->percentString($checked++, $total));
|
||||
$this->colorCli->overWritePrimary('Renamed Releases: ['.number_format($updated).'] '.$this->consoletools->percentString($checked++, $total));
|
||||
}
|
||||
}
|
||||
if ($echo === 1) {
|
||||
ColorCLI::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 {
|
||||
ColorCLI::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;
|
||||
|
||||
+3
-3
@@ -268,7 +268,7 @@ class Nfo
|
||||
$nfoCount = $res->count();
|
||||
|
||||
if ($nfoCount > 0) {
|
||||
ColorCLI::primary(
|
||||
$this->colorCli->primary(
|
||||
PHP_EOL.
|
||||
($guidChar === '' ? '' : '['.$guidChar.'] ').
|
||||
($groupID === '' ? '' : '['.$groupID.'] ').
|
||||
@@ -308,7 +308,7 @@ class Nfo
|
||||
foreach ($nfoStats as $row) {
|
||||
$outString .= ', '.$row['status'].' = '.number_format($row['count']);
|
||||
}
|
||||
ColorCLI::header($outString.'.');
|
||||
$this->colorCli->header($outString.'.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,7 +370,7 @@ class Nfo
|
||||
echo PHP_EOL;
|
||||
}
|
||||
if ($ret > 0) {
|
||||
ColorCLI::primary($ret.' NFO file(s) found/processed.');
|
||||
$this->colorCli->primary($ret.' NFO file(s) found/processed.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,11 +51,17 @@ class ReleaseImage
|
||||
*/
|
||||
public $vidSavePath;
|
||||
|
||||
/**
|
||||
* @var \Blacklight\ColorCLI
|
||||
*/
|
||||
protected $colorCli;
|
||||
|
||||
/**
|
||||
* ReleaseImage constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->colorCli = new ColorCLI();
|
||||
$this->audSavePath = NN_COVERS.'audiosample'.DS;
|
||||
$this->imgSavePath = NN_COVERS.'preview'.DS;
|
||||
$this->jpgSavePath = NN_COVERS.'sample'.DS;
|
||||
@@ -74,20 +80,20 @@ class ReleaseImage
|
||||
$img = Image::make($imgLoc);
|
||||
} catch (NotFoundException $e) {
|
||||
if ($e->getCode() === 404) {
|
||||
ColorCLI::notice('Data not available on server');
|
||||
$this->colorCli->notice('Data not available on server');
|
||||
} elseif ($e->getCode() === 503) {
|
||||
ColorCLI::notice('Service unavailable');
|
||||
$this->colorCli->notice('Service unavailable');
|
||||
} else {
|
||||
ColorCLI::notice('Unable to fetch image: '.$e->getMessage());
|
||||
$this->colorCli->notice('Unable to fetch image: '.$e->getMessage());
|
||||
}
|
||||
|
||||
$img = false;
|
||||
} catch (NotReadableException $e) {
|
||||
ColorCLI::notice($e->getMessage());
|
||||
$this->colorCli->notice($e->getMessage());
|
||||
|
||||
$img = false;
|
||||
} catch (ImageException $e) {
|
||||
ColorCLI::notice('Image error: '.$e->getMessage());
|
||||
$this->colorCli->notice('Image error: '.$e->getMessage());
|
||||
|
||||
$img = false;
|
||||
}
|
||||
|
||||
@@ -97,6 +97,11 @@ class ReleaseRemover
|
||||
*/
|
||||
private $releaseImage;
|
||||
|
||||
/**
|
||||
* @var \Blacklight\ColorCLI
|
||||
*/
|
||||
protected $colorCli;
|
||||
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
@@ -120,6 +125,7 @@ class ReleaseRemover
|
||||
$this->releases = ($options['Releases'] instanceof Releases ? $options['Releases'] : new Releases(['Settings' => null]));
|
||||
$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->query = '';
|
||||
$this->error = '';
|
||||
@@ -177,8 +183,8 @@ class ReleaseRemover
|
||||
$this->deleteReleases();
|
||||
|
||||
if ($this->echoCLI) {
|
||||
ColorCLI::headerOver(($this->delete ? 'Deleted ' : 'Would have deleted ').$this->deletedCount.' release(s). This script ran for ');
|
||||
ColorCLI::header(now()->diffInSeconds($timeStart).' seconds');
|
||||
$this->colorCli->headerOver(($this->delete ? 'Deleted ' : 'Would have deleted ').$this->deletedCount.' release(s). This script ran for ');
|
||||
$this->colorCli->header(now()->diffInSeconds($timeStart).' seconds');
|
||||
}
|
||||
|
||||
return $this->browser
|
||||
@@ -219,7 +225,7 @@ class ReleaseRemover
|
||||
|
||||
if ($time === 'full') {
|
||||
if ($this->echoCLI) {
|
||||
ColorCLI::header('Removing '.($type === '' ? 'All crap releases ' : $type.' crap releases').' - no time limit.');
|
||||
$this->colorCli->header('Removing '.($type === '' ? 'All crap releases ' : $type.' crap releases').' - no time limit.');
|
||||
}
|
||||
} else {
|
||||
if (! is_numeric($time)) {
|
||||
@@ -228,7 +234,7 @@ class ReleaseRemover
|
||||
return $this->returnError();
|
||||
}
|
||||
if ($this->echoCLI) {
|
||||
ColorCLI::header('Removing '.($type === '' ? 'All crap releases ' : $type.' crap releases').' from the past '.$time.' hour(s).');
|
||||
$this->colorCli->header('Removing '.($type === '' ? 'All crap releases ' : $type.' crap releases').' from the past '.$time.' hour(s).');
|
||||
}
|
||||
$this->crapTime = ' AND r.adddate > (NOW() - INTERVAL '.$time.' HOUR)';
|
||||
}
|
||||
@@ -306,8 +312,8 @@ class ReleaseRemover
|
||||
}
|
||||
|
||||
if ($this->echoCLI) {
|
||||
ColorCLI::headerOver(($this->delete ? 'Deleted ' : 'Would have deleted ').$this->deletedCount.' release(s). This script ran for ');
|
||||
ColorCLI::header(now()->diffInSeconds($timeStart).' seconds');
|
||||
$this->colorCli->headerOver(($this->delete ? 'Deleted ' : 'Would have deleted ').$this->deletedCount.' release(s). This script ran for ');
|
||||
$this->colorCli->header(now()->diffInSeconds($timeStart).' seconds');
|
||||
}
|
||||
|
||||
return $this->browser
|
||||
@@ -776,7 +782,7 @@ class ReleaseRemover
|
||||
}
|
||||
|
||||
// Provide useful output of operations
|
||||
ColorCLI::header(
|
||||
$this->colorCli->header(
|
||||
sprintf(
|
||||
'Finding crap releases for %s: Using %s method against release %s.'.
|
||||
'%s',
|
||||
@@ -809,7 +815,7 @@ class ReleaseRemover
|
||||
$this->deleteReleases();
|
||||
}
|
||||
} else {
|
||||
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.");
|
||||
$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.");
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -878,7 +884,7 @@ class ReleaseRemover
|
||||
$ftUsing = PHP_EOL;
|
||||
|
||||
// Provide useful output of operations
|
||||
ColorCLI::header(
|
||||
$this->colorCli->header(
|
||||
sprintf(
|
||||
'Finding crap releases for %s: Using %s method against release filenames.'.PHP_EOL.
|
||||
'%s',
|
||||
@@ -1005,10 +1011,10 @@ class ReleaseRemover
|
||||
if ($this->delete) {
|
||||
$this->releases->deleteSingle(['g' => $release->guid, 'i' => $release->id], $this->nzb, $this->releaseImage);
|
||||
if ($this->echoCLI) {
|
||||
ColorCLI::primary('Deleting: '.$this->method.': '.$release->searchname);
|
||||
$this->colorCli->primary('Deleting: '.$this->method.': '.$release->searchname);
|
||||
}
|
||||
} elseif ($this->echoCLI) {
|
||||
ColorCLI::primary('Would be deleting: '.$this->method.': '.$release->searchname);
|
||||
$this->colorCli->primary('Would be deleting: '.$this->method.': '.$release->searchname);
|
||||
}
|
||||
$deletedCount++;
|
||||
}
|
||||
@@ -1225,7 +1231,7 @@ class ReleaseRemover
|
||||
}
|
||||
|
||||
// Print the query to the user, ask them if they want to continue using it.
|
||||
ColorCLI::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.'
|
||||
@@ -1234,7 +1240,7 @@ class ReleaseRemover
|
||||
// Check the users response.
|
||||
$userInput = trim(fgets(fopen('php://stdin', 'rtb')));
|
||||
if ($userInput !== 'yes') {
|
||||
ColorCLI::primary('You typed: "'.$userInput.'", the program will exit.');
|
||||
$this->colorCli->primary('You typed: "'.$userInput.'", the program will exit.');
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -1285,7 +1291,7 @@ class ReleaseRemover
|
||||
}
|
||||
|
||||
if ($this->echoCLI && $this->error !== '') {
|
||||
ColorCLI::error($this->error);
|
||||
$this->colorCli->error($this->error);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
+11
-4
@@ -30,6 +30,11 @@ class Steam
|
||||
*/
|
||||
protected $steamFront;
|
||||
|
||||
/**
|
||||
* @var \Blacklight\ColorCLI
|
||||
*/
|
||||
protected $colorCli;
|
||||
|
||||
/**
|
||||
* Steam constructor.
|
||||
*
|
||||
@@ -47,6 +52,8 @@ class Steam
|
||||
'local_lang' => 'english',
|
||||
]
|
||||
);
|
||||
|
||||
$this->colorCli = new ColorCLI();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,7 +85,7 @@ class Steam
|
||||
}
|
||||
|
||||
if ($res === false) {
|
||||
ColorCLI::notice('Steam did not return game data');
|
||||
$this->colorCli->notice('Steam did not return game data');
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -97,7 +104,7 @@ class Steam
|
||||
$bestMatch = false;
|
||||
|
||||
if (empty($searchTerm)) {
|
||||
ColorCLI::notice('Search term cannot be empty');
|
||||
$this->colorCli->notice('Search term cannot be empty');
|
||||
|
||||
return $bestMatch;
|
||||
}
|
||||
@@ -128,7 +135,7 @@ class Steam
|
||||
}
|
||||
}
|
||||
if ($bestMatch === false) {
|
||||
ColorCLI::notice('Steam search returned no valid results');
|
||||
$this->colorCli->notice('Steam search returned no valid results');
|
||||
}
|
||||
|
||||
return $bestMatch;
|
||||
@@ -148,7 +155,7 @@ class Steam
|
||||
$this->setLastUpdated();
|
||||
$fullAppArray = $this->steamFront->getFullAppList();
|
||||
$inserted = $dupe = 0;
|
||||
ColorCLI::info('Populating steam apps table');
|
||||
$this->colorCli->info('Populating steam apps table');
|
||||
foreach ($fullAppArray as $appsArray) {
|
||||
foreach ($appsArray as $appArray) {
|
||||
foreach ($appArray as $app) {
|
||||
|
||||
+8
-2
@@ -22,12 +22,18 @@ class Tmux
|
||||
*/
|
||||
public $tmux_session;
|
||||
|
||||
/**
|
||||
* @var \Blacklight\ColorCLI
|
||||
*/
|
||||
protected $colorCli;
|
||||
|
||||
/**
|
||||
* Tmux constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->pdo = DB::connection()->getPdo();
|
||||
$this->colorCli = new ColorCLI();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -530,12 +536,12 @@ class Tmux
|
||||
if ($this->isRunning() === true) {
|
||||
Settings::query()->where(['section' => 'site', 'subsection' => 'tmux', 'setting' => 'running'])->update(['value' => 0]);
|
||||
$sleep = Settings::settingValue('site.tmux.monitor_delay');
|
||||
ColorCLI::header('Stopping tmux scripts and waiting '.$sleep.' seconds for all panes to shutdown');
|
||||
$this->colorCli->header('Stopping tmux scripts and waiting '.$sleep.' seconds for all panes to shutdown');
|
||||
sleep($sleep);
|
||||
|
||||
return true;
|
||||
}
|
||||
ColorCLI::info('Tmux scripts are not running!');
|
||||
$this->colorCli->info('Tmux scripts are not running!');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
+19
-13
@@ -64,6 +64,11 @@ class XXX
|
||||
*/
|
||||
protected $cookie;
|
||||
|
||||
/**
|
||||
* @var \Blacklight\ColorCLI
|
||||
*/
|
||||
protected $colorCli;
|
||||
|
||||
/**
|
||||
* @param array $options Echo to cli / Class instances.
|
||||
*
|
||||
@@ -78,6 +83,7 @@ class XXX
|
||||
];
|
||||
$options += $defaults;
|
||||
$this->releaseImage = ($options['ReleaseImage'] instanceof ReleaseImage ? $options['ReleaseImage'] : new ReleaseImage());
|
||||
$this->colorCli = new ColorCLI();
|
||||
|
||||
$this->movieQty = Settings::settingValue('..maxxxxprocessed') !== '' ? (int) Settings::settingValue('..maxxxxprocessed') : 100;
|
||||
$this->showPasswords = (new Releases())->showPasswords();
|
||||
@@ -466,14 +472,14 @@ class XXX
|
||||
$this->whichClass = 'aebn';
|
||||
$mov = new AEBN();
|
||||
$mov->cookie = $this->cookie;
|
||||
ColorCLI::info('Checking AEBN for movie info');
|
||||
$this->colorCli->info('Checking AEBN for movie info');
|
||||
$res = $mov->processSite($movie);
|
||||
|
||||
if ($res === false) {
|
||||
$this->whichClass = 'pop';
|
||||
$mov = new Popporn();
|
||||
$mov->cookie = $this->cookie;
|
||||
ColorCLI::info('Checking PopPorn for movie info');
|
||||
$this->colorCli->info('Checking PopPorn for movie info');
|
||||
$res = $mov->processSite($movie);
|
||||
}
|
||||
|
||||
@@ -481,14 +487,14 @@ class XXX
|
||||
$this->whichClass = 'adm';
|
||||
$mov = new ADM();
|
||||
$mov->cookie = $this->cookie;
|
||||
ColorCLI::info('Checking ADM for movie info');
|
||||
$this->colorCli->info('Checking ADM for movie info');
|
||||
$res = $mov->processSite($movie);
|
||||
}
|
||||
|
||||
if ($res === false) {
|
||||
$this->whichClass = 'ade';
|
||||
$mov = new ADE();
|
||||
ColorCLI::info('Checking ADE for movie info');
|
||||
$this->colorCli->info('Checking ADE for movie info');
|
||||
$res = $mov->processSite($movie);
|
||||
}
|
||||
|
||||
@@ -496,7 +502,7 @@ class XXX
|
||||
$this->whichClass = 'hotm';
|
||||
$mov = new Hotmovies();
|
||||
$mov->cookie = $this->cookie;
|
||||
ColorCLI::info('Checking HotMovies for movie info');
|
||||
$this->colorCli->info('Checking HotMovies for movie info');
|
||||
$res = $mov->processSite($movie);
|
||||
}
|
||||
|
||||
@@ -522,7 +528,7 @@ class XXX
|
||||
default:
|
||||
$fromstr = '';
|
||||
}
|
||||
ColorCLI::primary('Fetching XXX info from: '.$fromstr);
|
||||
$this->colorCli->primary('Fetching XXX info from: '.$fromstr);
|
||||
}
|
||||
$res = $mov->getAll();
|
||||
} else {
|
||||
@@ -601,7 +607,7 @@ class XXX
|
||||
}
|
||||
|
||||
if ($this->echoOutput) {
|
||||
ColorCLI::headerOver(($xxxID !== false ? 'Added/updated XXX movie: '.ColorCLI::primary($mov['title']) : 'Nothing to update for XXX movie: '.ColorCLI::primary($mov['title'])));
|
||||
$this->colorCli->headerOver(($xxxID !== false ? 'Added/updated XXX movie: '.$this->colorCli->primary($mov['title']) : 'Nothing to update for XXX movie: '.$this->colorCli->primary($mov['title'])));
|
||||
}
|
||||
|
||||
return $xxxID;
|
||||
@@ -636,7 +642,7 @@ class XXX
|
||||
|
||||
if ($movieCount > 0) {
|
||||
if ($this->echoOutput) {
|
||||
ColorCLI::header('Processing '.$movieCount.' XXX releases.');
|
||||
$this->colorCli->header('Processing '.$movieCount.' XXX releases.');
|
||||
}
|
||||
|
||||
// Loop over releases.
|
||||
@@ -648,17 +654,17 @@ class XXX
|
||||
$check = $this->checkXXXInfoExists($this->currentTitle);
|
||||
if ($check === null) {
|
||||
if ($this->echoOutput) {
|
||||
ColorCLI::primaryOver('Looking up: ').ColorCLI::headerOver($this->currentTitle);
|
||||
$this->colorCli->primaryOver('Looking up: ').$this->colorCli->headerOver($this->currentTitle);
|
||||
}
|
||||
|
||||
ColorCLI::info('Local match not found, checking web!');
|
||||
$this->colorCli->info('Local match not found, checking web!');
|
||||
$idcheck = $this->updateXXXInfo($this->currentTitle);
|
||||
} else {
|
||||
ColorCLI::info('Local match found for XXX Movie: '.ColorCLI::headerOver($this->currentTitle));
|
||||
$this->colorCli->info('Local match found for XXX Movie: '.$this->colorCli->headerOver($this->currentTitle));
|
||||
$idcheck = (int) $check['id'];
|
||||
}
|
||||
} else {
|
||||
ColorCLI::primary('.');
|
||||
$this->colorCli->primary('.');
|
||||
}
|
||||
Release::query()
|
||||
->where('id', $arr['id'])
|
||||
@@ -666,7 +672,7 @@ class XXX
|
||||
->update(['xxxinfo_id' => $idcheck]);
|
||||
}
|
||||
} elseif ($this->echoOutput) {
|
||||
ColorCLI::header('No xxx releases to process.');
|
||||
$this->colorCli->header('No xxx releases to process.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+18
-23
@@ -54,13 +54,7 @@ class DbUpdate
|
||||
*/
|
||||
public $settings;
|
||||
|
||||
/**
|
||||
* Has the Db been backed up?
|
||||
*
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $backedUp = false;
|
||||
protected $colorCli;
|
||||
|
||||
/**
|
||||
* DbUpdate constructor.
|
||||
@@ -80,6 +74,7 @@ class DbUpdate
|
||||
$this->git = $options['git'];
|
||||
$this->log = $options['logger'];
|
||||
$this->pdo = DB::connection()->getPdo();
|
||||
$this->colorCli = new ColorCLI();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,21 +101,21 @@ class DbUpdate
|
||||
|
||||
$this->processPatches(['safe' => $options['safe']]); // Make sure we are completely up to date!
|
||||
|
||||
ColorCLI::primaryOver('Looking for new patches...');
|
||||
$this->colorCli->primaryOver('Looking for new patches...');
|
||||
$files = Utility::getDirFiles($options);
|
||||
|
||||
$count = \count($files);
|
||||
ColorCLI::header(" $count found");
|
||||
$this->colorCli->header(" $count found");
|
||||
if ($count > 0) {
|
||||
ColorCLI::header('Processing...');
|
||||
$this->colorCli->header('Processing...');
|
||||
natsort($files);
|
||||
$local = $this->isLocalDb() ? '' : 'LOCAL ';
|
||||
|
||||
foreach ($files as $file) {
|
||||
if (! preg_match($options['regex'], $file, $matches)) {
|
||||
ColorCLI::error("$file does not match the pattern {$options['regex']}. Please fix this before continuing");
|
||||
$this->colorCli->error("$file does not match the pattern {$options['regex']}. Please fix this before continuing");
|
||||
} else {
|
||||
ColorCLI::header('Processing patch file: '.$file);
|
||||
$this->colorCli->header('Processing patch file: '.$file);
|
||||
$this->splitSQL($file, ['local' => $local]);
|
||||
$current = Settings::settingValue('..sqlpatch');
|
||||
$current++;
|
||||
@@ -166,7 +161,7 @@ class DbUpdate
|
||||
if (\count($files)) {
|
||||
natsort($files);
|
||||
$local = $this->isLocalDb() ? '' : 'LOCAL ';
|
||||
ColorCLI::primary('Looking for unprocessed patches...');
|
||||
$this->colorCli->primary('Looking for unprocessed patches...');
|
||||
foreach ($files as $file) {
|
||||
$setPatch = false;
|
||||
$fp = fopen($file, 'rb');
|
||||
@@ -186,7 +181,7 @@ class DbUpdate
|
||||
throw new \RuntimeException('No patch information available, stopping!!');
|
||||
}
|
||||
if ($patch > $currentVersion) {
|
||||
ColorCLI::header('Processing patch file: '.$file);
|
||||
$this->colorCli->header('Processing patch file: '.$file);
|
||||
$this->splitSQL($file, ['local' => $local]);
|
||||
if ($setPatch) {
|
||||
Settings::query()->where('setting', '=', 'sqlpatch')->update(['value' => $patch]);
|
||||
@@ -195,12 +190,12 @@ class DbUpdate
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ColorCLI::error('Have you changed the path to the patches folder, or do you have the right permissions?');
|
||||
$this->colorCli->error('Have you changed the path to the patches folder, or do you have the right permissions?');
|
||||
exit();
|
||||
}
|
||||
|
||||
if ($patched === 0) {
|
||||
ColorCLI::info("Nothing to patch, you are already on version $currentVersion");
|
||||
$this->colorCli->info("Nothing to patch, you are already on version $currentVersion");
|
||||
}
|
||||
|
||||
return $patched;
|
||||
@@ -240,7 +235,7 @@ class DbUpdate
|
||||
|
||||
// Skip comments.
|
||||
if (preg_match('!^\s*(#|--|//)\s*(.+?)\s*$!', $line, $matches)) {
|
||||
ColorCLI::info('COMMENT: '.$matches[2]).PHP_EOL;
|
||||
$this->colorCli->info('COMMENT: '.$matches[2]).PHP_EOL;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -272,7 +267,7 @@ class DbUpdate
|
||||
|
||||
try {
|
||||
$this->pdo->exec($query);
|
||||
ColorCLI::alternateOver('SUCCESS: ').ColorCLI::primary($query);
|
||||
$this->colorCli->alternateOver('SUCCESS: ').$this->colorCli->primary($query);
|
||||
} catch (\PDOException $e) {
|
||||
// Log the problem and the query.
|
||||
file_put_contents(
|
||||
@@ -289,12 +284,12 @@ class DbUpdate
|
||||
\in_array($e->errorInfo[0], [23505, 42701, 42703, '42P07', '42P16'], false)
|
||||
) {
|
||||
if ($e->errorInfo[1] === 1060) {
|
||||
ColorCLI::warning(
|
||||
$this->colorCli->warning(
|
||||
"$query The column already exists - No need to worry \{".
|
||||
$e->errorInfo[1]."}.\n"
|
||||
);
|
||||
} else {
|
||||
ColorCLI::warning(
|
||||
$this->colorCli->warning(
|
||||
"$query Skipped - No need to worry \{".
|
||||
$e->errorInfo[1]."}.\n"
|
||||
);
|
||||
@@ -303,13 +298,13 @@ class DbUpdate
|
||||
$this->pdo->exec('SET SESSION old_alter_table = 1');
|
||||
try {
|
||||
$this->pdo->exec($query);
|
||||
ColorCLI::alternateOver('SUCCESS: ').ColorCLI::primary($query);
|
||||
$this->colorCli->alternateOver('SUCCESS: ').$this->colorCli->primary($query);
|
||||
} catch (\PDOException $e) {
|
||||
ColorCLI::error("$query Failed {".$e->errorInfo[1].'}'.$e->errorInfo[2]);
|
||||
$this->colorCli->error("$query Failed {".$e->errorInfo[1].'}'.$e->errorInfo[2]);
|
||||
exit();
|
||||
}
|
||||
} else {
|
||||
ColorCLI::error("$query Failed \{".$e->errorInfo[1].'}'.$e->errorInfo[2]);
|
||||
$this->colorCli->error("$query Failed \{".$e->errorInfo[1].'}'.$e->errorInfo[2]);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,11 @@ class AniDB
|
||||
*/
|
||||
private $updateInterval;
|
||||
|
||||
/**
|
||||
* @var \Blacklight\ColorCLI
|
||||
*/
|
||||
protected $colorCli;
|
||||
|
||||
/**
|
||||
* @param array $options Class instances / Echo to cli.
|
||||
*
|
||||
@@ -64,6 +69,7 @@ class AniDB
|
||||
$options += $defaults;
|
||||
|
||||
$this->echooutput = ($options['Echo'] && config('nntmux.echocli'));
|
||||
$this->colorCli = new ColorCLI();
|
||||
|
||||
$anidbupdint = Settings::settingValue('APIs.AniDB.max_update_frequency');
|
||||
$lastupdated = Settings::settingValue('APIs.AniDB.last_full_update');
|
||||
@@ -257,7 +263,7 @@ class AniDB
|
||||
if ($check === false) {
|
||||
AnidbTitle::insertIgnore(['anidbid' => $id, 'type' => $type, 'lang' => $lang, 'title' => $title]);
|
||||
} else {
|
||||
ColorCLI::warning("Duplicate: $id");
|
||||
$this->colorCli->warning("Duplicate: $id");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -327,7 +333,7 @@ class AniDB
|
||||
|
||||
if ($current->diff($lastUpdate)->format('%d') > $this->updateInterval) {
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::header('Updating anime titles by grabbing full data AniDB dump.');
|
||||
$this->colorCli->header('Updating anime titles by grabbing full data AniDB dump.');
|
||||
}
|
||||
|
||||
$animetitles = new \SimpleXMLElement('compress.zlib://http://anidb.net/api/anime-titles.xml.gz', null, true);
|
||||
@@ -339,7 +345,7 @@ class AniDB
|
||||
if ($animetitles instanceof \Traversable) {
|
||||
$count = $animetitles->count();
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::header(
|
||||
$this->colorCli->header(
|
||||
'Total of '.number_format($count).' titles to add.'.PHP_EOL
|
||||
);
|
||||
}
|
||||
@@ -354,7 +360,7 @@ class AniDB
|
||||
(string) $xmlAttribs->lang,
|
||||
(string) $title[0]
|
||||
);
|
||||
ColorCLI::primary(
|
||||
$this->colorCli->primary(
|
||||
sprintf(
|
||||
'Inserting: %d, %s, %s, %s',
|
||||
$anime['aid'],
|
||||
@@ -368,11 +374,11 @@ class AniDB
|
||||
}
|
||||
} else {
|
||||
echo PHP_EOL.
|
||||
ColorCLI::error('Error retrieving XML data from AniDB. Please try again later.').
|
||||
$this->colorCli->error('Error retrieving XML data from AniDB. Please try again later.').
|
||||
PHP_EOL;
|
||||
}
|
||||
} else {
|
||||
ColorCLI::info(
|
||||
$this->colorCli->info(
|
||||
'AniDB has been updated within the past '.$this->updateInterval.' days. '.
|
||||
'Either set this value lower in Site Edit (at your own risk of being banned) or try again later.'
|
||||
);
|
||||
@@ -399,14 +405,14 @@ class AniDB
|
||||
$AniDBAPIArray = $this->getAniDbAPI($anidb['anidbid']);
|
||||
|
||||
if ($this->banned === true) {
|
||||
ColorCLI::error(
|
||||
$this->colorCli->error(
|
||||
'AniDB Banned, import will fail, please wait 24 hours before retrying.'
|
||||
);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($AniDBAPIArray === false && $this->echooutput) {
|
||||
ColorCLI::info(
|
||||
$this->colorCli->info(
|
||||
'Anime ID: '.$anidb['anidbid'].' not available for update yet.'
|
||||
);
|
||||
} else {
|
||||
@@ -418,14 +424,14 @@ class AniDB
|
||||
$AniDBAPIArray = $this->getAniDbAPI($anidbId);
|
||||
|
||||
if ($this->banned === true) {
|
||||
ColorCLI::error(
|
||||
$this->colorCli->error(
|
||||
'AniDB Banned, import will fail, please wait 24 hours before retrying.'
|
||||
);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($AniDBAPIArray === false && $this->echooutput) {
|
||||
ColorCLI::info(
|
||||
$this->colorCli->info(
|
||||
'Anime ID: '.$anidbId.' not available for update yet.'
|
||||
);
|
||||
} else {
|
||||
|
||||
@@ -28,7 +28,7 @@ class Forking extends \fork_daemon
|
||||
/**
|
||||
* @var \Blacklight\ColorCLI
|
||||
*/
|
||||
public $_colorCLI;
|
||||
public $colorCli;
|
||||
|
||||
/**
|
||||
* @var int The type of output
|
||||
@@ -126,7 +126,7 @@ class Forking extends \fork_daemon
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->_colorCLI = new ColorCLI();
|
||||
$this->colorCli = new ColorCLI();
|
||||
|
||||
$this->register_logging(
|
||||
[0 => $this, 1 => 'logger'],
|
||||
@@ -211,7 +211,7 @@ class Forking extends \fork_daemon
|
||||
$this->processEndWork();
|
||||
|
||||
if (config('nntmux.echocli')) {
|
||||
ColorCLI::header(
|
||||
$this->colorCli->header(
|
||||
'Multi-processing for '.$this->workType.' finished in '.(microtime(true) - $startTime).
|
||||
' seconds at '.date(DATE_RFC2822).'.'.PHP_EOL
|
||||
);
|
||||
@@ -303,7 +303,7 @@ class Forking extends \fork_daemon
|
||||
$this->_workCount = \count($this->work);
|
||||
if ($this->_workCount > 0) {
|
||||
if (config('nntmux.echocli') === true) {
|
||||
ColorCLI::header(
|
||||
$this->colorCli->header(
|
||||
'Multi-processing started at '.date(DATE_RFC2822).' for '.$this->workType.' with '.$this->_workCount.
|
||||
' job(s) to do using a max of '.$this->maxProcesses.' child process(es).'
|
||||
);
|
||||
@@ -313,7 +313,7 @@ class Forking extends \fork_daemon
|
||||
$this->process_work(true);
|
||||
} else {
|
||||
if (config('nntmux.echocli') === true) {
|
||||
ColorCLI::header('No work to do!');
|
||||
$this->colorCli->header('No work to do!');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1101,7 +1101,7 @@ class Forking extends \fork_daemon
|
||||
public function childExit($pid, $identifier = '')
|
||||
{
|
||||
if (config('nntmux.echocli')) {
|
||||
ColorCLI::header(
|
||||
$this->colorCli->header(
|
||||
'Process ID #'.$pid.' has completed.'.PHP_EOL.
|
||||
'There are '.($this->forked_children_count - 1).' process(es) still active with '.
|
||||
(--$this->_workCount).' job(s) left in the queue.'.PHP_EOL
|
||||
|
||||
@@ -63,12 +63,12 @@ class ForkingImportNZB extends Forking
|
||||
$this->_workCount = \count($directories);
|
||||
|
||||
if ((int) $this->_workCount === 0) {
|
||||
ColorCLI::error('No sub-folders were found in your specified folder ('.$folder.').');
|
||||
$this->colorCli->error('No sub-folders were found in your specified folder ('.$folder.').');
|
||||
exit();
|
||||
}
|
||||
|
||||
if (config('nntmux.echocli')) {
|
||||
ColorCLI::header(
|
||||
$this->colorCli->header(
|
||||
'Multi-processing started at '.date(DATE_RFC2822).' with '.$this->_workCount.
|
||||
' job(s) to do using a max of '.$maxProcesses.' child process(es).'
|
||||
);
|
||||
@@ -86,7 +86,7 @@ class ForkingImportNZB extends Forking
|
||||
$this->process_work(true);
|
||||
|
||||
if (config('nntmux.echocli')) {
|
||||
ColorCLI::header(
|
||||
$this->colorCli->header(
|
||||
'Multi-processing for import finished in '.(microtime(true) - $startTime).
|
||||
' seconds at '.date(DATE_RFC2822).'.'.PHP_EOL
|
||||
);
|
||||
|
||||
@@ -111,6 +111,11 @@ class ProcessReleases
|
||||
*/
|
||||
private $collectionTimeout;
|
||||
|
||||
/**
|
||||
* @var \Blacklight\ColorCLI
|
||||
*/
|
||||
protected $colorCli;
|
||||
|
||||
/**
|
||||
* @param array $options Class instances / Echo to cli ?
|
||||
*
|
||||
@@ -138,6 +143,7 @@ class ProcessReleases
|
||||
$this->releaseCleaning = ($options['ReleaseCleaning'] instanceof ReleaseCleaning ? $options['ReleaseCleaning'] : new ReleaseCleaning());
|
||||
$this->releases = ($options['Releases'] instanceof Releases ? $options['Releases'] : new Releases(['Groups' => null]));
|
||||
$this->releaseImage = ($options['ReleaseImage'] instanceof ReleaseImage ? $options['ReleaseImage'] : new ReleaseImage());
|
||||
$this->colorCli = new ColorCLI();
|
||||
|
||||
$dummy = Settings::settingValue('..delaytime');
|
||||
$this->collectionDelayTime = ($dummy !== '' ? (int) $dummy : 2);
|
||||
@@ -149,7 +155,7 @@ class ProcessReleases
|
||||
$this->completion = ($dummy !== '' ? (int) $dummy : 0);
|
||||
if ($this->completion > 100) {
|
||||
$this->completion = 100;
|
||||
ColorCLI::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');
|
||||
}
|
||||
@@ -179,12 +185,12 @@ class ProcessReleases
|
||||
}
|
||||
|
||||
if ($this->echoCLI) {
|
||||
ColorCLI::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) {
|
||||
ColorCLI::error('Bad or missing nzb directory - '.Settings::settingValue('..nzbpath'));
|
||||
$this->colorCli->error('Bad or missing nzb directory - '.Settings::settingValue('..nzbpath'));
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -288,7 +294,7 @@ class ProcessReleases
|
||||
$this->initiateTableNames($groupID);
|
||||
|
||||
if ($this->echoCLI) {
|
||||
ColorCLI::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.' ' : ' ');
|
||||
@@ -314,7 +320,7 @@ class ProcessReleases
|
||||
)
|
||||
);
|
||||
|
||||
ColorCLI::primary(
|
||||
$this->colorCli->primary(
|
||||
($count === null ? 0 : $count->complete).' collections were found to be complete. Time: '.
|
||||
now()->diffInSeconds($startTime).' seconds'
|
||||
);
|
||||
@@ -332,7 +338,7 @@ class ProcessReleases
|
||||
$this->initiateTableNames($groupID);
|
||||
|
||||
if ($this->echoCLI) {
|
||||
ColorCLI::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.
|
||||
$checked = DB::update(
|
||||
@@ -356,10 +362,10 @@ class ProcessReleases
|
||||
)
|
||||
);
|
||||
if ($checked > 0 && $this->echoCLI) {
|
||||
ColorCLI::primary(
|
||||
$this->colorCli->primary(
|
||||
$checked.' collections set to filecheck = 3(size calculated)'
|
||||
);
|
||||
ColorCLI::primary(now()->diffInSeconds($startTime).' seconds');
|
||||
$this->colorCli->primary(now()->diffInSeconds($startTime).' seconds');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,7 +381,7 @@ class ProcessReleases
|
||||
$this->initiateTableNames($groupID);
|
||||
|
||||
if ($this->echoCLI) {
|
||||
ColorCLI::header(
|
||||
$this->colorCli->header(
|
||||
'Process Releases -> Delete collections smaller/larger than minimum size/file count from group/site setting.'
|
||||
);
|
||||
}
|
||||
@@ -483,7 +489,7 @@ class ProcessReleases
|
||||
}
|
||||
|
||||
if ($this->echoCLI) {
|
||||
ColorCLI::primary(
|
||||
$this->colorCli->primary(
|
||||
'Deleted '.($minSizeDeleted + $maxSizeDeleted + $minFilesDeleted).' collections: '.PHP_EOL.
|
||||
$minSizeDeleted.' smaller than, '.
|
||||
$maxSizeDeleted.' bigger than, '.
|
||||
@@ -528,7 +534,7 @@ class ProcessReleases
|
||||
$returnCount = $duplicate = 0;
|
||||
|
||||
if ($this->echoCLI) {
|
||||
ColorCLI::header('Process Releases -> Create releases from complete collections.');
|
||||
$this->colorCli->header('Process Releases -> Create releases from complete collections.');
|
||||
}
|
||||
|
||||
$collections = DB::select(
|
||||
@@ -548,7 +554,7 @@ class ProcessReleases
|
||||
);
|
||||
|
||||
if ($this->echoCLI && \count($collections) > 0) {
|
||||
ColorCLI::primary(\count($collections).' Collections ready to be converted to releases.');
|
||||
$this->colorCli->primary(\count($collections).' Collections ready to be converted to releases.');
|
||||
}
|
||||
|
||||
foreach ($collections as $collection) {
|
||||
@@ -697,7 +703,7 @@ class ProcessReleases
|
||||
}
|
||||
|
||||
if ($this->echoCLI) {
|
||||
ColorCLI::primary(
|
||||
$this->colorCli->primary(
|
||||
PHP_EOL.
|
||||
number_format($returnCount).
|
||||
' Releases added and '.
|
||||
@@ -724,7 +730,7 @@ class ProcessReleases
|
||||
$this->formFromNamesQuery();
|
||||
|
||||
if ($this->echoCLI) {
|
||||
ColorCLI::header('Process Releases -> Create the NZB, delete collections/binaries/parts.');
|
||||
$this->colorCli->header('Process Releases -> Create the NZB, delete collections/binaries/parts.');
|
||||
}
|
||||
|
||||
$releases = DB::select(
|
||||
@@ -752,7 +758,7 @@ class ProcessReleases
|
||||
if ($this->nzb->writeNzbForReleaseId($release->id, $release->guid, $release->name, $release->title) === true) {
|
||||
$nzbCount++;
|
||||
if ($this->echoCLI) {
|
||||
ColorCLI::primaryOver('Creating NZBs and deleting Collections: '.$nzbCount.'/'.$total);
|
||||
$this->colorCli->primaryOver('Creating NZBs and deleting Collections: '.$nzbCount.'/'.$total);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -761,7 +767,7 @@ class ProcessReleases
|
||||
$totalTime = now()->diffInSeconds($startTime);
|
||||
|
||||
if ($this->echoCLI) {
|
||||
ColorCLI::primary(
|
||||
$this->colorCli->primary(
|
||||
number_format($nzbCount).' NZBs created/Collections deleted in '.
|
||||
$totalTime.' seconds.'.PHP_EOL.
|
||||
'Total time: '.$totalTime.' seconds'
|
||||
@@ -784,7 +790,7 @@ class ProcessReleases
|
||||
{
|
||||
$startTime = now();
|
||||
if ($this->echoCLI) {
|
||||
ColorCLI::header('Process Releases -> Categorize releases.');
|
||||
$this->colorCli->header('Process Releases -> Categorize releases.');
|
||||
}
|
||||
switch ((int) $categorize) {
|
||||
case 2:
|
||||
@@ -804,7 +810,7 @@ class ProcessReleases
|
||||
);
|
||||
|
||||
if ($this->echoCLI) {
|
||||
ColorCLI::primary(now()->diffInSeconds($startTime).' seconds');
|
||||
$this->colorCli->primary(now()->diffInSeconds($startTime).' seconds');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -822,7 +828,7 @@ class ProcessReleases
|
||||
if ((int) $postProcess === 1) {
|
||||
(new PostProcess(['Echo' => $this->echoCLI]))->processAll($nntp);
|
||||
} elseif ($this->echoCLI) {
|
||||
ColorCLI::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.'
|
||||
);
|
||||
@@ -845,8 +851,8 @@ class ProcessReleases
|
||||
// CBP older than retention.
|
||||
if ($this->echoCLI) {
|
||||
echo
|
||||
ColorCLI::header('Process Releases -> Delete finished collections.'.PHP_EOL).
|
||||
ColorCLI::primary(sprintf(
|
||||
$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')
|
||||
));
|
||||
@@ -874,7 +880,7 @@ class ProcessReleases
|
||||
$firstQuery = $fourthQuery = now();
|
||||
|
||||
if ($this->echoCLI) {
|
||||
ColorCLI::primary(
|
||||
$this->colorCli->primary(
|
||||
'Finished deleting '.$deleted.' old collections/binaries/parts in '.
|
||||
$firstQuery->diffInSeconds($startTime).' seconds.'.PHP_EOL
|
||||
);
|
||||
@@ -886,8 +892,8 @@ class ProcessReleases
|
||||
// CBP collection orphaned with no binaries or parts.
|
||||
if ($this->echoCLI) {
|
||||
echo
|
||||
ColorCLI::header('Process Releases -> Remove CBP orphans.'.PHP_EOL).
|
||||
ColorCLI::primary('Deleting orphaned collections.');
|
||||
$this->colorCli->header('Process Releases -> Remove CBP orphans.'.PHP_EOL).
|
||||
$this->colorCli->primary('Deleting orphaned collections.');
|
||||
}
|
||||
|
||||
$deleted = 0;
|
||||
@@ -915,7 +921,7 @@ class ProcessReleases
|
||||
$secondQuery = now();
|
||||
|
||||
if ($this->echoCLI) {
|
||||
ColorCLI::primary(
|
||||
$this->colorCli->primary(
|
||||
'Finished deleting '.$deleted.' orphaned collections in '.
|
||||
$secondQuery->diffInSeconds($firstQuery).' seconds.'.PHP_EOL
|
||||
);
|
||||
@@ -924,7 +930,7 @@ class ProcessReleases
|
||||
// orphaned binaries - binaries with no parts or binaries with no collection
|
||||
// Don't delete currently inserting binaries by checking the max id.
|
||||
if ($this->echoCLI) {
|
||||
ColorCLI::primary('Deleting orphaned binaries/parts with no collection.');
|
||||
$this->colorCli->primary('Deleting orphaned binaries/parts with no collection.');
|
||||
}
|
||||
|
||||
$deleted = 0;
|
||||
@@ -952,7 +958,7 @@ class ProcessReleases
|
||||
$thirdQuery = now();
|
||||
|
||||
if ($this->echoCLI) {
|
||||
ColorCLI::primary(
|
||||
$this->colorCli->primary(
|
||||
'Finished deleting '.$deleted.' binaries with no collections or parts in '.
|
||||
$thirdQuery->diffInSeconds($secondQuery).' seconds.'
|
||||
);
|
||||
@@ -961,7 +967,7 @@ class ProcessReleases
|
||||
// orphaned parts - parts with no binary
|
||||
// Don't delete currently inserting parts by checking the max id.
|
||||
if ($this->echoCLI) {
|
||||
ColorCLI::primary('Deleting orphaned parts with no binaries.');
|
||||
$this->colorCli->primary('Deleting orphaned parts with no binaries.');
|
||||
}
|
||||
$deleted = 0;
|
||||
$deleteQuery = DB::transaction(function () {
|
||||
@@ -988,7 +994,7 @@ class ProcessReleases
|
||||
$fourthQuery = now();
|
||||
|
||||
if ($this->echoCLI) {
|
||||
ColorCLI::primary(
|
||||
$this->colorCli->primary(
|
||||
'Finished deleting '.$deleted.' parts with no binaries in '.
|
||||
$fourthQuery->diffInSeconds($thirdQuery).' seconds.'.PHP_EOL
|
||||
);
|
||||
@@ -996,7 +1002,7 @@ class ProcessReleases
|
||||
} // done cleaning up Binaries/Parts orphans
|
||||
|
||||
if ($this->echoCLI) {
|
||||
ColorCLI::primary(
|
||||
$this->colorCli->primary(
|
||||
'Deleting collections that were missed after NZB creation.'
|
||||
);
|
||||
}
|
||||
@@ -1032,7 +1038,7 @@ class ProcessReleases
|
||||
$deletedCount += $deleted;
|
||||
|
||||
if ($this->echoCLI) {
|
||||
ColorCLI::primary(
|
||||
$this->colorCli->primary(
|
||||
'Finished deleting '.$deleted.' collections missed after NZB creation in '.
|
||||
now()->diffInSeconds($fourthQuery).' seconds.'.PHP_EOL.
|
||||
'Removed '.
|
||||
@@ -1058,7 +1064,7 @@ class ProcessReleases
|
||||
$minSizeDeleted = $maxSizeDeleted = $minFilesDeleted = 0;
|
||||
|
||||
if ($this->echoCLI) {
|
||||
ColorCLI::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.');
|
||||
}
|
||||
|
||||
$groupID === '' ? $groupIDs = Group::getActiveIDs() : $groupIDs = [['id' => $groupID]];
|
||||
@@ -1127,7 +1133,7 @@ class ProcessReleases
|
||||
}
|
||||
|
||||
if ($this->echoCLI) {
|
||||
ColorCLI::primary(
|
||||
$this->colorCli->primary(
|
||||
'Deleted '.($minSizeDeleted + $maxSizeDeleted + $minFilesDeleted).
|
||||
' releases: '.PHP_EOL.
|
||||
$minSizeDeleted.' smaller than, '.$maxSizeDeleted.' bigger than, '.$minFilesDeleted.
|
||||
@@ -1153,7 +1159,7 @@ class ProcessReleases
|
||||
|
||||
// Delete old releases and finished collections.
|
||||
if ($this->echoCLI) {
|
||||
ColorCLI::header('Process Releases -> Delete old releases and passworded releases.');
|
||||
$this->colorCli->header('Process Releases -> Delete old releases and passworded releases.');
|
||||
}
|
||||
|
||||
// Releases past retention.
|
||||
@@ -1331,7 +1337,7 @@ class ProcessReleases
|
||||
}
|
||||
|
||||
if ($this->echoCLI) {
|
||||
ColorCLI::primary(
|
||||
$this->colorCli->primary(
|
||||
'Removed releases: '.
|
||||
number_format($retentionDeleted).
|
||||
' past retention, '.
|
||||
@@ -1362,7 +1368,7 @@ class ProcessReleases
|
||||
$categoryMinSizeDeleted
|
||||
);
|
||||
if ($totalDeleted > 0) {
|
||||
ColorCLI::primary(
|
||||
$this->colorCli->primary(
|
||||
'Removed '.number_format($totalDeleted).' releases in '.
|
||||
now()->diffInSeconds($startTime).' seconds'
|
||||
);
|
||||
@@ -1654,7 +1660,7 @@ class ProcessReleases
|
||||
}, 3);
|
||||
|
||||
if ($this->echoCLI && $obj > 0) {
|
||||
ColorCLI::primary('Deleted '.$obj.' broken/stuck collections.');
|
||||
$this->colorCli->primary('Deleted '.$obj.' broken/stuck collections.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,11 @@ class AniDB
|
||||
*/
|
||||
private $status;
|
||||
|
||||
/**
|
||||
* @var \Blacklight\ColorCLI
|
||||
*/
|
||||
protected $colorCli;
|
||||
|
||||
/**
|
||||
* @param array $options Class instances / Echo to cli.
|
||||
* @throws \Exception
|
||||
@@ -57,6 +62,7 @@ class AniDB
|
||||
$this->echooutput = ($options['Echo'] && config('nntmux.echocli'));
|
||||
$this->pdo = DB::connection()->getPdo();
|
||||
$this->padb = new PaDb(['Echo' => $options['Echo']]);
|
||||
$this->colorCli = new ColorCLI();
|
||||
|
||||
$qty = (int) Settings::settingValue('..maxanidbprocessed');
|
||||
$this->aniqty = $qty ?? 100;
|
||||
@@ -106,7 +112,7 @@ class AniDB
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ColorCLI::info('No anidb releases to process.');
|
||||
$this->colorCli->info('No anidb releases to process.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,8 +232,8 @@ class AniDB
|
||||
$cleanArr = $this->extractTitleEpisode($release->searchname);
|
||||
|
||||
if (\is_array($cleanArr) && isset($cleanArr['title']) && is_numeric($cleanArr['epno'])) {
|
||||
ColorCLI::header(PHP_EOL.'Looking Up: ').
|
||||
ColorCLI::primary(' Title: '.$cleanArr['title'].PHP_EOL.
|
||||
$this->colorCli->header(PHP_EOL.'Looking Up: ').
|
||||
$this->colorCli->primary(' Title: '.$cleanArr['title'].PHP_EOL.
|
||||
' Episode: '.$cleanArr['epno']);
|
||||
|
||||
// get anidb number for the title of the name
|
||||
@@ -249,21 +255,21 @@ class AniDB
|
||||
$type = 'Remote';
|
||||
} else {
|
||||
echo PHP_EOL.
|
||||
ColorCLI::info('This AniDB ID was not found to be accurate locally, but has been updated too recently to check AniDB.').
|
||||
$this->colorCli->info('This AniDB ID was not found to be accurate locally, but has been updated too recently to check AniDB.').
|
||||
PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
$this->updateRelease($anidbId->anidbid, $release->id);
|
||||
|
||||
ColorCLI::headerOver('Matched '.$type.' AniDB ID: ').
|
||||
ColorCLI::primary($anidbId->anidbid).
|
||||
ColorCLI::alternateOver(' Title: ').
|
||||
ColorCLI::primary($anidbId->title).
|
||||
ColorCLI::alternateOver(' Episode #: ').
|
||||
ColorCLI::primary($cleanArr['epno']).
|
||||
ColorCLI::alternateOver(' Episode Title: ').
|
||||
ColorCLI::primary($updatedAni['episode_title']);
|
||||
$this->colorCli->headerOver('Matched '.$type.' AniDB ID: ').
|
||||
$this->colorCli->primary($anidbId->anidbid).
|
||||
$this->colorCli->alternateOver(' Title: ').
|
||||
$this->colorCli->primary($anidbId->title).
|
||||
$this->colorCli->alternateOver(' Episode #: ').
|
||||
$this->colorCli->primary($cleanArr['epno']).
|
||||
$this->colorCli->alternateOver(' Episode Title: ').
|
||||
$this->colorCli->primary($updatedAni['episode_title']);
|
||||
|
||||
$matched = true;
|
||||
} else {
|
||||
|
||||
@@ -2327,7 +2327,7 @@ class ProcessAdditional
|
||||
protected function _echo($string, $type): void
|
||||
{
|
||||
if ($this->_echoCLI) {
|
||||
ColorCLI::$type($string);
|
||||
(new ColorCLI())->$type($string);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ class TMDB extends TV
|
||||
$lookupSetting = true;
|
||||
|
||||
if ($this->echooutput && $tvcount > 0) {
|
||||
ColorCLI::header('Processing TMDB lookup for '.number_format($tvcount).' release(s).');
|
||||
$this->colorCli->header('Processing TMDB lookup for '.number_format($tvcount).' release(s).');
|
||||
}
|
||||
|
||||
if ($res instanceof \Traversable) {
|
||||
@@ -115,9 +115,9 @@ class TMDB extends TV
|
||||
if (\is_array($release) && $release['name'] !== '') {
|
||||
if (\in_array($release['cleanname'], $this->titleCache, false)) {
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::headerOver('Title: ').
|
||||
ColorCLI::warningOver($release['cleanname']).
|
||||
ColorCLI::header(' already failed lookup for this site. Skipping.');
|
||||
$this->colorCli->headerOver('Title: ').
|
||||
$this->colorCli->warningOver($release['cleanname']).
|
||||
$this->colorCli->header(' already failed lookup for this site. Skipping.');
|
||||
}
|
||||
$this->setVideoNotFound(parent::PROCESS_TRAKT, $row['id']);
|
||||
continue;
|
||||
@@ -134,9 +134,9 @@ class TMDB extends TV
|
||||
// If lookups are allowed lets try to get it.
|
||||
if ($videoId === false && $lookupSetting) {
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::primaryOver('Checking TMDB for previously failed title: ').
|
||||
ColorCLI::headerOver($release['cleanname']).
|
||||
ColorCLI::primary('.');
|
||||
$this->colorCli->primaryOver('Checking TMDB for previously failed title: ').
|
||||
$this->colorCli->headerOver($release['cleanname']).
|
||||
$this->colorCli->primary('.');
|
||||
}
|
||||
|
||||
// Get the show from TMDB
|
||||
@@ -157,9 +157,9 @@ class TMDB extends TV
|
||||
}
|
||||
} else {
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::primaryOver('Found local TMDB match for: ').
|
||||
ColorCLI::headerOver($release['cleanname']).
|
||||
ColorCLI::primary('. Attempting episode lookup!');
|
||||
$this->colorCli->primaryOver('Found local TMDB match for: ').
|
||||
$this->colorCli->headerOver($release['cleanname']).
|
||||
$this->colorCli->primary('. Attempting episode lookup!');
|
||||
}
|
||||
$tmdbid = $this->getSiteIDFromVideoID('tmdb', $videoId);
|
||||
}
|
||||
@@ -174,7 +174,7 @@ class TMDB extends TV
|
||||
if ($episodeNo === 'all') {
|
||||
// Set the video ID and leave episode 0
|
||||
$this->setVideoIdFound($videoId, $row['id'], 0);
|
||||
ColorCLI::primary('Found TMDB Match for Full Season!');
|
||||
$this->colorCli->primary('Found TMDB Match for Full Season!');
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ class TMDB extends TV
|
||||
// Mark the releases video and episode IDs
|
||||
$this->setVideoIdFound($videoId, $row['id'], $episode);
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::primary('Found TMDB Match!');
|
||||
$this->colorCli->primary('Found TMDB Match!');
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -58,6 +58,11 @@ abstract class TV extends Videos
|
||||
*/
|
||||
public $catWhere;
|
||||
|
||||
/**
|
||||
* @var \Blacklight\processing\tv\ColorCLI
|
||||
*/
|
||||
protected $colorCli;
|
||||
|
||||
/**
|
||||
* TV constructor.
|
||||
*
|
||||
@@ -67,6 +72,7 @@ abstract class TV extends Videos
|
||||
public function __construct(array $options = [])
|
||||
{
|
||||
parent::__construct($options);
|
||||
$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 = NN_COVERS.'tvshows'.DS;
|
||||
|
||||
@@ -60,7 +60,7 @@ class TVDB extends TV
|
||||
try {
|
||||
$this->token = $this->client->authentication()->login(self::TVDB_API_KEY);
|
||||
} catch (UnauthorizedException $error) {
|
||||
ColorCLI::warning('Could not reach TVDB API. Running in local mode only!');
|
||||
$this->colorCli->warning('Could not reach TVDB API. Running in local mode only!');
|
||||
$this->local = true;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ class TVDB extends TV
|
||||
$tvCount = \count($res);
|
||||
|
||||
if ($this->echooutput && $tvCount > 0) {
|
||||
ColorCLI::header('Processing TVDB lookup for '.number_format($tvCount).' release(s).');
|
||||
$this->colorCli->header('Processing TVDB lookup for '.number_format($tvCount).' release(s).');
|
||||
}
|
||||
$this->titleCache = [];
|
||||
|
||||
@@ -97,9 +97,9 @@ class TVDB extends TV
|
||||
if (\is_array($release) && $release['name'] !== '') {
|
||||
if (\in_array($release['cleanname'], $this->titleCache, false)) {
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::headerOver('Title: ').
|
||||
ColorCLI::warningOver($release['cleanname']).
|
||||
ColorCLI::header(' already failed lookup for this site. Skipping.');
|
||||
$this->colorCli->headerOver('Title: ').
|
||||
$this->colorCli->warningOver($release['cleanname']).
|
||||
$this->colorCli->header(' already failed lookup for this site. Skipping.');
|
||||
}
|
||||
$this->setVideoNotFound(parent::PROCESS_TVMAZE, $row['id']);
|
||||
continue;
|
||||
@@ -122,9 +122,9 @@ class TVDB extends TV
|
||||
|
||||
// If it doesnt exist locally and lookups are allowed lets try to get it.
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::primaryOver('Video ID for ').
|
||||
ColorCLI::headerOver($release['cleanname']).
|
||||
ColorCLI::primary(' not found in local db, checking web.');
|
||||
$this->colorCli->primaryOver('Video ID for ').
|
||||
$this->colorCli->headerOver($release['cleanname']).
|
||||
$this->colorCli->primary(' not found in local db, checking web.');
|
||||
}
|
||||
|
||||
// Check if we have a valid country and set it in the array
|
||||
@@ -143,9 +143,9 @@ class TVDB extends TV
|
||||
$tvDbId = (int) $tvdbShow['tvdb'];
|
||||
}
|
||||
} elseif ($this->echooutput && $tvDbId !== false) {
|
||||
ColorCLI::primaryOver('Video ID for ').
|
||||
ColorCLI::headerOver($release['cleanname']).
|
||||
ColorCLI::primary(' found in local db, attempting episode match.');
|
||||
$this->colorCli->primaryOver('Video ID for ').
|
||||
$this->colorCli->headerOver($release['cleanname']).
|
||||
$this->colorCli->primary(' found in local db, attempting episode match.');
|
||||
}
|
||||
|
||||
if (is_numeric($videoId) && $videoId > 0 && is_numeric($tvDbId) && $tvDbId > 0) {
|
||||
@@ -168,7 +168,7 @@ class TVDB extends TV
|
||||
if ($episodeNo === 'all') {
|
||||
// Set the video ID and leave episode 0
|
||||
$this->setVideoIdFound($videoId, $row['id'], 0);
|
||||
ColorCLI::primary('Found TVDB Match for Full Season!');
|
||||
$this->colorCli->primary('Found TVDB Match for Full Season!');
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ class TVDB extends TV
|
||||
// Mark the releases video and episode IDs
|
||||
$this->setVideoIdFound($videoId, $row['id'], $episode);
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::primary('Found TVDB Match!');
|
||||
$this->colorCli->primary('Found TVDB Match!');
|
||||
}
|
||||
} else {
|
||||
//Processing failed, set the episode ID to the next processing group
|
||||
@@ -248,7 +248,7 @@ class TVDB extends TV
|
||||
$response = $this->client->search()->searchByName($cleanName);
|
||||
} catch (ResourceNotFoundException $e) {
|
||||
$response = false;
|
||||
ColorCLI::notice('Show not found on TVDB');
|
||||
$this->colorCli->notice('Show not found on TVDB');
|
||||
}
|
||||
|
||||
if ($response === false && $country !== '') {
|
||||
@@ -256,7 +256,7 @@ class TVDB extends TV
|
||||
$response = $this->client->search()->searchByName(rtrim(str_replace($country, '', $cleanName)));
|
||||
} catch (ResourceNotFoundException $e) {
|
||||
$response = false;
|
||||
ColorCLI::notice('Show not found on TVDB');
|
||||
$this->colorCli->notice('Show not found on TVDB');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -393,13 +393,13 @@ class TVDB extends TV
|
||||
try {
|
||||
$poster = $this->client->series()->getImagesWithQuery($show->id, ['keyType' => 'poster']);
|
||||
} catch (ResourceNotFoundException $e) {
|
||||
ColorCLI::notice('Poster image not found on TVDB');
|
||||
$this->colorCli->notice('Poster image not found on TVDB');
|
||||
}
|
||||
|
||||
try {
|
||||
$fanart = $this->client->series()->getImagesWithQuery($show->id, ['keyType' => 'fanart']);
|
||||
} catch (ResourceNotFoundException $e) {
|
||||
ColorCLI::notice('Fanart image not found on TVDB');
|
||||
$this->colorCli->notice('Fanart image not found on TVDB');
|
||||
}
|
||||
|
||||
$imdbid = $this->client->series()->getById($show->id);
|
||||
|
||||
@@ -69,7 +69,7 @@ class TVMaze extends TV
|
||||
$tvCount = \count($res);
|
||||
|
||||
if ($this->echooutput && $tvCount > 0) {
|
||||
ColorCLI::header('Processing TVMaze lookup for '.number_format($tvCount).' release(s).');
|
||||
$this->colorCli->header('Processing TVMaze lookup for '.number_format($tvCount).' release(s).');
|
||||
}
|
||||
|
||||
if ($res instanceof \Traversable) {
|
||||
@@ -84,9 +84,9 @@ class TVMaze extends TV
|
||||
if (\is_array($release) && $release['name'] !== '') {
|
||||
if (\in_array($release['cleanname'], $this->titleCache, false)) {
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::headerOver('Title: ').
|
||||
ColorCLI::warningOver($release['cleanname']).
|
||||
ColorCLI::header(' already failed lookup for this site. Skipping.');
|
||||
$this->colorCli->headerOver('Title: ').
|
||||
$this->colorCli->warningOver($release['cleanname']).
|
||||
$this->colorCli->header(' already failed lookup for this site. Skipping.');
|
||||
}
|
||||
$this->setVideoNotFound(parent::PROCESS_TMDB, $row['id']);
|
||||
continue;
|
||||
@@ -102,9 +102,9 @@ class TVMaze extends TV
|
||||
if ($videoId === false && $lookupSetting) {
|
||||
// If lookups are allowed lets try to get it.
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::primaryOver('Checking TVMaze for previously failed title: ').
|
||||
ColorCLI::headerOver($release['cleanname']).
|
||||
ColorCLI::primary('.');
|
||||
$this->colorCli->primaryOver('Checking TVMaze for previously failed title: ').
|
||||
$this->colorCli->headerOver($release['cleanname']).
|
||||
$this->colorCli->primary('.');
|
||||
}
|
||||
|
||||
// Get the show from TVMaze
|
||||
@@ -128,9 +128,9 @@ class TVMaze extends TV
|
||||
}
|
||||
} else {
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::primaryOver('Found local TVMaze match for: ').
|
||||
ColorCLI::headerOver($release['cleanname']).
|
||||
ColorCLI::primary('. Attempting episode lookup!');
|
||||
$this->colorCli->primaryOver('Found local TVMaze match for: ').
|
||||
$this->colorCli->headerOver($release['cleanname']).
|
||||
$this->colorCli->primary('. Attempting episode lookup!');
|
||||
}
|
||||
$tvMazeId = $this->getSiteIDFromVideoID('tvmaze', $videoId);
|
||||
}
|
||||
@@ -145,7 +145,7 @@ class TVMaze extends TV
|
||||
if ($episodeNo === 'all') {
|
||||
// Set the video ID and leave episode 0
|
||||
$this->setVideoIdFound($videoId, $row['id'], 0);
|
||||
ColorCLI::primary('Found TVMaze Match for Full Season!');
|
||||
$this->colorCli->primary('Found TVMaze Match for Full Season!');
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ class TVMaze extends TV
|
||||
// Mark the releases video and episode IDs
|
||||
$this->setVideoIdFound($videoId, $row['id'], $episode);
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::primary('Found TVMaze Match!');
|
||||
$this->colorCli->primary('Found TVMaze Match!');
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ class TraktTv extends TV
|
||||
$tvcount = \count($res);
|
||||
|
||||
if ($this->echooutput && $tvcount > 1) {
|
||||
ColorCLI::header('Processing TRAKT lookup for '.number_format($tvcount).' release(s).');
|
||||
$this->colorCli->header('Processing TRAKT lookup for '.number_format($tvcount).' release(s).');
|
||||
}
|
||||
|
||||
if ($res instanceof \Traversable) {
|
||||
@@ -96,9 +96,9 @@ class TraktTv extends TV
|
||||
if (\is_array($release) && $release['name'] !== '') {
|
||||
if (\in_array($release['cleanname'], $this->titleCache, false)) {
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::headerOver('Title: ').
|
||||
ColorCLI::warningOver($release['cleanname']).
|
||||
ColorCLI::header(' already failed lookup for this site. Skipping.');
|
||||
$this->colorCli->headerOver('Title: ').
|
||||
$this->colorCli->warningOver($release['cleanname']).
|
||||
$this->colorCli->header(' already failed lookup for this site. Skipping.');
|
||||
}
|
||||
$this->setVideoNotFound(parent::PROCESS_IMDB, $row['id']);
|
||||
continue;
|
||||
@@ -118,9 +118,9 @@ class TraktTv extends TV
|
||||
|
||||
// If it doesn't exist locally and lookups are allowed lets try to get it.
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::primaryOver('Checking Trakt for previously failed title: ').
|
||||
ColorCLI::headerOver($release['cleanname']).
|
||||
ColorCLI::primary('.');
|
||||
$this->colorCli->primaryOver('Checking Trakt for previously failed title: ').
|
||||
$this->colorCli->headerOver($release['cleanname']).
|
||||
$this->colorCli->primary('.');
|
||||
}
|
||||
|
||||
// Get the show from TRAKT
|
||||
@@ -132,9 +132,9 @@ class TraktTv extends TV
|
||||
}
|
||||
} else {
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::primaryOver('Found local TMDB match for: ').
|
||||
ColorCLI::headerOver($release['cleanname']).
|
||||
ColorCLI::primary('. Attempting episode lookup!');
|
||||
$this->colorCli->primaryOver('Found local TMDB match for: ').
|
||||
$this->colorCli->headerOver($release['cleanname']).
|
||||
$this->colorCli->primary('. Attempting episode lookup!');
|
||||
}
|
||||
$traktid = $this->getSiteIDFromVideoID('trakt', $videoId);
|
||||
$this->localizedTZ = $this->getLocalZoneFromVideoID($videoId);
|
||||
@@ -150,7 +150,7 @@ class TraktTv extends TV
|
||||
if ($episodeNo === 'all') {
|
||||
// Set the video ID and leave episode 0
|
||||
$this->setVideoIdFound($videoId, $row['id'], 0);
|
||||
ColorCLI::primary('Found TRAKT Match for Full Season!');
|
||||
$this->colorCli->primary('Found TRAKT Match for Full Season!');
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ class TraktTv extends TV
|
||||
// Mark the releases video and episode IDs
|
||||
$this->setVideoIdFound($videoId, $row['id'], $episode);
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::primary('Found TRAKT Match!');
|
||||
$this->colorCli->primary('Found TRAKT Match!');
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ class Utility
|
||||
$message = "\nYour database is not up to date. Reported patch levels\n Db: $patch\nfile: $ver\nPlease update.\n php ".
|
||||
NN_ROOT."./tmux nntmux:db\n";
|
||||
if (self::isCLI()) {
|
||||
ColorCLI::error($message);
|
||||
(new ColorCLI())->error($message);
|
||||
}
|
||||
throw new \RuntimeException($message);
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ class Versions
|
||||
$count++;
|
||||
}
|
||||
if ($count !== $this->_vers->git->commit) {
|
||||
ColorCLI::primary("Updating commit number to {$count}");
|
||||
$this->out->primary("Updating commit number to {$count}");
|
||||
$this->_vers->git->commit = $count;
|
||||
$this->_changes |= self::UPDATED_GIT_COMMIT;
|
||||
}
|
||||
@@ -163,18 +163,18 @@ class Versions
|
||||
// Check if version file's entry is the same as current branch's tag
|
||||
if (version_compare($this->_vers->git->tag, $latest, '!=')) {
|
||||
if ($update) {
|
||||
ColorCLI::primaryOver('Updating tag version to ').ColorCLI::headerOver($latest);
|
||||
$this->out->primaryOver('Updating tag version to ').$this->out->headerOver($latest);
|
||||
$this->_vers->git->tag = $ver;
|
||||
$this->_changes |= self::UPDATED_GIT_TAG;
|
||||
} else {
|
||||
ColorCLI::primaryOver('Leaving tag version at ').
|
||||
ColorCLI::headerOver($this->_vers->git->tag);
|
||||
$this->out->primaryOver('Leaving tag version at ').
|
||||
$this->out->headerOver($this->_vers->git->tag);
|
||||
}
|
||||
|
||||
return $this->_vers->git->tag;
|
||||
}
|
||||
|
||||
ColorCLI::primaryOver('Tag version is ').ColorCLI::header($latest);
|
||||
$this->out->primaryOver('Tag version is ').$this->out->header($latest);
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -192,7 +192,7 @@ class Versions
|
||||
|
||||
if ($this->_vers->sql->db->__toString() !== $this->_vers->sql->file->__toString()) {
|
||||
if ($update) {
|
||||
ColorCLI::primaryOver('Updating Db revision to '.$this->_vers->sql->file);
|
||||
$this->out->primaryOver('Updating Db revision to '.$this->_vers->sql->file);
|
||||
$this->_vers->sql->db = $this->_vers->sql->file->__toString();
|
||||
$this->_changes |= self::UPDATED_SQL_DB_PATCH;
|
||||
}
|
||||
@@ -226,7 +226,7 @@ class Versions
|
||||
|
||||
if ($update) {
|
||||
if ($last !== false && $this->_vers->sql->file->__toString() !== $last) {
|
||||
ColorCLI::primary('Updating latest patch file to '.$last);
|
||||
$this->out->primary('Updating latest patch file to '.$last);
|
||||
$this->_vers->sql->file = $last;
|
||||
$this->_changes |= self::UPDATED_SQL_FILE_LAST;
|
||||
}
|
||||
@@ -285,7 +285,7 @@ class Versions
|
||||
|
||||
if ($this->_xml === false) {
|
||||
if (Utility::isCLI()) {
|
||||
ColorCLI::error('Your versions XML file ('.$filepath.') is broken, try updating from git.');
|
||||
$this->out->error('Your versions XML file ('.$filepath.') is broken, try updating from git.');
|
||||
}
|
||||
throw new \RuntimeException('Failed to open versions XML file '.$filepath);
|
||||
}
|
||||
@@ -294,10 +294,10 @@ class Versions
|
||||
$vers = $this->_xml->xpath('/nntmux/versions');
|
||||
|
||||
if ($vers[0]->count() === 0) {
|
||||
ColorCLI::error('Your versions XML file ('.NN_VERSIONS.') does not contain version info, try updating from git.');
|
||||
$this->out->error('Your versions XML file ('.NN_VERSIONS.') does not contain version info, try updating from git.');
|
||||
throw new \RuntimeException('Failed to find versions node in XML file '.$filepath);
|
||||
}
|
||||
ColorCLI::primary('Your versions XML file ('.NN_VERSIONS.') looks okay, continuing.');
|
||||
$this->out->primary('Your versions XML file ('.NN_VERSIONS.') looks okay, continuing.');
|
||||
$this->_vers = &$this->_xml->versions;
|
||||
} else {
|
||||
throw new \RuntimeException("No elements in file!\n");
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
2018-10-31 DariusIII
|
||||
* Chg: Refactor ColorCLI class
|
||||
* Chg: Update nunomaduro/larastan to version 0.3.7
|
||||
2018-10-30 DariusIII
|
||||
* Chg: Update laravel/framework to version 5.7.12
|
||||
|
||||
@@ -42,7 +42,7 @@ class TmuxUIStart extends Command
|
||||
// Kill the placeholder
|
||||
exec('tmux kill-session -t placeholder');
|
||||
if ($session === null) {
|
||||
ColorCLI::info('Starting the tmux server and monitor script.');
|
||||
(new ColorCLI())->info('Starting the tmux server and monitor script.');
|
||||
passthru('php '.app()->/* @scrutinizer ignore-call */ path().'/../misc/update/tmux/run.php');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -589,6 +589,6 @@ class Group extends Model
|
||||
public static function disableIfNotExist($id): void
|
||||
{
|
||||
self::updateGroupStatus($id, 'active');
|
||||
ColorCLI::error('Group does not exist on server, disabling');
|
||||
(new ColorCLI())->error('Group does not exist on server, disabling');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ class Predb extends Model
|
||||
$updated = 0;
|
||||
|
||||
if (config('nntmux.echocli')) {
|
||||
ColorCLI::header('Querying DB for release search names not matched with PreDB titles.');
|
||||
(new ColorCLI())->header('Querying DB for release search names not matched with PreDB titles.');
|
||||
}
|
||||
|
||||
$query = self::query()
|
||||
@@ -113,7 +113,7 @@ class Predb extends Model
|
||||
|
||||
if ($res !== null) {
|
||||
$total = \count($res);
|
||||
ColorCLI::primary(number_format($total).' releases to match.');
|
||||
(new ColorCLI())->primary(number_format($total).' releases to match.');
|
||||
|
||||
foreach ($res as $row) {
|
||||
Release::query()->where('id', $row['releases_id'])->update(['predb_id' => $row['predb_id']]);
|
||||
@@ -129,7 +129,7 @@ class Predb extends Model
|
||||
}
|
||||
|
||||
if (config('nntmux.echocli')) {
|
||||
ColorCLI::header(
|
||||
(new ColorCLI())->header(
|
||||
'Matched '.number_format(($updated > 0) ? $updated : 0).' PreDB titles to release search names.'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ if ($argc > 1 && $argv[1] === 'true' && isset($argv[2])) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ColorCLI::error(
|
||||
(new ColorCLI())->error(
|
||||
'To execute this script you must provide a boolean argument.'.PHP_EOL.
|
||||
'Argument1: true|false to run this script or not'.PHP_EOL.
|
||||
'Argument2: full|info for what type of data to populate.'.PHP_EOL.
|
||||
|
||||
@@ -87,6 +87,7 @@ foreach ($data as $dir => $files) {
|
||||
$total--;
|
||||
|
||||
$predb = new PreDb();
|
||||
$colorCli = new ColorCLI();
|
||||
|
||||
$progress = $predb->progress(settings_array());
|
||||
|
||||
@@ -145,7 +146,7 @@ foreach ($data as $dir => $files) {
|
||||
$verbose = $argv[3] === true;
|
||||
|
||||
if ($verbose) {
|
||||
ColorCLI::info('Clearing import table');
|
||||
$colorCli->info('Clearing import table');
|
||||
}
|
||||
|
||||
// Truncate to clear any old data
|
||||
@@ -163,7 +164,7 @@ foreach ($data as $dir => $files) {
|
||||
|
||||
// Remove any titles where length <=8
|
||||
if ($verbose === true) {
|
||||
ColorCLI::info('Deleting any records where title <=8 from Temporary Table');
|
||||
$colorCli->info('Deleting any records where title <=8 from Temporary Table');
|
||||
}
|
||||
$predb->executeDeleteShort();
|
||||
|
||||
@@ -173,7 +174,7 @@ foreach ($data as $dir => $files) {
|
||||
// Fill the groups_id
|
||||
$predb->executeUpdateGroupID();
|
||||
|
||||
ColorCLI::info('Inserting records from temporary table into predb table');
|
||||
$colorCli->info('Inserting records from temporary table into predb table');
|
||||
$predb->executeInsert();
|
||||
|
||||
// Delete the dump.
|
||||
|
||||
@@ -9,6 +9,7 @@ use Illuminate\Support\Facades\DB;
|
||||
|
||||
$pdo = DB::connection()->getPdo();
|
||||
$consoletools = new ConsoleTools();
|
||||
$colorCli = new ColorCLI();
|
||||
$ran = false;
|
||||
|
||||
if (isset($argv[1]) && $argv[1] === 'all' && isset($argv[2]) && $argv[2] === 'true') {
|
||||
@@ -32,7 +33,7 @@ if (isset($argv[1]) && $argv[1] === 'all' && isset($argv[2]) && $argv[2] === 'tr
|
||||
$pdo->exec('TRUNCATE TABLE anidb_info');
|
||||
$pdo->exec('TRUNCATE TABLE anidb_episodes');
|
||||
}
|
||||
ColorCLI::header('Resetting all postprocessing');
|
||||
$colorCli->header('Resetting all postprocessing');
|
||||
$qry = $pdo->query('SELECT id FROM releases');
|
||||
$affected = 0;
|
||||
if ($qry instanceof \Traversable) {
|
||||
@@ -59,10 +60,10 @@ if (isset($argv[1]) && ($argv[1] === 'consoles' || $argv[1] === 'all')) {
|
||||
$pdo->exec('TRUNCATE TABLE consoleinfo');
|
||||
}
|
||||
if (isset($argv[2]) && $argv[2] === 'true') {
|
||||
ColorCLI::header('Resetting all Console postprocessing');
|
||||
$colorCli->header('Resetting all Console postprocessing');
|
||||
$where = ' WHERE consoleinfo_id IS NOT NULL';
|
||||
} else {
|
||||
ColorCLI::header('Resetting all failed Console postprocessing');
|
||||
$colorCli->header('Resetting all failed Console postprocessing');
|
||||
$where = ' WHERE consoleinfo_id IN (-2, 0) AND categories_id BETWEEN '.Category::GAME_ROOT.' AND '.Category::GAME_OTHER;
|
||||
}
|
||||
|
||||
@@ -79,7 +80,7 @@ if (isset($argv[1]) && ($argv[1] === 'consoles' || $argv[1] === 'all')) {
|
||||
$consoletools->overWritePrimary('Resetting Console Releases: '.$consoletools->percentString(++$concount, $total));
|
||||
}
|
||||
}
|
||||
ColorCLI::header(PHP_EOL.number_format($concount).' consoleinfoIDs reset.');
|
||||
$colorCli->header(PHP_EOL.number_format($concount).' consoleinfoIDs reset.');
|
||||
}
|
||||
if (isset($argv[1]) && ($argv[1] === 'games' || $argv[1] === 'all')) {
|
||||
$ran = true;
|
||||
@@ -87,10 +88,10 @@ if (isset($argv[1]) && ($argv[1] === 'games' || $argv[1] === 'all')) {
|
||||
$pdo->exec('TRUNCATE TABLE gamesinfo');
|
||||
}
|
||||
if (isset($argv[2]) && $argv[2] === 'true') {
|
||||
ColorCLI::header('Resetting all Games postprocessing');
|
||||
$colorCli->header('Resetting all Games postprocessing');
|
||||
$where = ' WHERE gamesinfo_id != 0';
|
||||
} else {
|
||||
ColorCLI::header('Resetting all failed Games postprocessing');
|
||||
$colorCli->header('Resetting all failed Games postprocessing');
|
||||
$where = ' WHERE gamesinfo_id IN (-2, 0) AND categories_id = 4050';
|
||||
}
|
||||
|
||||
@@ -107,7 +108,7 @@ if (isset($argv[1]) && ($argv[1] === 'games' || $argv[1] === 'all')) {
|
||||
$pdo->exec('UPDATE releases SET gamesinfo_id = 0 WHERE id = '.$releases['id']);
|
||||
$consoletools->overWritePrimary('Resetting Games Releases: '.$consoletools->percentString(++$concount, $total));
|
||||
}
|
||||
ColorCLI::header(PHP_EOL.number_format($concount).' gameinfo_IDs reset.');
|
||||
$colorCli->header(PHP_EOL.number_format($concount).' gameinfo_IDs reset.');
|
||||
}
|
||||
}
|
||||
if (isset($argv[1]) && ($argv[1] === 'movies' || $argv[1] === 'all')) {
|
||||
@@ -116,10 +117,10 @@ if (isset($argv[1]) && ($argv[1] === 'movies' || $argv[1] === 'all')) {
|
||||
$pdo->exec('TRUNCATE TABLE movieinfo');
|
||||
}
|
||||
if (isset($argv[2]) && $argv[2] === 'true') {
|
||||
ColorCLI::header('Resetting all Movie postprocessing');
|
||||
$colorCli->header('Resetting all Movie postprocessing');
|
||||
$where = ' WHERE imdbid IS NOT NULL';
|
||||
} else {
|
||||
ColorCLI::header('Resetting all failed Movie postprocessing');
|
||||
$colorCli->header('Resetting all failed Movie postprocessing');
|
||||
$where = ' WHERE imdbid IN (-2, 0) AND categories_id BETWEEN '.Category::MOVIE_ROOT.' AND '.Category::MOVIE_OTHER;
|
||||
}
|
||||
|
||||
@@ -136,7 +137,7 @@ if (isset($argv[1]) && ($argv[1] === 'movies' || $argv[1] === 'all')) {
|
||||
$consoletools->overWritePrimary('Resetting Movie Releases: '.$consoletools->percentString(++$concount, $total));
|
||||
}
|
||||
}
|
||||
ColorCLI::header(PHP_EOL.number_format($concount).' imdbIDs reset.');
|
||||
$colorCli->header(PHP_EOL.number_format($concount).' imdbIDs reset.');
|
||||
}
|
||||
if (isset($argv[1]) && ($argv[1] === 'music' || $argv[1] === 'all')) {
|
||||
$ran = true;
|
||||
@@ -144,10 +145,10 @@ if (isset($argv[1]) && ($argv[1] === 'music' || $argv[1] === 'all')) {
|
||||
$pdo->exec('TRUNCATE TABLE musicinfo');
|
||||
}
|
||||
if (isset($argv[2]) && $argv[2] === 'true') {
|
||||
ColorCLI::header('Resetting all Music postprocessing');
|
||||
$colorCli->header('Resetting all Music postprocessing');
|
||||
$where = ' WHERE musicinfo_id IS NOT NULL';
|
||||
} else {
|
||||
ColorCLI::header('Resetting all failed Music postprocessing');
|
||||
$colorCli->header('Resetting all failed Music postprocessing');
|
||||
$where = ' WHERE musicinfo_id IN (-2, 0) AND categories_id BETWEEN '.Category::MUSIC_ROOT.' AND '.Category::MUSIC_OTHER;
|
||||
}
|
||||
|
||||
@@ -160,19 +161,19 @@ if (isset($argv[1]) && ($argv[1] === 'music' || $argv[1] === 'all')) {
|
||||
$consoletools->overWritePrimary('Resetting Music Releases: '.$consoletools->percentString(++$concount, $total));
|
||||
}
|
||||
}
|
||||
ColorCLI::header(PHP_EOL.number_format($concount).' musicinfo_ids reset.');
|
||||
$colorCli->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');
|
||||
$colorCli->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');
|
||||
$colorCli->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';
|
||||
}
|
||||
|
||||
ColorCLI::primary('SELECT id FROM releases'.$where);
|
||||
$colorCli->primary('SELECT id FROM releases'.$where);
|
||||
$qry = $pdo->query('SELECT id FROM releases'.$where);
|
||||
if ($qry !== false) {
|
||||
$total = $qry->rowCount();
|
||||
@@ -186,7 +187,7 @@ if (isset($argv[1]) && ($argv[1] === 'misc' || $argv[1] === 'all')) {
|
||||
$consoletools->overWritePrimary('Resetting Releases: '.$consoletools->percentString(++$concount, $total));
|
||||
}
|
||||
}
|
||||
ColorCLI::header(PHP_EOL.number_format($concount).' Releases reset.');
|
||||
$colorCli->header(PHP_EOL.number_format($concount).' Releases reset.');
|
||||
}
|
||||
if (isset($argv[1]) && ($argv[1] === 'tv' || $argv[1] === 'all')) {
|
||||
$ran = true;
|
||||
@@ -196,10 +197,10 @@ if (isset($argv[1]) && ($argv[1] === 'tv' || $argv[1] === 'all')) {
|
||||
$pdo->exec('TRUNCATE TABLE tv_episodes');
|
||||
}
|
||||
if (isset($argv[2]) && $argv[2] === 'true') {
|
||||
ColorCLI::header('Resetting all TV postprocessing');
|
||||
$colorCli->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');
|
||||
$colorCli->header('Resetting all failed TV postprocessing');
|
||||
$where = ' WHERE tv_episodes_id < 0 AND categories_id BETWEEN '.Category::TV_ROOT.' AND '.Category::TV_OTHER;
|
||||
}
|
||||
|
||||
@@ -216,7 +217,7 @@ if (isset($argv[1]) && ($argv[1] === 'tv' || $argv[1] === 'all')) {
|
||||
$consoletools->overWritePrimary('Resetting TV Releases: '.$consoletools->percentString(++$concount, $total));
|
||||
}
|
||||
}
|
||||
ColorCLI::header(PHP_EOL.number_format($concount).' Video IDs reset.');
|
||||
$colorCli->header(PHP_EOL.number_format($concount).' Video IDs reset.');
|
||||
}
|
||||
if (isset($argv[1]) && ($argv[1] === 'anime' || $argv[1] === 'all')) {
|
||||
$ran = true;
|
||||
@@ -225,10 +226,10 @@ if (isset($argv[1]) && ($argv[1] === 'anime' || $argv[1] === 'all')) {
|
||||
$pdo->exec('TRUNCATE TABLE anidb_episodes');
|
||||
}
|
||||
if (isset($argv[2]) && $argv[2] === 'true') {
|
||||
ColorCLI::header('Resetting all Anime postprocessing');
|
||||
$colorCli->header('Resetting all Anime postprocessing');
|
||||
$where = ' WHERE categories_id = 5070';
|
||||
} else {
|
||||
ColorCLI::header('Resetting all failed Anime postprocessing');
|
||||
$colorCli->header('Resetting all failed Anime postprocessing');
|
||||
$where = ' WHERE anidbid BETWEEN -2 AND -1 AND categories_id = '.Category::TV_ANIME;
|
||||
}
|
||||
|
||||
@@ -245,7 +246,7 @@ if (isset($argv[1]) && ($argv[1] === 'anime' || $argv[1] === 'all')) {
|
||||
$consoletools->overWritePrimary('Resetting Anime Releases: '.$consoletools->percentString(++$concount, $total));
|
||||
}
|
||||
}
|
||||
ColorCLI::header(PHP_EOL.number_format($concount).' anidbIDs reset.');
|
||||
$colorCli->header(PHP_EOL.number_format($concount).' anidbIDs reset.');
|
||||
}
|
||||
if (isset($argv[1]) && ($argv[1] === 'books' || $argv[1] === 'all')) {
|
||||
$ran = true;
|
||||
@@ -253,10 +254,10 @@ if (isset($argv[1]) && ($argv[1] === 'books' || $argv[1] === 'all')) {
|
||||
$pdo->exec('TRUNCATE TABLE bookinfo');
|
||||
}
|
||||
if (isset($argv[2]) && $argv[2] === 'true') {
|
||||
ColorCLI::header('Resetting all Book postprocessing');
|
||||
$colorCli->header('Resetting all Book postprocessing');
|
||||
$where = ' WHERE bookinfo_id IS NOT NULL';
|
||||
} else {
|
||||
ColorCLI::header('Resetting all failed Book postprocessing');
|
||||
$colorCli->header('Resetting all failed Book postprocessing');
|
||||
$where = ' WHERE bookinfo_id IN (-2, 0) AND categories_id BETWEEN '.Category::BOOKS_ROOT.' AND '.Category::BOOKS_UNKNOWN;
|
||||
}
|
||||
|
||||
@@ -269,7 +270,7 @@ if (isset($argv[1]) && ($argv[1] === 'books' || $argv[1] === 'all')) {
|
||||
$consoletools->overWritePrimary('Resetting Book Releases: '.$consoletools->percentString(++$concount, $total));
|
||||
}
|
||||
}
|
||||
ColorCLI::header(PHP_EOL.number_format($concount).' bookinfoIDs reset.');
|
||||
$colorCli->header(PHP_EOL.number_format($concount).' bookinfoIDs reset.');
|
||||
}
|
||||
if (isset($argv[1]) && ($argv[1] === 'xxx' || $argv[1] === 'all')) {
|
||||
$ran = true;
|
||||
@@ -277,10 +278,10 @@ if (isset($argv[1]) && ($argv[1] === 'xxx' || $argv[1] === 'all')) {
|
||||
$pdo->exec('TRUNCATE TABLE xxxinfo');
|
||||
}
|
||||
if (isset($argv[2]) && $argv[2] === 'true') {
|
||||
ColorCLI::header('Resetting all XXX postprocessing');
|
||||
$colorCli->header('Resetting all XXX postprocessing');
|
||||
$where = ' WHERE xxxinfo_id != 0';
|
||||
} else {
|
||||
ColorCLI::header('Resetting all failed XXX postprocessing');
|
||||
$colorCli->header('Resetting all failed XXX postprocessing');
|
||||
$where = ' WHERE xxxinfo_id IN (-2, 0) AND categories_id BETWEEN '.Category::XXX_ROOT.' AND '.Category::XXX_X264;
|
||||
}
|
||||
|
||||
@@ -296,7 +297,7 @@ if (isset($argv[1]) && ($argv[1] === 'xxx' || $argv[1] === 'all')) {
|
||||
));
|
||||
}
|
||||
}
|
||||
ColorCLI::header(PHP_EOL.number_format($concount).' xxxinfo_IDs reset.');
|
||||
$colorCli->header(PHP_EOL.number_format($concount).' xxxinfo_IDs reset.');
|
||||
}
|
||||
if (isset($argv[1]) && ($argv[1] === 'nfos' || $argv[1] === 'all')) {
|
||||
$ran = true;
|
||||
@@ -304,10 +305,10 @@ if (isset($argv[1]) && ($argv[1] === 'nfos' || $argv[1] === 'all')) {
|
||||
$pdo->exec('TRUNCATE TABLE release_nfos');
|
||||
}
|
||||
if (isset($argv[2]) && $argv[2] === 'true') {
|
||||
ColorCLI::header('Resetting all NFO postprocessing');
|
||||
$colorCli->header('Resetting all NFO postprocessing');
|
||||
$where = ' WHERE nfostatus != -1';
|
||||
} else {
|
||||
ColorCLI::header('Resetting all failed NFO postprocessing');
|
||||
$colorCli->header('Resetting all failed NFO postprocessing');
|
||||
$where = ' WHERE nfostatus < -1';
|
||||
}
|
||||
|
||||
@@ -320,12 +321,12 @@ if (isset($argv[1]) && ($argv[1] === 'nfos' || $argv[1] === 'all')) {
|
||||
$consoletools->overWritePrimary('Resetting NFO Releases: '.$consoletools->percentString(++$concount, $total));
|
||||
}
|
||||
}
|
||||
ColorCLI::header(PHP_EOL.number_format($concount).' NFOs reset.');
|
||||
$colorCli->header(PHP_EOL.number_format($concount).' NFOs reset.');
|
||||
}
|
||||
|
||||
if ($ran === false) {
|
||||
exit(
|
||||
ColorCLI::error(
|
||||
$colorCli->error(
|
||||
'\nThis script will reset postprocessing per category. It can also truncate the associated tables.'
|
||||
.'\nTo reset only those that have previously failed, those without covers, samples, previews, etc. use the '
|
||||
.'second argument false.\n'
|
||||
|
||||
@@ -10,9 +10,10 @@ use Blacklight\ReleaseImage;
|
||||
use Blacklight\utility\Utility;
|
||||
|
||||
$dir = NN_RES.'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"
|
||||
$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"
|
||||
."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();
|
||||
@@ -30,8 +31,8 @@ $timestart = date('r');
|
||||
$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");
|
||||
$colorCli->header('Getting List of nzbs to check against db.');
|
||||
$colorCli->header("Checked / {$couldbe}moved\n");
|
||||
|
||||
$dirItr = new \RecursiveDirectoryIterator(Settings::settingValue('..nzbpath'));
|
||||
$itr = new \RecursiveIteratorIterator($dirItr, \RecursiveIteratorIterator::LEAVES_ONLY);
|
||||
@@ -53,9 +54,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");
|
||||
$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");
|
||||
|
||||
$checked = $deleted = 0;
|
||||
|
||||
@@ -71,5 +72,5 @@ $res = DB::select('SELECT id, guid, nzbstatus FROM releases');
|
||||
$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 [".date('r').']');
|
||||
$colorCli->header("\n".number_format($checked).' releases checked, '.number_format($deleted).' releases deleted.');
|
||||
$colorCli->header("Script started at [$timestart], finished at [".date('r').']');
|
||||
|
||||
@@ -12,6 +12,7 @@ use Blacklight\utility\Utility;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
$movie = new Movie(['Echo' => true]);
|
||||
$colorCli = new ColorCLI();
|
||||
|
||||
$row = Settings::settingValue('site.main.coverspath');
|
||||
if ($row !== null) {
|
||||
@@ -28,7 +29,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');
|
||||
$colorCli->header('Scanning for releases missing covers');
|
||||
$res = DB::select('SELECT r.id, r.imdbid
|
||||
FROM releases r
|
||||
LEFT JOIN movieinfo m ON m.imdbid = r.imdbid
|
||||
@@ -38,7 +39,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);
|
||||
$colorCli->warning('Missing cover '.$nzbpath);
|
||||
if ($argv[1] === 'true') {
|
||||
$cover = $movie->updateMovieInfo($row->imdbid);
|
||||
if ($cover === false || ! file_exists($nzbpath)) {
|
||||
@@ -51,9 +52,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));
|
||||
$colorCli->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"
|
||||
$colorCli->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"
|
||||
|
||||
@@ -15,6 +15,7 @@ use Blacklight\utility\Utility;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
$pdo = DB::connection()->getPdo();
|
||||
$colorCli = new ColorCLI();
|
||||
|
||||
$row = Settings::settingValue('site.main.coverspath');
|
||||
if ($row !== null) {
|
||||
@@ -35,14 +36,14 @@ 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 previews');
|
||||
$colorCli->header('Scanning for releases missing previews');
|
||||
$res = $pdo->query('SELECT id, guid FROM releases where nzbstatus = 1 AND haspreview = 1');
|
||||
if ($res instanceof \Traversable) {
|
||||
foreach ($res as $row) {
|
||||
$nzbpath = $path2preview.$row['guid'].'_thumb.jpg';
|
||||
if (! file_exists($nzbpath)) {
|
||||
$counterfixed++;
|
||||
ColorCLI::warning('Missing preview '.$nzbpath);
|
||||
$colorCli->warning('Missing preview '.$nzbpath);
|
||||
if ($argv[1] === 'true') {
|
||||
$pdo->exec(
|
||||
sprintf('UPDATE releases SET consoleinfo_id = NULL, gamesinfo_id = 0, imdbid = NULL, musicinfo_id = NULL, bookinfo_id = NULL, videos_id = 0, xxxinfo_id = 0, passwordstatus = -1, haspreview = -1, jpgstatus = 0, videostatus = 0, audiostatus = 0, nfostatus = -1 WHERE id = %s', $row['id'])
|
||||
@@ -55,9 +56,9 @@ if (isset($argv[1]) && ($argv[1] === 'true' || $argv[1] === 'check')) {
|
||||
}
|
||||
}
|
||||
}
|
||||
ColorCLI::header('Total releases missing previews that '.$couldbe.'reset for reprocessing= '.number_format($counterfixed));
|
||||
$colorCli->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"
|
||||
$colorCli->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"
|
||||
|
||||
@@ -11,6 +11,7 @@ use Illuminate\Support\Facades\DB;
|
||||
|
||||
$pdo = DB::connection()->getPdo();
|
||||
$console = new Console(['Echo' => true]);
|
||||
$colorCli = new ColorCLI();
|
||||
|
||||
$res = $pdo->query(
|
||||
sprintf(
|
||||
@@ -21,7 +22,7 @@ $res = $pdo->query(
|
||||
)
|
||||
);
|
||||
if ($res instanceof \Traversable) {
|
||||
ColorCLI::header('Updating console info for '.number_format($res->rowCount()).' releases.');
|
||||
$colorCli->header('Updating console info for '.number_format($res->rowCount()).' releases.');
|
||||
|
||||
foreach ($res as $arr) {
|
||||
$starttime = microtime(true);
|
||||
@@ -29,14 +30,14 @@ if ($res instanceof \Traversable) {
|
||||
if ($gameInfo !== false) {
|
||||
$game = $console->updateConsoleInfo($gameInfo);
|
||||
if ($game === false) {
|
||||
ColorCLI::primary($gameInfo['release'].' not found');
|
||||
$colorCli->primary($gameInfo['release'].' not found');
|
||||
}
|
||||
}
|
||||
|
||||
// amazon limits are 1 per 1 sec
|
||||
$diff = floor((microtime(true) - $starttime) * 1000000);
|
||||
if (1000000 - $diff > 0) {
|
||||
ColorCLI::alternate('Sleeping');
|
||||
$colorCli->alternate('Sleeping');
|
||||
usleep(1000000 - $diff);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,22 +9,23 @@ use Blacklight\ColorCLI;
|
||||
|
||||
$pdo = DB::connection()->getPdo();
|
||||
$game = new Games(['Echo' => true]);
|
||||
$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.');
|
||||
$colorCli->header('Updating game covers for '.number_format($total).' releases.');
|
||||
|
||||
foreach ($res as $arr) {
|
||||
$starttime = microtime(true);
|
||||
$gameInfo = $game->parseTitle($arr['title']);
|
||||
if ($gameInfo !== false) {
|
||||
ColorCLI::primary('Looking up: '.$gameInfo['release']);
|
||||
$colorCli->primary('Looking up: '.$gameInfo['release']);
|
||||
$gameData = $game->updateGamesInfo($gameInfo);
|
||||
if ($gameData === false) {
|
||||
ColorCLI::primary($gameInfo['release'].' not found');
|
||||
$colorCli->primary($gameInfo['release'].' not found');
|
||||
} else {
|
||||
if (file_exists(NN_COVERS.'games'.DS.$gameData.'.jpg')) {
|
||||
$pdo->exec(sprintf('UPDATE gamesinfo SET cover = 1 WHERE id = %d', $arr['id']));
|
||||
@@ -35,7 +36,7 @@ if ($total > 0) {
|
||||
// amazon limits are 1 per 1 sec
|
||||
$diff = floor((microtime(true) - $starttime) * 1000000);
|
||||
if (1000000 - $diff > 0) {
|
||||
ColorCLI::alternate('Sleeping');
|
||||
$colorCli->alternate('Sleeping');
|
||||
usleep(1000000 - $diff);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,12 +9,13 @@ use Illuminate\Support\Facades\DB;
|
||||
|
||||
$pdo = DB::connection()->getPdo();
|
||||
$movie = new Movie(['Echo' => 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.');
|
||||
$colorCli->header('Updating movie info for '.number_format($count).' movies.');
|
||||
|
||||
foreach ($movies as $mov) {
|
||||
$startTime = microtime(true);
|
||||
@@ -28,6 +29,6 @@ if ($movies instanceof \Traversable) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ColorCLI::header('No movies to update');
|
||||
$colorCli->header('No movies to update');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,15 +8,16 @@ use Blacklight\ColorCLI;
|
||||
use App\Models\MovieInfo;
|
||||
|
||||
$movie = new Movie(['Echo' => 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.');
|
||||
$colorCli->primary('Updating '.number_format($count).' movie covers.');
|
||||
foreach ($movies as $mov) {
|
||||
$startTime = microtime(true);
|
||||
$mov = $movie->updateMovieInfo($mov['imdbid']);
|
||||
}
|
||||
} else {
|
||||
ColorCLI::header('No movie covers to update');
|
||||
$colorCli->header('No movie covers to update');
|
||||
}
|
||||
|
||||
@@ -9,24 +9,25 @@ use App\Models\MovieInfo;
|
||||
use Blacklight\processing\tv\TraktTv;
|
||||
|
||||
$movie = new Movie(['Echo' => 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.');
|
||||
$colorCli->primary('Updating '.number_format($count).' movies for TraktTV id.');
|
||||
foreach ($movies as $mov) {
|
||||
$traktTv = new TraktTv(['Settings' => null]);
|
||||
$traktmovie = $traktTv->client->movieSummary('tt'.str_pad($mov['imdbid'], 7, '0', STR_PAD_LEFT), 'full');
|
||||
if ($traktmovie !== false) {
|
||||
ColorCLI::info('Updating IMDb id: tt'.str_pad($mov['imdbid'], 7, '0', STR_PAD_LEFT));
|
||||
$colorCli->info('Updating IMDb id: tt'.str_pad($mov['imdbid'], 7, '0', STR_PAD_LEFT));
|
||||
$trakt = $movie->parseTraktTv($traktmovie);
|
||||
if ($trakt === true) {
|
||||
ColorCLI::info('Added traktid: '.$traktmovie['ids']['trakt']);
|
||||
$colorCli->info('Added traktid: '.$traktmovie['ids']['trakt']);
|
||||
} else {
|
||||
ColorCLI::info('No traktid found.');
|
||||
$colorCli->info('No traktid found.');
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ColorCLI::header('No movies to update');
|
||||
$colorCli->header('No movies to update');
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@ use App\Models\Category;
|
||||
use Blacklight\ColorCLI;
|
||||
use Blacklight\ReleaseImage;
|
||||
|
||||
$pdo = DB::getPdo();
|
||||
$pdo = DB::connection()->getPdo();
|
||||
$colorCli = new ColorCLI();
|
||||
|
||||
$path2cover = NN_COVERS.'samples'.DS;
|
||||
|
||||
@@ -18,7 +19,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');
|
||||
$colorCli->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.nzbstatus = 1 AND 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));
|
||||
@@ -35,10 +36,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']);
|
||||
$colorCli->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!');
|
||||
$colorCli->notice('Sample download failed!');
|
||||
$pdo->exec(sprintf('UPDATE releases SET jpgstatus = -2 WHERE id = %d', $row['id']));
|
||||
}
|
||||
}
|
||||
@@ -48,9 +49,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));
|
||||
$colorCli->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"
|
||||
$colorCli->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();
|
||||
|
||||
@@ -6,9 +6,10 @@ use Blacklight\ColorCLI;
|
||||
require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
|
||||
|
||||
$covers = $updated = $deleted = 0;
|
||||
$colorCli = new ColorCLI();
|
||||
|
||||
if ($argc === 1 || $argv[1] !== 'true') {
|
||||
ColorCLI::error("\nThis script will check all images in covers/book and compare to db->bookinfo.\nTo run:\nphp $argv[0] true\n");
|
||||
$colorCli->error("\nThis script will check all images in covers/book and compare to db->bookinfo.\nTo run:\nphp $argv[0] true\n");
|
||||
exit();
|
||||
}
|
||||
|
||||
@@ -26,7 +27,7 @@ foreach ($itr as $filePath) {
|
||||
} else {
|
||||
$run = BookInfo::query()->where('id', $match[1])->select(['id'])->get();
|
||||
if ($run->count() === 0) {
|
||||
ColorCLI::info($filePath.' not found in db.');
|
||||
$colorCli->info($filePath.' not found in db.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,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.');
|
||||
$colorCli->info($path2covers.$rows['id'].'.jpg does not exist.');
|
||||
$deleted++;
|
||||
}
|
||||
}
|
||||
ColorCLI::header($covers.' covers set.');
|
||||
ColorCLI::header($deleted.' books unset.');
|
||||
$colorCli->header($covers.' covers set.');
|
||||
$colorCli->header($deleted.' books unset.');
|
||||
|
||||
@@ -6,9 +6,10 @@ use Blacklight\ColorCLI;
|
||||
use App\Models\ConsoleInfo;
|
||||
|
||||
$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");
|
||||
$colorCli->error("\nThis script will check all images in covers/console and compare to db->consoleinfo.\nTo run:\nphp $argv[0] true\n");
|
||||
exit();
|
||||
}
|
||||
|
||||
@@ -31,7 +32,7 @@ foreach ($itr as $filePath) {
|
||||
} else {
|
||||
$run = ConsoleInfo::query()->where('id', $match[1])->value('id');
|
||||
if ($run === 0) {
|
||||
ColorCLI::info($filePath.' not found in db.');
|
||||
$colorCli->info($filePath.' not found in db.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,10 +49,10 @@ if ($qry instanceof \Traversable) {
|
||||
['id' => $rows['id']],
|
||||
]
|
||||
)->update(['cover' => 0]);
|
||||
ColorCLI::info($path2covers.$rows['id'].'.jpg does not exist.');
|
||||
$colorCli->info($path2covers.$rows['id'].'.jpg does not exist.');
|
||||
$deleted++;
|
||||
}
|
||||
}
|
||||
}
|
||||
ColorCLI::header($covers.' covers set.');
|
||||
ColorCLI::header($deleted.' consoles unset.');
|
||||
$colorCli->header($covers.' covers set.');
|
||||
$colorCli->header($deleted.' consoles unset.');
|
||||
|
||||
@@ -9,9 +9,10 @@ use Blacklight\utility\Utility;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
$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");
|
||||
$colorCli->error("\nThis script will check all images in covers/games and compare to db->gamesinfo.\nTo run:\nphp $argv[0] true\n");
|
||||
exit();
|
||||
}
|
||||
|
||||
@@ -38,7 +39,7 @@ foreach ($itr as $filePath) {
|
||||
} else {
|
||||
$run = GamesInfo::query()->where('id', $match[1])->select(['id'])->get();
|
||||
if ($run !== null && $run === 0) {
|
||||
ColorCLI::info($filePath.' not found in db.');
|
||||
$colorCli->info($filePath.' not found in db.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,10 +52,10 @@ if ($qry instanceof \Traversable) {
|
||||
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.');
|
||||
$colorCli->info($path2covers.$rows['id'].'.jpg does not exist.');
|
||||
$deleted++;
|
||||
}
|
||||
}
|
||||
}
|
||||
ColorCLI::header($covers.' covers set.');
|
||||
ColorCLI::header($deleted.' games unset.');
|
||||
$colorCli->header($covers.' covers set.');
|
||||
$colorCli->header($deleted.' games unset.');
|
||||
|
||||
@@ -8,9 +8,10 @@ use App\Models\MovieInfo;
|
||||
use Blacklight\utility\Utility;
|
||||
|
||||
$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");
|
||||
$colorCli->error("\nThis script will check all images in covers/movies and compare to db->movieinfo.\nTo run:\nphp $argv[0] true\n");
|
||||
exit();
|
||||
}
|
||||
|
||||
@@ -34,7 +35,7 @@ foreach ($itr as $filePath) {
|
||||
} else {
|
||||
$run = MovieInfo::query()->where('imdbid', '=', $match[1])->select(['imdbid'])->get();
|
||||
if ($run->count() === 0) {
|
||||
ColorCLI::info($filePath.' not found in db.');
|
||||
$colorCli->info($filePath.' not found in db.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,7 +49,7 @@ foreach ($itr as $filePath) {
|
||||
} else {
|
||||
$run = MovieInfo::query()->where('imdbid', $match1[1])->select(['imdbid'])->get();
|
||||
if ($run->count() === 0) {
|
||||
ColorCLI::info($filePath.' not found in db.');
|
||||
$colorCli->info($filePath.' not found in db.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,7 +60,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.');
|
||||
$colorCli->info($path2covers.$rows['imdbid'].'-cover.jpg does not exist.');
|
||||
$deleted++;
|
||||
}
|
||||
}
|
||||
@@ -67,10 +68,10 @@ $qry = MovieInfo::query()->where('cover', '=', 1)->select(['imdbid'])->get();
|
||||
foreach ($qry1 as $rows) {
|
||||
if (! is_file($path2covers.$rows['imdbid'].'-backdrop.jpg')) {
|
||||
MovieInfo::query()->where('backdrop', '=', 1)->where('imdbid', $rows['imdbid'])->update(['backdrop' => 0]);
|
||||
ColorCLI::info($path2covers.$rows['imdbid'].'-backdrop.jpg does not exist.');
|
||||
$colorCli->info($path2covers.$rows['imdbid'].'-backdrop.jpg does not exist.');
|
||||
$deleted++;
|
||||
}
|
||||
}
|
||||
ColorCLI::header($covers.' covers set.');
|
||||
ColorCLI::header($updated.' backdrops set.');
|
||||
ColorCLI::header($deleted.' movies unset.');
|
||||
$colorCli->header($covers.' covers set.');
|
||||
$colorCli->header($updated.' backdrops set.');
|
||||
$colorCli->header($deleted.' movies unset.');
|
||||
|
||||
@@ -6,9 +6,10 @@ use Blacklight\ColorCLI;
|
||||
use App\Models\MusicInfo;
|
||||
|
||||
$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");
|
||||
$colorCli->error("\nThis script will check all images in covers/music and compare to db->musicinfo.\nTo run:\nphp $argv[0] true\n");
|
||||
exit();
|
||||
}
|
||||
|
||||
@@ -26,7 +27,7 @@ foreach ($itr as $filePath) {
|
||||
} else {
|
||||
$run = MusicInfo::query()->where('id', $match[1])->select(['id'])->get();
|
||||
if ($run->count() === 0) {
|
||||
ColorCLI::info($filePath.' not found in db.');
|
||||
$colorCli->info($filePath.' not found in db.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,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.');
|
||||
$colorCli->info($path2covers.$rows['id'].'.jpg does not exist.');
|
||||
$deleted++;
|
||||
}
|
||||
}
|
||||
ColorCLI::header($covers.' covers set.');
|
||||
ColorCLI::header($deleted.' music unset.');
|
||||
$colorCli->header($covers.' covers set.');
|
||||
$colorCli->header($deleted.' music unset.');
|
||||
|
||||
@@ -6,9 +6,10 @@ use App\Models\XxxInfo;
|
||||
use Blacklight\ColorCLI;
|
||||
|
||||
$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");
|
||||
$colorCli->error("\nThis script will check all images in covers/xxx and compare to db->xxxinfo.\nTo run:\nphp $argv[0] true\n");
|
||||
exit();
|
||||
}
|
||||
|
||||
@@ -26,7 +27,7 @@ foreach ($itr as $filePath) {
|
||||
} else {
|
||||
$run = XxxInfo::query()->where('id', $match[1])->select(['id'])->get();
|
||||
if ($run->count() === 0) {
|
||||
ColorCLI::info($filePath.' not found in db.');
|
||||
$colorCli->info($filePath.' not found in db.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,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.' not found in db.');
|
||||
$colorCli->info($filePath.' not found in db.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,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.');
|
||||
$colorCli->info($path2covers.$rows['id'].'-cover.jpg does not exist.');
|
||||
$deleted++;
|
||||
}
|
||||
}
|
||||
@@ -59,10 +60,10 @@ $qry = 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.');
|
||||
$colorCli->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.');
|
||||
$colorCli->header($covers.' covers set.');
|
||||
$colorCli->header($updated.' backdrops set.');
|
||||
$colorCli->header($deleted.' movies unset.');
|
||||
|
||||
@@ -15,6 +15,7 @@ use Blacklight\ColorCLI;
|
||||
use Blacklight\NameFixer;
|
||||
|
||||
$namefixer = new NameFixer();
|
||||
$colorCli = new ColorCLI();
|
||||
|
||||
if (isset($argv[1], $argv[2], $argv[3], $argv[4])) {
|
||||
$update = $argv[2] === 'true';
|
||||
@@ -32,7 +33,7 @@ if (isset($argv[1], $argv[2], $argv[3], $argv[4])) {
|
||||
if ($argv[1] === 7 || $argv[1] === 8) {
|
||||
$nntp = new NNTP();
|
||||
if ((Settings::settingValue('..alternate_nntp') === 1 ? $nntp->doConnect(true, true) : $nntp->doConnect()) !== true) {
|
||||
ColorCLI::error('Unable to connect to usenet.'.PHP_EOL);
|
||||
$colorCli->error('Unable to connect to usenet.');
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -94,12 +95,12 @@ if (isset($argv[1], $argv[2], $argv[3], $argv[4])) {
|
||||
$namefixer->fixNamesWithMediaMovieName(2, $update, $other, $setStatus, $show);
|
||||
break;
|
||||
default:
|
||||
ColorCLI::error(PHP_EOL.'ERROR: Wrong argument, type php $argv[0] to see a list of valid arguments.');
|
||||
$colorCli->error(PHP_EOL.'ERROR: Wrong argument, type php $argv[0] to see a list of valid arguments.');
|
||||
exit();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
ColorCLI::error(PHP_EOL.'You must supply 4 arguments.'.PHP_EOL
|
||||
$colorCli->error(PHP_EOL.'You must supply 4 arguments.'.PHP_EOL
|
||||
.'The 2nd argument, false, will display the results, but not change the name, type true to have the names changed.'.PHP_EOL
|
||||
.'The 3rd argument, other, will only do against other categories, to do against all categories use all, or predb_id to process all not matched to predb.'.PHP_EOL
|
||||
.'The 4th argument, yes, will set the release as checked, so the next time you run it will not be processed, to not set as checked type no.'.PHP_EOL
|
||||
|
||||
@@ -8,8 +8,10 @@ use Blacklight\Categorize;
|
||||
use Blacklight\ConsoleTools;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
$colorCli = new ColorCLI();
|
||||
|
||||
if (! (isset($argv[1]) && ($argv[1] === 'all' || $argv[1] === 'misc' || preg_match('/\([\d, ]+\)/', $argv[1]) || is_numeric($argv[1])))) {
|
||||
ColorCLI::error(
|
||||
$colorCli->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, test, will display the number of category changes that would be made\n"
|
||||
@@ -41,11 +43,11 @@ function reCategorize($argv)
|
||||
}
|
||||
|
||||
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.');
|
||||
$colorCli->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.');
|
||||
$colorCli->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.');
|
||||
$colorCli->header('Categorizing all releases using searchname. This can take a while, be patient.');
|
||||
}
|
||||
$timestart = now();
|
||||
if (isset($argv[1]) && (is_numeric($argv[1]) || $argv[1] === 'misc')) {
|
||||
@@ -55,9 +57,9 @@ function reCategorize($argv)
|
||||
}
|
||||
$time = now()->diffInSeconds($timestart);
|
||||
if ($update === true) {
|
||||
ColorCLI::header('Finished re-categorizing '.number_format($chgcount).' releases in '.$time.' , using the searchname.'.PHP_EOL);
|
||||
$colorCli->header('Finished re-categorizing '.number_format($chgcount).' releases in '.$time.' , using the searchname.'.PHP_EOL);
|
||||
} else {
|
||||
ColorCLI::header('Finished re-categorizing in '.$time.' seconds , using the searchname.'.PHP_EOL
|
||||
$colorCli->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);
|
||||
}
|
||||
}
|
||||
@@ -69,7 +71,7 @@ function categorizeRelease($where, $update = true, $echooutput = false)
|
||||
$cat = new Categorize();
|
||||
$consoletools = new ConsoleTools();
|
||||
$relcount = $chgcount = 0;
|
||||
ColorCLI::primary('SELECT id, searchname, fromname, groups_id, categories_id FROM releases '.$where);
|
||||
$colorCli->primary('SELECT id, searchname, fromname, groups_id, categories_id FROM releases '.$where);
|
||||
$resrel = DB::select('SELECT id, searchname, fromname, groups_id, categories_id FROM releases '.$where);
|
||||
$total = \count($resrel);
|
||||
if ($total > 0) {
|
||||
|
||||
@@ -7,6 +7,7 @@ use Blacklight\ColorCLI;
|
||||
use Blacklight\libraries\FanartTV;
|
||||
|
||||
$fanart = new FanartTV(Settings::settingValue('APIs..fanarttvkey'));
|
||||
$colorCli = new ColorCLI();
|
||||
|
||||
if (! empty($argv[1])) {
|
||||
|
||||
@@ -17,10 +18,10 @@ if (! empty($argv[1])) {
|
||||
if ($moviefanart) {
|
||||
dump($moviefanart);
|
||||
} else {
|
||||
ColorCLI::error('Error retrieving Fanart.TV data.');
|
||||
$colorCli->error('Error retrieving Fanart.TV data.');
|
||||
exit();
|
||||
}
|
||||
} else {
|
||||
ColorCLI::error('Invalid arguments. This script requires a number or string (TMDB or IMDb ID.');
|
||||
$colorCli->error('Invalid arguments. This script requires a number or string (TMDB or IMDb ID.');
|
||||
exit();
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ use aharen\OMDbAPI;
|
||||
use Blacklight\ColorCLI;
|
||||
|
||||
$omdb = new OMDbAPI();
|
||||
$colorCli = new ColorCLI();
|
||||
|
||||
if (! empty($argv[1]) && ! empty($argv[2]) && ($argv[2] !== 'series' || $argv[2] !== 'movie')) {
|
||||
|
||||
@@ -24,10 +25,10 @@ if (! empty($argv[1]) && ! empty($argv[2]) && ($argv[2] !== 'series' || $argv[2]
|
||||
|
||||
dump($search);
|
||||
} else {
|
||||
ColorCLI::error('Error retrieving OMDb API data.');
|
||||
$colorCli->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.');
|
||||
$colorCli->error('Invalid arguments. This script requires a text string (show name), and a second argument, movie or series.');
|
||||
exit();
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
|
||||
use Blacklight\processing\tv\TMDB;
|
||||
|
||||
$tmdb = new TMDB();
|
||||
$colorCli = new ColorCLI();
|
||||
|
||||
if (! empty($argv[1]) && is_numeric($argv[2]) && is_numeric($argv[3])) {
|
||||
|
||||
@@ -47,11 +48,11 @@ if (! empty($argv[1]) && is_numeric($argv[2]) && is_numeric($argv[3])) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
exit(\Blacklight\ColorCLI::error('Invalid episode data returned from TMDB API.'));
|
||||
exit($colorCli->error('Invalid episode data returned from TMDB API.'));
|
||||
}
|
||||
} else {
|
||||
exit(\Blacklight\ColorCLI::error('Invalid show data returned from TMDB API.'));
|
||||
exit($colorCli->error('Invalid show data returned from TMDB API.'));
|
||||
}
|
||||
} else {
|
||||
exit(\Blacklight\ColorCLI::error('Invalid arguments. This script requires a text string (show name) followed by a season and episode number.'));
|
||||
exit($colorCli->error('Invalid arguments. This script requires a text string (show name) followed by a season and episode number.'));
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ if (isset($argv[1]) && is_numeric($argv[1])) {
|
||||
|
||||
UserVerification::send($user, 'User email verification required');
|
||||
|
||||
ColorCLI::notice('Email has been sent');
|
||||
echo 'Email has been sent';
|
||||
} else {
|
||||
ColorCLI::info('You need to provide user id as argument');
|
||||
echo 'You need to provide user id as argument';
|
||||
}
|
||||
|
||||
@@ -27,12 +27,12 @@ if (isset($argv[1]) && $argv[1] === 'all' && ! isset($argv[2])) {
|
||||
$backfill = new Backfill(['NNTP' => $nntp]);
|
||||
$backfill->safeBackfill($argv[2]);
|
||||
} else {
|
||||
exit(\Blacklight\ColorCLI::error("\nWrong set of arguments.\n"
|
||||
.'php backfill.php safe 200000 ...: Backfill an active group alphabetically, x articles, the script stops,'."\n"
|
||||
.' ...: if the group has reached reached 2012-06-24, the next group will backfill.'."\n"
|
||||
.'php backfill.php alph 200000 ...: Backfills all groups (sorted alphabetically) by number of articles'."\n"
|
||||
.'php backfill.php date 200000 ...: Backfills all groups (sorted by least backfilled in time) by number of articles'."\n"
|
||||
.'php backfill.php alt.binaries.ath 200000 ...: Backfills a group by name by number of articles'."\n"
|
||||
.'php backfill.php all ...: Backfills all groups 1 at a time, by date (set in admin-view groups)'."\n"
|
||||
.'php backfill.php alt.binaries.ath ...: Backfills a group by name, by date (set in admin-view groups)'."\n"));
|
||||
exit((new \Blacklight\ColorCLI())->error("Wrong set of arguments."
|
||||
.'php backfill.php safe 200000 ...: Backfill an active group alphabetically, x articles, the script stops,'
|
||||
.' ...: if the group has reached reached 2012-06-24, the next group will backfill.'
|
||||
.'php backfill.php alph 200000 ...: Backfills all groups (sorted alphabetically) by number of articles'
|
||||
.'php backfill.php date 200000 ...: Backfills all groups (sorted by least backfilled in time) by number of articles'
|
||||
.'php backfill.php alt.binaries.ath 200000 ...: Backfills a group by name by number of articles'
|
||||
.'php backfill.php all ...: Backfills all groups 1 at a time, by date (set in admin-view groups)'
|
||||
.'php backfill.php alt.binaries.ath ...: Backfills a group by name, by date (set in admin-view groups)'));
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ use Blacklight\NameFixer;
|
||||
|
||||
if (! isset($argv[1]) && ($argv[1] !== 'full' || ! is_numeric($argv[1]))) {
|
||||
exit(
|
||||
ColorCLI::error(
|
||||
(new ColorCLI())->error(
|
||||
PHP_EOL
|
||||
.'This script tries to match release filenames to PreDB filenames.'.PHP_EOL
|
||||
.'To display the changes, use "show" as the second argument. The optional third argument will limit the amount of filenames to attempt to match.'.PHP_EOL.PHP_EOL
|
||||
|
||||
@@ -36,7 +36,7 @@ $bool = [
|
||||
|
||||
if (! isset($argv[1], $argv[2]) || ! in_array($argv[1], $args, false) || ! in_array($argv[2], $bool, false)) {
|
||||
exit(
|
||||
\Blacklight\ColorCLI::error(
|
||||
(new \Blacklight\ColorCLI())->error(
|
||||
"\nIncorrect arguments.\n"
|
||||
."The second argument (true/false) determines wether to echo or not.\n\n"
|
||||
."php postprocess.php all true ...: Does all the types of post processing.\n"
|
||||
|
||||
@@ -14,8 +14,9 @@ use Blacklight\NZBContents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Blacklight\processing\PostProcess;
|
||||
|
||||
$colorCli = new ColorCLI();
|
||||
if (! isset($argv[1])) {
|
||||
ColorCLI::error('This script is not intended to be run manually, it is called from Multiprocessing.');
|
||||
$colorCli->error('This script is not intended to be run manually, it is called from Multiprocessing.');
|
||||
exit();
|
||||
}
|
||||
$nameFixer = new NameFixer();
|
||||
@@ -95,15 +96,15 @@ switch (true) {
|
||||
$nameFixer->checked++;
|
||||
$nameFixer->reset();
|
||||
|
||||
ColorCLI::primary("[{$release->releases_id}]");
|
||||
$colorCli->primary("[{$release->releases_id}]", true);
|
||||
|
||||
if ((int) $release->ishashed === 1 && (int) $release->dehashstatus >= -6 && (int) $release->dehashstatus <= 0) {
|
||||
ColorCLI::primaryOver('m');
|
||||
$colorCli->primaryOver('m');
|
||||
if (preg_match('/[a-fA-F0-9]{32,40}/i', $release->name, $matches)) {
|
||||
$nameFixer->matchPredbHash($matches[0], $release, true, 1, true);
|
||||
}
|
||||
if ($nameFixer->matched === false && ! empty($release->filehash) && preg_match('/[a-fA-F0-9]{32,40}/i', $release->filehash, $matches)) {
|
||||
ColorCLI::primaryOver('h');
|
||||
$colorCli->primaryOver('h');
|
||||
$nameFixer->matchPredbHash($matches[0], $release, true, 1, true);
|
||||
}
|
||||
}
|
||||
@@ -114,7 +115,7 @@ switch (true) {
|
||||
$nameFixer->reset();
|
||||
|
||||
if ((int) $release->proc_uid === NameFixer::PROC_UID_NONE && ! empty($release->uid)) {
|
||||
ColorCLI::primaryOver('U');
|
||||
$colorCli->primaryOver('U');
|
||||
$nameFixer->uidCheck($release, true, 'UID, ', 1, 1);
|
||||
}
|
||||
// Not all gate requirements in query always set column status as PP Add check is in query
|
||||
@@ -126,7 +127,7 @@ switch (true) {
|
||||
$nameFixer->reset();
|
||||
|
||||
if ((int) $release->proc_srr === NameFixer::PROC_SRR_NONE) {
|
||||
ColorCLI::primaryOver('sr');
|
||||
$colorCli->primaryOver('sr');
|
||||
$nameFixer->srrNameCheck($release, true, 'SRR, ', 1, 1);
|
||||
}
|
||||
// Not all gate requirements in query always set column status as PP Add check is in query
|
||||
@@ -138,7 +139,7 @@ switch (true) {
|
||||
$nameFixer->reset();
|
||||
|
||||
if ((int) $release->proc_hash16k === NameFixer::PROC_HASH16K_NONE && ! empty($release->hash)) {
|
||||
ColorCLI::primaryOver('H');
|
||||
$colorCli->primaryOver('H');
|
||||
$nameFixer->hashCheck($release, true, 'PAR2 hash, ', 1, 1);
|
||||
}
|
||||
// Not all gate requirements in query always set column status as PP Add check is in query
|
||||
@@ -151,7 +152,7 @@ switch (true) {
|
||||
|
||||
if ((int) $release->nfostatus === Nfo::NFO_FOUND && (int) $release->proc_nfo === NameFixer::PROC_NFO_NONE) {
|
||||
if (! empty($release->textstring) && ! preg_match('/^=newz\[NZB\]=\w+/', $release->textstring)) {
|
||||
ColorCLI::primaryOver('n');
|
||||
$colorCli->primaryOver('n');
|
||||
$nameFixer->done = $nameFixer->matched = false;
|
||||
$nameFixer->checkName($release, true, 'NFO, ', 1, 1);
|
||||
}
|
||||
@@ -164,14 +165,14 @@ switch (true) {
|
||||
$nameFixer->reset();
|
||||
|
||||
if ((int) $release->fileid > 0 && (int) $release->proc_files === NameFixer::PROC_FILES_NONE) {
|
||||
ColorCLI::primaryOver('F');
|
||||
$colorCli->primaryOver('F');
|
||||
$nameFixer->done = $nameFixer->matched = false;
|
||||
$fileNames = explode('|', $release->filestring);
|
||||
if (is_array($fileNames)) {
|
||||
$releaseFile = $release;
|
||||
foreach ($fileNames as $fileName) {
|
||||
if ($nameFixer->matched === false) {
|
||||
ColorCLI::primaryOver('f');
|
||||
$colorCli->primaryOver('f');
|
||||
$releaseFile->textstring = $fileName;
|
||||
$nameFixer->checkName($releaseFile, true, 'Filenames, ', 1, 1);
|
||||
}
|
||||
@@ -187,11 +188,11 @@ switch (true) {
|
||||
$nameFixer->reset();
|
||||
|
||||
if ((int) $release->proc_par2 === NameFixer::PROC_PAR2_NONE) {
|
||||
ColorCLI::primaryOver('p');
|
||||
$colorCli->primaryOver('p');
|
||||
if (! isset($nzbcontents)) {
|
||||
$nntp = new NNTP();
|
||||
if (((int) Settings::settingValue('..alternate_nntp') === 1 ? $nntp->doConnect(true, true) : $nntp->doConnect()) !== true) {
|
||||
ColorCLI::error('Unable to connect to usenet.');
|
||||
$colorCli->error('Unable to connect to usenet.');
|
||||
}
|
||||
$Nfo = new Nfo();
|
||||
$nzbcontents = new NZBContents([
|
||||
|
||||
@@ -11,22 +11,23 @@ use Illuminate\Support\Facades\DB;
|
||||
|
||||
$start = now();
|
||||
$consoleTools = new ConsoleTools();
|
||||
$colorCli = new ColorCLI();
|
||||
|
||||
// Create the connection here and pass
|
||||
$nntp = new NNTP();
|
||||
if ($nntp->doConnect() !== true) {
|
||||
ColorCLI::error('Unable to connect to usenet.');
|
||||
$colorCli->error('Unable to connect to usenet.');
|
||||
exit();
|
||||
}
|
||||
|
||||
ColorCLI::header('Getting first/last for all your active groups.');
|
||||
$colorCli->header('Getting first/last for all your active groups.');
|
||||
$data = $nntp->getGroups();
|
||||
if ($nntp->isError($data)) {
|
||||
ColorCLI::error('Failed to getGroups() from nntp server.');
|
||||
$colorCli->error('Failed to getGroups() from nntp server.');
|
||||
exit();
|
||||
}
|
||||
|
||||
ColorCLI::header('Inserting new values into short_groups table.');
|
||||
$colorCli->header('Inserting new values into short_groups table.');
|
||||
|
||||
DB::unprepared('TRUNCATE TABLE short_groups');
|
||||
DB::commit();
|
||||
@@ -42,8 +43,8 @@ foreach ($data as $newgroup) {
|
||||
'last_record' => $newgroup['last'],
|
||||
'updated' => now(),
|
||||
]);
|
||||
ColorCLI::primary('Updated '.$newgroup['group']);
|
||||
$colorCli->primary('Updated '.$newgroup['group']);
|
||||
}
|
||||
}
|
||||
|
||||
ColorCLI::header('Running time: '.now()->diffInSeconds($start).' seconds');
|
||||
$colorCli->header('Running time: '.now()->diffInSeconds($start).' seconds');
|
||||
|
||||
@@ -13,6 +13,7 @@ use Illuminate\Support\Facades\DB;
|
||||
|
||||
$pdo = DB::connection()->getPdo();
|
||||
$tMain = new Tmux();
|
||||
$colorCli = new ColorCLI();
|
||||
try {
|
||||
$tRun = new TmuxRun();
|
||||
} catch (Exception $e) {
|
||||
@@ -120,7 +121,7 @@ while ($runVar['counts']['iterations'] > 0) {
|
||||
$runVar['counts']['now']['total_work'] = 0;
|
||||
$runVar['modsettings']['fix_crap'] = explode(', ', $runVar['settings']['fix_crap']);
|
||||
|
||||
ColorCLI::info("\nThe numbers(queries) above are currently being refreshed. \nNo pane(script) can be (re)started until these have completed.\n");
|
||||
$colorCli->info("\nThe numbers(queries) above are currently being refreshed. \nNo pane(script) can be (re)started until these have completed.\n");
|
||||
$timer02 = time();
|
||||
|
||||
try {
|
||||
@@ -417,7 +418,7 @@ while ($runVar['counts']['iterations'] > 0) {
|
||||
|
||||
function errorOnSQL()
|
||||
{
|
||||
ColorCLI::error(PHP_EOL.'Monitor encountered severe errors retrieving process data from MySQL. Please diagnose and try running again.'.PHP_EOL);
|
||||
$colorCli->error(PHP_EOL.'Monitor encountered severe errors retrieving process data from MySQL. Please diagnose and try running again.'.PHP_EOL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,6 +14,7 @@ $tmux_session = Settings::settingValue('site.tmux.tmux_session') ?? 0;
|
||||
$seq = Settings::settingValue('site.tmux.sequential') ?? 0;
|
||||
$delaytimet = Settings::settingValue('..delaytime');
|
||||
$delaytimet = $delaytimet ? (int) $delaytimet : 2;
|
||||
$colorCli = new ColorCLI();
|
||||
|
||||
try {
|
||||
Utility::isPatched();
|
||||
@@ -31,12 +32,12 @@ $session = shell_exec("tmux list-session | grep $tmux_session");
|
||||
// Kill the placeholder
|
||||
exec('tmux kill-session -t placeholder');
|
||||
if ($session !== null) {
|
||||
ColorCLI::error("tmux session: '".$tmux_session."' is already running, aborting.");
|
||||
$colorCli->error("tmux session: '".$tmux_session."' is already running, aborting.");
|
||||
exit();
|
||||
}
|
||||
|
||||
//reset collections dateadded to now if dateadded > delay time check
|
||||
ColorCLI::header('Resetting expired collections dateadded to now. This could take a minute or two. Really.');
|
||||
$colorCli->header('Resetting expired collections dateadded to now. This could take a minute or two. Really.');
|
||||
|
||||
$sql = 'SHOW table status';
|
||||
$tables = DB::select($sql);
|
||||
@@ -56,7 +57,7 @@ foreach ($tables as $row) {
|
||||
}
|
||||
}
|
||||
}
|
||||
ColorCLI::primary(number_format($ran).' collections reset.');
|
||||
$colorCli->primary(number_format($ran).' collections reset.');
|
||||
sleep(2);
|
||||
|
||||
function writelog($pane)
|
||||
@@ -82,7 +83,7 @@ function command_exist($cmd)
|
||||
$apps = ['time', 'tmux', 'nice', 'tee'];
|
||||
foreach ($apps as &$value) {
|
||||
if (! command_exist($value)) {
|
||||
ColorCLI::error('Tmux scripts require '.$value.' but its not installed. Aborting.');
|
||||
$colorCli->error('Tmux scripts require '.$value.' but its not installed. Aborting.');
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,18 +9,19 @@ use Blacklight\Binaries;
|
||||
use Blacklight\ColorCLI;
|
||||
|
||||
$maxHeaders = (int) Settings::settingValue('..max_headers_iteration') ?: 1000000;
|
||||
$colorCli = new ColorCLI();
|
||||
|
||||
// Create the connection here and pass
|
||||
$nntp = new NNTP();
|
||||
if ($nntp->doConnect() !== true) {
|
||||
ColorCLI::error('Unable to connect to usenet.');
|
||||
$colorCli->error('Unable to connect to usenet.');
|
||||
exit();
|
||||
}
|
||||
$binaries = new Binaries(['NNTP' => $nntp]);
|
||||
|
||||
if (isset($argv[1]) && ! is_numeric($argv[1])) {
|
||||
$groupName = $argv[1];
|
||||
ColorCLI::header("Updating group: $groupName");
|
||||
$colorCli->header("Updating group: $groupName");
|
||||
|
||||
$group = Group::getByName($groupName);
|
||||
if (is_array($group)) {
|
||||
|
||||
Reference in New Issue
Block a user