From 05b0c894dd83213ea32a3e7bcb4e6647cfc91d89 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Wed, 14 Feb 2018 14:07:12 +0100 Subject: [PATCH] Fix echoing of cli messages (most of them) --- Changelog | 1 + app/Extensions/helper/helpers.php | 10 +++--- app/Models/Group.php | 2 +- cli/data/predb_import_daily_batch.php | 6 ++-- misc/testing/DB/reset_truncate.php | 2 +- nntmux/Backfill.php | 6 ++-- nntmux/Binaries.php | 12 +++---- nntmux/Books.php | 20 +++++------ nntmux/Console.php | 13 ++++--- nntmux/Games.php | 14 ++++---- nntmux/Movie.php | 50 +++++++++++++-------------- nntmux/Music.php | 12 +++---- nntmux/Nfo.php | 4 +-- nntmux/ReleaseImage.php | 8 ++--- nntmux/Steam.php | 6 ++-- nntmux/Tmux.php | 2 +- nntmux/XXX.php | 18 +++++----- nntmux/libraries/Forking.php | 8 ++--- nntmux/libraries/ForkingImportNZB.php | 2 +- nntmux/libraries/TraktAPI.php | 10 +++--- nntmux/processing/ProcessReleases.php | 24 ++++++------- nntmux/processing/post/AniDB.php | 2 +- 22 files changed, 117 insertions(+), 115 deletions(-) diff --git a/Changelog b/Changelog index 200ebc0cd..96f2bfe63 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2018-02-14 DariusIII + * Fix: Fix echoing of cli messages (most of them) * Chg: Update echoing of informational messages in update_groups.php * Chg: Update ColorCLI class * Chg: Update API and RSS classes diff --git a/app/Extensions/helper/helpers.php b/app/Extensions/helper/helpers.php index c142d89fc..245c6b454 100644 --- a/app/Extensions/helper/helpers.php +++ b/app/Extensions/helper/helpers.php @@ -30,15 +30,15 @@ if (! function_exists('getRawHtml')) { } catch (RequestException $e) { if ($e->hasResponse()) { if ($e->getCode() === 404) { - ColorCLI::doEcho(ColorCLI::notice('Data not available on server')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on server'), true); } elseif ($e->getCode() === 503) { - ColorCLI::doEcho(ColorCLI::notice('Service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('Service unavailable'), true); } else { - ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data from server, http error reported: '.$e->getCode())); + ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data from server, http error reported: '.$e->getCode()), true); } } } catch (\RuntimeException $e) { - ColorCLI::doEcho(ColorCLI::notice('Runtime error: '.$e->getCode())); + ColorCLI::doEcho(ColorCLI::notice('Runtime error: '.$e->getCode()), true); } return $response; @@ -51,7 +51,9 @@ if (! function_exists('makeFieldLinks')) { * @param $data * @param $field * @param $type + * * @return string + * @throws \Exception */ function makeFieldLinks($data, $field, $type) { diff --git a/app/Models/Group.php b/app/Models/Group.php index 739f2daa4..9340dbfb3 100644 --- a/app/Models/Group.php +++ b/app/Models/Group.php @@ -560,7 +560,7 @@ class Group extends Model ColorCLI::doEcho( ColorCLI::error( 'Group does not exist on server, disabling' - ) + ), true ); } } diff --git a/cli/data/predb_import_daily_batch.php b/cli/data/predb_import_daily_batch.php index 9cd01b7a7..d54f077b1 100755 --- a/cli/data/predb_import_daily_batch.php +++ b/cli/data/predb_import_daily_batch.php @@ -147,7 +147,7 @@ foreach ($data as $dir => $files) { $verbose = $argv[3] === true; if ($verbose) { - ColorCLI::doEcho(ColorCLI::info('Clearing import table')); + ColorCLI::doEcho(ColorCLI::info('Clearing import table'), true); } // Truncate to clear any old data @@ -165,7 +165,7 @@ foreach ($data as $dir => $files) { // Remove any titles where length <=8 if ($verbose === true) { - ColorCLI::doEcho(ColorCLI::info('Deleting any records where title <=8 from Temporary Table')); + ColorCLI::doEcho(ColorCLI::info('Deleting any records where title <=8 from Temporary Table'), true); } $predb->executeDeleteShort(); @@ -175,7 +175,7 @@ foreach ($data as $dir => $files) { // Fill the groups_id $predb->executeUpdateGroupID(); - ColorCLI::doEcho(ColorCLI::info('Inserting records from temporary table into predb table')); + ColorCLI::doEcho(ColorCLI::info('Inserting records from temporary table into predb table'), true); $predb->executeInsert(); // Delete the dump. diff --git a/misc/testing/DB/reset_truncate.php b/misc/testing/DB/reset_truncate.php index 2c2b5410c..7efacd36e 100644 --- a/misc/testing/DB/reset_truncate.php +++ b/misc/testing/DB/reset_truncate.php @@ -54,7 +54,7 @@ if (isset($argv[1]) && ($argv[1] === 'true' || $argv[1] === 'drop')) { 'This script removes releases with no NZBs, resets all groups, truncates or drops(tpg) article tables. All other releases are left alone. php '.$argv[0].' [true, drop] ...: To reset all groups and truncate/drop the tables.' - ) + ), true ); exit; } diff --git a/nntmux/Backfill.php b/nntmux/Backfill.php index 3b4cae724..ceb670fff 100755 --- a/nntmux/Backfill.php +++ b/nntmux/Backfill.php @@ -152,7 +152,7 @@ class Backfill $dMessage = 'Backfilling completed in '.number_format(microtime(true) - $allTime, 2).' seconds.'; if ($this->_echoCLI) { - ColorCLI::doEcho(ColorCLI::primary($dMessage)); + ColorCLI::doEcho(ColorCLI::primary($dMessage), true); } } else { $dMessage = 'No groups specified. Ensure groups are added to database for updating.'; @@ -190,7 +190,7 @@ class Backfill '. Otherwise the group is dead, you must disable it.'; if ($this->_echoCLI) { - ColorCLI::doEcho(ColorCLI::error($dMessage)); + ColorCLI::doEcho(ColorCLI::error($dMessage), true); } return; @@ -259,7 +259,7 @@ class Backfill '. Our oldest article is article '. number_format($groupArr['first_record']). '.' - ) + ), true ); } diff --git a/nntmux/Binaries.php b/nntmux/Binaries.php index 791c9fc63..b2450c964 100755 --- a/nntmux/Binaries.php +++ b/nntmux/Binaries.php @@ -995,7 +995,7 @@ class Binaries ColorCLI::debug( 'Sending '.round(\strlen($partsQuery) / 1024, 2). ' KB of'.($this->multiGroup ? ' MGR' : '').' parts to MySQL' - ) + ), true ); } if (\strlen($partsQuery) === \strlen($partsCheck) ? true : $this->_pdo->queryExec(rtrim($partsQuery, ','))) { @@ -1068,7 +1068,7 @@ class Binaries 'Received '.\count($this->headersReceived). ' articles of '.number_format($this->last - $this->first + 1).' requested, '. $this->headersBlackListed.' blacklisted, '.$this->notYEnc.' not yEnc.' - ) + ), true ); } @@ -1090,7 +1090,7 @@ class Binaries ColorCLI::primaryOver(' for part repair, '). ColorCLI::alternateOver(number_format($currentMicroTime - $this->startLoop, 2).'s'). ColorCLI::primary(' total.') - ); + , true); } } @@ -1328,7 +1328,7 @@ class Binaries $currentPost = $tempPost; if ($this->_debug) { - ColorCLI::doEcho(ColorCLI::debug('Postdate retried '.$attempts.' time(s).')); + ColorCLI::doEcho(ColorCLI::debug('Postdate retried '.$attempts.' time(s).'), true); } } while ($attempts++ <= 20); @@ -1375,7 +1375,7 @@ class Binaries ColorCLI::doEcho( ColorCLI::primary( 'Searching for an approximate article number for group '.$data['group'].' '.$days.' days back.' - ) + ), true ); } @@ -1436,7 +1436,7 @@ class Binaries 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.' - ) + ), true ); } diff --git a/nntmux/Books.php b/nntmux/Books.php index cfcb50277..a06c13908 100755 --- a/nntmux/Books.php +++ b/nntmux/Books.php @@ -421,7 +421,7 @@ class Books { if ($res instanceof \Traversable && $res->count() > 0) { if ($this->echooutput) { - ColorCLI::doEcho(ColorCLI::header("\nProcessing ".$res->count().' book release(s) for categories id '.$categoryID)); + ColorCLI::doEcho(ColorCLI::header("\nProcessing ".$res->count().' book release(s) for categories id '.$categoryID), true); } $bookId = -2; @@ -439,7 +439,7 @@ class Books if ($bookInfo !== false) { if ($this->echooutput) { - ColorCLI::doEcho(ColorCLI::headerOver('Looking up: ').ColorCLI::primary($bookInfo)); + ColorCLI::doEcho(ColorCLI::headerOver('Looking up: ').ColorCLI::primary($bookInfo), true); } // Do a local lookup first @@ -448,7 +448,7 @@ class Books if ($bookCheck === false && \in_array($bookInfo, $this->failCache, false)) { // Lookup recently failed, no point trying again if ($this->echooutput) { - ColorCLI::doEcho(ColorCLI::headerOver('Cached previous failure. Skipping.').PHP_EOL); + ColorCLI::doEcho(ColorCLI::headerOver('Cached previous failure. Skipping.'), true); } $bookId = -2; } elseif ($bookCheck === false) { @@ -478,7 +478,7 @@ class Books } } } elseif ($this->echooutput) { - ColorCLI::doEcho(ColorCLI::header('No book releases to process for categories id '.$categoryID)); + ColorCLI::doEcho(ColorCLI::header('No book releases to process for categories id '.$categoryID), true); } } @@ -506,7 +506,7 @@ class Books 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(c|k)tober|November|De(c|z)ember)))[a-z]+( (ebooks?|The))?$|NY Times|(Book|Massive) Dump|Sexual/i', $releasename)) { if ($this->echooutput) { ColorCLI::doEcho( - ColorCLI::headerOver('Changing category to misc books: ').ColorCLI::primary($releasename) + ColorCLI::headerOver('Changing category to misc books: ').ColorCLI::primary($releasename), true ); } Release::query()->where('id', $releaseID)->update(['categories_id' => Category::BOOKS_UNKNOWN]); @@ -517,7 +517,7 @@ class Books if (preg_match('/^([a-z0-9ΓΌ!]+ ){1,2}(N|Vol)?\d{1,4}(a|b|c)?$|^([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(c|k)t( |ober|$)|Nov( |ember|$)|De(c|z)( |ember|$))/ui', $releasename) && ! preg_match('/Part \d+/i', $releasename)) { if ($this->echooutput) { ColorCLI::doEcho( - ColorCLI::headerOver('Changing category to magazines: ').ColorCLI::primary($releasename) + ColorCLI::headerOver('Changing category to magazines: ').ColorCLI::primary($releasename), true ); } Release::query()->where('id', $releaseID)->update(['categories_id' => Category::BOOKS_MAGAZINES]); @@ -672,13 +672,13 @@ class Books if ($bookId && $bookId !== -2) { if ($this->echooutput) { - ColorCLI::doEcho(ColorCLI::header('Added/updated book: ')); + ColorCLI::doEcho(ColorCLI::header('Added/updated book: '), true); if ($book['author'] !== '') { - ColorCLI::doEcho(ColorCLI::alternateOver(' Author: ').ColorCLI::primary($book['author'])); + ColorCLI::doEcho(ColorCLI::alternateOver(' Author: ').ColorCLI::primary($book['author']), true); } echo ColorCLI::alternateOver(' Title: ').ColorCLI::primary(' '.$book['title']); if ($book['genre'] !== 'null') { - ColorCLI::doEcho(ColorCLI::alternateOver(' Genre: ').ColorCLI::primary(' '.$book['genre'])); + ColorCLI::doEcho(ColorCLI::alternateOver(' Genre: ').ColorCLI::primary(' '.$book['genre']), true); } } @@ -689,7 +689,7 @@ class Books ColorCLI::header('Nothing to update: '). ColorCLI::header($book['author']. ' - '. - $book['title']) + $book['title']), true ); } } diff --git a/nntmux/Console.php b/nntmux/Console.php index bbb3b7265..adf1e4647 100755 --- a/nntmux/Console.php +++ b/nntmux/Console.php @@ -420,7 +420,7 @@ class Console ColorCLI::alternateOver(' Platform: '). ColorCLI::primary($con['platform']). ColorCLI::alternateOver(' Genre: '). - ColorCLI::primary($con['consolegenre']) + ColorCLI::primary($con['consolegenre']), true ); } } @@ -812,7 +812,7 @@ class Console $releaseCount = $res->count(); if ($res instanceof \Traversable && $releaseCount > 0) { if ($this->echooutput) { - ColorCLI::doEcho(ColorCLI::header('Processing '.$releaseCount.' console release(s).')); + ColorCLI::doEcho(ColorCLI::header('Processing '.$releaseCount.' console release(s).'), true); } foreach ($res as $arr) { @@ -829,7 +829,7 @@ class Console $gameInfo['title']. ' ('. $gameInfo['platform'].')' - ) + ), true ); } @@ -839,7 +839,7 @@ class Console if ($gameCheck === null && \in_array($gameInfo['title'].$gameInfo['platform'], $this->failCache, false)) { // Lookup recently failed, no point trying again if ($this->echooutput) { - ColorCLI::doEcho(ColorCLI::headerOver('Cached previous failure. Skipping.').PHP_EOL); + ColorCLI::doEcho(ColorCLI::headerOver('Cached previous failure. Skipping.'), true); } $gameId = -2; } elseif ($gameCheck === null) { @@ -853,8 +853,7 @@ class Console if ($this->echooutput) { ColorCLI::doEcho( ColorCLI::headerOver('Found Local: '). - ColorCLI::primary("{$gameCheck['title']} - {$gameCheck['platform']}"). - PHP_EOL + ColorCLI::primary("{$gameCheck['title']} - {$gameCheck['platform']}"), true ); } $gameId = $gameCheck['id']; @@ -873,7 +872,7 @@ class Console } } } elseif ($this->echooutput) { - ColorCLI::doEcho(ColorCLI::header('No console releases to process.')); + ColorCLI::doEcho(ColorCLI::header('No console releases to process.'), true); } } diff --git a/nntmux/Games.php b/nntmux/Games.php index f15816297..bfae2a6d9 100755 --- a/nntmux/Games.php +++ b/nntmux/Games.php @@ -589,12 +589,12 @@ class Games $game['review'] = (string) $this->_gameResults->deck; } } else { - ColorCLI::doEcho(ColorCLI::notice('GiantBomb returned no valid results')); + ColorCLI::doEcho(ColorCLI::notice('GiantBomb returned no valid results'), true); return false; } } else { - ColorCLI::doEcho(ColorCLI::notice('GiantBomb found no valid results')); + ColorCLI::doEcho(ColorCLI::notice('GiantBomb found no valid results'), true); return false; } @@ -702,7 +702,7 @@ class Games ColorCLI::alternateOver(' Title: '). ColorCLI::primary($game['title']). ColorCLI::alternateOver(' Source: '). - ColorCLI::primary($this->_classUsed) + ColorCLI::primary($this->_classUsed), true ); } if ($game['cover'] === 1) { @@ -715,7 +715,7 @@ class Games if ($this->echoOutput) { ColorCLI::doEcho( ColorCLI::headerOver('Nothing to update: '). - ColorCLI::primary($game['title'].' (PC)') + ColorCLI::primary($game['title'].' (PC)'), true ); } } @@ -747,7 +747,7 @@ class Games if ($res instanceof \Traversable && $res->rowCount() > 0) { if ($this->echoOutput) { - ColorCLI::doEcho(ColorCLI::header('Processing '.$res->rowCount().' games release(s).')); + ColorCLI::doEcho(ColorCLI::header('Processing '.$res->rowCount().' games release(s).'), true); } foreach ($res as $arr) { @@ -760,7 +760,7 @@ class Games if ($this->echoOutput) { ColorCLI::doEcho( ColorCLI::headerOver('Looking up: '). - ColorCLI::primary($gameInfo['title'].' (PC)') + ColorCLI::primary($gameInfo['title'].' (PC)'), true ); } @@ -793,7 +793,7 @@ class Games } } else { if ($this->echoOutput) { - ColorCLI::doEcho(ColorCLI::header('No games releases to process.')); + ColorCLI::doEcho(ColorCLI::header('No games releases to process.'), true); } } } diff --git a/nntmux/Movie.php b/nntmux/Movie.php index 40f05d2dd..7c9d53e77 100755 --- a/nntmux/Movie.php +++ b/nntmux/Movie.php @@ -620,7 +620,7 @@ class Movie public function updateMovieInfo($imdbId): bool { if ($this->echooutput && $this->service !== '') { - ColorCLI::doEcho(ColorCLI::primary('Fetching IMDB info from TMDB/IMDB/Trakt/OMDB using IMDB id: '.$imdbId)); + ColorCLI::doEcho(ColorCLI::primary('Fetching IMDB info from TMDB/IMDB/Trakt/OMDB using IMDB id: '.$imdbId), true); } // Check TMDB for IMDB info. @@ -744,7 +744,7 @@ class Movie $mov['year']. ') - '. $mov['imdbid'] - ) + ), true ); } @@ -905,15 +905,15 @@ class Movie } catch (RequestException $e) { if ($e->hasResponse()) { if ($e->getCode() === 404) { - ColorCLI::doEcho(ColorCLI::notice('Data not available on IMDB server')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on IMDB server'), true); } elseif ($e->getCode() === 503) { - ColorCLI::doEcho(ColorCLI::notice('IMDB service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('IMDB service unavailable'), true); } else { - ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data from IMDB, http error reported: '.$e->getCode())); + ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data from IMDB, http error reported: '.$e->getCode()), true); } } } catch (\RuntimeException $e) { - ColorCLI::doEcho(ColorCLI::notice('Runtime error: '.$e->getCode())); + ColorCLI::doEcho(ColorCLI::notice('Runtime error: '.$e->getCode()), true); } if (isset($buffer) && $buffer !== false) { @@ -1064,7 +1064,7 @@ class Movie if ($imdbID !== false) { $this->service = $service; if ($this->echooutput && $this->service !== '') { - ColorCLI::doEcho(ColorCLI::headerOver($service.' found IMDBid: ').ColorCLI::primary('tt'.$imdbID)); + ColorCLI::doEcho(ColorCLI::headerOver($service.' found IMDBid: ').ColorCLI::primary('tt'.$imdbID), true); } Release::query()->where('id', $id)->update(['imdbid' => $imdbID]); @@ -1124,7 +1124,7 @@ class Movie $this->traktTv = new TraktTv(['Settings' => $this->pdo]); } if ($this->echooutput && $movieCount > 1) { - ColorCLI::doEcho(ColorCLI::header('Processing '.$movieCount.' movie releases.')); + ColorCLI::doEcho(ColorCLI::header('Processing '.$movieCount.' movie releases.'), true); } // Loop over releases. @@ -1341,15 +1341,15 @@ class Movie } catch (RequestException $e) { if ($e->hasResponse()) { if ($e->getCode() === 404) { - ColorCLI::doEcho(ColorCLI::notice('Data not available on Google search')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on Google search'), true); } elseif ($e->getCode() === 503) { - ColorCLI::doEcho(ColorCLI::notice('Google service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('Google service unavailable'), true); } else { - ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data from Google, http error reported: '.$e->getCode())); + ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data from Google, http error reported: '.$e->getCode()), true); } } } catch (\RuntimeException $e) { - ColorCLI::doEcho(ColorCLI::notice('Runtime error: '.$e->getCode())); + ColorCLI::doEcho(ColorCLI::notice('Runtime error: '.$e->getCode()), true); } // Make sure we got some data. @@ -1391,15 +1391,15 @@ class Movie } catch (RequestException $e) { if ($e->hasResponse()) { if ($e->getCode() === 404) { - ColorCLI::doEcho(ColorCLI::notice('Data not available on Bing search')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on Bing search'), true); } elseif ($e->getCode() === 503) { - ColorCLI::doEcho(ColorCLI::notice('Bing search service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('Bing search service unavailable'), true); } else { - ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data from Bing search , http error reported: '.$e->getCode())); + ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data from Bing search , http error reported: '.$e->getCode()), true); } } } catch (\RuntimeException $e) { - ColorCLI::doEcho(ColorCLI::notice('Runtime error: '.$e->getCode())); + ColorCLI::doEcho(ColorCLI::notice('Runtime error: '.$e->getCode()), true); } if (! empty($buffer)) { @@ -1450,17 +1450,17 @@ class Movie } catch (RequestException $e) { if ($e->hasResponse()) { if ($e->getCode() === 999) { - ColorCLI::doEcho(ColorCLI::notice('Banned from Yahoo search')); + ColorCLI::doEcho(ColorCLI::notice('Banned from Yahoo search'), true); } elseif ($e->getCode() === 404) { - ColorCLI::doEcho(ColorCLI::notice('Data not available on Yahoo search')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on Yahoo search'), true); } elseif ($e->getCode() === 503) { - ColorCLI::doEcho(ColorCLI::notice('Yahoo search service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('Yahoo search service unavailable'), true); } else { - ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data from Yahoo search, http error reported: '.$e->getCode())); + ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data from Yahoo search, http error reported: '.$e->getCode()), true); } } } catch (\RuntimeException $e) { - ColorCLI::doEcho(ColorCLI::notice('Runtime error: '.$e->getCode())); + ColorCLI::doEcho(ColorCLI::notice('Runtime error: '.$e->getCode()), true); } if (! empty($buffer)) { @@ -1493,15 +1493,15 @@ class Movie } catch (RequestException $e) { if ($e->hasResponse()) { if ($e->getCode() === 404) { - ColorCLI::doEcho(ColorCLI::notice('Data not available on DuckDuckGo search')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on DuckDuckGo search'), true); } elseif ($e->getCode() === 503) { - ColorCLI::doEcho(ColorCLI::notice('DuckDuckGo search service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('DuckDuckGo search service unavailable'), true); } else { - ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data from DuckDuckGo search , http error reported: '.$e->getCode())); + ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data from DuckDuckGo search , http error reported: '.$e->getCode()), true); } } } catch (\RuntimeException $e) { - ColorCLI::doEcho(ColorCLI::notice('Runtime error: '.$e->getCode())); + ColorCLI::doEcho(ColorCLI::notice('Runtime error: '.$e->getCode()), true); } if (! empty($buffer)) { diff --git a/nntmux/Music.php b/nntmux/Music.php index cc682306e..2e0a81f2a 100755 --- a/nntmux/Music.php +++ b/nntmux/Music.php @@ -536,7 +536,7 @@ class Music ColorCLI::alternateOver(' Title: '). ColorCLI::primary($mus['title']). ColorCLI::alternateOver(' Year: '). - ColorCLI::primary($mus['year']) + ColorCLI::primary($mus['year']), true ); } $mus['cover'] = $ri->saveImage($musicId, $mus['coverurl'], $this->imgSavePath, 250, 250); @@ -555,7 +555,7 @@ class Music ' ('. $mus['year']. ')' - ) + ), true ); } } @@ -666,7 +666,7 @@ class Music ColorCLI::doEcho( ColorCLI::header( 'Processing '.$res->count().' music release(s).' - ) + ), true ); } @@ -678,7 +678,7 @@ class Music $newname = $album['name'].' ('.$album['year'].')'; if ($this->echooutput) { - ColorCLI::doEcho(ColorCLI::headerOver('Looking up: ').ColorCLI::primary($newname)); + ColorCLI::doEcho(ColorCLI::headerOver('Looking up: ').ColorCLI::primary($newname), true); } // Do a local lookup first @@ -687,7 +687,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::doEcho(ColorCLI::headerOver('Cached previous failure. Skipping.').PHP_EOL); + ColorCLI::doEcho(ColorCLI::headerOver('Cached previous failure. Skipping.'), true); } $albumId = -2; } elseif ($musicCheck === null && $local === false) { @@ -719,7 +719,7 @@ class Music } } else { if ($this->echooutput) { - ColorCLI::doEcho(ColorCLI::header('No music releases to process.')); + ColorCLI::doEcho(ColorCLI::header('No music releases to process.'), true); } } } diff --git a/nntmux/Nfo.php b/nntmux/Nfo.php index 03fe59afa..85b9aaae9 100755 --- a/nntmux/Nfo.php +++ b/nntmux/Nfo.php @@ -280,7 +280,7 @@ class Nfo 'Processing '.$nfoCount. ' NFO(s), starting at '.$this->nzbs. ' * = hidden NFO, + = NFO, - = no NFO, f = download failed.' - ) + ), true ); if ($this->echo) { @@ -315,7 +315,7 @@ class Nfo foreach ($nfoStats as $row) { $outString .= ', '.$row['status'].' = '.number_format($row['count']); } - ColorCLI::doEcho(ColorCLI::header($outString.'.')); + ColorCLI::doEcho(ColorCLI::header($outString.'.'), true); } } diff --git a/nntmux/ReleaseImage.php b/nntmux/ReleaseImage.php index 48a38427a..917764606 100755 --- a/nntmux/ReleaseImage.php +++ b/nntmux/ReleaseImage.php @@ -72,16 +72,16 @@ class ReleaseImage $img = (new ImageManager())->make($imgLoc); } catch (NotReadableException $e) { if ($e->getCode() === 404) { - ColorCLI::doEcho(ColorCLI::notice('Data not available on server')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on server'), true); } elseif ($e->getCode() === 503) { - ColorCLI::doEcho(ColorCLI::notice('Service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('Service unavailable'), true); } else { - ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data, server responded with code: '.$e->getCode())); + ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data, server responded with code: '.$e->getCode()), true); } return false; } catch (ImageException $e) { - ColorCLI::doEcho(ColorCLI::notice('Image error: '.$e->getCode())); + ColorCLI::doEcho(ColorCLI::notice('Image error: '.$e->getCode()), true); return false; } diff --git a/nntmux/Steam.php b/nntmux/Steam.php index 15657fc1c..c4d8c6a51 100755 --- a/nntmux/Steam.php +++ b/nntmux/Steam.php @@ -86,7 +86,7 @@ class Steam } if ($res === false) { - ColorCLI::doEcho(ColorCLI::notice('Steam did not return game data')); + ColorCLI::doEcho(ColorCLI::notice('Steam did not return game data'), true); } return false; @@ -105,7 +105,7 @@ class Steam $bestMatch = false; if (empty($searchTerm)) { - ColorCLI::doEcho(ColorCLI::notice('Search term cannot be empty')); + ColorCLI::doEcho(ColorCLI::notice('Search term cannot be empty'), true); return $bestMatch; } @@ -136,7 +136,7 @@ class Steam } } if ($bestMatch === false) { - ColorCLI::doEcho(ColorCLI::notice('Steam search returned no valid results')); + ColorCLI::doEcho(ColorCLI::notice('Steam search returned no valid results'), true); } return $bestMatch; diff --git a/nntmux/Tmux.php b/nntmux/Tmux.php index 7b579a43d..ea80eaaf3 100755 --- a/nntmux/Tmux.php +++ b/nntmux/Tmux.php @@ -605,7 +605,7 @@ class Tmux return true; } - ColorCLI::doEcho(ColorCLI::info('Tmux scripts are not running!')); + ColorCLI::doEcho(ColorCLI::info('Tmux scripts are not running!'), true); return false; } diff --git a/nntmux/XXX.php b/nntmux/XXX.php index 67f1bd4f6..d6c16e0a6 100755 --- a/nntmux/XXX.php +++ b/nntmux/XXX.php @@ -494,14 +494,14 @@ class XXX $this->whichclass = 'aebn'; $mov = new AEBN(); $mov->cookie = $this->cookie; - ColorCLI::doEcho(ColorCLI::info('Checking AEBN for movie info')); + ColorCLI::doEcho(ColorCLI::info('Checking AEBN for movie info'), true); $res = $mov->processSite($movie); if ($res === false) { $this->whichclass = 'pop'; $mov = new Popporn(); $mov->cookie = $this->cookie; - ColorCLI::doEcho(ColorCLI::info('Checking PopPorn for movie info')); + ColorCLI::doEcho(ColorCLI::info('Checking PopPorn for movie info'), true); $res = $mov->processSite($movie); } @@ -509,14 +509,14 @@ class XXX $this->whichclass = 'adm'; $mov = new ADM(); $mov->cookie = $this->cookie; - ColorCLI::doEcho(ColorCLI::info('Checking ADM for movie info')); + ColorCLI::doEcho(ColorCLI::info('Checking ADM for movie info'), true); $res = $mov->processSite($movie); } if ($res === false) { $this->whichclass = 'ade'; $mov = new ADE(); - ColorCLI::doEcho(ColorCLI::info('Checking ADE for movie info')); + ColorCLI::doEcho(ColorCLI::info('Checking ADE for movie info'), true); $res = $mov->processSite($movie); } @@ -524,7 +524,7 @@ class XXX $this->whichclass = 'hotm'; $mov = new Hotmovies(); $mov->cookie = $this->cookie; - ColorCLI::doEcho(ColorCLI::info('Checking HotMovies for movie info')); + ColorCLI::doEcho(ColorCLI::info('Checking HotMovies for movie info'), true); $res = $mov->processSite($movie); } @@ -550,7 +550,7 @@ class XXX default: $fromstr = ''; } - ColorCLI::doEcho(ColorCLI::primary('Fetching XXX info from: '.$fromstr)); + ColorCLI::doEcho(ColorCLI::primary('Fetching XXX info from: '.$fromstr), true); } $res = $mov->getAll(); } else { @@ -629,7 +629,7 @@ class XXX if ($this->echooutput) { ColorCLI::doEcho( ColorCLI::headerOver(($xxxID !== false ? 'Added/updated XXX movie: '.ColorCLI::primary($mov['title']) : 'Nothing to update for XXX movie: '.ColorCLI::primary($mov['title']))) - ); + , true); } return $xxxID; @@ -664,7 +664,7 @@ class XXX if ($movieCount > 0) { if ($this->echooutput) { - ColorCLI::doEcho(ColorCLI::header('Processing '.$movieCount.' XXX releases.')); + ColorCLI::doEcho(ColorCLI::header('Processing '.$movieCount.' XXX releases.'), true); } // Loop over releases. @@ -695,7 +695,7 @@ class XXX ->update(['xxxinfo_id' => $idcheck]); } } elseif ($this->echooutput) { - ColorCLI::doEcho(ColorCLI::header('No xxx releases to process.')); + ColorCLI::doEcho(ColorCLI::header('No xxx releases to process.'), true); } } diff --git a/nntmux/libraries/Forking.php b/nntmux/libraries/Forking.php index ade99e479..9d3791d4d 100755 --- a/nntmux/libraries/Forking.php +++ b/nntmux/libraries/Forking.php @@ -217,7 +217,7 @@ class Forking extends \fork_daemon ColorCLI::header( 'Multi-processing for '.$this->workType.' finished in '.(microtime(true) - $startTime). ' seconds at '.date(DATE_RFC2822).'.'.PHP_EOL - ) + ), true ); } } @@ -311,7 +311,7 @@ class Forking extends \fork_daemon 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).' - ) + ), true ); } @@ -320,7 +320,7 @@ class Forking extends \fork_daemon } else { if (NN_ECHOCLI) { ColorCLI::doEcho( - ColorCLI::header('No work to do!') + ColorCLI::header('No work to do!'), true ); } } @@ -1114,7 +1114,7 @@ class Forking extends \fork_daemon '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 - ) + ), true ); } } diff --git a/nntmux/libraries/ForkingImportNZB.php b/nntmux/libraries/ForkingImportNZB.php index aeb7d4924..e80260acd 100755 --- a/nntmux/libraries/ForkingImportNZB.php +++ b/nntmux/libraries/ForkingImportNZB.php @@ -72,7 +72,7 @@ class ForkingImportNZB extends Forking ColorCLI::header( 'Multi-processing for import finished in '.(microtime(true) - $startTime). ' seconds at '.date(DATE_RFC2822).'.'.PHP_EOL - ) + ), true ); } } diff --git a/nntmux/libraries/TraktAPI.php b/nntmux/libraries/TraktAPI.php index 06c6bc2ad..f1a3940a9 100755 --- a/nntmux/libraries/TraktAPI.php +++ b/nntmux/libraries/TraktAPI.php @@ -165,17 +165,17 @@ class TraktAPI } catch (RequestException $e) { if ($e->hasResponse()) { if ($e->getCode() === 404) { - ColorCLI::doEcho(ColorCLI::notice('Data not available on TraktTV server')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on TraktTV server'), true); } elseif ($e->getCode() === 503) { - ColorCLI::doEcho(ColorCLI::notice('TraktTV service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('TraktTV service unavailable'), true); } elseif ($e->getCode() === 401) { - ColorCLI::doEcho(ColorCLI::notice('Unauthorized - OAuth must be provided for TraktTV')); + ColorCLI::doEcho(ColorCLI::notice('Unauthorized - OAuth must be provided for TraktTV'), true); } else { - ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data from TraktTV, server responded with code: '.$e->getCode())); + ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data from TraktTV, server responded with code: '.$e->getCode()), true); } } } catch (\RuntimeException $e) { - ColorCLI::doEcho(ColorCLI::notice('Unknown error occurred!')); + ColorCLI::doEcho(ColorCLI::notice('Unknown error occurred!'), true); } if ($json !== null && $json !== false) { diff --git a/nntmux/processing/ProcessReleases.php b/nntmux/processing/ProcessReleases.php index a47755553..43872d7a1 100755 --- a/nntmux/processing/ProcessReleases.php +++ b/nntmux/processing/ProcessReleases.php @@ -333,7 +333,7 @@ class ProcessReleases $this->initiateTableNames($groupID); if ($this->echoCLI) { - ColorCLI::doEcho(ColorCLI::header('Process Releases -> Calculating collection sizes (in bytes).')); + ColorCLI::doEcho(ColorCLI::header('Process Releases -> Calculating collection sizes (in bytes).'), true); } // Get the total size in bytes of the collection for collections where filecheck = 2. $checked = $this->pdo->queryExec( @@ -360,7 +360,7 @@ class ProcessReleases ColorCLI::doEcho( ColorCLI::primary( $checked->rowCount().' collections set to filecheck = 3(size calculated)' - ) + ), true ); ColorCLI::doEcho(ColorCLI::primary($this->consoleTools->convertTime(time() - $startTime)), true); } @@ -380,7 +380,7 @@ class ProcessReleases ColorCLI::doEcho( ColorCLI::header( 'Process Releases -> Delete collections smaller/larger than minimum size/file count from group/site setting.' - ) + ), true ); } @@ -526,7 +526,7 @@ class ProcessReleases $returnCount = $duplicate = 0; if ($this->echoCLI) { - ColorCLI::doEcho(ColorCLI::header('Process Releases -> Create releases from complete collections.')); + ColorCLI::doEcho(ColorCLI::header('Process Releases -> Create releases from complete collections.'), true); } $this->pdo->ping(true); @@ -727,7 +727,7 @@ class ProcessReleases $this->formFromNamesQuery(); if ($this->echoCLI) { - ColorCLI::doEcho(ColorCLI::header('Process Releases -> Create the NZB, delete collections/binaries/parts.')); + ColorCLI::doEcho(ColorCLI::header('Process Releases -> Create the NZB, delete collections/binaries/parts.'), true); } $releases = $this->pdo->queryDirect( @@ -769,7 +769,7 @@ class ProcessReleases number_format($nzbCount).' NZBs created/Collections deleted in '. $totalTime.' seconds.'.PHP_EOL. 'Total time: '.ColorCLI::primary($this->consoleTools->convertTime($totalTime)).PHP_EOL - ) + ), true ); } @@ -832,7 +832,7 @@ class ProcessReleases ColorCLI::info( "\nPost-processing is not running inside the Process Releases class.\n". 'If you are using tmux or screen they might have their own scripts running Post-processing.' - ) + ), true ); } } @@ -1039,7 +1039,7 @@ class ProcessReleases number_format($deletedCount). ' parts/binaries/collection rows in '. $this->consoleTools->convertTime($fourthQuery - $startTime).PHP_EOL - ) + ), true ); } } @@ -1163,7 +1163,7 @@ class ProcessReleases // Delete old releases and finished collections. if ($this->echoCLI) { - ColorCLI::doEcho(ColorCLI::header('Process Releases -> Delete old releases and passworded releases.')); + ColorCLI::doEcho(ColorCLI::header('Process Releases -> Delete old releases and passworded releases.'), true); } // Releases past retention. @@ -1387,7 +1387,7 @@ class ProcessReleases ? ', '.number_format($completionDeleted).' under '.$this->completion.'% completion.' : '.' ) - ) + ), true ); $totalDeleted = ( @@ -1400,7 +1400,7 @@ class ProcessReleases ColorCLI::primary( 'Removed '.number_format($totalDeleted).' releases in '. $this->consoleTools->convertTime(time() - $startTime) - ) + ), true ); } } @@ -1686,7 +1686,7 @@ class ProcessReleases ); if ($this->echoCLI && \is_object($obj) && $obj->rowCount()) { ColorCLI::doEcho( - ColorCLI::primary('Deleted '.$obj->rowCount().' broken/stuck collections.') + ColorCLI::primary('Deleted '.$obj->rowCount().' broken/stuck collections.'), true ); } } diff --git a/nntmux/processing/post/AniDB.php b/nntmux/processing/post/AniDB.php index b19d28bf1..fd8a60d92 100755 --- a/nntmux/processing/post/AniDB.php +++ b/nntmux/processing/post/AniDB.php @@ -263,7 +263,7 @@ class AniDB ColorCLI::alternateOver(' Episode #: '). ColorCLI::primary($cleanArr['epno']). ColorCLI::alternateOver(' Episode Title: '). - ColorCLI::primary($updatedAni['episode_title']) + ColorCLI::primary($updatedAni['episode_title']), true ); $matched = true;