Updates to PAR2 file checking

This commit is contained in:
Darko
2013-09-27 23:03:47 +02:00
parent 5cc6df0267
commit ab0b82d077
2 changed files with 13 additions and 10 deletions
+1 -1
View File
@@ -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__);
+12 -9
View File
@@ -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.