From ab0b82d077bb01c321ad8be733837b4ac2b232cb Mon Sep 17 00:00:00 2001 From: Darko Date: Fri, 27 Sep 2013 23:03:47 +0200 Subject: [PATCH] Updates to PAR2 file checking --- bin/monitor.php | 2 +- test/nzbcontents.php | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/bin/monitor.php b/bin/monitor.php index cb4a7b6cf..bb0e021fc 100644 --- a/bin/monitor.php +++ b/bin/monitor.php @@ -2,7 +2,7 @@ require(dirname(__FILE__)."/config.php"); require(WWW_DIR.'/lib/postprocess.php'); -$version="0.1r836"; +$version="0.1r837"; $db = new DB(); $DIR = dirname (__FILE__); diff --git a/test/nzbcontents.php b/test/nzbcontents.php index 28646a699..1ebca9d13 100644 --- a/test/nzbcontents.php +++ b/test/nzbcontents.php @@ -53,7 +53,7 @@ Class NZBcontents } // Attempts to get the releasename from a par2 file - public function checkPAR2($guid, $relID, $groupID, $db, $pp) + public function checkPAR2($guid, $?relID, $groupID, $db, $pp) { $nzbfile = $this->LoadNZB($guid); if ($nzbfile !== false) @@ -75,23 +75,19 @@ Class NZBcontents } // Gets the completion from the NZB, optionally looks if there is an NFO/PAR2 file. - public function NZBcompletion($guid, $relID, $groupID, $nntp, $nfocheck=false) + public function NZBcompletion($guid, $relID, $groupID, $nntp, $db, $nfocheck=false) { $nzbfile = $this->LoadNZB($guid); if ($nzbfile !== false) { - $db = new DB(); $messageid = ''; $actualParts = $artificialParts = 0; $foundnfo = $foundpar2 = false; - $pp = new Functions($this->echooutput); foreach ($nzbfile->file as $nzbcontents) { foreach($nzbcontents->segments->segment as $segment) - { $actualParts++; - } $subject = $nzbcontents->attributes()->subject; if(preg_match('/(\d+)\)$/', $subject, $parts)) @@ -107,8 +103,9 @@ Class NZBcontents } if ($foundpar2 === false) { - if (preg_match('/\.(par2?|\d{2,3}").+(yEnc \(1\/1\)|\(1\/1\))$/i', $subject)) + if (preg_match('/\.(par[2" ]|\d{2,3}").+\(1\/1\)$/i', $subject)) { + $pp = new Functions($this->echooutput); if ($pp->parsePAR2($nzbcontents->segments->segment, $relID, $groupID, $nntp) === true) $foundpar2 = true; } @@ -124,12 +121,18 @@ Class NZBcontents if ($completion > 100) $completion = 100; - $this->updateCompletion($completion, $relID); + $db->query(sprintf('UPDATE releases SET completion = %d WHERE ID = %d', $completion, $relID)); if ($nfocheck !== false) - return $messageid; + { + if ($foundnfo === true) + return $messageid; + else + return false; + } else return true; } + return false; } // Look for an .nfo file in the NZB, return the NFO. Also gets the NZB completion.