Skip to content

Commit

Permalink
Upgrade nntmux configuration method
Browse files Browse the repository at this point in the history
  • Loading branch information
DariusIII committed Mar 3, 2018
1 parent e091378 commit d5e7ba4
Show file tree
Hide file tree
Showing 76 changed files with 296 additions and 572 deletions.
12 changes: 0 additions & 12 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,5 @@ RECAPTCHA_SECRETKEY=
MYCELIUM_GATEWAY_ID=
MYCELIUM_GATEWAY_SECRET=


ITEMS_PER_PAGE=50
ITEMS_PER_COVER_PAGE=20
MAX_PAGER_RESULTS=125000
FLOOD_CHECK=false
FLOOD_WAIT_TIME=5
FLOOD_MAX_REQUESTS_PER_SECOND=5

ECHOCLI=true
RENAME_PAR2=true
RENAME_MUSIC_MEDIAINFO=true

SCOUT_DRIVER=mysql
SCOUT_QUEUE=false
2 changes: 1 addition & 1 deletion Blacklight/Backfill.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function __construct(array $options = [])
];
$options += $defaults;

$this->_echoCLI = ($options['Echo'] && env('echocli', true));
$this->_echoCLI = ($options['Echo'] && config('nntmux.echocli'));

$this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB());
$this->_nntp = (
Expand Down
4 changes: 2 additions & 2 deletions Blacklight/Binaries.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public function __construct(array $options = [])
];
$options += $defaults;

$this->_echoCLI = ($options['Echo'] && env('echocli', true));
$this->_echoCLI = ($options['Echo'] && config('nntmux.echocli'));

$this->_pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB());
$this->_colorCLI = ($options['ColorCLI'] instanceof ColorCLI ? $options['ColorCLI'] : new ColorCLI());
Expand Down Expand Up @@ -1736,7 +1736,7 @@ protected function getMultiGroupPosters()
}

$poster = MultigroupPoster::query()->get(['poster'])->toArray();
$expiresAt = Carbon::now()->addSeconds(NN_CACHE_EXPIRY_SHORT);
$expiresAt = Carbon::now()->addSeconds(config('nntmux.cache_expiry_short'));
Cache::put('mgrposter', $poster, $expiresAt);

return $poster;
Expand Down
4 changes: 2 additions & 2 deletions Blacklight/Books.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function __construct(array $options = [])
];
$options += $defaults;

$this->echooutput = ($options['Echo'] && env('echocli', true));
$this->echooutput = ($options['Echo'] && config('nntmux.echocli'));
$this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB());

$this->pubkey = Settings::settingValue('APIs..amazonpubkey');
Expand Down Expand Up @@ -187,7 +187,7 @@ public function getBookRange($cat, $start, $num, $orderby, array $excludedcats =
$order[1],
($start === false ? '' : ' LIMIT '.$num.' OFFSET '.$start)
);
$expiresAt = Carbon::now()->addSeconds(NN_CACHE_EXPIRY_MEDIUM);
$expiresAt = Carbon::now()->addSeconds(config('nntmux.cache_expiry_medium'));
$bookscache = Cache::get(md5($booksql));
if ($bookscache !== null) {
$books = $bookscache;
Expand Down
6 changes: 3 additions & 3 deletions Blacklight/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function __construct(array $options = [])
];
$options += $defaults;

$this->echooutput = ($options['Echo'] && env('echocli', true));
$this->echooutput = ($options['Echo'] && config('nntmux.echocli'));
$this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB());

$this->pubkey = Settings::settingValue('APIs..amazonpubkey');
Expand Down Expand Up @@ -201,7 +201,7 @@ public function getConsoleRange($cat, $start, $num, $orderBy, array $excludedcat
$consoles = $cached;
} else {
$consoles = $this->pdo->queryCalc($calcSql);
$expiresAt = Carbon::now()->addSeconds(NN_CACHE_EXPIRY_MEDIUM);
$expiresAt = Carbon::now()->addSeconds(config('nntmux.cache_expiry_medium'));
Cache::put(md5($calcSql), $consoles, $expiresAt);
}

Expand Down Expand Up @@ -264,7 +264,7 @@ public function getConsoleRange($cat, $start, $num, $orderBy, array $excludedcat
$return[0]['_totalcount'] = $consoles['total'] ?? 0;
}

