Skip to content

Commit

Permalink
Updates to PAR2 file checking
Browse files Browse the repository at this point in the history
  • Loading branch information
DariusIII committed Sep 27, 2013
1 parent 5cc6df0 commit ab0b82d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion bin/monitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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__);
Expand Down
21 changes: 12 additions & 9 deletions test/nzbcontents.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function LoadNZB($guid)
}

// 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)
Expand All @@ -75,23 +75,19 @@ public function checkPAR2($guid, $relID, $groupID, $db, $pp)
}

// 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))
Expand All @@ -107,8 +103,9 @@ public function NZBcompletion($guid, $relID, $groupID, $nntp, $nfocheck=false)
}
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;
}
Expand All @@ -124,12 +121,18 @@ public function NZBcompletion($guid, $relID, $groupID, $nntp, $nfocheck=false)
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.
Expand Down

0 comments on commit ab0b82d

Please sign in to comment.