Added Enzebe.php for nzb managment, new columns to releases table (nzb_guid and nzbstatus)

This commit is contained in:
Darko
2014-04-28 14:01:05 +02:00
parent 83cad3eff5
commit 330c62c5f3
8 changed files with 426 additions and 151 deletions
+35 -32
View File
@@ -2,30 +2,33 @@ ALTER TABLE `predb`
ADD `md5` VARCHAR( 32 ) NULL,
ADD INDEX (`md5`);
ALTER TABLE `releases`
ADD `dehashstatus` TINYINT( 1 ) NOT NULL DEFAULT 0,
ADD `nfostatus` TINYINT NOT NULL DEFAULT 0,
ADD `jpgstatus` TINYINT(1) NOT NULL DEFAULT 0,
ADD `audiostatus` TINYINT(1) NOT NULL DEFAULT 0,
ADD `videostatus` TINYINT(1) NOT NULL DEFAULT 0,
ADD `reqidstatus` TINYINT(1) NOT NULL DEFAULT 0,
ADD `prehashID` INT UNSIGNED NOT NULL DEFAULT 0,
ADD `iscategorized` BIT NOT NULL DEFAULT 0,
ADD `isrenamed` BIT NOT NULL DEFAULT 0,
ADD `ishashed` BIT NOT NULL DEFAULT 0,
ADD `isrequestid` BIT NOT NULL DEFAULT 0,
ADD `proc_pp` TINYINT(1) NOT NULL DEFAULT 0,
ADD `proc_par2` BIT NOT NULL DEFAULT 0,
ADD `proc_nfo` BIT NOT NULL DEFAULT 0,
ADD `proc_files` BIT NOT NULL DEFAULT 0,
ADD INDEX `ix_releases_nfostatus` (`nfostatus` ASC) USING HASH,
ADD INDEX `ix_releases_reqidstatus` (`reqidstatus` ASC) USING HASH,
ADD INDEX `ix_releases_passwordstatus` (`passwordstatus`),
ADD INDEX `ix_releases_releasenfoID` (`releasenfoID`),
ADD INDEX `ix_releases_dehashstatus` (`dehashstatus`),
ADD INDEX `ix_releases_haspreview` (`haspreview` ASC) USING HASH,
ADD INDEX `ix_releases_postdate_name` (`postdate`, `name`),
ADD INDEX `ix_releases_status` (`iscategorized`, `isrenamed`, `nfostatus`, `ishashed`, `passwordstatus`, `dehashstatus`, `releasenfoID`, `musicinfoID`, `consoleinfoID`, `bookinfoID`, `haspreview`, `categoryID`, `imdbID`, `rageID`),
ADD INDEX `ix_releases_prehashid_searchname` (`prehashID`, `searchname`);
ADD `dehashstatus` TINYINT( 1 ) NOT NULL DEFAULT 0,
ADD `nfostatus` TINYINT NOT NULL DEFAULT 0,
ADD `jpgstatus` TINYINT(1) NOT NULL DEFAULT 0,
ADD `audiostatus` TINYINT(1) NOT NULL DEFAULT 0,
ADD `videostatus` TINYINT(1) NOT NULL DEFAULT 0,
ADD `reqidstatus` TINYINT(1) NOT NULL DEFAULT 0,
ADD `prehashID` INT UNSIGNED NOT NULL DEFAULT 0,
ADD `iscategorized` BIT NOT NULL DEFAULT 0,
ADD `isrenamed` BIT NOT NULL DEFAULT 0,
ADD `ishashed` BIT NOT NULL DEFAULT 0,
ADD `isrequestid` BIT NOT NULL DEFAULT 0,
ADD `proc_pp` TINYINT(1) NOT NULL DEFAULT 0,
ADD `proc_par2` BIT NOT NULL DEFAULT 0,
ADD `proc_nfo` BIT NOT NULL DEFAULT 0,
ADD `proc_files` BIT NOT NULL DEFAULT 0,
ADD `nzb_guid` VARCHAR(50) NULL,
ADD `nzbstatus` TINYINT(1) NOT NULL DEFAULT 0,
ADD INDEX `ix_releases_nfostatus` (`nfostatus` ASC) USING HASH,
ADD INDEX `ix_releases_reqidstatus` (`reqidstatus` ASC) USING HASH,
ADD INDEX `ix_releases_passwordstatus` (`passwordstatus`),
ADD INDEX `ix_releases_releasenfoID` (`releasenfoID`),
ADD INDEX `ix_releases_dehashstatus` (`dehashstatus`),
ADD INDEX `ix_releases_haspreview` (`haspreview` ASC) USING HASH,
ADD INDEX `ix_releases_postdate_name` (`postdate`, `name`),
ADD INDEX `ix_releases_status` (`nzbstatus`, `iscategorized`, `isrenamed`, `nfostatus`, `ishashed`, `passwordstatus`, `dehashstatus`, `releasenfoID`, `musicinfoID`, `consoleinfoID`, `bookinfoID`, `haspreview`, `categoryID`, `imdbID`, `rageID`),
ADD INDEX `ix_releases_nzb_guid` (`nzb_guid`),
ADD INDEX `ix_releases_prehashid_searchname` (`prehashID`, `searchname`);
DROP TABLE IF EXISTS prehash;
CREATE TABLE prehash (
@@ -36,9 +39,9 @@ CREATE TABLE prehash (
category VARCHAR(255) NULL,
predate DATETIME DEFAULT NULL,
source VARCHAR(50) NOT NULL DEFAULT '',
md5 VARCHAR(32) NOT NULL DEFAULT '',
sha1 VARCHAR(40) NOT NULL DEFAULT '',
requestID INT(10) UNSIGNED NOT NULL DEFAULT '0',
md5 VARCHAR(32) NOT NULL DEFAULT '',
sha1 VARCHAR(40) NOT NULL DEFAULT '',
requestID INT(10) UNSIGNED NOT NULL DEFAULT '0',
groupID INT(10) UNSIGNED NOT NULL DEFAULT '0',
nuked TINYINT(1) NOT NULL DEFAULT '0',
nukereason VARCHAR(255) NULL,
@@ -118,8 +121,8 @@ INSERT INTO tmux (setting, value) values ('defrag_cache','900'),
('backfill_order','2'),
('backfill_days', '1'),
('post_amazon', '0'),
('amazonsleep', 1000),
('post_non', '0'),
('amazonsleep', 1000),
('post_non', '0'),
('post_timer_amazon', '30'),
('post_timer_non', '30'),
('colors_start', '1'),
@@ -132,8 +135,8 @@ INSERT INTO tmux (setting, value) values ('defrag_cache','900'),
('fix_crap_opt', 'Disabled'),
('showprocesslist', '0'),
('processupdate', '2'),
('maxaddprocessed', 25),
('maxnfoprocessed', 100),
('maxaddprocessed', 25),
('maxnfoprocessed', 100),
('maxrageprocessed', 75),
('maximdbprocessed', 100),
('maxanidbprocessed', 100),
@@ -194,7 +197,7 @@ INSERT INTO tmux (setting, value) values ('defrag_cache','900'),
('ffmpeg_duration', '5'),
('ffmpeg_image_time', '5'),
('processvideos', '0'),
('sqlpatch', '28');
('sqlpatch', '29');
DROP TABLE IF EXISTS country;
CREATE TABLE country (
@@ -0,0 +1,11 @@
ALTER TABLE `releases` ADD COLUMN `nzbstatus` TINYINT(1) NOT NULL DEFAULT 0;
ALTER TABLE `releases` ADD COLUMN `nzb_guid` VARCHAR(50) NULL;
ALTER TABLE `releases` DROP INDEX `ix_releases_status`;
ALTER TABLE `releases` ADD INDEX `ix_releases_status` (`nzbstatus`, `iscategorized`, `isrenamed`, `nfostatus`, `ishashed`, `passwordstatus`, `dehashstatus`, `releasenfoID`, `musicinfoID`, `consoleinfoID`, `bookinfoID`, `haspreview`, `categoryID`, `imdbID`, `rageID`);
CREATE INDEX `ix_releases_nzb_guid` ON `releases` (`nzb_guid`);
UPDATE `releases` SET nzbstatus = 1 WHERE nzbstatus = 0;
UPDATE `tmux` set `value` = '29' where `setting` = 'sqlpatch';
+354
View File
@@ -0,0 +1,354 @@
<?php
require_once(dirname(__FILE__) . "/../bin/config.php");
require_once(WWW_DIR."/lib/framework/db.php");
require_once(WWW_DIR."/lib/site.php");
require_once(WWW_DIR."/lib/category.php");
/**
* Class for reading and writing NZB files on the hard disk,
* building folder paths to store the NZB files.
*/
class Enzebe
{
/**
* Instance of class site.
* @var object
* @access private
*/
private $s;
/**
* Site settings.
* @var object
* @access private
*/
private $site;
/**
* Determines if the site setting table per group is enabled.
* @var int
* @access private
*/
private $tablePerGroup;
/**
* Group ID when writing NZBs.
* @var int
* @access protected
*/
protected $groupID;
/**
* Instance of class db.
* @var nzedb\db\DB
* @access protected
*/
protected $db;
/**
* Date when writing NZBs.
* @var string
* @access protected
*/
protected $writeDate;
/*
* Table names for TPG.
*/
protected $bname;
protected $pname;
const NZB_NONE = 0; // Release has no NZB file yet.
const NZB_ADDED = 1; // Release had an NZB file created.
/**
* Default constructor.
*
* @access public
*/
public function __construct()
{
$this->s = new Sites();
$this->site = $this->s->get();
}
/**
* Initiate class vars when writing NZB's.
*
* @param string $date
* @param int $groupID
*
* @access public
*/
public function initiateForWrite($db, $date, $groupID)
{
$this->db = $db;
$this->writeDate = $date;
$this->groupID = $groupID;
$this->bname = 'binaries';
$this->pname = 'parts';
}
/**
* Clean up class vars when done writing NZB's.
*
* @access public
*/
public function cleanForWrite()
{
$this->writeDate = null;
$this->groupID = null;
}
/**
* Write an NZB to the hard drive for a single release.
*
* @param int $relID The ID of the release in the DB.
* @param string $relGuid The guid of the release.
* @param string $name The name of the release.
* @param string $cTitle The name of the category this release is in.
*
* @return bool Have we successfully written the NZB to the hard drive?
*
* @access public
*/
public function writeNZBforReleaseId($relID, $relGuid, $name, $cTitle)
{
$path = $this->getNZBPath($relGuid, true);
$fp = gzopen($path, 'w5');
if ($fp) {
$nzb_guid = '';
gzwrite($fp,
'<?xml version="1.0" encoding="UTF-8"?>' .
"\n" .
'<!DOCTYPE nzb PUBLIC "-//newzBin//DTD NZB 1.1//EN" "http://www.newzbin.com/DTD/nzb/nzb-1.1.dtd">' .
"\n" .
'<!-- NZB Generated by: newznab ' . $site->version() . ' ' . $this->writeDate . ' -->' .
"\n" .
"<nzb xmlns=\"http://www.newzbin.com/DTD/2003/nzb\">\n<head>\n <meta type=\"category\">" .
htmlspecialchars($cTitle, ENT_QUOTES, 'utf-8') .
"</meta>\n <meta type=\"name\">" .
htmlspecialchars($name, ENT_QUOTES, 'utf-8') .
"</meta>\n</head>\n\n"
);
$result =
$this->db->query(
sprintf('
SELECT binaries.*,
UNIX_TIMESTAMP(date) AS udate,
groups.name as groupname FROM binaries
INNER JOIN groups on binaries.groupID = groups.ID
WHERE binaries.releaseID = %d
ORDER BY binaries.name', $relID
)
);
foreach ($result as $binRow) {
$unixDate = strtotime($binRow['udate']);
$poster = htmlspecialchars($binRow['fromname'], ENT_QUOTES, 'utf-8');
$result2 = $this->db->query(
sprintf(
'SELECT ID, name, totalparts FROM %s WHERE releaseID = %d ORDER BY name',
$this->bname,
$binRow['ID']
)
);
foreach ($result2 as $binRow2) {
gzwrite($fp,
'<file poster="' . $poster .
'" date="' . $unixDate .
'" subject="' .
htmlspecialchars($binRow2['name'], ENT_QUOTES, 'utf-8') .
' (1/' . $binRow2['totalparts'] .
")\">\n <groups>\n <group>" . $binRow['groupname'] .
"</group>\n </groups>\n <segments>\n"
);
$resParts = $this->db->query(
sprintf('
SELECT DISTINCT(messageID), size, partnumber FROM %s WHERE binaryID = %d ORDER BY partnumber',
$this->pname,
$binRow2['ID']
)
);
foreach ($resParts as $partsRow) {
if ($nzb_guid === '') {
$nzb_guid = $partsRow['messageID'];
}
gzwrite($fp, ' <segment bytes="' . $partsRow['size']
. '" number="' . $partsRow['partnumber'] . '">'
. htmlspecialchars($partsRow['messageID'], ENT_QUOTES, 'utf-8')
. "</segment>\n"
);
}
gzwrite($fp, " </segments>\n</file>\n");
}
}
gzwrite($fp, '</nzb>');
gzclose($fp);
if (is_file($path)) {
$this->db->queryExec(
sprintf('
UPDATE releases SET nzbstatus = %d %s WHERE ID = %d',
NZB::NZB_ADDED,
($nzb_guid === '' ? '' : ', nzb_guid = ' . $this->db->escapestring(md5($nzb_guid))),
$relID
)
);
// Chmod to fix issues some users have with file permissions.
chmod($path, 0777);
return true;
} else {
echo "ERROR: $path does not exist.\n";
}
}
return false;
}
/**
* Build a folder path on the hard drive where the NZB file will be stored.
*
* @param string $releaseGuid The guid of the release.
* @param bool $createIfNotExist Create the folder if it doesn't exist.
*
* @return string $nzbpath The path to store the NZB file.
*
* @access public
*/
private function buildNZBPath($releaseGuid, $createIfNotExist)
{
$siteNzbPath = $this->site->nzbpath;
$nzbPath .= substr($releaseGuid, 0, 1) ."/";
$nzbPath = $siteNzbPath . $nzbPath;
if ($createIfNotExist && !is_dir($nzbPath)) {
mkdir($nzbPath, 0777, true);
}
return $nzbPath;
}
/**
* Retrieve path + filename of the NZB to be stored.
*
* @param string $releaseGuid The guid of the release.
* @param bool $createIfNotExist Create the folder if it doesn't exist. (optional)
*
* @return string Path+filename.
*
* @access public
*/
public function getNZBPath($releaseGuid, $createIfNotExist = false)
{
return ($this->buildNZBPath($releaseGuid, $createIfNotExist) . $releaseGuid . '.nzb.gz');
}
/**
* Determine is an NZB exists, returning the path+filename, if not return false.
*
* @param string $releaseGuid The guid of the release.
*
* @return bool|string On success: (string) Path+file name of the nzb.
* On failure: (bool) False.
*
* @access public
*/
public function NZBPath($releaseGuid)
{
$nzbFile = $this->getNZBPath($releaseGuid);
return !is_file($nzbFile) ? false : $nzbFile;
}
/**
* Retrieve various information on a NZB file (the subject, # of pars,
* file extensions, file sizes, file completion, group names, # of parts).
*
* @param string $nzb The NZB contents in a string.
*
* @return array $result Empty if not an NZB or the contents of the NZB.
*
* @access public
*/
public function nzbFileList($nzb)
{
$num_pars = $i = 0;
$result = array();
$nzb = str_replace("\x0F", '', $nzb);
$xml = @simplexml_load_string($nzb);
if (!$xml || strtolower($xml->getName()) !== 'nzb') {
return $result;
}
foreach ($xml->file as $file) {
// Subject.
$title = $file->attributes()->subject;
// Amount of pars.
if (stripos($title, '.par2')) {
$num_pars++;
}
$result[$i]['title'] = $title;
// Extensions.
if (preg_match(
'/\.(\d{2,3}|7z|ace|ai7|srr|srt|sub|aiff|asc|avi|audio|bin|bz2|'
. 'c|cfc|cfm|chm|class|conf|cpp|cs|css|csv|cue|deb|divx|doc|dot|'
. 'eml|enc|exe|file|gif|gz|hlp|htm|html|image|iso|jar|java|jpeg|'
. 'jpg|js|lua|m|m3u|mkv|mm|mov|mp3|mp4|mpg|nfo|nzb|odc|odf|odg|odi|odp|'
. 'ods|odt|ogg|par2|parity|pdf|pgp|php|pl|png|ppt|ps|py|r\d{2,3}|'
. 'ram|rar|rb|rm|rpm|rtf|sfv|sig|sql|srs|swf|sxc|sxd|sxi|sxw|tar|'
. 'tex|tgz|txt|vcf|video|vsd|wav|wma|wmv|xls|xml|xpi|xvid|zip7|zip)'
. '[" ](?!(\)|\-))/i', $file->attributes()->subject, $ext)) {
if (preg_match('/\.r\d{2,3}/i', $ext[0])) {
$ext[1] = 'rar';
}
$result[$i]['ext'] = strtolower($ext[1]);
} else {
$result[$i]['ext'] = '';
}
$fileSize = $numSegments = 0;
// Parts.
if (!isset($result[$i]['segments'])) {
$result[$i]['segments'] = array();
}
// File size.
foreach ($file->segments->segment as $segment) {
array_push($result[$i]['segments'], (string) $segment);
$fileSize += $segment->attributes()->bytes;
$numSegments++;
}
$result[$i]['size'] = $fileSize;
// File completion.
if (preg_match('/(\d+)\)$/', $title, $parts)) {
$result[$i]['partstotal'] = $parts[1];
}
$result[$i]['partsactual'] = $numSegments;
// Groups.
if (!isset($result[$i]['groups'])) {
$result[$i]['groups'] = array();
}
foreach ($file->groups->group as $g) {
array_push($result[$i]['groups'], (string) $g);
}
unset($result[$i]['segments']['@attributes']);
$i++;
}
return $result;
}
}
+1 -1
View File
@@ -358,7 +358,7 @@ class Info
// Remove nfo that we cant fetch after 5 attempts.
if ($releaseToWork === '') {
$relres = $this->db->query('SELECT ID FROM releases WHERE nfostatus < -6 OR releasenfoID = -1');
$relres = $this->db->query('SELECT ID FROM releases WHERE nfostatus < -6');
foreach ($relres as $relrow) {
$this->db->exec(sprintf('DELETE FROM releasenfo WHERE nfo IS NULL AND releaseID = %d', $relrow['ID']));
}
+4 -3
View File
@@ -10,7 +10,6 @@ require_once(WWW_DIR . "/lib/releaseimage.php");
require_once(WWW_DIR . "/lib/releaseextra.php");
require_once(WWW_DIR . "/lib/groups.php");
require_once(WWW_DIR . '/lib/nntp.php');
require_once(WWW_DIR . "/lib/nzb.php");
require_once(WWW_DIR . "/lib/site.php");
require_once(WWW_DIR . "/lib/Tmux.php");
require_once(WWW_DIR . "/lib/amazon.php");
@@ -27,6 +26,7 @@ require_once("TraktTv.php");
require_once("Film.php");
require_once("TvAnger.php");
require_once("Konsole.php");
require_once("Enzebe.php");
/**
* Class PProcess
@@ -132,6 +132,7 @@ class PProcess
$this->Nfo = new Info($this->echooutput);
$this->releaseFiles = new ReleaseFiles();
$this->functions = new Functions(true);
$this->nzb = new Enzebe();
$s = new sites();
$t = new Tmux();
//\\
@@ -797,7 +798,7 @@ class PProcess
$this->doEcho('Added: m = video mediainfo, n = nfo, ^ = file details from inside the rar/zip');
}
$nzb = new NZB($this->echooutput);
$nzb = new Enzebe($this->echooutput);
// Loop through the releases.
foreach ($result as $rel) {
@@ -856,7 +857,7 @@ class PProcess
ob_end_clean();
// Get a list of files in the nzb.
$nzbFiles = $this->functions->nzbFileList($nzbFile);
$nzbFiles = $this->nzb->nzbFileList($nzbFile);
if (count($nzbFiles) === 0) {
// There does not appear to be any files in the nzb, decrement password status.
$this->c->debug('processAdditional', 'NZB file is empty: ' . $rel['guid']);
+2 -96
View File
@@ -21,6 +21,7 @@ require_once("ColorCLI.php");
require_once("nzbcontents.php");
require_once("namefixer.php");
require_once("TraktTv.php");
require_once("Enzebe.php");
//*addedd from nZEDb for testing
@@ -238,7 +239,7 @@ class Functions
public
function fastDelete($ID, $guid)
{
$nzb = new NZB();
$nzb = new Enzebe();
$ri = new ReleaseImage();
$ri->delete($guid);
@@ -276,15 +277,6 @@ class Functions
return $res["name"];
}
// Check if the NZB is there, returns path, else false.
function NZBPath($releaseGuid, $sitenzbpath = "")
{
$nzb = new NZB();
$nzbfile = $nzb->getNZBPath($releaseGuid, $sitenzbpath, false);
return !file_exists($nzbfile) ? false : $nzbfile;
}
// Sends releases back to other->misc.
public
function resetCategorize($where = '')
@@ -404,92 +396,6 @@ class Functions
}
}
/**
* Retrieve various information on a NZB file (the subject, # of pars,
* file extensions, file sizes, file completion, group names, # of parts).
*
* @param string $nzb The NZB contents in a string.
*
* @return array $result Empty if not an NZB or the contents of the NZB.
*
* @access public
*/
public function nzbFileList($nzb)
{
$num_pars = $i = 0;
$result = array();
$nzb = str_replace("\x0F", '', $nzb);
$xml = @simplexml_load_string($nzb);
if (!$xml || strtolower($xml->getName()) !== 'nzb') {
return $result;
}
foreach ($xml->file as $file) {
// Subject.
$title = $file->attributes()->subject;
// Amount of pars.
if (stripos($title, '.par2')) {
$num_pars++;
}
$result[$i]['title'] = $title;
// Extensions.
if (preg_match(
'/\.(\d{2,3}|7z|ace|ai7|srr|srt|sub|aiff|asc|avi|audio|bin|bz2|'
. 'c|cfc|cfm|chm|class|conf|cpp|cs|css|csv|cue|deb|divx|doc|dot|'
. 'eml|enc|exe|file|gif|gz|hlp|htm|html|image|iso|jar|java|jpeg|'
. 'jpg|js|lua|m|m3u|mkv|mm|mov|mp3|mp4|mpg|nfo|nzb|odc|odf|odg|odi|odp|'
. 'ods|odt|ogg|par2|parity|pdf|pgp|php|pl|png|ppt|ps|py|r\d{2,3}|'
. 'ram|rar|rb|rm|rpm|rtf|sfv|sig|sql|srs|swf|sxc|sxd|sxi|sxw|tar|'
. 'tex|tgz|txt|vcf|video|vsd|wav|wma|wmv|xls|xml|xpi|xvid|zip7|zip)'
. '[" ](?!(\)|\-))/i', $file->attributes()->subject, $ext)) {
if (preg_match('/\.r\d{2,3}/i', $ext[0])) {
$ext[1] = 'rar';
}
$result[$i]['ext'] = strtolower($ext[1]);
} else {
$result[$i]['ext'] = '';
}
$fileSize = $numSegments = 0;
// Parts.
if (!isset($result[$i]['segments'])) {
$result[$i]['segments'] = array();
}
// File size.
foreach ($file->segments->segment as $segment) {
array_push($result[$i]['segments'], (string) $segment);
$fileSize += $segment->attributes()->bytes;
$numSegments++;
}
$result[$i]['size'] = $fileSize;
// File completion.
if (preg_match('/(\d+)\)$/', $title, $parts)) {
$result[$i]['partstotal'] = $parts[1];
}
$result[$i]['partsactual'] = $numSegments;
// Groups.
if (!isset($result[$i]['groups'])) {
$result[$i]['groups'] = array();
}
foreach ($file->groups->group as $g) {
array_push($result[$i]['groups'], (string) $g);
}
unset($result[$i]['segments']['@attributes']);
$i++;
}
return $result;
}
/**
* @param string $group
* @param int $first
+3 -3
View File
@@ -1,13 +1,13 @@
<?php
require_once(dirname(__FILE__)."/../bin/config.php");
require_once(WWW_DIR."/lib/framework/db.php");
require_once(WWW_DIR."/lib/nzb.php");
require_once(WWW_DIR."/lib/nntp.php");
require_once(WWW_DIR."/lib/Tmux.php");
require_once("functions.php");
require_once("ColorCLI.php");
require_once("Info.php");
require_once("Pprocess.php");
require_once("Enzebe.php");
/**
* Gets information contained within the NZB.
@@ -37,7 +37,7 @@ Class NZBcontents
protected $pp;
/**
* @var NZB
* @var Enzebe
*/
protected $nzb;
@@ -82,7 +82,7 @@ Class NZBcontents
$this->nntp = $options['nntp'];
$this->nfo = $options['nfo'];
$this->pp = $options['pp'];
$this->nzb = new NZB();
$this->nzb = new Enzebe();
}
/**
+16 -16
View File
@@ -132,76 +132,76 @@ process_additional = run_threads * ppperrun
process_nfo = run_threads * nfoperrun
if sys.argv[1] == "additional":
run = "SELECT r.ID, r.guid, r.name, c.disablepreview, r.size, r.groupID, r.nfostatus, r.categoryID, r.searchname from releases r LEFT JOIN category c ON c.ID = r.categoryID WHERE "+maxsize+" AND r.passwordstatus = -1 AND r.haspreview = -1 AND c.disablepreview = 0 "+groupID+" ORDER BY postdate DESC LIMIT %s"
run = "SELECT r.ID, r.guid, r.name, c.disablepreview, r.size, r.groupID, r.nfostatus, r.categoryID, r.searchname from releases r LEFT JOIN category c ON c.ID = r.categoryID WHERE nzbstatus = 1 "+maxsize+" AND r.passwordstatus = -1 AND r.haspreview = -1 AND c.disablepreview = 0 "+groupID+" ORDER BY postdate DESC LIMIT %s"
cur[0].execute(run, process_additional)
datas = cur[0].fetchall()
maxtries = -1
if len(datas) < process_additional:
run = "SELECT r.ID, r.guid, r.name, c.disablepreview, r.size, r.groupID, r.nfostatus, r.categoryID, r.searchname from releases r LEFT JOIN category c ON c.ID = r.categoryID WHERE "+maxsize+" AND r.passwordstatus = -2 AND r.haspreview = -1 AND c.disablepreview = 0 "+groupID+" ORDER BY postdate DESC LIMIT %s"
run = "SELECT r.ID, r.guid, r.name, c.disablepreview, r.size, r.groupID, r.nfostatus, r.categoryID, r.searchname from releases r LEFT JOIN category c ON c.ID = r.categoryID WHERE nzbstatus = 1 "+maxsize+" AND r.passwordstatus = -2 AND r.haspreview = -1 AND c.disablepreview = 0 "+groupID+" ORDER BY postdate DESC LIMIT %s"
cur[0].execute(run, (process_additional - len(datas)))
datas += cur[0].fetchall()
maxtries = -2
if len(datas) < process_additional:
run = "SELECT r.ID, r.guid, r.name, c.disablepreview, r.size, r.groupID, r.nfostatus, r.categoryID, r.searchname from releases r LEFT JOIN category c ON c.ID = r.categoryID WHERE "+maxsize+" AND r.passwordstatus = -3 AND r.haspreview = -1 AND c.disablepreview = 0 "+groupID+" ORDER BY postdate DESC LIMIT %s"
run = "SELECT r.ID, r.guid, r.name, c.disablepreview, r.size, r.groupID, r.nfostatus, r.categoryID, r.searchname from releases r LEFT JOIN category c ON c.ID = r.categoryID WHERE nzbstatus = 1 "+maxsize+" AND r.passwordstatus = -3 AND r.haspreview = -1 AND c.disablepreview = 0 "+groupID+" ORDER BY postdate DESC LIMIT %s"
cur[0].execute(run, (process_additional - len(datas)))
datas += cur[0].fetchall()
maxtries = -3
if len(datas) < process_additional:
run = "SELECT r.ID, r.guid, r.name, c.disablepreview, r.size, r.groupID, r.nfostatus, r.categoryID, r.searchname from releases r LEFT JOIN category c ON c.ID = r.categoryID WHERE "+maxsize+" AND r.passwordstatus = -4 AND r.haspreview = -1 AND c.disablepreview = 0 "+groupID+" ORDER BY postdate DESC LIMIT %s"
run = "SELECT r.ID, r.guid, r.name, c.disablepreview, r.size, r.groupID, r.nfostatus, r.categoryID, r.searchname from releases r LEFT JOIN category c ON c.ID = r.categoryID WHERE nzbstatus = 1 "+maxsize+" AND r.passwordstatus = -4 AND r.haspreview = -1 AND c.disablepreview = 0 "+groupID+" ORDER BY postdate DESC LIMIT %s"
cur[0].execute(run, (process_additional - len(datas)))
datas += cur[0].fetchall()
maxtries = -4
if len(datas) < process_additional:
run = "SELECT r.ID, r.guid, r.name, c.disablepreview, r.size, r.groupID, r.nfostatus, r.categoryID, r.searchname from releases r LEFT JOIN category c ON c.ID = r.categoryID WHERE "+maxsize+" AND r.passwordstatus = -5 AND r.haspreview = -1 AND c.disablepreview = 0 "+groupID+" ORDER BY postdate DESC LIMIT %s"
run = "SELECT r.ID, r.guid, r.name, c.disablepreview, r.size, r.groupID, r.nfostatus, r.categoryID, r.searchname from releases r LEFT JOIN category c ON c.ID = r.categoryID WHERE nzbstatus = 1 "+maxsize+" AND r.passwordstatus = -5 AND r.haspreview = -1 AND c.disablepreview = 0 "+groupID+" ORDER BY postdate DESC LIMIT %s"
cur[0].execute(run, (process_additional - len(datas)))
datas += cur[0].fetchall()
maxtries = -5
if len(datas) < process_additional:
run = "SELECT r.ID, r.guid, r.name, c.disablepreview, r.size, r.groupID, r.nfostatus, r.categoryID, r.searchname from releases r LEFT JOIN category c ON c.ID = r.categoryID WHERE "+maxsize+" AND r.passwordstatus = -6 AND r.haspreview = -1 AND c.disablepreview = 0 "+groupID+" ORDER BY postdate DESC LIMIT %s"
run = "SELECT r.ID, r.guid, r.name, c.disablepreview, r.size, r.groupID, r.nfostatus, r.categoryID, r.searchname from releases r LEFT JOIN category c ON c.ID = r.categoryID WHERE nzbstatus = 1 "+maxsize+" AND r.passwordstatus = -6 AND r.haspreview = -1 AND c.disablepreview = 0 "+groupID+" ORDER BY postdate DESC LIMIT %s"
cur[0].execute(run, (process_additional - len(datas)))
datas += cur[0].fetchall()
maxtries = -6
elif sys.argv[1] == "nfo":
cur[0].execute("SELECT ID, guid, groupID, name from releases WHERE nfostatus = -1 "+groupID+" ORDER BY postdate DESC LIMIT "+str(process_nfo))
cur[0].execute("SELECT ID, guid, groupID, name from releases WHERE nzbstatus = 1 AND nfostatus = -1 "+groupID+" ORDER BY postdate DESC LIMIT "+str(process_nfo))
datas = cur[0].fetchall()
maxtries = -1
if len(datas) < process_nfo:
cur[0].execute("SELECT ID, guid, groupID, name from releases WHERE nfostatus = -2 "+groupID+" ORDER BY postdate DESC LIMIT "+str(process_nfo - len(datas)))
cur[0].execute("SELECT ID, guid, groupID, name from releases WHERE nzbstatus = 1 AND nfostatus = -2 "+groupID+" ORDER BY postdate DESC LIMIT "+str(process_nfo - len(datas)))
datas += cur[0].fetchall()
maxtries = -2
if len(datas) < process_nfo:
cur[0].execute("SELECT ID, guid, groupID, name from releases WHERE nfostatus = -3 "+groupID+" ORDER BY postdate DESC LIMIT "+str(process_nfo - len(datas)))
cur[0].execute("SELECT ID, guid, groupID, name from releases WHERE nzbstatus = 1 AND nfostatus = -3 "+groupID+" ORDER BY postdate DESC LIMIT "+str(process_nfo - len(datas)))
datas += cur[0].fetchall()
maxtries = -3
if len(datas) < process_nfo:
cur[0].execute("SELECT ID, guid, groupID, name from releases WHERE nfostatus = -4 "+groupID+" ORDER BY postdate DESC LIMIT "+str(process_nfo - len(datas)))
cur[0].execute("SELECT ID, guid, groupID, name from releases WHERE nzbstatus = 1 AND nfostatus = -4 "+groupID+" ORDER BY postdate DESC LIMIT "+str(process_nfo - len(datas)))
datas += cur[0].fetchall()
maxtries = -4
if len(datas) < process_nfo:
cur[0].execute("SELECT ID, guid, groupID, name from releases WHERE nfostatus = -5 "+groupID+" ORDER BY postdate DESC LIMIT "+str(process_nfo - len(datas)))
cur[0].execute("SELECT ID, guid, groupID, name from releases WHERE nzbstatus = 1 AND nfostatus = -5 "+groupID+" ORDER BY postdate DESC LIMIT "+str(process_nfo - len(datas)))
datas += cur[0].fetchall()
maxtries = -5
if len(datas) < process_nfo:
cur[0].execute("SELECT ID, guid, groupID, name from releases WHERE nfostatus = -6 "+groupID+" ORDER BY postdate DESC LIMIT "+str(process_nfo - len(datas)))
cur[0].execute("SELECT ID, guid, groupID, name from releases WHERE nzbstatus = 1 AND nfostatus = -6 "+groupID+" ORDER BY postdate DESC LIMIT "+str(process_nfo - len(datas)))
datas += cur[0].fetchall()
maxtries = -6
elif sys.argv[1] == "movie" and len(sys.argv) == 3 and sys.argv[2] == "clean":
run = "SELECT DISTINCT searchname AS name, ID, categoryID from releases WHERE isrenamed = 1 AND searchname IS NOT NULL AND imdbID IS NULL AND categoryID IN (SELECT ID FROM category WHERE parentID = 2000) ORDER BY postdate DESC LIMIT %s"
run = "SELECT DISTINCT searchname AS name, ID, categoryID from releases WHERE nzbstatus = 1 AND isrenamed = 1 AND searchname IS NOT NULL AND imdbID IS NULL AND categoryID IN (SELECT ID FROM category WHERE parentID = 2000) ORDER BY postdate DESC LIMIT %s"
cur[0].execute(run, (run_threads * movieperrun))
datas = cur[0].fetchall()
elif sys.argv[1] == "movie":
run = "SELECT searchname AS name, ID, categoryID from releases WHERE searchname IS NOT NULL AND imdbID IS NULL AND categoryID IN (SELECT ID FROM category WHERE parentID = 2000) ORDER BY postdate DESC LIMIT %s"
run = "SELECT searchname AS name, ID, categoryID from releases WHERE nzbstatus = 1 AND searchname IS NOT NULL AND imdbID IS NULL AND categoryID IN (SELECT ID FROM category WHERE parentID = 2000) ORDER BY postdate DESC LIMIT %s"
cur[0].execute(run, (run_threads * movieperrun))
datas = cur[0].fetchall()
elif sys.argv[1] == "tv" and len(sys.argv) == 3 and sys.argv[2] == "clean":
run = "SELECT searchname, ID from releases WHERE isrenamed = 1 AND searchname IS NOT NULL AND rageID = -1 AND categoryID IN (SELECT ID FROM category WHERE parentID = 5000 ) "+orderBY+" LIMIT %s"
run = "SELECT searchname, ID from releases WHERE nzbstatus = 1 AND isrenamed = 1 AND searchname IS NOT NULL AND rageID = -1 AND categoryID IN (SELECT ID FROM category WHERE parentID = 5000 ) "+orderBY+" LIMIT %s"
cur[0].execute(run, (run_threads * tvrageperrun))
datas = cur[0].fetchall()
elif sys.argv[1] == "tv":
run = "SELECT searchname, ID from releases WHERE searchname IS NOT NULL AND rageID = -1 AND categoryID IN (SELECT ID FROM category WHERE parentID = 5000 ) "+orderBY+" LIMIT %s"
run = "SELECT searchname, ID from releases WHERE nzbstatus = 1 AND searchname IS NOT NULL AND rageID = -1 AND categoryID IN (SELECT ID FROM category WHERE parentID = 5000 ) "+orderBY+" LIMIT %s"
cur[0].execute(run, (run_threads * tvrageperrun))
datas = cur[0].fetchall()