Files
newznab-tmux/misc/update_scripts/update_binaries.php
T

30 lines
897 B
PHP

<?php
require_once(dirname(__FILE__) . "/config.php");
use newznab\db\Settings;
$pdo = new Settings();
$maxHeaders = $pdo->getSetting('max.headers.iteration') ?: 1000000;
// Create the connection here and pass
$nntp = new NNTP(['Settings' => $pdo]);
if ($nntp->doConnect() !== true) {
exit($pdo->log->error("Unable to connect to usenet."));
}
$binaries = new Binaries(['NNTP' => $nntp, 'Settings' => $pdo]);
if (isset($argv[1]) && !is_numeric($argv[1])) {
$groupName = $argv[1];
echo $pdo->log->header("Updating group: $groupName");
$grp = new Groups(['Settings' => $pdo]);
$group = $grp->getByName($groupName);
if (is_array($group)) {
$binaries->updateGroup($group,
(isset($argv[2]) && is_numeric($argv[2]) && $argv[2] > 0 ? $argv[2] : $maxHeaders));
}
} else {
$binaries->updateAllGroups((isset($argv[1]) && is_numeric($argv[1]) && $argv[1] > 0 ? $argv[1] :
$maxHeaders));
}