$expiresAt = Carbon::now()->addSeconds(NN_CACHE_EXPIRY_LONG);
$expiresAt = Carbon::now()->addSeconds(config('nntmux.cache_expiry_long'));
Cache::put(md5($sql), $return, $expiresAt);

return $return;
Expand Down
4 changes: 2 additions & 2 deletions Blacklight/Games.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function __construct(array $options = [])
'Settings' => null,
];
$options += $defaults;
$this->echoOutput = ($options['Echo'] && env('echocli', true));
$this->echoOutput = ($options['Echo'] && config('nntmux.echocli'));

$this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB());

Expand Down Expand Up @@ -270,7 +270,7 @@ public function getGamesRange($cat, $start, $num, $orderBy = '', $maxAge = '', a
($start === false ? '' : ' LIMIT '.$num.' OFFSET '.$start)
);

$expiresAt = Carbon::now()->addSeconds(NN_CACHE_EXPIRY_MEDIUM);
$expiresAt = Carbon::now()->addSeconds(config('nntmux.cache_expiry_medium'));
$gamesCache = Cache::get(md5($gamesSql));
if ($gamesCache !== null) {
$games = $gamesCache;
Expand Down
4 changes: 2 additions & 2 deletions Blacklight/Genres.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function getGenres($type = '', $activeonly = false)
return $genres;
}
$genres = $this->pdo->query($sql);
$expiresAt = Carbon::now()->addSeconds(NN_CACHE_EXPIRY_LONG);
$expiresAt = Carbon::now()->addSeconds(config('nntmux.cache_expiry_long'));
Cache::put(md5($sql), $genres, $expiresAt);

return $genres;
Expand Down Expand Up @@ -186,7 +186,7 @@ public function getDisabledIDs()
$disabled = $cats;
} else {
$disabled = Genre::query()->where('disabled', '=', 1)->get(['id']);
$expiresAt = Carbon::now()->addSeconds(NN_CACHE_EXPIRY_LONG);
$expiresAt = Carbon::now()->addSeconds(config('nntmux.cache_expiry_long'));
Cache::put('disabledcats', $disabled, $expiresAt);
}

