From 5a37a43a8618e269fe40abafdb4722bd13b9f941 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Tue, 4 Apr 2017 13:05:39 +0200 Subject: [PATCH] Use ColorCLI directly --- Changelog | 1 + nntmux/ADE.php | 12 +- nntmux/ADM.php | 12 +- nntmux/AEBN.php | 12 +- nntmux/Backfill.php | 28 ++--- nntmux/Books.php | 30 ++--- nntmux/Console.php | 34 +++--- nntmux/Games.php | 24 ++-- nntmux/MiscSorter.php | 2 +- nntmux/Movie.php | 60 +++++----- nntmux/Music.php | 32 ++--- nntmux/NNTP.php | 26 ++--- nntmux/NameFixer.php | 90 +++++++------- nntmux/Nfo.php | 8 +- nntmux/PreDb.php | 14 +-- nntmux/ReleaseImage.php | 8 +- nntmux/ReleaseRemover.php | 28 ++--- nntmux/RequestID.php | 6 +- nntmux/RequestIDWeb.php | 6 +- nntmux/Steam.php | 8 +- nntmux/Tmux.php | 2 +- nntmux/TmuxOutput.php | 32 ++--- nntmux/XXX.php | 22 ++-- nntmux/db/DbUpdate.php | 4 +- nntmux/db/populate/AniDB.php | 24 ++-- nntmux/libraries/ForkingImportNZB.php | 8 +- nntmux/libraries/TraktAPI.php | 14 ++- nntmux/processing/PostProcess.php | 4 +- nntmux/processing/ProcessReleases.php | 116 +++++++++---------- nntmux/processing/post/AniDB.php | 30 ++--- nntmux/processing/post/ProcessAdditional.php | 2 +- nntmux/processing/tv/TMDB.php | 24 ++-- nntmux/processing/tv/TV.php | 2 +- nntmux/processing/tv/TVDB.php | 28 ++--- nntmux/processing/tv/TVMaze.php | 24 ++-- nntmux/processing/tv/TraktTv.php | 24 ++-- nntmux/processing/tv/TvRage.php | 18 +-- www/pages/details.php | 2 +- 38 files changed, 412 insertions(+), 409 deletions(-) diff --git a/Changelog b/Changelog index 9d869f0c7..d94f1d9f1 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2017-04-04 DariusIII + * Chg: Use ColorCLI directly * Chg: Add material design icons 2017-04-03 DariusIII * Chg: Update Category class diff --git a/nntmux/ADE.php b/nntmux/ADE.php index f7235bc24..286b7f297 100755 --- a/nntmux/ADE.php +++ b/nntmux/ADE.php @@ -341,11 +341,11 @@ class ADE } catch (RequestException $e) { if ($e->hasResponse()) { if($e->getCode() === 404) { - $this->pdo->log->doEcho($this->pdo->log->notice('Data not available on server')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on server')); } else if ($e->getCode() === 503) { - $this->pdo->log->doEcho($this->pdo->log->notice('Service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('Service unavailable')); } else { - $this->pdo->log->doEcho($this->pdo->log->notice('Unable to fetch data, http error reported: ' . $e->getCode())); + ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data, http error reported: ' . $e->getCode())); } } } @@ -357,11 +357,11 @@ class ADE } catch (RequestException $e) { if ($e->hasResponse()) { if($e->getCode() === 404) { - $this->pdo->log->doEcho($this->pdo->log->notice('Data not available on server')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on server')); } else if ($e->getCode() === 503) { - $this->pdo->log->doEcho($this->pdo->log->notice('Service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('Service unavailable')); } else { - $this->pdo->log->doEcho($this->pdo->log->notice('Unable to fetch data, http error reported: ' . $e->getCode())); + ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data, http error reported: ' . $e->getCode())); } } } diff --git a/nntmux/ADM.php b/nntmux/ADM.php index 3a0dc20e8..b9c0c7132 100755 --- a/nntmux/ADM.php +++ b/nntmux/ADM.php @@ -301,11 +301,11 @@ class ADM } catch (RequestException $e) { if ($e->hasResponse()) { if($e->getCode() === 404) { - $this->pdo->log->doEcho($this->pdo->log->notice('Data not available on server')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on server')); } else if ($e->getCode() === 503) { - $this->pdo->log->doEcho($this->pdo->log->notice('Service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('Service unavailable')); } else { - $this->pdo->log->doEcho($this->pdo->log->notice('Unable to fetch data, http error reported: ' . $e->getCode())); + ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data, http error reported: ' . $e->getCode())); } } } @@ -315,11 +315,11 @@ class ADM } catch (RequestException $e) { if ($e->hasResponse()) { if($e->getCode() === 404) { - $this->pdo->log->doEcho($this->pdo->log->notice('Data not available on server')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on server')); } else if ($e->getCode() === 503) { - $this->pdo->log->doEcho($this->pdo->log->notice('Service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('Service unavailable')); } else { - $this->pdo->log->doEcho($this->pdo->log->notice('Unable to fetch data, http error reported: ' . $e->getCode())); + ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data, http error reported: ' . $e->getCode())); } } } diff --git a/nntmux/AEBN.php b/nntmux/AEBN.php index 58a11d000..441858029 100755 --- a/nntmux/AEBN.php +++ b/nntmux/AEBN.php @@ -368,11 +368,11 @@ class AEBN } catch (RequestException $e) { if ($e->hasResponse()) { if($e->getCode() === 404) { - $this->pdo->log->doEcho($this->pdo->log->notice('Data not available on server')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on server')); } else if ($e->getCode() === 503) { - $this->pdo->log->doEcho($this->pdo->log->notice('Service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('Service unavailable')); } else { - $this->pdo->log->doEcho($this->pdo->log->notice('Unable to fetch data, http error reported: ' . $e->getCode())); + ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data, http error reported: ' . $e->getCode())); } } } @@ -382,11 +382,11 @@ class AEBN } catch (RequestException $e) { if ($e->hasResponse()) { if($e->getCode() === 404) { - $this->pdo->log->doEcho($this->pdo->log->notice('Data not available on server')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on server')); } else if ($e->getCode() === 503) { - $this->pdo->log->doEcho($this->pdo->log->notice('Service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('Service unavailable')); } else { - $this->pdo->log->doEcho($this->pdo->log->notice('Unable to fetch data, http error reported: ' . $e->getCode())); + ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data, http error reported: ' . $e->getCode())); } } } diff --git a/nntmux/Backfill.php b/nntmux/Backfill.php index 2cb61eba3..1d0860c31 100755 --- a/nntmux/Backfill.php +++ b/nntmux/Backfill.php @@ -153,7 +153,7 @@ class Backfill } if ($this->_echoCLI) { - $this->pdo->log->doEcho($this->pdo->log->header($dMessage), true); + ColorCLI::doEcho(ColorCLI::header($dMessage), true); } $this->_binaries = new Binaries( @@ -173,7 +173,7 @@ class Backfill } if ($this->_echoCLI) { - $this->pdo->log->doEcho($this->pdo->log->header($dMessage), true); + ColorCLI::doEcho(ColorCLI::header($dMessage), true); } } $this->backfillGroup($groupArr, $groupCount - $counter, $articles); @@ -186,7 +186,7 @@ class Backfill } if ($this->_echoCLI) { - $this->pdo->log->doEcho($this->pdo->log->primary($dMessage)); + ColorCLI::doEcho(ColorCLI::primary($dMessage)); } } else { $dMessage = "No groups specified. Ensure groups are added to nntmux's database for updating."; @@ -195,7 +195,7 @@ class Backfill } if ($this->_echoCLI) { - $this->pdo->log->doEcho($this->pdo->log->warning($dMessage), true); + ColorCLI::doEcho(ColorCLI::warning($dMessage), true); } } } @@ -229,7 +229,7 @@ class Backfill } if ($this->_echoCLI) { - $this->pdo->log->doEcho($this->pdo->log->error($dMessage)); + ColorCLI::doEcho(ColorCLI::error($dMessage)); } return; } @@ -244,7 +244,7 @@ class Backfill } if ($this->_echoCLI) { - $this->pdo->log->doEcho($this->pdo->log->primary('Processing ' . $groupName), true); + ColorCLI::doEcho(ColorCLI::primary('Processing ' . $groupName), true); } // Check if this is days or post backfill. @@ -279,14 +279,14 @@ class Backfill } if ($this->_echoCLI) { - $this->pdo->log->doEcho($this->pdo->log->notice($dMessage), true); + ColorCLI::doEcho(ColorCLI::notice($dMessage), true); } return; } if ($this->_echoCLI) { - $this->pdo->log->doEcho( - $this->pdo->log->primary( + ColorCLI::doEcho( + ColorCLI::primary( 'Group ' . $groupName . "'s oldest article is " . @@ -316,8 +316,8 @@ class Backfill while ($done === false) { if ($this->_echoCLI) { - $this->pdo->log->doEcho( - $this->pdo->log->set256('Yellow') . + ColorCLI::doEcho( + ColorCLI::set256('Yellow') . PHP_EOL . 'Getting ' . number_format($last - $first + 1) . ' articles from ' . @@ -327,7 +327,7 @@ class Backfill ' group(s) left. (' . number_format($first - $targetpost) . ' articles in queue).' . - $this->pdo->log->rsetColor(), true + ColorCLI::rsetColor(), true ); } @@ -365,8 +365,8 @@ class Backfill } if ($this->_echoCLI) { - $this->pdo->log->doEcho( - $this->pdo->log->primary( + ColorCLI::doEcho( + ColorCLI::primary( PHP_EOL . 'Group ' . $groupName . diff --git a/nntmux/Books.php b/nntmux/Books.php index 403069c9e..b543bc5bf 100755 --- a/nntmux/Books.php +++ b/nntmux/Books.php @@ -423,7 +423,7 @@ class Books { if ($res instanceof \Traversable && $res->rowCount() > 0) { if ($this->echooutput) { - $this->pdo->log->doEcho($this->pdo->log->header("\nProcessing " . $res->rowCount() . ' book release(s) for categories id ' . $categoryID)); + ColorCLI::doEcho(ColorCLI::header("\nProcessing " . $res->rowCount() . ' book release(s) for categories id ' . $categoryID)); } foreach ($res as $arr) { @@ -440,7 +440,7 @@ class Books if ($bookInfo !== false) { if ($this->echooutput) { - $this->pdo->log->doEcho($this->pdo->log->headerOver('Looking up: ') . $this->pdo->log->primary($bookInfo)); + ColorCLI::doEcho(ColorCLI::headerOver('Looking up: ') . ColorCLI::primary($bookInfo)); } // Do a local lookup first @@ -449,7 +449,7 @@ class Books if ($bookCheck === false && in_array($bookInfo, $this->failCache)) { // Lookup recently failed, no point trying again if ($this->echooutput) { - $this->pdo->log->doEcho($this->pdo->log->headerOver('Cached previous failure. Skipping.') . PHP_EOL); + ColorCLI::doEcho(ColorCLI::headerOver('Cached previous failure. Skipping.') . PHP_EOL); } $bookId = -2; } else if ($bookCheck === false) { @@ -478,7 +478,7 @@ class Books } } } else if ($this->echooutput) { - $this->pdo->log->doEcho($this->pdo->log->header('No book releases to process for categories id ' . $categoryID)); + ColorCLI::doEcho(ColorCLI::header('No book releases to process for categories id ' . $categoryID)); } } @@ -499,8 +499,8 @@ 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) { - $this->pdo->log->doEcho( - $this->pdo->log->headerOver('Changing category to misc books: ') . $this->pdo->log->primary($releasename) + ColorCLI::doEcho( + ColorCLI::headerOver('Changing category to misc books: ') . ColorCLI::primary($releasename) ); } $this->pdo->queryExec(sprintf('UPDATE releases SET categories_id = %s WHERE id = %d', Category::BOOKS_UNKNOWN, $releaseID)); @@ -508,8 +508,8 @@ class Books } else 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) { - $this->pdo->log->doEcho( - $this->pdo->log->headerOver('Changing category to magazines: ') . $this->pdo->log->primary($releasename) + ColorCLI::doEcho( + ColorCLI::headerOver('Changing category to magazines: ') . ColorCLI::primary($releasename) ); } $this->pdo->queryExec(sprintf('UPDATE releases SET categories_id = %s WHERE id = %d', Category::BOOKS_MAGAZINES, $releaseID)); @@ -644,22 +644,22 @@ class Books if ($bookId) { if ($this->echooutput) { - $this->pdo->log->doEcho($this->pdo->log->header('Added/updated book: ')); + ColorCLI::doEcho(ColorCLI::header('Added/updated book: ')); if ($book['author'] !== '') { - $this->pdo->log->doEcho($this->pdo->log->alternateOver(' Author: ') . $this->pdo->log->primary($book['author'])); + ColorCLI::doEcho(ColorCLI::alternateOver(' Author: ') . ColorCLI::primary($book['author'])); } - echo $this->pdo->log->alternateOver(' Title: ') . $this->pdo->log->primary(' ' . $book['title']); + echo ColorCLI::alternateOver(' Title: ') . ColorCLI::primary(' ' . $book['title']); if ($book['genre'] !== 'null') { - $this->pdo->log->doEcho($this->pdo->log->alternateOver(' Genre: ') . $this->pdo->log->primary(' ' . $book['genre'])); + ColorCLI::doEcho(ColorCLI::alternateOver(' Genre: ') . ColorCLI::primary(' ' . $book['genre'])); } } $book['cover'] = $ri->saveImage($bookId, $book['coverurl'], $this->imgSavePath, 250, 250); } else { if ($this->echooutput) { - $this->pdo->log->doEcho( - $this->pdo->log->header('Nothing to update: ') . - $this->pdo->log->header($book['author'] . + ColorCLI::doEcho( + ColorCLI::header('Nothing to update: ') . + ColorCLI::header($book['author'] . ' - ' . $book['title']) ); diff --git a/nntmux/Console.php b/nntmux/Console.php index 1297870eb..e752c3752 100755 --- a/nntmux/Console.php +++ b/nntmux/Console.php @@ -396,14 +396,14 @@ class Console if ($this->echooutput) { if ($consoleId !== -2) { - $this->pdo->log->doEcho( - $this->pdo->log->header('Added/updated game: ') . - $this->pdo->log->alternateOver(' Title: ') . - $this->pdo->log->primary($con['title']) . - $this->pdo->log->alternateOver(' Platform: ') . - $this->pdo->log->primary($con['platform']) . - $this->pdo->log->alternateOver(' Genre: ') . - $this->pdo->log->primary($con['consolegenre']) + ColorCLI::doEcho( + 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']) ); } } @@ -775,7 +775,7 @@ class Console if ($res instanceof \Traversable && $res->rowCount() > 0) { if ($this->echooutput) { - $this->pdo->log->doEcho($this->pdo->log->header('Processing ' . $res->rowCount() . ' console release(s).')); + ColorCLI::doEcho(ColorCLI::header('Processing ' . $res->rowCount() . ' console release(s).')); } foreach ($res as $arr) { @@ -786,9 +786,9 @@ class Console if ($gameInfo !== false) { if ($this->echooutput) { - $this->pdo->log->doEcho( - $this->pdo->log->headerOver('Looking up: ') . - $this->pdo->log->primary( + ColorCLI::doEcho( + ColorCLI::headerOver('Looking up: ') . + ColorCLI::primary( $gameInfo['title'] . ' (' . $gameInfo['platform'] . ')' @@ -802,7 +802,7 @@ class Console if ($gameCheck === false && in_array($gameInfo['title'] . $gameInfo['platform'], $this->failCache)) { // Lookup recently failed, no point trying again if ($this->echooutput) { - $this->pdo->log->doEcho($this->pdo->log->headerOver('Cached previous failure. Skipping.') . PHP_EOL); + ColorCLI::doEcho(ColorCLI::headerOver('Cached previous failure. Skipping.') . PHP_EOL); } $gameId = -2; } else if ($gameCheck === false) { @@ -814,9 +814,9 @@ class Console } } else { if ($this->echooutput) { - $this->pdo->log->doEcho( - $this->pdo->log->headerOver("Found Local: ") . - $this->pdo->log->primary("{$gameCheck['title']} - {$gameCheck['platform']}") . + ColorCLI::doEcho( + ColorCLI::headerOver("Found Local: ") . + ColorCLI::primary("{$gameCheck['title']} - {$gameCheck['platform']}") . PHP_EOL ); } @@ -847,7 +847,7 @@ class Console } } else if ($this->echooutput) { - $this->pdo->log->doEcho($this->pdo->log->header('No console releases to process.')); + ColorCLI::doEcho(ColorCLI::header('No console releases to process.')); } } diff --git a/nntmux/Games.php b/nntmux/Games.php index 9451584d6..950bef134 100755 --- a/nntmux/Games.php +++ b/nntmux/Games.php @@ -709,10 +709,10 @@ class Games if ($gamesId) { if ($this->echoOutput) { - $this->pdo->log->doEcho( - $this->pdo->log->header('Added/updated game: ') . - $this->pdo->log->alternateOver(' Title: ') . - $this->pdo->log->primary($game['title']) + ColorCLI::doEcho( + ColorCLI::header('Added/updated game: ') . + ColorCLI::alternateOver(' Title: ') . + ColorCLI::primary($game['title']) ); } if($game['cover'] === 1){ @@ -723,9 +723,9 @@ class Games } } else { if ($this->echoOutput) { - $this->pdo->log->doEcho( - $this->pdo->log->headerOver('Nothing to update: ') . - $this->pdo->log->primary($game['title'] . ' (PC)' ) + ColorCLI::doEcho( + ColorCLI::headerOver('Nothing to update: ') . + ColorCLI::primary($game['title'] . ' (PC)' ) ); } } @@ -751,7 +751,7 @@ class Games if ($res instanceof \Traversable && $res->rowCount() > 0) { if ($this->echoOutput) { - $this->pdo->log->doEcho($this->pdo->log->header('Processing ' . $res->rowCount() . ' games release(s).')); + ColorCLI::doEcho(ColorCLI::header('Processing ' . $res->rowCount() . ' games release(s).')); } foreach ($res as $arr) { @@ -763,9 +763,9 @@ class Games if ($gameInfo !== false) { if ($this->echoOutput) { - $this->pdo->log->doEcho( - $this->pdo->log->headerOver('Looking up: ') . - $this->pdo->log->primary($gameInfo['title'] . ' (PC)' ) + ColorCLI::doEcho( + ColorCLI::headerOver('Looking up: ') . + ColorCLI::primary($gameInfo['title'] . ' (PC)' ) ); } @@ -799,7 +799,7 @@ class Games } } else { if ($this->echoOutput) { - $this->pdo->log->doEcho($this->pdo->log->header('No games releases to process.')); + ColorCLI::doEcho(ColorCLI::header('No games releases to process.')); } } } diff --git a/nntmux/MiscSorter.php b/nntmux/MiscSorter.php index 92e9673fd..d4c029b62 100755 --- a/nntmux/MiscSorter.php +++ b/nntmux/MiscSorter.php @@ -483,7 +483,7 @@ class MiscSorter $ok = $this->_doAmazonVG($response, $id); break; default: - echo PHP_EOL . $this->pdo->log->error("Amazon category $type could not be parsed for " . $name) . PHP_EOL; + echo PHP_EOL . ColorCLI::error("Amazon category $type could not be parsed for " . $name) . PHP_EOL; } } diff --git a/nntmux/Movie.php b/nntmux/Movie.php index c980548f9..e59999241 100755 --- a/nntmux/Movie.php +++ b/nntmux/Movie.php @@ -670,7 +670,7 @@ class Movie public function updateMovieInfo($imdbId) { if ($this->echooutput && $this->service !== '') { - $this->pdo->log->doEcho($this->pdo->log->primary('Fetching IMDB info from TMDB and/or Trakt using IMDB id: ' . $imdbId)); + ColorCLI::doEcho(ColorCLI::primary('Fetching IMDB info from TMDB and/or Trakt using IMDB id: ' . $imdbId)); } // Check TMDB for IMDB info. @@ -768,9 +768,9 @@ class Movie ]); if ($this->echooutput && $this->service !== '') { - $this->pdo->log->doEcho( - $this->pdo->log->headerOver(($movieID !== 0 ? 'Added/updated movie: ' : 'Nothing to update for movie: ')) . - $this->pdo->log->primary($mov['title'] . + ColorCLI::doEcho( + ColorCLI::headerOver(($movieID !== 0 ? 'Added/updated movie: ' : 'Nothing to update for movie: ')) . + ColorCLI::primary($mov['title'] . ' (' . $mov['year'] . ') - ' . @@ -798,11 +798,11 @@ class Movie } catch (RequestException $e) { if ($e->hasResponse()) { if($e->getCode() === 404) { - $this->pdo->log->doEcho($this->pdo->log->notice('Data not available on server')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on server')); } else if ($e->getCode() === 503) { - $this->pdo->log->doEcho($this->pdo->log->notice('Service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('Service unavailable')); } else { - $this->pdo->log->doEcho($this->pdo->log->notice('Unable to fetch data, http error reported: ' . $e->getCode())); + ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data, http error reported: ' . $e->getCode())); } } } @@ -831,7 +831,7 @@ class Movie $ret['title'] = $art['name']; } if ($this->echooutput) { - $this->pdo->log->doEcho($this->pdo->log->alternateOver("Fanart Found ") . $this->pdo->log->headerOver($ret['title']), true); + ColorCLI::doEcho(ColorCLI::alternateOver("Fanart Found ") . ColorCLI::headerOver($ret['title']), true); } return $ret; } @@ -922,7 +922,7 @@ class Movie $ret['backdrop'] = 'http://image.tmdb.org/t/p/original' . $backdrop; } if ($this->echooutput) { - $this->pdo->log->doEcho($this->pdo->log->primaryOver('TMDb Found ') . $this->pdo->log->headerOver($ret['title']), true); + ColorCLI::doEcho(ColorCLI::primaryOver('TMDb Found ') . ColorCLI::headerOver($ret['title']), true); } return $ret; } @@ -963,11 +963,11 @@ class Movie } catch (RequestException $e) { if ($e->hasResponse()) { if($e->getCode() === 404) { - $this->pdo->log->doEcho($this->pdo->log->notice('Data not available on server')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on server')); } else if ($e->getCode() === 503) { - $this->pdo->log->doEcho($this->pdo->log->notice('Service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('Service unavailable')); } else { - $this->pdo->log->doEcho($this->pdo->log->notice('Unable to fetch data, http error reported: ' . $e->getCode())); + ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data, http error reported: ' . $e->getCode())); } } } @@ -1026,7 +1026,7 @@ class Movie } } if ($this->echooutput && isset($ret['title'])) { - $this->pdo->log->doEcho($this->pdo->log->headerOver("IMDb Found ") . $this->pdo->log->primaryOver($ret['title']), true); + ColorCLI::doEcho(ColorCLI::headerOver("IMDb Found ") . ColorCLI::primaryOver($ret['title']), true); } return $ret; } @@ -1058,7 +1058,7 @@ class Movie return false; } if ($this->echooutput) { - $this->pdo->log->doEcho($this->pdo->log->alternateOver("Trakt Found ") . $this->pdo->log->headerOver($ret['title']), true); + ColorCLI::doEcho(ColorCLI::alternateOver("Trakt Found ") . ColorCLI::headerOver($ret['title']), true); } return $ret; } @@ -1085,7 +1085,7 @@ class Movie if ($imdbID !== false) { $this->service = $service; if ($this->echooutput && $this->service !== '') { - $this->pdo->log->doEcho($this->pdo->log->headerOver($service . ' found IMDBid: ') . $this->pdo->log->primary('tt' . $imdbID)); + ColorCLI::doEcho(ColorCLI::headerOver($service . ' found IMDBid: ') . ColorCLI::primary('tt' . $imdbID)); } $this->pdo->queryExec(sprintf('UPDATE releases SET imdbid = %s WHERE id = %d %s', $this->pdo->escapeString($imdbID), $id, $this->catWhere)); @@ -1139,7 +1139,7 @@ class Movie $this->traktTv = new TraktTv(['Settings' => $this->pdo]); } if ($this->echooutput && $movieCount > 1) { - $this->pdo->log->doEcho($this->pdo->log->header("Processing " . $movieCount . " movie releases.")); + ColorCLI::doEcho(ColorCLI::header("Processing " . $movieCount . " movie releases.")); } // Loop over releases. @@ -1159,7 +1159,7 @@ class Movie } if ($this->echooutput) { - $this->pdo->log->doEcho($this->pdo->log->primaryOver("Looking up: ") . $this->pdo->log->headerOver($movieName), true); + ColorCLI::doEcho(ColorCLI::primaryOver("Looking up: ") . ColorCLI::headerOver($movieName), true); } // Check local DB. @@ -1184,11 +1184,11 @@ class Movie } catch (RequestException $e) { if ($e->hasResponse()) { if($e->getCode() === 404) { - $this->pdo->log->doEcho($this->pdo->log->notice('Data not available on server')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on server')); } else if ($e->getCode() === 503) { - $this->pdo->log->doEcho($this->pdo->log->notice('Service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('Service unavailable')); } else { - $this->pdo->log->doEcho($this->pdo->log->notice('Unable to fetch data, http error reported: ' . $e->getCode())); + ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data, http error reported: ' . $e->getCode())); } } } @@ -1353,11 +1353,11 @@ class Movie } catch (RequestException $e) { if ($e->hasResponse()) { if($e->getCode() === 404) { - $this->pdo->log->doEcho($this->pdo->log->notice('Data not available on server')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on server')); } else if ($e->getCode() === 503) { - $this->pdo->log->doEcho($this->pdo->log->notice('Service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('Service unavailable')); } else { - $this->pdo->log->doEcho($this->pdo->log->notice('Unable to fetch data, http error reported: ' . $e->getCode())); + ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data, http error reported: ' . $e->getCode())); } } } @@ -1399,11 +1399,11 @@ class Movie } catch (RequestException $e) { if ($e->hasResponse()) { if($e->getCode() === 404) { - $this->pdo->log->doEcho($this->pdo->log->notice('Data not available on server')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on server')); } else if ($e->getCode() === 503) { - $this->pdo->log->doEcho($this->pdo->log->notice('Service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('Service unavailable')); } else { - $this->pdo->log->doEcho($this->pdo->log->notice('Unable to fetch data, http error reported: ' . $e->getCode())); + ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data, http error reported: ' . $e->getCode())); } } } @@ -1453,11 +1453,11 @@ class Movie } catch (RequestException $e) { if ($e->hasResponse()) { if($e->getCode() === 404) { - $this->pdo->log->doEcho($this->pdo->log->notice('Data not available on server')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on server')); } else if ($e->getCode() === 503) { - $this->pdo->log->doEcho($this->pdo->log->notice('Service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('Service unavailable')); } else { - $this->pdo->log->doEcho($this->pdo->log->notice('Unable to fetch data, http error reported: ' . $e->getCode())); + ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data, http error reported: ' . $e->getCode())); } } } @@ -1512,7 +1512,7 @@ class Movie // Check if the name is long enough and not just numbers. if (strlen($name) > 4 && !preg_match('/^\d+$/', $name)) { if ($this->debug && $this->echooutput) { - $this->pdo->log->doEcho("DB name: {$releaseName}", true); + ColorCLI::doEcho("DB name: {$releaseName}", true); } $this->currentTitle = $name; $this->currentYear = ($year === '' ? false : $year); diff --git a/nntmux/Music.php b/nntmux/Music.php index 4dd84124f..84fcbb89c 100755 --- a/nntmux/Music.php +++ b/nntmux/Music.php @@ -549,14 +549,14 @@ class Music if ($musicId) { if ($this->echooutput) { - $this->pdo->log->doEcho( - $this->pdo->log->header(PHP_EOL . 'Added/updated album: ') . - $this->pdo->log->alternateOver(' Artist: ') . - $this->pdo->log->primary($mus['artist']) . - $this->pdo->log->alternateOver(' Title: ') . - $this->pdo->log->primary($mus['title']) . - $this->pdo->log->alternateOver(' Year: ') . - $this->pdo->log->primary($mus['year']) + ColorCLI::doEcho( + ColorCLI::header(PHP_EOL . 'Added/updated album: ') . + ColorCLI::alternateOver(' Artist: ') . + ColorCLI::primary($mus['artist']) . + ColorCLI::alternateOver(' Title: ') . + ColorCLI::primary($mus['title']) . + ColorCLI::alternateOver(' Year: ') . + ColorCLI::primary($mus['year']) ); } $mus['cover'] = $ri->saveImage($musicId, $mus['coverurl'], $this->imgSavePath, 250, 250); @@ -567,9 +567,9 @@ class Music } else { $artist = 'Artist: ' . $mus['artist'] . ', Album: '; } - $this->pdo->log->doEcho( - $this->pdo->log->headerOver('Nothing to update: ') . - $this->pdo->log->primaryOver( + ColorCLI::doEcho( + ColorCLI::headerOver('Nothing to update: ') . + ColorCLI::primaryOver( $artist . $mus['title'] . ' (' . @@ -701,8 +701,8 @@ class Music ); if ($res instanceof \Traversable && $res->rowCount() > 0) { if ($this->echooutput) { - $this->pdo->log->doEcho( - $this->pdo->log->header('Processing ' . $res->rowCount() .' music release(s).' + ColorCLI::doEcho( + ColorCLI::header('Processing ' . $res->rowCount() .' music release(s).' ) ); } @@ -715,7 +715,7 @@ class Music $newname = $album['name'] . ' (' . $album['year'] . ')'; if ($this->echooutput) { - $this->pdo->log->doEcho($this->pdo->log->headerOver('Looking up: ') . $this->pdo->log->primary($newname)); + ColorCLI::doEcho(ColorCLI::headerOver('Looking up: ') . ColorCLI::primary($newname)); } // Do a local lookup first @@ -724,7 +724,7 @@ class Music if ($musicCheck === false && in_array($album['name'] . $album['year'], $this->failCache, false)) { // Lookup recently failed, no point trying again if ($this->echooutput) { - $this->pdo->log->doEcho($this->pdo->log->headerOver('Cached previous failure. Skipping.') . PHP_EOL); + ColorCLI::doEcho(ColorCLI::headerOver('Cached previous failure. Skipping.') . PHP_EOL); } $albumId = -2; } else if ($musicCheck === false && $local === false) { @@ -759,7 +759,7 @@ class Music } else { if ($this->echooutput) { - $this->pdo->log->doEcho($this->pdo->log->header('No music releases to process.')); + ColorCLI::doEcho(ColorCLI::header('No music releases to process.')); } } } diff --git a/nntmux/NNTP.php b/nntmux/NNTP.php index d135f8e00..5491e1e41 100755 --- a/nntmux/NNTP.php +++ b/nntmux/NNTP.php @@ -224,7 +224,7 @@ class NNTP extends \Net_NNTP_Client if ($this->_debugBool) { $this->_debugging->log(get_class(), __FUNCTION__, $message, Logger::LOG_ERROR); } - return $this->throwError($this->pdo->log->error($message)); + return $this->throwError(ColorCLI::error($message)); } // If we are connected, try to authenticate. @@ -265,7 +265,7 @@ class NNTP extends \Net_NNTP_Client if ($this->_debugBool) { $this->_debugging->log(get_class(), __FUNCTION__, $message, Logger::LOG_ERROR); } - return $this->throwError($this->pdo->log->error($message)); + return $this->throwError(ColorCLI::error($message)); } } } @@ -294,7 +294,7 @@ class NNTP extends \Net_NNTP_Client if ($this->_debugBool) { $this->_debugging->log(get_class(), __FUNCTION__, $message, Logger::LOG_ERROR); } - return $this->throwError($this->pdo->log->error($message)); + return $this->throwError(ColorCLI::error($message)); } /** @@ -640,7 +640,7 @@ class NNTP extends \Net_NNTP_Client if ($this->_debugBool) { $this->_debugging->log(get_class(), __FUNCTION__, $message, Logger::LOG_WARNING); } - return $this->throwError($this->pdo->log->error($message)); + return $this->throwError(ColorCLI::error($message)); } if ($aConnected === true) { @@ -826,7 +826,7 @@ class NNTP extends \Net_NNTP_Client if ($this->_debugBool) { $this->_debugging->log(get_class(), __FUNCTION__, $message, Logger::LOG_NOTICE); } - return $this->throwError($this->pdo->log->error($message)); + return $this->throwError(ColorCLI::error($message)); } $connected = $this->_checkConnection(); @@ -840,7 +840,7 @@ class NNTP extends \Net_NNTP_Client if ($this->_debugBool) { $this->_debugging->log(get_class(), __FUNCTION__, $message, Logger::LOG_WARNING); } - return $this->throwError($this->pdo->log->error($message)); + return $this->throwError(ColorCLI::error($message)); } if (strlen($from) > 510) { @@ -848,7 +848,7 @@ class NNTP extends \Net_NNTP_Client if ($this->_debugBool) { $this->_debugging->log(get_class(), __FUNCTION__, $message, Logger::LOG_WARNING); } - return $this->throwError($this->pdo->log->error($message)); + return $this->throwError(ColorCLI::error($message)); } // Check if the group is string or array. @@ -909,7 +909,7 @@ class NNTP extends \Net_NNTP_Client } if ($this->_echo) { - $this->pdo->log->doEcho($this->pdo->log->error($message), true); + ColorCLI::doEcho(ColorCLI::error($message), true); } $nntp->doQuit(); } @@ -1295,8 +1295,8 @@ class NNTP extends \Net_NNTP_Client $bytesReceived = strlen($data); if ($this->_echo && $bytesReceived > 10240) { - $this->pdo->log->doEcho( - $this->pdo->log->primaryOver( + ColorCLI::doEcho( + ColorCLI::primaryOver( 'Received ' . round($bytesReceived / 1024) . 'KB from group (' . $this->group() . ').' ), true @@ -1311,7 +1311,7 @@ class NNTP extends \Net_NNTP_Client if ($this->_debugBool) { $this->_debugging->log(get_class(), __FUNCTION__, $message, Logger::LOG_NOTICE); } - $message = $this->throwError($this->pdo->log->error($message), 1000); + $message = $this->throwError(ColorCLI::error($message), 1000); return $message; } @@ -1335,7 +1335,7 @@ class NNTP extends \Net_NNTP_Client if ($this->_debugBool) { $this->_debugging->log(get_class(), __FUNCTION__, $message, Logger::LOG_NOTICE); } - $message = $this->throwError($this->pdo->log->error($message), 1000); + $message = $this->throwError(ColorCLI::error($message), 1000); return $message; } } @@ -1354,7 +1354,7 @@ class NNTP extends \Net_NNTP_Client if ($this->_debugBool) { $this->_debugging->log(get_class(), __FUNCTION__, $message, Logger::LOG_NOTICE); } - $message = $this->throwError($this->pdo->log->error($message), 1000); + $message = $this->throwError(ColorCLI::error($message), 1000); return $message; } diff --git a/nntmux/NameFixer.php b/nntmux/NameFixer.php index f905bcc85..7fa279832 100755 --- a/nntmux/NameFixer.php +++ b/nntmux/NameFixer.php @@ -219,7 +219,7 @@ class NameFixer if ($total > 0) { $this->_totalReleases = $total; - echo $this->pdo->log->primary(number_format($total) . ' releases to process.'); + echo ColorCLI::primary(number_format($total) . ' releases to process.'); foreach ($releases as $rel) { $releaseRow = $this->pdo->queryOneRow( @@ -247,7 +247,7 @@ class NameFixer } $this->_echoFoundCount($echo, ' NFO\'s'); } else { - echo $this->pdo->log->info('Nothing to fix.'); + echo ColorCLI::info('Nothing to fix.'); } } } @@ -300,7 +300,7 @@ class NameFixer $total = $releases->rowCount(); if ($total > 0) { $this->_totalReleases = $total; - echo $this->pdo->log->primary(number_format($total) . ' file names to process.'); + echo ColorCLI::primary(number_format($total) . ' file names to process.'); foreach ($releases as $release) { $this->done = $this->matched = false; @@ -311,7 +311,7 @@ class NameFixer $this->_echoFoundCount($echo, ' files'); } else { - echo $this->pdo->log->info('Nothing to fix.'); + echo ColorCLI::info('Nothing to fix.'); } } } @@ -362,7 +362,7 @@ class NameFixer $total = $releases->rowCount(); if ($total > 0) { $this->_totalReleases = $total; - echo $this->pdo->log->primary(number_format($total) . ' xxx file names to process.'); + echo ColorCLI::primary(number_format($total) . ' xxx file names to process.'); foreach ($releases as $release) { $this->done = $this->matched = false; @@ -372,7 +372,7 @@ class NameFixer } $this->_echoFoundCount($echo, ' files'); } else { - echo $this->pdo->log->info('Nothing to fix.'); + echo ColorCLI::info('Nothing to fix.'); } } } @@ -423,7 +423,7 @@ class NameFixer $total = $releases->rowCount(); if ($total > 0) { $this->_totalReleases = $total; - echo $this->pdo->log->primary(number_format($total) . ' srr file extensions to process.'); + echo ColorCLI::primary(number_format($total) . ' srr file extensions to process.'); foreach ($releases as $release) { $this->done = $this->matched = false; @@ -433,7 +433,7 @@ class NameFixer } $this->_echoFoundCount($echo, ' files'); } else { - echo $this->pdo->log->info('Nothing to fix.'); + echo ColorCLI::info('Nothing to fix.'); } } } @@ -480,7 +480,7 @@ class NameFixer if ($total > 0) { $this->_totalReleases = $total; - echo $this->pdo->log->primary(number_format($total) . ' releases to process.'); + echo ColorCLI::primary(number_format($total) . ' releases to process.'); $Nfo = new Nfo(['Echo' => $this->echooutput, 'Settings' => $this->pdo]); $nzbContents = new NZBContents( [ @@ -502,7 +502,7 @@ class NameFixer } $this->_echoFoundCount($echo, ' files'); } else { - echo $this->pdo->log->alternate('Nothing to fix.'); + echo ColorCLI::alternate('Nothing to fix.'); } } } @@ -564,7 +564,7 @@ class NameFixer $total = $releases->rowCount(); if ($total > 0) { $this->_totalReleases = $total; - echo $this->pdo->log->primary(number_format($total) . ' unique ids to process.'); + echo ColorCLI::primary(number_format($total) . ' unique ids to process.'); foreach ($releases as $rel) { $this->checked++; $this->done = $this->matched = false; @@ -573,7 +573,7 @@ class NameFixer } $this->_echoFoundCount($echo, ' UID\'s'); } else { - echo $this->pdo->log->info('Nothing to fix.'); + echo ColorCLI::info('Nothing to fix.'); } } } @@ -635,7 +635,7 @@ class NameFixer $total = $releases->rowCount(); if ($total > 0) { $this->_totalReleases = $total; - echo $this->pdo->log->primary(number_format($total) . ' hash_16K to process.'); + echo ColorCLI::primary(number_format($total) . ' hash_16K to process.'); foreach ($releases as $rel) { $this->checked++; $this->done = $this->matched = false; @@ -644,7 +644,7 @@ class NameFixer } $this->_echoFoundCount($echo, ' hashes'); } else { - echo $this->pdo->log->info('Nothing to fix.'); + echo ColorCLI::info('Nothing to fix.'); } } } @@ -664,19 +664,19 @@ class NameFixer $queryLimit = ($limit === '') ? '' : ' LIMIT ' . $limit; // 24 hours, other cats if ($time == 1 && $cats == 1) { - echo $this->pdo->log->header($query . $this->timeother . $queryLimit . ";\n"); + echo ColorCLI::header($query . $this->timeother . $queryLimit . ";\n"); $releases = $this->pdo->queryDirect($query . $this->timeother . $queryLimit); } // 24 hours, all cats else if ($time == 1 && $cats == 2) { - echo $this->pdo->log->header($query . $this->timeall . $queryLimit . ";\n"); + echo ColorCLI::header($query . $this->timeall . $queryLimit . ";\n"); $releases = $this->pdo->queryDirect($query . $this->timeall . $queryLimit); } //other cats else if ($time == 2 && $cats == 1) { - echo $this->pdo->log->header($query . $this->fullother . $queryLimit . ";\n"); + echo ColorCLI::header($query . $this->fullother . $queryLimit . ";\n"); $releases = $this->pdo->queryDirect($query . $this->fullother . $queryLimit); } // all cats else if ($time == 2 && $cats == 2) { - echo $this->pdo->log->header($query . $this->fullall . $queryLimit . ";\n"); + echo ColorCLI::header($query . $this->fullall . $queryLimit . ";\n"); $releases = $this->pdo->queryDirect($query . $this->fullall . $queryLimit); } @@ -692,7 +692,7 @@ class NameFixer protected function _echoFoundCount($echo, $type) { if ($echo == 1) { - echo $this->pdo->log->header( + echo ColorCLI::header( PHP_EOL . number_format($this->fixed) . ' releases have had their names changed out of: ' . @@ -700,7 +700,7 @@ class NameFixer $type . '.' ); } else { - echo $this->pdo->log->header( + echo ColorCLI::header( PHP_EOL . number_format($this->fixed) . ' releases could have their names changed. ' . @@ -716,7 +716,7 @@ class NameFixer */ protected function _echoStartMessage($time, $type) { - echo $this->pdo->log->header( + echo ColorCLI::header( sprintf( 'Fixing search names %s using %s.', ($time == 1 ? 'in the past 6 hours' : 'since the beginning'), @@ -732,7 +732,7 @@ class NameFixer protected function _echoRenamed($show) { if ($this->checked % 500 == 0 && $show === 1) { - echo $this->pdo->log->alternate(PHP_EOL . number_format($this->checked) . ' files processed.' . PHP_EOL); + echo ColorCLI::alternate(PHP_EOL . number_format($this->checked) . ' files processed.' . PHP_EOL); } if ($show === 2) { @@ -794,26 +794,26 @@ class NameFixer } echo - $this->pdo->log->headerOver(PHP_EOL . 'New name: ') . - $this->pdo->log->primary(substr($newName, 0, 255)) . - $this->pdo->log->headerOver('Old name: ') . - $this->pdo->log->primary($release['searchname']) . - $this->pdo->log->headerOver('Use name: ') . - $this->pdo->log->primary($release['name']) . - $this->pdo->log->headerOver('New cat: ') . - $this->pdo->log->primary($newCatName) . - $this->pdo->log->headerOver('Old cat: ') . - $this->pdo->log->primary($oldCatName) . - $this->pdo->log->headerOver('Group: ') . - $this->pdo->log->primary($groupName) . - $this->pdo->log->headerOver('Method: ') . - $this->pdo->log->primary($type . $method) . - $this->pdo->log->headerOver('Releases ID: ') . - $this->pdo->log->primary($release['releases_id']); + ColorCLI::headerOver(PHP_EOL . 'New name: ') . + ColorCLI::primary(substr($newName, 0, 255)) . + 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']); if (!empty($release['filename'])) { echo - $this->pdo->log->headerOver('Filename: ') . - $this->pdo->log->primary($release['filename']); + ColorCLI::headerOver('Filename: ') . + ColorCLI::primary($release['filename']); } if ($type !== 'PAR2, ') { @@ -1034,8 +1034,8 @@ class NameFixer $limit = 'LIMIT 1000000'; } - echo $this->pdo->log->header(PHP_EOL . 'Match PreFiles (${args[1]}) Started at ' . date('g:i:s')); - echo $this->pdo->log->primary('Matching predb filename to cleaned release_files.name.' . PHP_EOL); + echo ColorCLI::header(PHP_EOL . 'Match PreFiles (${args[1]}) Started at ' . date('g:i:s')); + echo ColorCLI::primary('Matching predb filename to cleaned release_files.name.' . PHP_EOL); do { $counter = $counted = 0; @@ -1063,7 +1063,7 @@ class NameFixer $total = $query->rowCount(); if ($total > 0 && $query instanceof \Traversable) { - echo $this->pdo->log->header($n . number_format($total) . ' releases to process.'); + echo ColorCLI::header($n . number_format($total) . ' releases to process.'); foreach ($query as $row) { $success = $this->matchPredbFiles($row, 1, 1, true, $show); @@ -1077,9 +1077,9 @@ class NameFixer $maxrelid = $row['releases_id']; } } - echo $this->pdo->log->header($n . 'Renamed ' . number_format($counted) . ' releases in ' . $this->consoletools->convertTime(time() - $timestart) . '.'); + echo ColorCLI::header($n . 'Renamed ' . number_format($counted) . ' releases in ' . $this->consoletools->convertTime(time() - $timestart) . '.'); } else { - echo $this->pdo->log->info($n . 'Nothing to do.'); + echo ColorCLI::info($n . 'Nothing to do.'); break; } } else { diff --git a/nntmux/Nfo.php b/nntmux/Nfo.php index 3f1711180..0c1cc5ece 100755 --- a/nntmux/Nfo.php +++ b/nntmux/Nfo.php @@ -307,8 +307,8 @@ class Nfo $nfoCount = count($res); if ($nfoCount > 0) { - $this->pdo->log->doEcho( - $this->pdo->log->primary( + ColorCLI::doEcho( + ColorCLI::primary( PHP_EOL . ($guidChar === '' ? '' : '[' . $guidChar . '] ') . ($groupID === '' ? '' : '[' . $groupID . '] ') . @@ -337,7 +337,7 @@ class Nfo foreach ($nfoStats as $row) { $outString .= ', ' . $row['status'] . ' = ' . number_format($row['count']); } - $this->pdo->log->doEcho($this->pdo->log->header($outString . '.')); + ColorCLI::doEcho(ColorCLI::header($outString . '.')); } } @@ -415,7 +415,7 @@ class Nfo echo PHP_EOL; } if ($ret > 0) { - $this->pdo->log->doEcho($ret . ' NFO file(s) found/processed.', true); + ColorCLI::doEcho($ret . ' NFO file(s) found/processed.', true); } } return $ret; diff --git a/nntmux/PreDb.php b/nntmux/PreDb.php index 36ba7657a..2eb145be5 100755 --- a/nntmux/PreDb.php +++ b/nntmux/PreDb.php @@ -65,7 +65,7 @@ Class PreDb $datesql = ''; if ($this->echooutput) { - echo $this->pdo->log->header('Querying DB for release search names not matched with PreDB titles.'); + echo ColorCLI::header('Querying DB for release search names not matched with PreDB titles.'); } if ($this->dateLimit !== false && is_numeric($this->dateLimit)) { @@ -84,7 +84,7 @@ Class PreDb if ($res !== false) { $total = $res->rowCount(); - echo $this->pdo->log->primary(number_format($total) . ' releases to match.'); + echo ColorCLI::primary(number_format($total) . ' releases to match.'); if ($res instanceof \Traversable) { foreach ($res as $row) { @@ -104,7 +104,7 @@ Class PreDb } if ($this->echooutput) { - echo $this->pdo->log->header( + echo ColorCLI::header( 'Matched ' . number_format(($updated > 0) ? $updated : 0) . ' PreDB titles to release search names.' ); } @@ -182,7 +182,7 @@ Class PreDb if ($time == 1) { $te = ' in the past 3 hours'; } - echo $this->pdo->log->header('Fixing search names' . $te . " using the predb hash."); + echo ColorCLI::header('Fixing search names' . $te . " using the predb hash."); } $regex = "AND (r.ishashed = 1 OR rf.ishashed = 1)"; @@ -200,7 +200,7 @@ Class PreDb $res = $this->pdo->queryDirect($query); $total = $res->rowCount(); - echo $this->pdo->log->primary(number_format($total) . " releases to process."); + echo ColorCLI::primary(number_format($total) . " releases to process."); if ($res instanceof \Traversable) { foreach ($res as $row) { if (preg_match('/[a-fA-F0-9]{32,40}/i', $row['name'], $matches)) { @@ -214,9 +214,9 @@ Class PreDb } } if ($echo == 1) { - echo $this->pdo->log->header("\n" . $updated . " releases have had their names changed out of: " . number_format($checked) . " files."); + echo ColorCLI::header("\n" . $updated . " releases have had their names changed out of: " . number_format($checked) . " files."); } else { - echo $this->pdo->log->header("\n" . $updated . " releases could have their names changed. " . number_format($checked) . " files were checked."); + echo ColorCLI::header("\n" . $updated . " releases could have their names changed. " . number_format($checked) . " files were checked."); } return $updated; diff --git a/nntmux/ReleaseImage.php b/nntmux/ReleaseImage.php index a375357a0..868bea44c 100755 --- a/nntmux/ReleaseImage.php +++ b/nntmux/ReleaseImage.php @@ -97,11 +97,11 @@ class ReleaseImage } catch (RequestException $e) { if ($e->hasResponse()) { if($e->getCode() === 404) { - $this->pdo->log->doEcho($this->pdo->log->notice('Data not available on server')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on server')); } else if ($e->getCode() === 503) { - $this->pdo->log->doEcho($this->pdo->log->notice('Service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('Service unavailable')); } else { - $this->pdo->log->doEcho($this->pdo->log->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())); } } } @@ -115,7 +115,7 @@ class ReleaseImage try { $imagick->readImageBlob($img); } catch (\ImagickException $imgError) { - $this->pdo->log->doEcho($this->pdo->log->notice('Invalid image data, skipping processing') . PHP_EOL); + ColorCLI::doEcho(ColorCLI::notice('Invalid image data, skipping processing') . PHP_EOL); $imgFail = true; } if ($imgFail === false) { diff --git a/nntmux/ReleaseRemover.php b/nntmux/ReleaseRemover.php index cbb54825e..43c689886 100755 --- a/nntmux/ReleaseRemover.php +++ b/nntmux/ReleaseRemover.php @@ -187,8 +187,8 @@ class ReleaseRemover $this->deleteReleases(); if ($this->echoCLI) { - echo $this->pdo->log->headerOver(($this->delete ? 'Deleted ' : 'Would have deleted ') . $this->deletedCount . ' release(s). This script ran for '); - echo $this->pdo->log->header($this->consoleTools->convertTime(time() - $this->timeStart)); + echo ColorCLI::headerOver(($this->delete ? 'Deleted ' : 'Would have deleted ') . $this->deletedCount . ' release(s). This script ran for '); + echo ColorCLI::header($this->consoleTools->convertTime(time() - $this->timeStart)); } return ($this->browser @@ -231,7 +231,7 @@ class ReleaseRemover switch ($time) { case 'full': if ($this->echoCLI) { - echo $this->pdo->log->header('Removing ' . ($type === '' ? 'All crap releases ' : $type . ' crap releases') . ' - no time limit.\n'); + echo ColorCLI::header('Removing ' . ($type === '' ? 'All crap releases ' : $type . ' crap releases') . ' - no time limit.\n'); } break; default: @@ -241,7 +241,7 @@ class ReleaseRemover return $this->returnError(); } if ($this->echoCLI) { - echo $this->pdo->log->header('Removing ' . ($type === '' ? 'All crap releases ' : $type . ' crap releases') . ' from the past ' . $time . ' hour(s).\n'); + echo ColorCLI::header('Removing ' . ($type === '' ? 'All crap releases ' : $type . ' crap releases') . ' from the past ' . $time . ' hour(s).\n'); } $this->crapTime = ' AND r.adddate > (NOW() - INTERVAL ' . $time . ' HOUR)'; break; @@ -317,8 +317,8 @@ class ReleaseRemover } if ($this->echoCLI) { - echo $this->pdo->log->headerOver(($this->delete ? 'Deleted ' : 'Would have deleted ') . $this->deletedCount . ' release(s). This script ran for '); - echo $this->pdo->log->header($this->consoleTools->convertTime(time() - $this->timeStart)); + echo ColorCLI::headerOver(($this->delete ? 'Deleted ' : 'Would have deleted ') . $this->deletedCount . ' release(s). This script ran for '); + echo ColorCLI::header($this->consoleTools->convertTime(time() - $this->timeStart)); } return ($this->browser @@ -771,7 +771,7 @@ class ReleaseRemover } // Provide useful output of operations - echo $this->pdo->log->header(sprintf("Finding crap releases for %s: Using %s method against release %s.\n" . + echo ColorCLI::header(sprintf("Finding crap releases for %s: Using %s method against release %s.\n" . '%s', $this->method, $blType, $opTypeName, $ftUsing ) ); @@ -798,7 +798,7 @@ class ReleaseRemover } } else { - echo $this->pdo->log->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.\n"); + echo 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.\n"); } return true; @@ -868,7 +868,7 @@ class ReleaseRemover // Provide useful output of operations - echo $this->pdo->log->header(sprintf('Finding crap releases for %s: Using %s method against release filenames.' . PHP_EOL . + echo ColorCLI::header(sprintf('Finding crap releases for %s: Using %s method against release filenames.' . PHP_EOL . '%s', $this->method, $blType, $ftUsing ) ); @@ -989,10 +989,10 @@ class ReleaseRemover if ($this->delete) { $this->releases->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage); if ($this->echoCLI) { - echo $this->pdo->log->primary('Deleting: ' . $this->method . ': ' . $release['searchname']); + echo ColorCLI::primary('Deleting: ' . $this->method . ': ' . $release['searchname']); } } elseif ($this->echoCLI) { - echo $this->pdo->log->primary('Would be deleting: ' . $this->method . ': ' . $release['searchname']); + echo ColorCLI::primary('Would be deleting: ' . $this->method . ': ' . $release['searchname']); } $deletedCount++; } @@ -1210,7 +1210,7 @@ class ReleaseRemover } // Print the query to the user, ask them if they want to continue using it. - echo $this->pdo->log->primary( + echo 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:' . self::N . $this->query . ';' . self::N . 'If you are satisfied, type yes and press enter. Anything else will exit.' @@ -1219,7 +1219,7 @@ class ReleaseRemover // Check the users response. $userInput = trim(fgets(fopen('php://stdin', 'brt'))); if ($userInput !== 'yes') { - echo $this->pdo->log->primary('You typed: "' . $userInput . '", the program will exit.'); + echo ColorCLI::primary('You typed: "' . $userInput . '", the program will exit.'); return false; } @@ -1269,7 +1269,7 @@ class ReleaseRemover return $this->error . '
'; } else { if ($this->echoCLI && $this->error !== '') { - echo $this->pdo->log->error($this->error); + echo ColorCLI::error($this->error); } return false; diff --git a/nntmux/RequestID.php b/nntmux/RequestID.php index 346e28bdf..d38dd2934 100755 --- a/nntmux/RequestID.php +++ b/nntmux/RequestID.php @@ -85,15 +85,15 @@ abstract class RequestID if ($this->_releases !== false && $this->_releases->rowCount() > 0) { $this->_totalReleases = $this->_releases->rowCount(); - $this->pdo->log->doEcho($this->pdo->log->primary('Processing ' . $this->_totalReleases . " releases for RequestID's.")); + ColorCLI::doEcho(ColorCLI::primary('Processing ' . $this->_totalReleases . " releases for RequestID's.")); $renamed = $this->_processReleases(); if ($this->echoOutput) { - echo $this->pdo->log->header( + echo ColorCLI::header( "\nRenamed " . number_format($renamed) . " releases in " . $this->consoleTools->convertTime(time() - $startTime) . "." ); } } elseif ($this->echoOutput) { - $this->pdo->log->doEcho($this->pdo->log->primary("No RequestID's to process.")); + ColorCLI::doEcho(ColorCLI::primary("No RequestID's to process.")); } return $renamed; diff --git a/nntmux/RequestIDWeb.php b/nntmux/RequestIDWeb.php index 8a5d9175f..f7cac4a48 100755 --- a/nntmux/RequestIDWeb.php +++ b/nntmux/RequestIDWeb.php @@ -160,11 +160,11 @@ class RequestIDWeb extends RequestID } catch (RequestException $e) { if ($e->hasResponse()) { if($e->getCode() === 404) { - $this->pdo->log->doEcho($this->pdo->log->notice('Data not available on server')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on server')); } else if ($e->getCode() === 503) { - $this->pdo->log->doEcho($this->pdo->log->notice('Service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('Service unavailable')); } else { - $this->pdo->log->doEcho($this->pdo->log->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())); } } } diff --git a/nntmux/Steam.php b/nntmux/Steam.php index ed46631db..4e57dd1fb 100755 --- a/nntmux/Steam.php +++ b/nntmux/Steam.php @@ -79,7 +79,7 @@ class Steam } if ($res === false) { - $this->pdo->log->doEcho($this->pdo->log->notice('Steam did not return game data')); + ColorCLI::doEcho(ColorCLI::notice('Steam did not return game data')); } return false; @@ -97,7 +97,7 @@ class Steam $bestMatch = false; if (empty($searchTerm)) { - $this->pdo->log->doEcho($this->pdo->log->notice('Search term cannot be empty')); + ColorCLI::doEcho(ColorCLI::notice('Search term cannot be empty')); return $bestMatch; } @@ -132,7 +132,7 @@ class Steam } } if ($bestMatch === false) { - $this->pdo->log->doEcho($this->pdo->log->notice('Steam search returned no valid results')); + ColorCLI::doEcho(ColorCLI::notice('Steam search returned no valid results')); } return $bestMatch; @@ -150,7 +150,7 @@ class Steam $this->setLastUpdated(); $fullAppArray = $this->steamFront->getFullAppList(); $inserted = $dupe = 0; - echo $this->pdo->log->info('Populating steam apps table') . PHP_EOL; + echo ColorCLI::info('Populating steam apps table') . PHP_EOL; foreach ($fullAppArray as $appsArray) { foreach ($appsArray as $appArray) { foreach ($appArray as $app) { diff --git a/nntmux/Tmux.php b/nntmux/Tmux.php index cd9bdb4ea..e6a74a881 100755 --- a/nntmux/Tmux.php +++ b/nntmux/Tmux.php @@ -598,7 +598,7 @@ class Tmux if ($this->isRunning() == 1) { $this->pdo->queryExec("UPDATE tmux SET value = '0' WHERE setting = 'running'"); $sleep = $this->get()->monitor_delay; - echo $this->pdo->log->header("Stopping tmux scripts and waiting $sleep seconds for all panes to shutdown"); + echo ColorCLI::header("Stopping tmux scripts and waiting $sleep seconds for all panes to shutdown"); sleep($sleep); return true; } diff --git a/nntmux/TmuxOutput.php b/nntmux/TmuxOutput.php index e6be6de09..8e38302e4 100755 --- a/nntmux/TmuxOutput.php +++ b/nntmux/TmuxOutput.php @@ -473,16 +473,16 @@ class TmuxOutput extends Tmux ); $pieces = explode(" ", $this->pdo->getAttribute(\PDO::ATTR_SERVER_INFO)); - $buffer .= $this->pdo->log->primaryOver("\nThreads = ") . - $this->pdo->log->headerOver($pieces[4]) . - $this->pdo->log->primaryOver(', Opens = ') . - $this->pdo->log->headerOver($pieces[14]) . - $this->pdo->log->primaryOver(', Tables = ') . - $this->pdo->log->headerOver($pieces[22]) . - $this->pdo->log->primaryOver(', Slow = ') . - $this->pdo->log->headerOver($pieces[11]) . - $this->pdo->log->primaryOver(', QPS = ') . - $this->pdo->log->header($pieces[28]) + $buffer .= ColorCLI::primaryOver("\nThreads = ") . + ColorCLI::headerOver($pieces[4]) . + ColorCLI::primaryOver(', Opens = ') . + ColorCLI::headerOver($pieces[14]) . + ColorCLI::primaryOver(', Tables = ') . + ColorCLI::headerOver($pieces[22]) . + ColorCLI::primaryOver(', Slow = ') . + ColorCLI::headerOver($pieces[11]) . + ColorCLI::primaryOver(', QPS = ') . + ColorCLI::header($pieces[28]) ; return $buffer; @@ -512,11 +512,11 @@ class TmuxOutput extends Tmux protected function _setColourMasks() { - $this->_colourMasks[1] = $this->pdo->log->headerOver("%-18s") . " " . $this->pdo->log->tmuxOrange("%-48.48s"); - $this->_colourMasks['2.0'] = $this->pdo->log->alternateOver("%-20s") . " " . $this->pdo->log->tmuxOrange("%-33.33s"); - $this->_colourMasks['2.1'] = $this->pdo->log->headerOver("%-20s") . " " . $this->pdo->log->tmuxOrange("%-33.33s"); - $this->_colourMasks[3] = $this->pdo->log->header("%-16.16s %25.25s %25.25s"); - $this->_colourMasks[4] = $this->pdo->log->primaryOver("%-16.16s") . " " . $this->pdo->log->tmuxOrange("%25.25s %25.25s"); - $this->_colourMasks[5] = $this->pdo->log->tmuxOrange("%-16.16s %25.25s %25.25s"); + $this->_colourMasks[1] = ColorCLI::headerOver("%-18s") . " " . ColorCLI::tmuxOrange("%-48.48s"); + $this->_colourMasks['2.0'] = ColorCLI::alternateOver("%-20s") . " " . ColorCLI::tmuxOrange("%-33.33s"); + $this->_colourMasks['2.1'] = ColorCLI::headerOver("%-20s") . " " . ColorCLI::tmuxOrange("%-33.33s"); + $this->_colourMasks[3] = ColorCLI::header("%-16.16s %25.25s %25.25s"); + $this->_colourMasks[4] = ColorCLI::primaryOver("%-16.16s") . " " . ColorCLI::tmuxOrange("%25.25s %25.25s"); + $this->_colourMasks[5] = ColorCLI::tmuxOrange("%-16.16s %25.25s %25.25s"); } } diff --git a/nntmux/XXX.php b/nntmux/XXX.php index 0b88c94dc..53ddefca6 100755 --- a/nntmux/XXX.php +++ b/nntmux/XXX.php @@ -429,7 +429,7 @@ class XXX $res['title'] = $iafd->title; $res['directurl'] = (string)$iafd->directUrl; $this->whichclass = $iafd->classUsed; - $this->pdo->log->doEcho($this->pdo->log->primary("Fetching XXX info from IAFD -> Adult DVD Empire")); + ColorCLI::doEcho(ColorCLI::primary("Fetching XXX info from IAFD -> Adult DVD Empire")); break; } } @@ -487,7 +487,7 @@ class XXX default: $fromstr = null; } - $this->pdo->log->doEcho($this->pdo->log->primary("Fetching XXX info from: " . $fromstr)); + ColorCLI::doEcho(ColorCLI::primary("Fetching XXX info from: " . $fromstr)); } $res = $mov->getAll(); } else { @@ -572,9 +572,9 @@ class XXX } if ($this->echooutput) { - $this->pdo->log->doEcho( - $this->pdo->log->headerOver(($xxxID !== false ? 'Added/updated XXX movie: ' : 'Nothing to update for XXX movie: ')) . - $this->pdo->log->primary($mov['title']) + ColorCLI::doEcho( + ColorCLI::headerOver(($xxxID !== false ? 'Added/updated XXX movie: ' : 'Nothing to update for XXX movie: ')) . + ColorCLI::primary($mov['title']) ); } @@ -603,7 +603,7 @@ class XXX if ($movieCount > 0) { if ($this->echooutput) { - $this->pdo->log->doEcho($this->pdo->log->header("Processing " . $movieCount . " XXX releases.")); + ColorCLI::doEcho(ColorCLI::header("Processing " . $movieCount . " XXX releases.")); } // Loop over releases. @@ -618,10 +618,10 @@ class XXX $this->currentRelID = $arr['id']; $movieName = $this->currentTitle; if ($this->debug && $this->echooutput) { - $this->pdo->log->doEcho("DB name: " . $arr['searchname'], true); + ColorCLI::doEcho("DB name: " . $arr['searchname'], true); } if ($this->echooutput) { - $this->pdo->log->doEcho($this->pdo->log->primaryOver("Looking up: ") . $this->pdo->log->headerOver($movieName), true); + ColorCLI::doEcho(ColorCLI::primaryOver("Looking up: ") . ColorCLI::headerOver($movieName), true); } $idcheck = $this->updateXXXInfo($movieName); @@ -629,12 +629,12 @@ class XXX $idcheck = (int)$check['id']; } } else { - $this->pdo->log->doEcho(".", true); + ColorCLI::doEcho(".", true); } $this->pdo->queryExec(sprintf('UPDATE releases SET xxxinfo_id = %d WHERE id = %d %s', $idcheck, $arr['id'], $this->catWhere)); } } elseif ($this->echooutput) { - $this->pdo->log->doEcho($this->pdo->log->header('No xxx releases to process.')); + ColorCLI::doEcho(ColorCLI::header('No xxx releases to process.')); } } @@ -685,7 +685,7 @@ class XXX $this->currentTitle = $name; return true; } else { - $this->pdo->log->doEcho(".", false); + ColorCLI::doEcho(".", false); } } diff --git a/nntmux/db/DbUpdate.php b/nntmux/db/DbUpdate.php index 3d8782f50..d0ffadc98 100755 --- a/nntmux/db/DbUpdate.php +++ b/nntmux/db/DbUpdate.php @@ -298,7 +298,7 @@ class DbUpdate // Skip comments. if (preg_match('!^\s*(#|--|//)\s*(.+?)\s*$!', $line, $matches)) { - echo $this->pdo->log->info("COMMENT: " . $matches[2]); + echo ColorCLI::info("COMMENT: " . $matches[2]); continue; } @@ -306,7 +306,7 @@ class DbUpdate if (preg_match('#^\s*DELIMITER\s+(?P.+)\s*$#i', $line, $matches)) { $delimiter = $matches['delimiter']; if (NN_DEBUG) { - echo $this->pdo->log->debug("DEBUG: Delimiter switched to $delimiter"); + echo ColorCLI::debug("DEBUG: Delimiter switched to $delimiter"); } if ($delimiter != $options['delimiter']) { continue; diff --git a/nntmux/db/populate/AniDB.php b/nntmux/db/populate/AniDB.php index 388444a16..72057cc56 100755 --- a/nntmux/db/populate/AniDB.php +++ b/nntmux/db/populate/AniDB.php @@ -281,7 +281,7 @@ class AniDB ) ); } else { - echo $this->pdo->log->warning("Duplicate: $id"); + echo ColorCLI::warning("Duplicate: $id"); } } @@ -358,7 +358,7 @@ class AniDB if ($current->diff($lastUpdate)->format('%d') > $this->updateInterval) { if ($this->echooutput) { - echo $this->pdo->log->header('Updating anime titles by grabbing full data AniDB dump.'); + echo 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); @@ -370,7 +370,7 @@ class AniDB if ($animetitles instanceof \Traversable) { $count = $animetitles->count(); if ($this->echooutput) { - echo $this->pdo->log->header( + echo ColorCLI::header( 'Total of ' . number_format($count) . ' titles to add.' . PHP_EOL ); } @@ -385,7 +385,7 @@ class AniDB (string)$xmlAttribs->lang, (string)$title[0] ); - $this->pdo->log->primary( + ColorCLI::primary( sprintf( 'Inserting: %d, %s, %s, %s', $anime['aid'], @@ -399,11 +399,11 @@ class AniDB } } else { echo PHP_EOL . - $this->pdo->log->error('Error retrieving XML data from AniDB. Please try again later.') . + ColorCLI::error('Error retrieving XML data from AniDB. Please try again later.') . PHP_EOL; } } else { - echo PHP_EOL . $this->pdo->log->info( + echo PHP_EOL . 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.'); } @@ -417,16 +417,16 @@ class AniDB $AniDBAPIArray = $this->getAniDbAPI(); if ($this->banned === true) { - $this->pdo->log->doEcho( - $this->pdo->log->error( + ColorCLI::doEcho( + ColorCLI::error( 'AniDB Banned, import will fail, please wait 24 hours before retrying.' ), true ); exit; } elseif ($AniDBAPIArray === false && $this->echooutput) { - $this->pdo->log->doEcho( - $this->pdo->log->info( + ColorCLI::doEcho( + ColorCLI::info( 'Anime ID: ' . $this->anidbId . ' not available for update yet.' ), true @@ -434,8 +434,8 @@ class AniDB } else { $this->updateAniChildTables($AniDBAPIArray); if (NN_DEBUG) { - $this->pdo->log->doEcho( - $this->pdo->log->headerOver( + ColorCLI::doEcho( + ColorCLI::headerOver( 'Added/Updated AniDB ID: ' . $this->anidbId ), true diff --git a/nntmux/libraries/ForkingImportNZB.php b/nntmux/libraries/ForkingImportNZB.php index 15bff6291..6b5378174 100755 --- a/nntmux/libraries/ForkingImportNZB.php +++ b/nntmux/libraries/ForkingImportNZB.php @@ -44,12 +44,12 @@ class ForkingImportNZB extends Forking $this->_workCount = count($directories); if ($this->_workCount == 0) { - echo $this->pdo->log->error('No sub-folders were found in your specified folder (' . $folder . ').'); + echo ColorCLI::error('No sub-folders were found in your specified folder (' . $folder . ').'); exit(); } if (NN_ECHOCLI) { - echo $this->pdo->log->header( + echo ColorCLI::header( 'Multi-processing started at ' . date(DATE_RFC2822) . ' with ' . $this->_workCount . ' job(s) to do using a max of ' . $maxProcesses . ' child process(es).' ); @@ -67,8 +67,8 @@ class ForkingImportNZB extends Forking $this->process_work(true); if (NN_ECHOCLI) { - $this->pdo->log->doEcho( - $this->pdo->log->header( + ColorCLI::doEcho( + ColorCLI::header( 'Multi-processing for import finished in ' . (microtime(true) - $startTime) . ' seconds at ' . date(DATE_RFC2822) . '.' . PHP_EOL ) diff --git a/nntmux/libraries/TraktAPI.php b/nntmux/libraries/TraktAPI.php index ea09bc6eb..7c1e94dab 100755 --- a/nntmux/libraries/TraktAPI.php +++ b/nntmux/libraries/TraktAPI.php @@ -3,6 +3,7 @@ namespace nntmux\libraries; use GuzzleHttp\Client; use GuzzleHttp\Exception\RequestException; +use nntmux\ColorCLI; use nntmux\db\DB; /** @@ -48,9 +49,8 @@ Class TraktAPI { if (empty($headers)) { // Can't work without headers. exit; - } else { - $this->requestHeaders = $headers; } + $this->requestHeaders = $headers; $this->client = new Client(); $this->pdo = new DB(); @@ -153,7 +153,7 @@ Class TraktAPI { if ($extended === '') { $extendedString = ''; } else { - $extendedString = "?extended=" . $extended; + $extendedString = '?extended=' . $extended; } if (!empty($this->requestHeaders)) { @@ -168,13 +168,15 @@ Class TraktAPI { } catch (RequestException $e) { if ($e->hasResponse()) { if($e->getCode() === 404) { - $this->pdo->log->doEcho($this->pdo->log->notice('Data not available on server')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on server')); } else if ($e->getCode() === 503) { - $this->pdo->log->doEcho($this->pdo->log->notice('Service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('Service unavailable')); } else { - $this->pdo->log->doEcho($this->pdo->log->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())); } } + } catch (\RuntimeException $e) { + ColorCLI::doEcho(ColorCLI::notice('Unknown error occurred!')); } if (isset($json) && $json !== false) { diff --git a/nntmux/processing/PostProcess.php b/nntmux/processing/PostProcess.php index a9200ca4b..7d7e8ec1b 100755 --- a/nntmux/processing/PostProcess.php +++ b/nntmux/processing/PostProcess.php @@ -280,8 +280,8 @@ class PostProcess $processed = $spotnab->processGID(500); if ($processed > 0) { if ($this->echooutput) { - $this->pdo->log->doEcho( - $this->pdo->log->primary('Updating GID in releases table ' . $processed . ' release(s) updated') + ColorCLI::doEcho( + ColorCLI::primary('Updating GID in releases table ' . $processed . ' release(s) updated') ); } } diff --git a/nntmux/processing/ProcessReleases.php b/nntmux/processing/ProcessReleases.php index 137906a84..4d07ebdfe 100755 --- a/nntmux/processing/ProcessReleases.php +++ b/nntmux/processing/ProcessReleases.php @@ -151,7 +151,7 @@ class ProcessReleases $this->processRequestIDs = (int)Settings::value('lookup_reqids'); if ($this->completion > 100) { $this->completion = 100; - echo $this->pdo->log->error(PHP_EOL . 'You have an invalid setting for completion. It cannot be higher than 100.'); + echo ColorCLI::error(PHP_EOL . 'You have an invalid setting for completion. It cannot be higher than 100.'); } $this->collectionTimeout = intval(Settings::value('indexer.processing.collection_timeout')); } @@ -179,13 +179,13 @@ class ProcessReleases $processReleases = microtime(true); if ($this->echoCLI) { - $this->pdo->log->doEcho($this->pdo->log->header("Starting release update process (" . date('Y-m-d H:i:s') . ")"), true); + ColorCLI::doEcho(ColorCLI::header("Starting release update process (" . date('Y-m-d H:i:s') . ")"), true); } if (!file_exists(Settings::value('..nzbpath'))) { if ($this->echoCLI) { - $this->pdo->log->doEcho( - $this->pdo->log->error('Bad or missing nzb directory - ' . Settings::value('..nzbpath')), + ColorCLI::doEcho( + ColorCLI::error('Bad or missing nzb directory - ' . Settings::value('..nzbpath')), true ); } @@ -213,12 +213,12 @@ class ProcessReleases } else if ($this->processRequestIDs === 2) { $requestIDTime = time(); if ($this->echoCLI) { - $this->pdo->log->doEcho($this->pdo->log->header("Process Releases -> Request ID Threaded lookup.")); + ColorCLI::doEcho(ColorCLI::header("Process Releases -> Request ID Threaded lookup.")); } passthru("${DIR}update/nix/multiprocessing/requestid.php"); if ($this->echoCLI) { - $this->pdo->log->doEcho( - $this->pdo->log->primary( + ColorCLI::doEcho( + ColorCLI::primary( "\nReleases updated in " . $this->consoleTools->convertTime(time() - $requestIDTime) ) @@ -314,7 +314,7 @@ class ProcessReleases $this->initiateTableNames($groupID); if ($this->echoCLI) { - $this->pdo->log->doEcho($this->pdo->log->header("Process Releases -> Attempting to find complete collections.")); + ColorCLI::doEcho(ColorCLI::header("Process Releases -> Attempting to find complete collections.")); } $where = (!empty($groupID) ? ' AND c.groups_id = ' . $groupID . ' ' : ' '); @@ -338,8 +338,8 @@ class ProcessReleases $where ) ); - $this->pdo->log->doEcho( - $this->pdo->log->primary( + ColorCLI::doEcho( + ColorCLI::primary( ($count === false ? 0 : $count['complete']) . ' collections were found to be complete. Time: ' . $this->consoleTools->convertTime(time() - $startTime) ), true @@ -353,7 +353,7 @@ class ProcessReleases $this->initiateTableNames($groupID); if ($this->echoCLI) { - $this->pdo->log->doEcho($this->pdo->log->header('Process Releases -> Calculating collection sizes (in bytes).')); + ColorCLI::doEcho(ColorCLI::header('Process Releases -> Calculating collection sizes (in bytes).')); } // Get the total size in bytes of the collection for collections where filecheck = 2. $checked = $this->pdo->queryExec( @@ -376,12 +376,12 @@ class ProcessReleases ) ); if ($checked !== false && $this->echoCLI) { - $this->pdo->log->doEcho( - $this->pdo->log->primary( + ColorCLI::doEcho( + ColorCLI::primary( $checked->rowCount() . ' collections set to filecheck = 3(size calculated)' ) ); - $this->pdo->log->doEcho($this->pdo->log->primary($this->consoleTools->convertTime(time() - $startTime)), true); + ColorCLI::doEcho(ColorCLI::primary($this->consoleTools->convertTime(time() - $startTime)), true); } } @@ -391,8 +391,8 @@ class ProcessReleases $this->initiateTableNames($groupID); if ($this->echoCLI) { - $this->pdo->log->doEcho( - $this->pdo->log->header( + ColorCLI::doEcho( + ColorCLI::header( 'Process Releases -> Delete collections smaller/larger than minimum size/file count from group/site setting.' ) ); @@ -502,8 +502,8 @@ class ProcessReleases } if ($this->echoCLI) { - $this->pdo->log->doEcho( - $this->pdo->log->primary( + ColorCLI::doEcho( + ColorCLI::primary( 'Deleted ' . ($minSizeDeleted + $maxSizeDeleted + $minFilesDeleted) . ' collections: ' . PHP_EOL . $minSizeDeleted . ' smaller than, ' . $maxSizeDeleted . ' bigger than, ' . @@ -549,7 +549,7 @@ class ProcessReleases $returnCount = $duplicate = 0; if ($this->echoCLI) { - $this->pdo->log->doEcho($this->pdo->log->header('Process Releases -> Create releases from complete collections.')); + ColorCLI::doEcho(ColorCLI::header('Process Releases -> Create releases from complete collections.')); } $this->pdo->ping(true); @@ -570,7 +570,7 @@ class ProcessReleases ); if ($this->echoCLI && $collections !== false) { - echo $this->pdo->log->primary($collections->rowCount() . ' Collections ready to be converted to releases.'); + echo ColorCLI::primary($collections->rowCount() . ' Collections ready to be converted to releases.'); } if ($collections instanceof \Traversable) { @@ -746,8 +746,8 @@ class ProcessReleases } if ($this->echoCLI) { - $this->pdo->log->doEcho( - $this->pdo->log->primary( + ColorCLI::doEcho( + ColorCLI::primary( PHP_EOL . number_format($returnCount) . ' Releases added and ' . @@ -775,7 +775,7 @@ class ProcessReleases $this->formFromNamesQuery(); if ($this->echoCLI) { - $this->pdo->log->doEcho($this->pdo->log->header('Process Releases -> Create the NZB, delete collections/binaries/parts.')); + ColorCLI::doEcho(ColorCLI::header('Process Releases -> Create the NZB, delete collections/binaries/parts.')); } $releases = $this->pdo->queryDirect( @@ -803,7 +803,7 @@ class ProcessReleases if ($this->nzb->writeNZBforReleaseId($release['id'], $release['guid'], $release['name'], $release['title']) === true) { $nzbCount++; if ($this->echoCLI) { - echo $this->pdo->log->primaryOver("Creating NZBs and deleting Collections:\t" . $nzbCount . '/' . $total . "\r"); + echo ColorCLI::primaryOver("Creating NZBs and deleting Collections:\t" . $nzbCount . '/' . $total . "\r"); } } } @@ -812,11 +812,11 @@ class ProcessReleases $totalTime = (time() - $startTime); if ($this->echoCLI) { - $this->pdo->log->doEcho( - $this->pdo->log->primary( + ColorCLI::doEcho( + ColorCLI::primary( number_format($nzbCount) . ' NZBs created/Collections deleted in ' . $totalTime . ' seconds.' . PHP_EOL . - 'Total time: ' . $this->pdo->log->primary($this->consoleTools->convertTime($totalTime)) . PHP_EOL + 'Total time: ' . ColorCLI::primary($this->consoleTools->convertTime($totalTime)) . PHP_EOL ) ); } @@ -842,8 +842,8 @@ class ProcessReleases $startTime = time(); if ($this->echoCLI) { - $this->pdo->log->doEcho( - $this->pdo->log->header( + ColorCLI::doEcho( + ColorCLI::header( sprintf( 'Process Releases -> Request ID %s lookup -- limit %s', ($local === true ? 'local' : 'web'), @@ -877,8 +877,8 @@ class ProcessReleases )->lookupRequestIDs(['GroupID' => $groupID, 'limit' => $limit, 'time' => 168]); } if ($this->echoCLI) { - $this->pdo->log->doEcho( - $this->pdo->log->primary( + ColorCLI::doEcho( + ColorCLI::primary( number_format($foundRequestIDs) . ' releases updated in ' . $this->consoleTools->convertTime(time() - $startTime) @@ -900,7 +900,7 @@ class ProcessReleases { $startTime = time(); if ($this->echoCLI) { - echo $this->pdo->log->header('Process Releases -> Categorize releases.'); + echo ColorCLI::header('Process Releases -> Categorize releases.'); } switch ((int)$categorize) { case 2: @@ -920,7 +920,7 @@ class ProcessReleases ); if ($this->echoCLI) { - $this->pdo->log->doEcho($this->pdo->log->primary($this->consoleTools->convertTime(time() - $startTime)), true); + ColorCLI::doEcho(ColorCLI::primary($this->consoleTools->convertTime(time() - $startTime)), true); } } @@ -939,8 +939,8 @@ class ProcessReleases (new PostProcess(['Echo' => $this->echoCLI, 'Settings' => $this->pdo, 'Groups' => $this->groups]))->processAll($nntp); } else { if ($this->echoCLI) { - $this->pdo->log->doEcho( - $this->pdo->log->info( + ColorCLI::doEcho( + 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.' ) @@ -959,8 +959,8 @@ class ProcessReleases // CBP older than retention. if ($this->echoCLI) { echo ( - $this->pdo->log->header('Process Releases -> Delete finished collections.' . PHP_EOL) . - $this->pdo->log->primary(sprintf( + ColorCLI::header('Process Releases -> Delete finished collections.' . PHP_EOL) . + ColorCLI::primary(sprintf( 'Deleting collections/binaries/parts older than %d hours.', Settings::value('..partretentionhours') )) @@ -990,7 +990,7 @@ class ProcessReleases $firstQuery = $fourthQuery = time(); if ($this->echoCLI) { - echo $this->pdo->log->primary( + echo ColorCLI::primary( 'Finished deleting ' . $deleted . ' old collections/binaries/parts in ' . ($firstQuery - $startTime) . ' seconds.' . PHP_EOL ); @@ -1002,8 +1002,8 @@ class ProcessReleases // CBP collection orphaned with no binaries or parts. if ($this->echoCLI) { echo ( - $this->pdo->log->header('Process Releases -> Remove CBP orphans.' . PHP_EOL) . - $this->pdo->log->primary('Deleting orphaned collections.') + ColorCLI::header('Process Releases -> Remove CBP orphans.' . PHP_EOL) . + ColorCLI::primary('Deleting orphaned collections.') ); } @@ -1029,7 +1029,7 @@ class ProcessReleases $secondQuery = time(); if ($this->echoCLI) { - echo $this->pdo->log->primary( + echo ColorCLI::primary( 'Finished deleting ' . $deleted . ' orphaned collections in ' . ($secondQuery - $firstQuery) . ' seconds.' . PHP_EOL ); @@ -1038,7 +1038,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) { - echo $this->pdo->log->primary('Deleting orphaned binaries/parts with no collection.'); + echo ColorCLI::primary('Deleting orphaned binaries/parts with no collection.'); } $deleted = 0; @@ -1064,7 +1064,7 @@ class ProcessReleases $thirdQuery = time(); if ($this->echoCLI) { - echo $this->pdo->log->primary( + echo ColorCLI::primary( 'Finished deleting ' . $deleted . ' binaries with no collections or parts in ' . ($thirdQuery - $secondQuery) . ' seconds.' ); @@ -1073,7 +1073,7 @@ class ProcessReleases // orphaned parts - parts with no binary // Don't delete currently inserting parts by checking the max id. if ($this->echoCLI) { - echo $this->pdo->log->primary('Deleting orphaned parts with no binaries.'); + echo ColorCLI::primary('Deleting orphaned parts with no binaries.'); } $deleted = 0; $deleteQuery = $this->pdo->queryExec( @@ -1096,7 +1096,7 @@ class ProcessReleases $fourthQuery = time(); if ($this->echoCLI) { - echo $this->pdo->log->primary( + echo ColorCLI::primary( 'Finished deleting ' . $deleted . ' parts with no binaries in ' . ($fourthQuery - $thirdQuery) . ' seconds.' . PHP_EOL ); @@ -1104,7 +1104,7 @@ class ProcessReleases } // done cleaning up Binaries/Parts orphans if ($this->echoCLI) { - echo $this->pdo->log->primary( + echo ColorCLI::primary( 'Deleting collections that were missed after NZB creation.' ); } @@ -1142,8 +1142,8 @@ class ProcessReleases } if ($this->echoCLI) { - $this->pdo->log->doEcho( - $this->pdo->log->primary( + ColorCLI::doEcho( + ColorCLI::primary( 'Finished deleting ' . $deleted . ' collections missed after NZB creation in ' . (time() - $fourthQuery) . ' seconds.' . PHP_EOL . 'Removed ' . @@ -1170,7 +1170,7 @@ class ProcessReleases $minSizeDeleted = $maxSizeDeleted = $minFilesDeleted = 0; if ($this->echoCLI) { - echo $this->pdo->log->header('Process Releases -> Delete releases smaller/larger than minimum size/file count from group/site setting.'); + echo ColorCLI::header('Process Releases -> Delete releases smaller/larger than minimum size/file count from group/site setting.'); } $groupID === '' ? $groupIDs = $this->groups->getActiveIDs() : $groupIDs = [['id' => $groupID]]; @@ -1241,8 +1241,8 @@ class ProcessReleases } if ($this->echoCLI) { - $this->pdo->log->doEcho( - $this->pdo->log->primary( + ColorCLI::doEcho( + ColorCLI::primary( 'Deleted ' . ($minSizeDeleted + $maxSizeDeleted + $minFilesDeleted) . ' releases: ' . PHP_EOL . $minSizeDeleted . ' smaller than, ' . $maxSizeDeleted . ' bigger than, ' . $minFilesDeleted . @@ -1270,7 +1270,7 @@ class ProcessReleases // Delete old releases and finished collections. if ($this->echoCLI) { - $this->pdo->log->doEcho($this->pdo->log->header('Process Releases -> Delete old releases and passworded releases.')); + ColorCLI::doEcho(ColorCLI::header('Process Releases -> Delete old releases and passworded releases.')); } // Releases past retention. @@ -1465,8 +1465,8 @@ class ProcessReleases } if ($this->echoCLI) { - $this->pdo->log->doEcho( - $this->pdo->log->primary( + ColorCLI::doEcho( + ColorCLI::primary( 'Removed releases: ' . number_format($retentionDeleted) . ' past retention, ' . @@ -1497,8 +1497,8 @@ class ProcessReleases $categoryMinSizeDeleted ); if ($totalDeleted > 0) { - $this->pdo->log->doEcho( - $this->pdo->log->primary( + ColorCLI::doEcho( + ColorCLI::primary( 'Removed ' . number_format($totalDeleted) . ' releases in ' . $this->consoleTools->convertTime(time() - $startTime) ) @@ -1791,8 +1791,8 @@ class ProcessReleases ) ); if ($this->echoCLI && is_object($obj) && $obj->rowCount()) { - $this->pdo->log->doEcho( - $this->pdo->log->primary('Deleted ' . $obj->rowCount() . ' broken/stuck collections.') + ColorCLI::doEcho( + ColorCLI::primary('Deleted ' . $obj->rowCount() . ' broken/stuck collections.') ); } } diff --git a/nntmux/processing/post/AniDB.php b/nntmux/processing/post/AniDB.php index 45abc059d..f46399ba5 100755 --- a/nntmux/processing/post/AniDB.php +++ b/nntmux/processing/post/AniDB.php @@ -105,7 +105,7 @@ class AniDB } } } else { - $this->pdo->log->doEcho($this->pdo->log->info("No work to process."), true); + ColorCLI::doEcho(ColorCLI::info("No work to process."), true); } } @@ -166,7 +166,7 @@ class AniDB $matches['epno'] = 1; } else { if (NN_DEBUG) { - $this->pdo->log->doEcho( + ColorCLI::doEcho( PHP_EOL . "Could not parse searchname {$cleanName}.", true ); @@ -218,8 +218,8 @@ class AniDB if (is_array($cleanArr) && isset($cleanArr['title']) && is_numeric($cleanArr['epno'])) { - echo $this->pdo->log->header(PHP_EOL . "Looking Up: ") . - $this->pdo->log->primary(" Title: {$cleanArr['title']}" . PHP_EOL . + echo ColorCLI::header(PHP_EOL . "Looking Up: ") . + ColorCLI::primary(" Title: {$cleanArr['title']}" . PHP_EOL . " Episode: {$cleanArr['epno']}"); // get anidb number for the title of the name @@ -242,28 +242,28 @@ class AniDB $type = 'Remote'; } else { echo PHP_EOL . - $this->pdo->log->info("This AniDB ID was not found to be accurate locally, but has been updated too recently to check AniDB.") . + 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']); - $this->pdo->log->doEcho( - $this->pdo->log->headerOver("Matched {$type} AniDB ID: ") . - $this->pdo->log->primary($anidbId['anidbid']) . - $this->pdo->log->alternateOver(" Title: ") . - $this->pdo->log->primary($anidbId['title']) . - $this->pdo->log->alternateOver(" Episode #: ") . - $this->pdo->log->primary($cleanArr['epno']) . - $this->pdo->log->alternateOver(" Episode Title: ") . - $this->pdo->log->primary($updatedAni['episode_title']) + ColorCLI::doEcho( + 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']) ); $matched = true; } else { if (NN_DEBUG) { - $this->pdo->log->doEcho( + ColorCLI::doEcho( PHP_EOL . "Could not match searchname: {$release['searchname']}.", true ); diff --git a/nntmux/processing/post/ProcessAdditional.php b/nntmux/processing/post/ProcessAdditional.php index e1e838cb9..870245bb2 100755 --- a/nntmux/processing/post/ProcessAdditional.php +++ b/nntmux/processing/post/ProcessAdditional.php @@ -2555,7 +2555,7 @@ class ProcessAdditional protected function _echo($string, $type, $newLine = true) { if ($this->_echoCLI) { - $this->pdo->log->doEcho($this->pdo->log->$type($string), $newLine); + ColorCLI::doEcho(ColorCLI::$type($string), $newLine); } } diff --git a/nntmux/processing/tv/TMDB.php b/nntmux/processing/tv/TMDB.php index 623ce4b56..a3584ad2e 100755 --- a/nntmux/processing/tv/TMDB.php +++ b/nntmux/processing/tv/TMDB.php @@ -94,7 +94,7 @@ class TMDB extends TV $tvcount = $res->rowCount(); if ($this->echooutput && $tvcount > 0) { - echo $this->pdo->log->header("Processing TMDB lookup for " . number_format($tvcount) . " release(s)."); + echo ColorCLI::header("Processing TMDB lookup for " . number_format($tvcount) . " release(s)."); } if ($res instanceof \Traversable) { @@ -113,9 +113,9 @@ class TMDB extends TV if (in_array($release['cleanname'], $this->titleCache)) { if ($this->echooutput) { - echo $this->pdo->log->headerOver("Title: ") . - $this->pdo->log->warningOver('"' . $release['cleanname'] . '"') . - $this->pdo->log->header(" already failed lookup for this site. Skipping."); + echo ColorCLI::headerOver("Title: ") . + ColorCLI::warningOver('"' . $release['cleanname'] . '"') . + 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) { - echo $this->pdo->log->primaryOver("Checking TMDB for previously failed title: ") . - $this->pdo->log->headerOver($release['cleanname']) . - $this->pdo->log->primary("."); + echo ColorCLI::primaryOver("Checking TMDB for previously failed title: ") . + ColorCLI::headerOver($release['cleanname']) . + ColorCLI::primary("."); } // Get the show from TMDB @@ -157,9 +157,9 @@ class TMDB extends TV } } else { if ($this->echooutput) { - echo $this->pdo->log->primaryOver("Found local TMDB match for: ") . - $this->pdo->log->headerOver($release['cleanname']) . - $this->pdo->log->primary(". Attempting episode lookup!"); + echo ColorCLI::primaryOver("Found local TMDB match for: ") . + ColorCLI::headerOver($release['cleanname']) . + 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); - echo $this->pdo->log->primary("Found TMDB Match for Full Season!"); + echo 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) { - echo $this->pdo->log->primary("Found TMDB Match!"); + echo ColorCLI::primary("Found TMDB Match!"); } continue; } else { diff --git a/nntmux/processing/tv/TV.php b/nntmux/processing/tv/TV.php index 8248790a5..c808ed12d 100755 --- a/nntmux/processing/tv/TV.php +++ b/nntmux/processing/tv/TV.php @@ -520,7 +520,7 @@ abstract class TV extends Videos } } if (NN_DEBUG) { - $this->pdo->log->doEcho('Failed to parse release: ' . $relname, true); + ColorCLI::doEcho('Failed to parse release: ' . $relname, true); } return false; } diff --git a/nntmux/processing/tv/TVDB.php b/nntmux/processing/tv/TVDB.php index ebd585c68..b03163c93 100755 --- a/nntmux/processing/tv/TVDB.php +++ b/nntmux/processing/tv/TVDB.php @@ -57,12 +57,12 @@ class TVDB extends TV $this->serverTime = $this->client->getServerTime(); } catch (CurlException $error) { if (strpos($error->getMessage(), 'Cannot fetch') === 0) { - echo $this->pdo->log->warning('Could not reach TVDB API. Running in local mode only!'); + echo ColorCLI::warning('Could not reach TVDB API. Running in local mode only!'); $this->local = true; } } catch (XmlException $error) { if (strpos($error->getMessage(), 'Error in file') === 0) { - echo $this->pdo->log->warning('Bad response from TVDB API. Running in local mode only!'); + echo ColorCLI::warning('Bad response from TVDB API. Running in local mode only!'); $this->local = true; } } @@ -84,7 +84,7 @@ class TVDB extends TV $tvcount = $res->rowCount(); if ($this->echooutput && $tvcount > 0) { - echo $this->pdo->log->header("Processing TVDB lookup for " . number_format($tvcount) . " release(s)."); + echo ColorCLI::header("Processing TVDB lookup for " . number_format($tvcount) . " release(s)."); } if ($res instanceof \Traversable) { @@ -101,9 +101,9 @@ class TVDB extends TV if (in_array($release['cleanname'], $this->titleCache)) { if ($this->echooutput) { - echo $this->pdo->log->headerOver("Title: ") . - $this->pdo->log->warningOver('"' . $release['cleanname'] . '"') . - $this->pdo->log->header(" already failed lookup for this site. Skipping."); + echo ColorCLI::headerOver("Title: ") . + ColorCLI::warningOver('"' . $release['cleanname'] . '"') . + ColorCLI::header(" already failed lookup for this site. Skipping."); } $this->setVideoNotFound(parent::PROCESS_TVMAZE, $row['id']); continue; @@ -127,9 +127,9 @@ class TVDB extends TV // If it doesnt exist locally and lookups are allowed lets try to get it. if ($this->echooutput) { - echo $this->pdo->log->primaryOver("Video ID for ") . - $this->pdo->log->headerOver($release['cleanname']) . - $this->pdo->log->primary(" not found in local db, checking web."); + echo ColorCLI::primaryOver("Video ID for ") . + ColorCLI::headerOver($release['cleanname']) . + ColorCLI::primary(" not found in local db, checking web."); } // Check if we have a valid country and set it in the array @@ -148,9 +148,9 @@ class TVDB extends TV } } else if ($this->echooutput && $tvdbid !== false) { - echo $this->pdo->log->primaryOver("Video ID for ") . - $this->pdo->log->headerOver($release['cleanname']) . - $this->pdo->log->primary(" found in local db, attempting episode match."); + echo ColorCLI::primaryOver("Video ID for ") . + ColorCLI::headerOver($release['cleanname']) . + ColorCLI::primary(" found in local db, attempting episode match."); } if (is_numeric($videoId) && $videoId > 0 && is_numeric($tvdbid) && $tvdbid > 0) { @@ -163,7 +163,7 @@ class TVDB extends TV if ($episodeNo === 'all') { // Set the video ID and leave episode 0 $this->setVideoIdFound($videoId, $row['id'], 0); - echo $this->pdo->log->primary("Found TVDB Match for Full Season!"); + echo ColorCLI::primary("Found TVDB Match for Full Season!"); continue; } @@ -193,7 +193,7 @@ class TVDB extends TV // Mark the releases video and episode IDs $this->setVideoIdFound($videoId, $row['id'], $episode); if ($this->echooutput) { - echo $this->pdo->log->primary("Found TVDB Match!"); + echo ColorCLI::primary("Found TVDB Match!"); } } else { //Processing failed, set the episode ID to the next processing group diff --git a/nntmux/processing/tv/TVMaze.php b/nntmux/processing/tv/TVMaze.php index 0dca1c177..c7e7a86f9 100755 --- a/nntmux/processing/tv/TVMaze.php +++ b/nntmux/processing/tv/TVMaze.php @@ -67,7 +67,7 @@ class TVMaze extends TV $tvcount = $res->rowCount(); if ($this->echooutput && $tvcount > 0) { - echo $this->pdo->log->header("Processing TVMaze lookup for " . number_format($tvcount) . " release(s)."); + echo ColorCLI::header("Processing TVMaze lookup for " . number_format($tvcount) . " release(s)."); } if ($res instanceof \Traversable) { @@ -85,9 +85,9 @@ class TVMaze extends TV if (in_array($release['cleanname'], $this->titleCache)) { if ($this->echooutput) { - echo $this->pdo->log->headerOver("Title: ") . - $this->pdo->log->warningOver('"' . $release['cleanname'] . '"') . - $this->pdo->log->header(" already failed lookup for this site. Skipping."); + echo ColorCLI::headerOver("Title: ") . + ColorCLI::warningOver('"' . $release['cleanname'] . '"') . + ColorCLI::header(" already failed lookup for this site. Skipping."); } $this->setVideoNotFound(parent::PROCESS_TMDB, $row['id']); continue; @@ -106,9 +106,9 @@ class TVMaze extends TV if ($videoId === false && $lookupSetting) { // If lookups are allowed lets try to get it. if ($this->echooutput) { - echo $this->pdo->log->primaryOver("Checking TVMaze for previously failed title: ") . - $this->pdo->log->headerOver($release['cleanname']) . - $this->pdo->log->primary("."); + echo ColorCLI::primaryOver("Checking TVMaze for previously failed title: ") . + ColorCLI::headerOver($release['cleanname']) . + ColorCLI::primary("."); } // Get the show from TVMaze @@ -132,9 +132,9 @@ class TVMaze extends TV } } else { if ($this->echooutput) { - echo $this->pdo->log->primaryOver("Found local TVMaze match for: ") . - $this->pdo->log->headerOver($release['cleanname']) . - $this->pdo->log->primary(". Attempting episode lookup!"); + echo ColorCLI::primaryOver("Found local TVMaze match for: ") . + ColorCLI::headerOver($release['cleanname']) . + ColorCLI::primary(". Attempting episode lookup!"); } $tvmazeid = $this->getSiteIDFromVideoID('tvmaze', $videoId); } @@ -149,7 +149,7 @@ class TVMaze extends TV if ($episodeNo === 'all') { // Set the video ID and leave episode 0 $this->setVideoIdFound($videoId, $row['id'], 0); - echo $this->pdo->log->primary("Found TVDB Match for Full Season!"); + echo ColorCLI::primary("Found TVDB Match for Full Season!"); continue; } @@ -179,7 +179,7 @@ class TVMaze extends TV // Mark the releases video and episode IDs $this->setVideoIdFound($videoId, $row['id'], $episode); if ($this->echooutput) { - echo $this->pdo->log->primary("Found TVMaze Match!"); + echo ColorCLI::primary("Found TVMaze Match!"); } continue; } else { diff --git a/nntmux/processing/tv/TraktTv.php b/nntmux/processing/tv/TraktTv.php index bdbfc19a3..fa07cfe76 100755 --- a/nntmux/processing/tv/TraktTv.php +++ b/nntmux/processing/tv/TraktTv.php @@ -104,7 +104,7 @@ class TraktTv extends TV $tvcount = $res->rowCount(); if ($this->echooutput && $tvcount > 1) { - echo $this->pdo->log->header("Processing TRAKT lookup for " . number_format($tvcount) . " release(s)."); + echo ColorCLI::header("Processing TRAKT lookup for " . number_format($tvcount) . " release(s)."); } if ($res instanceof \Traversable) { @@ -118,9 +118,9 @@ class TraktTv extends TV if (is_array($release) && $release['name'] != '') { if (in_array($release['cleanname'], $this->titleCache)) { if ($this->echooutput) { - echo $this->pdo->log->headerOver("Title: ") . - $this->pdo->log->warningOver('"' . $release['cleanname'] . '"') . - $this->pdo->log->header(" already failed lookup for this site. Skipping."); + echo ColorCLI::headerOver("Title: ") . + ColorCLI::warningOver('"' . $release['cleanname'] . '"') . + ColorCLI::header(" already failed lookup for this site. Skipping."); } $this->setVideoNotFound(parent::PROCESS_IMDB, $row['id']); continue; @@ -140,9 +140,9 @@ class TraktTv extends TV // If it doesn't exist locally and lookups are allowed lets try to get it. if ($this->echooutput) { - echo $this->pdo->log->primaryOver("Checking Trakt for previously failed title: ") . - $this->pdo->log->headerOver($release['cleanname']) . - $this->pdo->log->primary("."); + echo ColorCLI::primaryOver("Checking Trakt for previously failed title: ") . + ColorCLI::headerOver($release['cleanname']) . + ColorCLI::primary("."); } // Get the show from TRAKT @@ -155,9 +155,9 @@ class TraktTv extends TV } else { if ($this->echooutput) { - echo $this->pdo->log->primaryOver("Found local TMDB match for: ") . - $this->pdo->log->headerOver($release['cleanname']) . - $this->pdo->log->primary(". Attempting episode lookup!"); + echo ColorCLI::primaryOver("Found local TMDB match for: ") . + ColorCLI::headerOver($release['cleanname']) . + ColorCLI::primary(". Attempting episode lookup!"); } $traktid = $this->getSiteIDFromVideoID('trakt', $videoId); $this->localizedTZ = $this->getLocalZoneFromVideoID($videoId); @@ -174,7 +174,7 @@ class TraktTv extends TV if ($episodeNo === 'all') { // Set the video ID and leave episode 0 $this->setVideoIdFound($videoId, $row['id'], 0); - echo $this->pdo->log->primary("Found TRAKT Match for Full Season!"); + echo ColorCLI::primary("Found TRAKT Match for Full Season!"); continue; } @@ -198,7 +198,7 @@ class TraktTv extends TV // Mark the releases video and episode IDs $this->setVideoIdFound($videoId, $row['id'], $episode); if ($this->echooutput) { - echo $this->pdo->log->primary("Found TRAKT Match!"); + echo ColorCLI::primary("Found TRAKT Match!"); } continue; } else { diff --git a/nntmux/processing/tv/TvRage.php b/nntmux/processing/tv/TvRage.php index 08727e0e2..f67c07218 100755 --- a/nntmux/processing/tv/TvRage.php +++ b/nntmux/processing/tv/TvRage.php @@ -97,7 +97,7 @@ class TvRage extends TV $tvcount = $res->rowCount(); if ($this->echooutput && $tvcount > 1) { - echo $this->pdo->log->header("Processing TV Rage lookup for " . number_format($tvcount) . " release(s)."); + echo ColorCLI::header("Processing TV Rage lookup for " . number_format($tvcount) . " release(s)."); } if ($res instanceof \Traversable) { @@ -116,9 +116,9 @@ class TvRage extends TV if ($this->videoId === false && $process) { // If it doesnt exist locally and lookups are allowed lets try to get it. if ($this->echooutput) { - echo $this->pdo->log->primaryOver("Video ID for ") . - $this->pdo->log->headerOver($show['cleanname']) . - $this->pdo->log->primary(" not found in local db, checking web."); + echo ColorCLI::primaryOver("Video ID for ") . + ColorCLI::headerOver($show['cleanname']) . + ColorCLI::primary(" not found in local db, checking web."); } $tvrShow = $this->getShowInfo($show); if ($tvrShow !== false && is_array($tvrShow)) { @@ -131,9 +131,9 @@ class TvRage extends TV } if ($this->videoId > 0) { if ($this->echooutput) { - echo $this->pdo->log->primaryOver("Video ID for ") . - $this->pdo->log->headerOver($show['cleanname']) . - $this->pdo->log->primary(" found in local db, setting tvrage ID and attempting episode lookup."); + echo ColorCLI::primaryOver("Video ID for ") . + ColorCLI::headerOver($show['cleanname']) . + ColorCLI::primary(" found in local db, setting tvrage ID and attempting episode lookup."); } $episodeId = $this->getBySeasonEp($this->videoId, $show['season'], $show['episode']); if ($episodeId === false) { @@ -154,7 +154,7 @@ class TvRage extends TV ); } } - echo $this->pdo->log->primary("Found TV Rage Match!"); + echo ColorCLI::primary("Found TV Rage Match!"); $this->setVideoIdFound($this->videoId, $arr['id'], $episodeId); // Cant find videos_id, so set tv_episodes_id to PROCESS_TVMAZE. } else { @@ -413,7 +413,7 @@ class TvRage extends TV } } else { if ($this->echooutput) { - echo $this->pdo->log->primary('Nothing returned from tvrage.'); + echo ColorCLI::primary('Nothing returned from tvrage.'); } } } diff --git a/www/pages/details.php b/www/pages/details.php index a215b0bba..7e37fd070 100644 --- a/www/pages/details.php +++ b/www/pages/details.php @@ -66,7 +66,7 @@ if (isset($_GET['id'])) { $mov['genre'] = $movie->makeFieldLinks($mov, 'genre'); $mov['director'] = $movie->makeFieldLinks($mov, 'director'); if (Settings::value('site.trailers.trailers_display')) { - $trailer = (!isset($mov['trailer']) || empty($mov['trailer']) || $mov['trailer'] == '' ? $movie->getTrailer($data['imdbid']) : $mov['trailer']); + $trailer = empty($mov['trailer']) || $mov['trailer'] == '' ? $movie->getTrailer($data['imdbid']) : $mov['trailer']; if ($trailer) { $mov['trailer'] = sprintf( '',