mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-31 02:08:57 +00:00
Move files around.
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
processAlternate*
|
||||
processAdditional*
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
require_once(dirname(__FILE__) . "/../../../../../www/config.php");
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
require_once(dirname(__FILE__) . "/config.php");
|
||||
|
||||
use newznab\db\DB;
|
||||
use newznab\processing\PProcess;
|
||||
|
||||
$c = new ColorCLI();
|
||||
if (!isset($argv[1])) {
|
||||
exit($c->error("This script is not intended to be run manually, it is called from fixreleasenames_threaded.py."));
|
||||
} else if (isset($argv[1])) {
|
||||
$db = new DB();
|
||||
$namefixer = new \NameFixer(['Settings' => $pdo]);
|
||||
$pieces = explode(' ', $argv[1]);
|
||||
if (isset($pieces[1]) && $pieces[0] == 'nfo') {
|
||||
$release = $pieces[1];
|
||||
if ($res = $db->queryOneRow(sprintf('SELECT rel.guid AS guid, nfo.releaseid AS nfoid, rel.groupid, rel.categoryid, rel.name, rel.searchname, uncompress(nfo) AS textstring, rel.id AS releaseid FROM releases rel INNER JOIN releasenfo nfo ON (nfo.releaseid = rel.id) WHERE rel.id = %d', $release))) {
|
||||
//ignore encrypted nfos
|
||||
if (preg_match('/^=newz\[NZB\]=\w+/', $res['textstring'])) {
|
||||
$namefixer->done = $namefixer->matched = false;
|
||||
$db->queryDirect(sprintf('UPDATE releases SET proc_nfo = 1 WHERE id = %d', $res['releaseid']));
|
||||
$namefixer->checked++;
|
||||
echo '.';
|
||||
} else {
|
||||
//echo $res['textstring']."\n";
|
||||
$namefixer->done = $namefixer->matched = false;
|
||||
if ($namefixer->checkName($res, true, 'NFO, ', 1, 1) !== true) {
|
||||
echo '.';
|
||||
}
|
||||
$namefixer->checked++;
|
||||
}
|
||||
}
|
||||
} else if (isset($pieces[1]) && $pieces[0] == 'filename') {
|
||||
$release = $pieces[1];
|
||||
if ($res = $db->queryOneRow(sprintf('SELECT relfiles.name AS textstring, rel.categoryid, rel.searchname, '
|
||||
. 'rel.groupid, relfiles.releaseid AS fileid, rel.id AS releaseid, rel.name FROM releases rel '
|
||||
. 'INNER JOIN releasefiles relfiles ON (relfiles.releaseid = rel.id) WHERE rel.id = %d', $release))) {
|
||||
$namefixer->done = $namefixer->matched = false;
|
||||
if ($namefixer->checkName($res, true, 'Filenames, ', 1, 1) !== true) {
|
||||
echo '.';
|
||||
}
|
||||
$namefixer->checked++;
|
||||
}
|
||||
} else if (isset($pieces[1]) && $pieces[0] == 'md5') {
|
||||
$release = $pieces[1];
|
||||
if ($res = $db->queryOneRow(sprintf('SELECT r.id AS releaseid, r.name, r.searchname, r.categoryid, r.groupid, dehashstatus, rf.name AS filename FROM releases r LEFT JOIN releasefiles rf ON r.id = rf.releaseid WHERE r.id = %d', $release))) {
|
||||
if (preg_match('/[a-fA-F0-9]{32,40}/i', $res['name'], $matches)) {
|
||||
$namefixer->matchPredbHash($matches[0], $res, 1, 1, true, 1);
|
||||
} else if (preg_match('/[a-fA-F0-9]{32,40}/i', $res['filename'], $matches)) {
|
||||
$namefixer->matchPredbHash($matches[0], $res, 1, 1, true, 1);
|
||||
} else {
|
||||
$db->queryExec(sprintf("UPDATE releases SET dehashstatus = %d - 1 WHERE id = %d", $res['dehashstatus'], $res['releaseid']));
|
||||
echo '.';
|
||||
}
|
||||
}
|
||||
} else if (isset($pieces[1]) && $pieces[0] == 'par2') {
|
||||
$nntp = new NNTP();
|
||||
if ($nntp->doConnect() === false) {
|
||||
exit($c->error("Unable to connect to usenet."));
|
||||
}
|
||||
|
||||
$relID = $pieces[1];
|
||||
$guid = $pieces[2];
|
||||
$groupID = $pieces[3];
|
||||
$nzbcontents = new NZBContents(array('echo' => true, 'nntp' => $nntp, 'nfo' => new Info(), 'db' => $db, 'pp' => new PProcess(['Settings' => $pdo, 'Nfo' => $Nfo, 'NameFixer' => $namefixer])));
|
||||
$res = $nzbcontents->checkPAR2($guid, $relID, $groupID, 1, 1);
|
||||
if ($res === false) {
|
||||
echo '.';
|
||||
}
|
||||
|
||||
$nntp->doQuit();
|
||||
|
||||
} else if (isset($pieces[1]) && $pieces[0] == 'predbft') {
|
||||
$pre = $pieces[1];
|
||||
if ($res = $db->queryOneRow(sprintf('SELECT id AS preid, title, source, searched FROM prehash '
|
||||
. 'WHERE id = %d', $pre
|
||||
)
|
||||
)
|
||||
) {
|
||||
$namefixer->done = $namefixer->matched = false;
|
||||
$ftmatched = $searched = 0;
|
||||
$ftmatched = $namefixer->matchPredbFT($res, 1, 1, true, 1);
|
||||
if ($ftmatched > 0) {
|
||||
$searched = 1;
|
||||
} elseif ($ftmatched < 0) {
|
||||
$searched = -6;
|
||||
echo "*";
|
||||
} else {
|
||||
$searched = $res['searched'] - 1;
|
||||
echo ".";
|
||||
}
|
||||
$db->queryExec(sprintf("UPDATE prehash SET searched = %d WHERE id = %d", $searched, $res['preid']));
|
||||
$namefixer->checked++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
<?php
|
||||
require_once(dirname(__FILE__) . "/config.php");
|
||||
|
||||
use newznab\db\DB;
|
||||
use newznab\processing\PProcess;
|
||||
|
||||
$pdo = new DB();
|
||||
$s = new Sites();
|
||||
$site = $s->get();
|
||||
|
||||
if (!isset($argv[1])) {
|
||||
exit($pdo->log->error("This script is not intended to be run manually, it is called from groupfixrelnames_threaded.py."));
|
||||
} else if (isset($argv[1])) {
|
||||
$namefixer = new \NameFixer(['Settings' => $pdo]);
|
||||
$pieces = explode(' ', $argv[1]);
|
||||
$guidChar = $pieces[1];
|
||||
$maxperrun = $pieces[2];
|
||||
$thread = $pieces[3];
|
||||
|
||||
switch (true) {
|
||||
case $pieces[0] === 'nfo' && isset($guidChar) && isset($maxperrun) && is_numeric($maxperrun):
|
||||
$releases = $pdo->queryDirect(
|
||||
sprintf('
|
||||
SELECT r.id AS releaseid, r.guid, r.groupid, r.categoryid, r.name, r.searchname,
|
||||
uncompress(nfo) AS textstring
|
||||
FROM releases r
|
||||
INNER JOIN releasenfo rn ON r.id = rn.releaseid
|
||||
WHERE r.guid %s
|
||||
AND r.nzbstatus = 1
|
||||
AND r.proc_nfo = 0
|
||||
AND r.nfostatus = 1
|
||||
AND r.prehashid = 0
|
||||
ORDER BY r.postdate DESC
|
||||
LIMIT %s',
|
||||
$pdo->likeString($guidChar, false, true),
|
||||
$maxperrun
|
||||
)
|
||||
);
|
||||
|
||||
if ($releases instanceof Traversable) {
|
||||
foreach ($releases as $release) {
|
||||
if (preg_match('/^=newz\[NZB\]=\w+/', $release['textstring'])) {
|
||||
$namefixer->done = $namefixer->matched = false;
|
||||
$pdo->queryDirect(sprintf('UPDATE releases SET proc_nfo = 1 WHERE id = %d', $release['releaseid']));
|
||||
$namefixer->checked++;
|
||||
echo '.';
|
||||
} else {
|
||||
$namefixer->done = $namefixer->matched = false;
|
||||
if ($namefixer->checkName($release, true, 'NFO, ', 1, 1) !== true) {
|
||||
echo '.';
|
||||
}
|
||||
$namefixer->checked++;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case $pieces[0] === 'filename' && isset($guidChar) && isset($maxperrun) && is_numeric($maxperrun):
|
||||
$releases = $pdo->queryDirect(
|
||||
sprintf('
|
||||
SELECT rf.name AS textstring, rf.releaseid AS fileid,
|
||||
r.id AS releaseid, r.name, r.searchname, r.categoryid, r.groupid
|
||||
FROM releases r
|
||||
INNER JOIN releasefiles rf ON r.id = rf.releaseid
|
||||
WHERE r.guid %s
|
||||
AND r.nzbstatus = 1 AND r.proc_files = 0
|
||||
AND r.prehashid = 0
|
||||
ORDER BY r.postdate ASC
|
||||
LIMIT %s',
|
||||
$pdo->likeString($guidChar, false, true),
|
||||
$maxperrun
|
||||
)
|
||||
);
|
||||
|
||||
if ($releases instanceof Traversable) {
|
||||
foreach ($releases as $release) {
|
||||
$namefixer->done = $namefixer->matched = false;
|
||||
if ($namefixer->checkName($release, true, 'Filenames, ', 1, 1) !== true) {
|
||||
echo '.';
|
||||
}
|
||||
$namefixer->checked++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case $pieces[0] === 'md5' && isset($guidChar) && isset($maxperrun) && is_numeric($maxperrun):
|
||||
$releases = $pdo->queryDirect(
|
||||
sprintf('
|
||||
SELECT DISTINCT r.id AS releaseid, r.name, r.searchname, r.categoryid, r.groupid, r.dehashstatus,
|
||||
rf.name AS filename
|
||||
FROM releases r
|
||||
LEFT OUTER JOIN releasefiles rf ON r.id = rf.releaseid AND rf.ishashed = 1
|
||||
WHERE r.guid %s
|
||||
AND nzbstatus = 1 AND r.ishashed = 1
|
||||
AND r.dehashstatus BETWEEN -6 AND 0
|
||||
AND r.prehashid = 0
|
||||
ORDER BY r.dehashstatus DESC, r.postdate ASC
|
||||
LIMIT %s',
|
||||
$pdo->likeString($guidChar, false, true),
|
||||
$maxperrun
|
||||
)
|
||||
);
|
||||
|
||||
if ($releases instanceof Traversable) {
|
||||
foreach ($releases as $release) {
|
||||
if (preg_match('/[a-fA-F0-9]{32,40}/i', $release['name'], $matches)) {
|
||||
$namefixer->matchPredbHash($matches[0], $release, 1, 1, true, 1);
|
||||
} else if (preg_match('/[a-fA-F0-9]{32,40}/i', $release['filename'], $matches)) {
|
||||
$namefixer->matchPredbHash($matches[0], $release, 1, 1, true, 1);
|
||||
} else {
|
||||
$pdo->queryExec(sprintf("UPDATE releases SET dehashstatus = %d - 1 WHERE id = %d", $release['dehashstatus'], $release['releaseid']));
|
||||
echo '.';
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case $pieces[0] === 'par2' && isset($guidChar) && isset($maxperrun) && is_numeric($maxperrun):
|
||||
$releases = $pdo->queryDirect(
|
||||
sprintf('
|
||||
SELECT r.id AS releaseid, r.guid, r.groupid
|
||||
FROM releases r
|
||||
WHERE r.guid %s
|
||||
AND r.nzbstatus = 1
|
||||
AND r.proc_par2 = 0
|
||||
AND r.prehashid = 0
|
||||
ORDER BY r.postdate ASC
|
||||
LIMIT %s',
|
||||
$pdo->likeString($guidChar, false, true),
|
||||
$maxperrun
|
||||
)
|
||||
);
|
||||
|
||||
if ($releases instanceof Traversable) {
|
||||
$nntp = new NNTP(['Settings' => $pdo]);
|
||||
if (($site->alternate_nntp == '1' ? $nntp->doConnect(true, true) : $nntp->doConnect()) !== true) {
|
||||
exit($pdo->log->error("Unable to connect to usenet."));
|
||||
}
|
||||
|
||||
$Nfo = new Info(['Settings' => $pdo, 'Echo' => true]);
|
||||
$nzbcontents = new NZBContents(
|
||||
array(
|
||||
'Echo' => true, 'NNTP' => $nntp, 'Nfo' => $Nfo, 'Settings' => $pdo,
|
||||
'PostProcess' => new PProcess(['Settings' => $pdo, 'Nfo' => $Nfo, 'NameFixer' => $namefixer])
|
||||
)
|
||||
);
|
||||
foreach ($releases as $release) {
|
||||
$res = $nzbcontents->checkPAR2($release['guid'], $release['releaseid'], $release['groupid'], 1, 1);
|
||||
if ($res === false) {
|
||||
echo '.';
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case $pieces[0] === 'miscsorter' && isset($guidChar) && isset($maxperrun) && is_numeric($maxperrun):
|
||||
$releases = $pdo->queryDirect(
|
||||
sprintf('
|
||||
SELECT r.id AS releaseid
|
||||
FROM releases r
|
||||
WHERE r.guid %s
|
||||
AND r.nzbstatus = 1 AND r.nfostatus = 1
|
||||
AND r.proc_sorter = 0 AND r.isrenamed = 0
|
||||
AND r.prehashid = 0
|
||||
ORDER BY r.postdate DESC
|
||||
LIMIT %s',
|
||||
$pdo->likeString($guidChar, false, true),
|
||||
$maxperrun
|
||||
)
|
||||
);
|
||||
|
||||
if ($releases instanceof Traversable) {
|
||||
$sorter = new MiscSorter(true, $pdo);
|
||||
foreach ($releases as $release) {
|
||||
$res = $sorter->nfosorter(null, $release['releaseid']);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case $pieces[0] === 'predbft' && isset($maxperrun) && is_numeric($maxperrun) && isset($thread) && is_numeric($thread):
|
||||
$pres = $pdo->queryDirect(
|
||||
sprintf('
|
||||
SELECT p.id AS prehashid, p.title, p.source, p.searched
|
||||
FROM prehash p
|
||||
WHERE LENGTH(title) >= 15 AND title NOT REGEXP "[\"\<\> ]"
|
||||
AND searched = 0
|
||||
AND DATEDIFF(NOW(), predate) > 1
|
||||
ORDER BY predate ASC
|
||||
LIMIT %s
|
||||
OFFSET %s',
|
||||
$maxperrun,
|
||||
$thread * $maxperrun - $maxperrun
|
||||
)
|
||||
);
|
||||
|
||||
if ($pres instanceof Traversable) {
|
||||
foreach ($pres as $pre) {
|
||||
$namefixer->done = $namefixer->matched = false;
|
||||
$ftmatched = $searched = 0;
|
||||
$ftmatched = $namefixer->matchPredbFT($pre, 1, 1, true, 1);
|
||||
if ($ftmatched > 0) {
|
||||
$searched = 1;
|
||||
} elseif ($ftmatched < 0) {
|
||||
$searched = -6;
|
||||
echo "*";
|
||||
} else {
|
||||
$searched = $pre['searched'] - 1;
|
||||
echo ".";
|
||||
}
|
||||
$pdo->queryExec(sprintf("UPDATE prehash SET searched = %d WHERE id = %d", $searched, $pre['prehashid']));
|
||||
$namefixer->checked++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
require_once(dirname(__FILE__) . '/config.php');
|
||||
|
||||
use newznab\db\DB;
|
||||
use newznab\processing\PProcess;
|
||||
|
||||
$pdo = new DB();
|
||||
$s = new Sites();
|
||||
$site = $s->get();
|
||||
/**
|
||||
Array with possible arguments for run and
|
||||
whether or not those methods of operation require NNTP
|
||||
**/
|
||||
|
||||
$args = array(
|
||||
'additional' => true,
|
||||
'all' => true,
|
||||
'allinf' => true,
|
||||
'amazon' => false,
|
||||
'anime' => false,
|
||||
'book' => false,
|
||||
'console' => false,
|
||||
'games' => false,
|
||||
'movies' => false,
|
||||
'music' => false,
|
||||
'nfo' => true,
|
||||
'pre' => true,
|
||||
'sharing' => true,
|
||||
'spotnab' => true,
|
||||
'tv' => false,
|
||||
'tvdb' => false,
|
||||
'xxx' => false,
|
||||
);
|
||||
|
||||
$bool = array(
|
||||
'true',
|
||||
'false'
|
||||
);
|
||||
|
||||
if (!isset($argv[1]) || !in_array($argv[1], $args) || !isset($argv[2]) || !in_array($argv[2], $bool)) {
|
||||
exit(
|
||||
$pdo->log->error(
|
||||
"\nIncorrect arguments.\n"
|
||||
. "The second argument (true/false) determines wether to echo or not.\n\n"
|
||||
. "php postprocess.php all true ...: Does all the types of post processing.\n"
|
||||
. "php postprocess.php pre true ...: Processes all Predb sites.\n"
|
||||
. "php postprocess.php nfo true ...: Processes NFO files.\n"
|
||||
. "php postprocess.php movies true ...: Processes movies.\n"
|
||||
. "php postprocess.php music true ...: Processes music.\n"
|
||||
. "php postprocess.php console true ...: Processes console games.\n"
|
||||
. "php postprocess.php games true ...: Processes games.\n"
|
||||
. "php postprocess.php book true ...: Processes books.\n"
|
||||
. "php postprocess.php anime true ...: Processes anime.\n"
|
||||
. "php postprocess.php tv true ...: Processes tv.\n"
|
||||
. "php postprocess.php tvdb true ...: Processes tvdb.\n"
|
||||
. "php postprocess.php xxx true ...: Processes xxx.\n"
|
||||
. "php postprocess.php additional true ...: Processes previews/mediainfo/etc...\n"
|
||||
. "php postprocess.php sharing true ...: Processes uploading/downloading comments.\n"
|
||||
. "php postprocess.php spotnab true ...: Processes uploading/downloading comments from spotnab.\n"
|
||||
. "php postprocess.php allinf true ...: Does all the types of post processing on a loop, sleeping 15 seconds between.\n"
|
||||
. "php postprocess.php amazon true ...: Does all the amazon (books/console/games/music/xxx).\n"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$nntp = null;
|
||||
if ($args[$argv[1]] === true) {
|
||||
$nntp = new NNTP(['Settings' => $pdo]);
|
||||
if (($site->alternate_nntp == 1 ? $nntp->doConnect(true, true) : $nntp->doConnect()) !== true) {
|
||||
exit($pdo->log->error("Unable to connect to usenet." . PHP_EOL));
|
||||
}
|
||||
}
|
||||
|
||||
$postProcess = new PProcess(['Settings' => $pdo, 'Echo' => ($argv[2] === 'true' ? true : false)]);
|
||||
|
||||
$charArray = ['a','b','c','d','e','f','0','1','2','3','4','5','6','7','8','9'];
|
||||
|
||||
switch ($argv[1]) {
|
||||
|
||||
case 'all':
|
||||
$postProcess->processAll($nntp);
|
||||
break;
|
||||
case 'allinf':
|
||||
$i = 1;
|
||||
while ($i = 1) {
|
||||
$postProcess->processAll($nntp);
|
||||
sleep(15);
|
||||
}
|
||||
break;
|
||||
case 'additional':
|
||||
$postProcess->processAdditional($nntp, '', (isset($argv[3]) && in_array($argv[3], $charArray) ? $argv[3] : ''));
|
||||
break;
|
||||
case 'amazon':
|
||||
$postProcess->processBooks();
|
||||
$postProcess->processConsoles();
|
||||
$postProcess->processGames();
|
||||
$postProcess->processMusic();
|
||||
$postProcess->processXXX();
|
||||
break;
|
||||
case 'anime':
|
||||
$postProcess->processAnime();
|
||||
break;
|
||||
case 'book':
|
||||
$postProcess->processBooks();
|
||||
break;
|
||||
case 'console':
|
||||
$postProcess->processConsoles();
|
||||
break;
|
||||
case 'games':
|
||||
$postProcess->processGames();
|
||||
break;
|
||||
case 'nfo':
|
||||
$postProcess->processNfos($nntp, '', (isset($argv[3]) && in_array($argv[3], $charArray) ? $argv[3] : ''));
|
||||
break;
|
||||
case 'movies':
|
||||
$postProcess->processMovies('', (isset($argv[3]) && in_array($argv[3], $charArray) ? $argv[3] : ''));
|
||||
break;
|
||||
case 'music':
|
||||
$postProcess->processMusic();
|
||||
break;
|
||||
case 'pre':
|
||||
break;
|
||||
case 'sharing':
|
||||
$postProcess->processSharing($nntp);
|
||||
break;
|
||||
case 'spotnab':
|
||||
$postProcess->processSpotnab();
|
||||
break;
|
||||
case 'tv':
|
||||
$postProcess->processTV('', (isset($argv[3]) && in_array($argv[3], $charArray) ? $argv[3] : ''));
|
||||
break;
|
||||
case 'tvdb':
|
||||
$postProcess->processTvDB();
|
||||
break;
|
||||
case 'xxx':
|
||||
$postProcess->processXXX();
|
||||
break;
|
||||
default:
|
||||
exit;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
require_once(dirname(__FILE__) . '/config.php');
|
||||
|
||||
use newznab\processing\PProcess;
|
||||
|
||||
|
||||
$c = new ColorCLI();
|
||||
if (!isset($argv[1])) {
|
||||
exit($c->error("This script is not intended to be run manually, it is called from postprocess_threaded.py."));
|
||||
}
|
||||
|
||||
|
||||
$tmux = new Tmux;
|
||||
$torun = $tmux->get()->post;
|
||||
|
||||
$pieces = explode(' =+= ', $argv[1]);
|
||||
|
||||
$postprocess = new PProcess(['Echo' => true]);
|
||||
if (isset($pieces[6])) {
|
||||
// Create the connection here and pass
|
||||
$nntp = new NNTP();
|
||||
if ($nntp->doConnect() === false) {
|
||||
exit($c->error("Unable to connect to usenet."));
|
||||
}
|
||||
|
||||
$postprocess->processAdditional($nntp, $argv[1]);
|
||||
$nntp->doQuit();
|
||||
} else if (isset($pieces[3])) {
|
||||
// Create the connection here and pass
|
||||
$nntp = new NNTP();
|
||||
if ($nntp->doConnect() === false) {
|
||||
exit($c->error("Unable to connect to usenet."));
|
||||
}
|
||||
|
||||
$postprocess->processNfos($argv[1], $nntp);
|
||||
$nntp->doQuit();
|
||||
|
||||
} else if (isset($pieces[2])) {
|
||||
$postprocess->processMovies($argv[1]);
|
||||
echo '.';
|
||||
} else if (isset($pieces[1])) {
|
||||
$postprocess->processTv($argv[1]);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
//This script is ported from nZEDb and adapted for newznab
|
||||
require_once('config.php');
|
||||
|
||||
// This script is simply so I can show sleep progress in bash script
|
||||
$consoletools = new ConsoleTools();
|
||||
if (isset($argv[1]) && is_numeric($argv[1]))
|
||||
{
|
||||
$consoletools->showsleep($argv[1]);
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
require_once(dirname(__FILE__) . "/config.php");
|
||||
|
||||
|
||||
$time = TIME();
|
||||
$c = new ColorCLI();
|
||||
|
||||
if (isset($argv[1])) {
|
||||
$group = $argv[1];
|
||||
echo $c->header("Updating group {$group}");
|
||||
|
||||
$g = new Groups;
|
||||
$group = $g->getByName($group);
|
||||
|
||||
$bin = new Binaries;
|
||||
$bin->updateGroup($group);
|
||||
} else {
|
||||
$binaries = new Binaries;
|
||||
$binaries->updateAllGroups();
|
||||
}
|
||||
|
||||
function relativeTime($_time)
|
||||
{
|
||||
$d = array();
|
||||
$d[0] = array(1, "sec");
|
||||
$d[1] = array(60, "min");
|
||||
$d[2] = array(3600, "hr");
|
||||
$d[3] = array(86400, "day");
|
||||
$d[4] = array(31104000, "yr");
|
||||
|
||||
$w = array();
|
||||
|
||||
$return = "";
|
||||
$now = TIME();
|
||||
$diff = ($now - $_time);
|
||||
$secondsLeft = $diff;
|
||||
|
||||
for ($i = 4; $i > -1; $i--) {
|
||||
$w[$i] = intval($secondsLeft / $d[$i][0]);
|
||||
$secondsLeft -= ($w[$i] * $d[$i][0]);
|
||||
if ($w[$i] != 0) {
|
||||
//$return.= abs($w[$i]). " " . $d[$i][1] . (($w[$i]>1)?'s':'') ." ";
|
||||
$return .= $w[$i] . " " . $d[$i][1] . (($w[$i] > 1) ? 's' : '') . " ";
|
||||
}
|
||||
}
|
||||
|
||||
//$return .= ($diff>0)?"ago":"left";
|
||||
return $return;
|
||||
}
|
||||
|
||||
echo $c->header("Group update process completed in: " . relativeTime($time) . "\n");
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
require_once(dirname(__FILE__) . '/config.php');
|
||||
|
||||
use newznab\db\DB;
|
||||
|
||||
|
||||
$start = TIME();
|
||||
$pdo = new DB();
|
||||
$consoleTools = new \ConsoleTools(['ColorCLI' => $pdo->log]);
|
||||
|
||||
// Create the connection here and pass
|
||||
$nntp = new \NNTP(['Settings' => $pdo]);
|
||||
if ($nntp->doConnect() !== true) {
|
||||
exit($pdo->log->error("Unable to connect to usenet."));
|
||||
}
|
||||
|
||||
echo $pdo->log->header("Getting first/last for all your active groups.");
|
||||
$data = $nntp->getGroups();
|
||||
if ($nntp->isError($data)) {
|
||||
exit($pdo->log->error("Failed to getGroups() from nntp server."));
|
||||
}
|
||||
|
||||
echo $pdo->log->header("Inserting new values into shortgroups table.");
|
||||
|
||||
$pdo->queryExec('TRUNCATE TABLE shortgroups');
|
||||
|
||||
// Put into an array all active groups
|
||||
$res = $pdo->query('SELECT name FROM groups WHERE active = 1 OR backfill = 1');
|
||||
|
||||
foreach ($data as $newgroup) {
|
||||
if (myInArray($res, $newgroup['group'], 'name')) {
|
||||
$pdo->queryInsert(sprintf('INSERT INTO shortgroups (name, first_record, last_record, updated) VALUES (%s, %s, %s, NOW())', $pdo->escapeString($newgroup['group']), $pdo->escapeString($newgroup['first']), $pdo->escapeString($newgroup['last'])));
|
||||
echo $pdo->log->primary('Updated ' . $newgroup['group']);
|
||||
}
|
||||
}
|
||||
echo $pdo->log->header('Running time: ' . $consoleTools->convertTimer(TIME() - $start));
|
||||
|
||||
function myInArray($array, $value, $key)
|
||||
{
|
||||
//loop through the array
|
||||
foreach ($array as $val) {
|
||||
//if $val is an array cal myInArray again with $val as array input
|
||||
if (is_array($val)) {
|
||||
if (myInArray($val, $value, $key)) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
//else check if the given key has $value as value
|
||||
if ($array[$key] == $value) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
require_once("config.php");
|
||||
|
||||
use newznab\db\DB;
|
||||
|
||||
|
||||
|
||||
$s = new \Sites();
|
||||
$site = $s->get();
|
||||
$pdo = new DB();
|
||||
|
||||
if (isset($argv[2]) && $argv[2] === 'true') {
|
||||
// Create the connection here and pass
|
||||
$nntp = new \NNTP(['Settings' => $pdo]);
|
||||
if ($nntp->doConnect() !== true) {
|
||||
exit($pdo->log->error("Unable to connect to usenet."));
|
||||
}
|
||||
}
|
||||
if ($site->tablepergroup === 1) {
|
||||
exit($pdo->log->error("You are using 'tablepergroup', you must use .../misc/update_scripts/nix_scripts/multiprocessing/releases.php"));
|
||||
}
|
||||
|
||||
$groupName = isset($argv[3]) ? $argv[3] : '';
|
||||
if (isset($argv[1]) && isset($argv[2])) {
|
||||
$consoletools = new \ConsoleTools(['ColorCLI' => $pdo->log]);
|
||||
$releases = new Releases(['Settings' => $pdo, 'ConsoleTools' => $consoletools]);
|
||||
if ($argv[1] == 1 && $argv[2] == 'true') {
|
||||
$releases->processReleases(1, 1, $groupName, $nntp, true);
|
||||
} else if ($argv[1] == 1 && $argv[2] == 'false') {
|
||||
$releases->processReleases(1, 2, $groupName, $nntp, true);
|
||||
} else if ($argv[1] == 2 && $argv[2] == 'true') {
|
||||
$releases->processReleases(2, 1, $groupName, $nntp, true);
|
||||
} else if ($argv[1] == 2 && $argv[2] == 'false') {
|
||||
$releases->processReleases(2, 2, $groupName, $nntp, true);
|
||||
} else if ($argv[1] == 4 && ($argv[2] == 'true' || $argv[2] == 'false')) {
|
||||
echo $pdo->log->header("Moving all releases to other -> misc, this can take a while, be patient.");
|
||||
$releases->resetCategorize();
|
||||
} else if ($argv[1] == 5 && ($argv[2] == 'true' || $argv[2] == 'false')) {
|
||||
echo $pdo->log->header("Categorizing all non-categorized releases in other->misc using usenet subject. This can take a while, be patient.");
|
||||
$timestart = TIME();
|
||||
$relcount = $releases->categorizeRelease('name', 'WHERE iscategorized = 0 AND categoryid = 8010');
|
||||
$time = $consoletools->convertTime(TIME() - $timestart);
|
||||
echo $pdo->log->primary("\n" . 'Finished categorizing ' . $relcount . ' releases in ' . $time . " seconds, using the usenet subject.");
|
||||
} else if ($argv[1] == 6 && $argv[2] == 'true') {
|
||||
echo $pdo->log->header("Categorizing releases in all sections using the searchname. This can take a while, be patient.");
|
||||
$timestart = TIME();
|
||||
$relcount = $releases->categorizeRelease('searchname', '');
|
||||
$consoletools = new \ConsoleTools(['ColorCLI' => $pdo->log]);
|
||||
$time = $consoletools->convertTime(TIME() - $timestart);
|
||||
echo $pdo->log->primary("\n" . 'Finished categorizing ' . $relcount . ' releases in ' . $time . " seconds, using the search name.");
|
||||
} else if ($argv[1] == 6 && $argv[2] == 'false') {
|
||||
echo $pdo->log->header("Categorizing releases in misc sections using the searchname. This can take a while, be patient.");
|
||||
$timestart = TIME();
|
||||
$relcount = $releases->categorizeRelease('searchname', 'WHERE categoryid IN (1090, 2020, 3050, 5050, 6050, 8010)');
|
||||
$consoletools = new \ConsoleTools(['ColorCLI' => $pdo->log]);
|
||||
$time = $consoletools->convertTime(TIME() - $timestart);
|
||||
echo $pdo->log->primary("\n" . 'Finished categorizing ' . $relcount . ' releases in ' . $time . " seconds, using the search name.");
|
||||
} else {
|
||||
exit($pdo->log->error("Wrong argument, type php update_releases.php to see a list of valid arguments."));
|
||||
}
|
||||
} else {
|
||||
exit($pdo->log->error("\nWrong set of arguments.\n"
|
||||
. "php update_releases.php 1 true ...: Creates releases and attempts to categorize new releases\n"
|
||||
. "php update_releases.php 2 true ...: Creates releases and leaves new releases in other -> misc\n"
|
||||
. "\nYou must pass a second argument whether to post process or not, true or false\n"
|
||||
. "You can pass a third optional argument, a group name (ex.: alt.binaries.multimedia).\n"
|
||||
. "\nExtra commands::\n"
|
||||
. "php update_releases.php 4 true ...: Puts all releases in other-> misc (also resets to look like they have never been categorized)\n"
|
||||
. "php update_releases.php 5 true ...: Categorizes all releases in other-> misc (which have not been categorized already)\n"
|
||||
. "php update_releases.php 6 false ...: Categorizes releases in misc sections using the search name\n"
|
||||
. "php update_releases.php 6 true ...: Categorizes releases in all sections using the search name\n"));
|
||||
}
|
||||
Reference in New Issue
Block a user