Expand Down
28 changes: 14 additions & 14 deletions Blacklight/IRCScraper.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ class IRCScraper extends IRCClient
*/
public function __construct(&$silent, &$debug)
{
if (defined('SCRAPE_IRC_SOURCE_IGNORE')) {
if (config('irc_settings.scrape_irc_source_ignore')) {
$this->_ignoredChannels = unserialize(
SCRAPE_IRC_SOURCE_IGNORE,
config('irc_settings.scrape_irc_source_ignore'),
['allowed_classes' => ['#a.b.cd.image',
'#a.b.console.ps3',
'#a.b.dvd',
Expand Down Expand Up @@ -124,12 +124,12 @@ public function __construct(&$silent, &$debug)
}

$this->_categoryIgnoreRegex = false;
if (defined('SCRAPE_IRC_CATEGORY_IGNORE') && SCRAPE_IRC_CATEGORY_IGNORE !== '') {
$this->_categoryIgnoreRegex = SCRAPE_IRC_CATEGORY_IGNORE;
if (config('irc_settings.scrape_irc_category_ignore') !== '') {
$this->_categoryIgnoreRegex = config('irc_settings.scrape_irc_category_ignore');
}

$this->_titleIgnoreRegex = false;
if (defined('SCRAPE_IRC_TITLE_IGNORE') && SCRAPE_IRC_TITLE_IGNORE !== '') {
if (config('irc_settings.scrape_irc_title_ignore') !== '') {
$this->_titleIgnoreRegex = SCRAPE_IRC_TITLE_IGNORE;
}

Expand All @@ -153,40 +153,40 @@ protected function _startScraping()
{

// Connect to IRC.
if ($this->connect(SCRAPE_IRC_SERVER, SCRAPE_IRC_PORT, SCRAPE_IRC_TLS) === false) {
if ($this->connect(config('irc_settings.scrape_irc_server'), config('irc_settings.scrape_irc_port'), config('irc_settings.scrape_irc_tls')) === false) {
exit(
'Error connecting to ('.
SCRAPE_IRC_SERVER.
config('irc_settings.scrape_irc_server').
':'.
SCRAPE_IRC_PORT.
config('irc_settings.scrape_irc_port').
'). Please verify your server information and try again.'.
PHP_EOL
);
}

// Login to IRC.
if ($this->login(SCRAPE_IRC_NICKNAME, SCRAPE_IRC_REALNAME, SCRAPE_IRC_USERNAME, SCRAPE_IRC_PASSWORD) === false) {
if ($this->login(config('irc_settings.scrape_irc_nickname'), config('irc_settings.scrape_irc_realname'), config('irc_settings.scrape_irc_username'), config('irc_settings.scrape_irc_password')) === false) {
exit('Error logging in to: ('.
SCRAPE_IRC_SERVER.':'.SCRAPE_IRC_PORT.') nickname: ('.SCRAPE_IRC_NICKNAME.
config('irc_settings.scrape_irc_server').':'.config('irc_settings.scrape_irc_port').') nickname: ('.config('irc_settings.scrape_irc_nickname').
'). Verify your connection information, you might also be banned from this server or there might have been a connection issue.'.
PHP_EOL
);
}

// Join channels.
$channels = defined('SCRAPE_IRC_CHANNELS') ? unserialize(SCRAPE_IRC_CHANNELS, ['allowed_classes' => ['#PreNNTmux', '#nZEDbPRE']]) : ['#PreNNTmux' => null];
$channels = config('irc_settings.scrape_irc_channels') ? unserialize(config('irc_settings.scrape_irc_channels'), ['allowed_classes' => ['#PreNNTmux', '#nZEDbPRE']]) : ['#PreNNTmux' => null];
$this->joinChannels($channels);

if (! $this->_silent) {
echo
'['.
date('r').
'] [Scraping of IRC channels for ('.
SCRAPE_IRC_SERVER.
config('irc_settings.scrape_irc_server').
':'.
SCRAPE_IRC_PORT.
config('irc_settings.scrape_irc_port').
') ('.
SCRAPE_IRC_NICKNAME.
config('irc_settings.scrape_irc_nickname').
') started.]'.
PHP_EOL;
}
Expand Down
2 changes: 1 addition & 1 deletion Blacklight/MiscSorter.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class MiscSorter
*/
public function __construct($echooutput = false, &$pdo)
{
$this->echooutput = (env('echocli', true) && $echooutput);
$this->echooutput = (config('nntmux.echocli') && $echooutput);

$this->pdo = ($pdo instanceof DB ? $pdo : new DB());
$this->movie = new Movie(['Echo' => $this->echooutput, 'Settings' => $this->pdo]);
Expand Down
4 changes: 2 additions & 2 deletions Blacklight/Movie.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public function __construct(array $options = [])
$this->searchEngines = true;
$this->showPasswords = Releases::showPasswords();

$this->echooutput = ($options['Echo'] && env('echocli', true) && $this->pdo->cli);
$this->echooutput = ($options['Echo'] && config('nntmux.echocli') && $this->pdo->cli);
$this->imgSavePath = NN_COVERS.'movies'.DS;
$this->service = '';
}
Expand Down Expand Up @@ -279,7 +279,7 @@ public function getMovieRange($cat, $start, $num, $orderBy, $maxAge = -1, array
}

$order = $this->getMovieOrder($orderBy);
$expiresAt = Carbon::now()->addSeconds(NN_CACHE_EXPIRY_MEDIUM);
$expiresAt = Carbon::now()->addSeconds(config('nntmux.cache_expiry_medium'));

$moviesSql =
sprintf(
Expand Down
4 changes: 2 additions & 2 deletions Blacklight/Music.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function __construct(array $options = [])
];
$options += $defaults;

$this->echooutput = ($options['Echo'] && env('echocli', true));
$this->echooutput = ($options['Echo'] && config('nntmux.echocli'));

$this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB());
$this->pubkey = Settings::settingValue('APIs..amazonpubkey');
Expand Down Expand Up @@ -162,7 +162,7 @@ public function getMusicRange($cat, $start, $num, $orderby, array $excludedcats
}

$order = $this->getMusicOrder($orderby);
$expiresAt = Carbon::now()->addSeconds(NN_CACHE_EXPIRY_MEDIUM);
$expiresAt = Carbon::now()->addSeconds(config('nntmux.cache_expiry_medium'));

$musicSql =
sprintf(
Expand Down
2 changes: 1 addition & 1 deletion Blacklight/NNTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function __construct(array $options = [])

parent::__construct();

$this->_echo = ($options['Echo'] && env('echocli', true));
$this->_echo = ($options['Echo'] && config('nntmux.echocli'));

$this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB());

Expand Down
2 changes: 1 addition & 1 deletion Blacklight/NZBContents.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function __construct(array $options = [])
];
$options += $defaults;

$this->echooutput = ($options['Echo'] && env('echocli', true));
$this->echooutput = ($options['Echo'] && config('nntmux.echocli'));
$this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB());
$this->nntp = ($options['NNTP'] instanceof NNTP ? $options['NNTP'] : new NNTP(['Echo' => $this->echooutput, 'Settings' => $this->pdo]));
$this->nfo = ($options['Nfo'] instanceof Nfo ? $options['Nfo'] : new Nfo());
Expand Down
2 changes: 1 addition & 1 deletion Blacklight/NZBExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function __construct(array $options = [])
$options += $defaults;

$this->browser = $options['Browser'];
$this->echoCLI = (! $this->browser && env('echocli', true) && $options['Echo']);
$this->echoCLI = (! $this->browser && config('nntmux.echocli') && $options['Echo']);
$this->pdo = ($options['Settings'] instanceof DB ? $options['Setting'] : new DB());
$this->releases = ($options['Releases'] instanceof Releases ? $options['Releases'] : new Releases(['Settings' => $this->pdo]));
$this->nzb = ($options['NZB'] instanceof NZB ? $options['NZB'] : new NZB());
Expand Down
2 changes: 1 addition & 1 deletion Blacklight/NZBImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function __construct(array $options = [])
];
$options += $defaults;

$this->echoCLI = (! $this->browser && env('echocli', true) && $options['Echo']);
$this->echoCLI = (! $this->browser && config('nntmux.echocli') && $options['Echo']);
$this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB());
$this->binaries = ($options['Binaries'] instanceof Binaries ? $options['Binaries'] : new Binaries(['Settings' => $this->pdo, 'Echo' => $this->echoCLI]));
$this->category = ($options['Categorize'] instanceof Categorize ? $options['Categorize'] : new Categorize(['Settings' => $this->pdo]));
Expand Down
2 changes: 1 addition & 1 deletion Blacklight/NameFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function __construct(array $options = [])
];
$options += $defaults;

$this->echooutput = ($options['Echo'] && env('echocli', true));
$this->echooutput = ($options['Echo'] && config('nntmux.echocli'));
$this->relid = $this->fixed = $this->checked = 0;
$this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB());
$this->othercats = implode(',', Category::OTHERS_GROUP);
Expand Down
2 changes: 1 addition & 1 deletion Blacklight/Nfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Nfo
*/
public function __construct()
{
$this->echo = env('echocli', true);
$this->echo = config('nntmux.echocli');
$this->nzbs = Settings::settingValue('..maxnfoprocessed') !== '' ? (int) Settings::settingValue('..maxnfoprocessed') : 100;
$this->maxRetries = (int) Settings::settingValue('..maxnforetries') >= 0 ? -((int) Settings::settingValue('..maxnforetries') + 1) : self::NFO_UNPROC;
$this->maxRetries = $this->maxRetries < -8 ? -8 : $this->maxRetries;
Expand Down
4 changes: 2 additions & 2 deletions Blacklight/Regexes.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ public function tryRegex($subject, $groupName): string
protected function _fetchRegex($groupName): void
{
// Check if we need to do an initial cache or refresh our cache.
if (isset($this->_regexCache[$groupName]['ttl']) && (time() - $this->_regexCache[$groupName]['ttl']) < NN_CACHE_EXPIRY_LONG) {
if (isset($this->_regexCache[$groupName]['ttl']) && (time() - $this->_regexCache[$groupName]['ttl']) < config('nntmux.cache_expiry_long')) {
return;
}

Expand All @@ -339,7 +339,7 @@ protected function _fetchRegex($groupName): void
$this->pdo->escapeString($groupName)
),
true,
NN_CACHE_EXPIRY_LONG
config('nntmux.cache_expiry_long')
);
// Set the TTL.
$this->_regexCache[$groupName]['ttl'] = time();
Expand Down
2 changes: 1 addition & 1 deletion Blacklight/ReleaseRemover.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public function __construct(array $options = [])
$this->error = '';
$this->ignoreUserCheck = false;
$this->browser = $options['Browser'];
$this->echoCLI = (! $this->browser && env('echocli', true) && $options['Echo']);
$this->echoCLI = (! $this->browser && config('nntmux.echocli') && $options['Echo']);
}

/**
Expand Down
Loading

0 comments on commit d5e7ba4

Please sign in to comment.