예제 #1
0
function categorizeRelease($where, $update = true, $echooutput = false)
{
    global $pdo;
    $cat = new Categorize(['Settings' => $pdo]);
    $pdo->log = new ColorCLI();
    $consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]);
    $relcount = $chgcount = 0;
    echo $pdo->log->primary("SELECT id, searchname, group_id, categoryid FROM releases " . $where);
    $resrel = $pdo->queryDirect("SELECT id, searchname, group_id, categoryid FROM releases " . $where);
    $total = $resrel->rowCount();
    if ($total > 0) {
        foreach ($resrel as $rowrel) {
            $catId = $cat->determineCategory($rowrel['group_id'], $rowrel['searchname']);
            if ($rowrel['categoryid'] != $catId) {
                if ($update === true) {
                    $pdo->queryExec(sprintf("\n\t\t\t\t\t\t\tUPDATE releases\n\t\t\t\t\t\t\tSET iscategorized = 1,\n\t\t\t\t\t\t\t\tvideos_id = 0,\n\t\t\t\t\t\t\t\ttv_episodes_id = 0,\n\t\t\t\t\t\t\t\timdbid = NULL,\n\t\t\t\t\t\t\t\tmusicinfoid = NULL,\n\t\t\t\t\t\t\t\tconsoleinfoid = NULL,\n\t\t\t\t\t\t\t\tgamesinfo_id = 0,\n\t\t\t\t\t\t\t\tbookinfoid = NULL,\n\t\t\t\t\t\t\t\tanidbid = NULL,\n\t\t\t\t\t\t\t\txxxinfo_id = 0,\n\t\t\t\t\t\t\t\tcategoryid = %d\n\t\t\t\t\t\t\tWHERE id = %d", $catId, $rowrel['id']));
                }
                $chgcount++;
            }
            $relcount++;
            if ($echooutput) {
                $consoletools->overWritePrimary("Re-Categorized: [" . number_format($chgcount) . "] " . $consoletools->percentString($relcount, $total));
            }
        }
    }
    if ($echooutput !== false && $relcount > 0) {
        echo "\n";
    }
    return $chgcount;
}
예제 #2
0
function getPreName($argv)
{
    global $pdo;
    $timestart = time();
    $consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]);
    $namefixer = new NameFixer(['Settings' => $pdo, 'ConsoleTools' => $consoletools]);
    $res = false;
    if (isset($argv[1]) && $argv[1] === "all") {
        $res = $pdo->queryDirect('SELECT id AS releaseid, name, searchname, group_id, categoryid, dehashstatus FROM releases WHERE preid = 0 AND ishashed = 1');
    } else {
        if (isset($argv[1]) && $argv[1] === "full") {
            $res = $pdo->queryDirect('SELECT id AS releaseid, name, searchname, group_id, categoryid, dehashstatus FROM releases WHERE categoryid = 7020 AND ishashed = 1 AND dehashstatus BETWEEN -6 AND 0');
        } else {
            if (isset($argv[1]) && is_numeric($argv[1])) {
                $res = $pdo->queryDirect('SELECT id AS releaseid, name, searchname, group_id, categoryid, dehashstatus FROM releases WHERE categoryid = 7020 AND ishashed = 1 AND dehashstatus BETWEEN -6 AND 0 ORDER BY postdate DESC LIMIT ' . $argv[1]);
            }
        }
    }
    $counter = $counted = $total = 0;
    if ($res !== false) {
        $total = $res->rowCount();
    }
    $show = !isset($argv[2]) || $argv[2] !== 'show' ? 0 : 1;
    if ($total > 0) {
        echo $pdo->log->header("\n" . number_format($total) . ' releases to process.');
        sleep(2);
        foreach ($res as $row) {
            $success = 0;
            if (preg_match('/[a-fA-F0-9]{32,40}/i', $row['name'], $matches)) {
                $success = $namefixer->matchPredbHash($matches[0], $row, 1, 1, true, $show);
            } else {
                if (preg_match('/[a-fA-F0-9]{32,40}/i', $row['searchname'], $matches)) {
                    $success = $namefixer->matchPredbHash($matches[0], $row, 1, 1, true, $show);
                }
            }
            if ($success === 0) {
                $pdo->queryDirect(sprintf('UPDATE releases SET dehashstatus = dehashstatus - 1 WHERE id = %d', $row['releaseid']));
            } else {
                $counted++;
            }
            if ($show === 0) {
                $consoletools->overWritePrimary("Renamed Releases: [" . number_format($counted) . "] " . $consoletools->percentString(++$counter, $total));
            }
        }
    }
    if ($total > 0) {
        echo $pdo->log->header("\nRenamed " . $counted . " releases in " . $consoletools->convertTime(TIME() - $timestart) . ".");
    } else {
        echo $pdo->log->info("\nNothing to do.");
    }
}
예제 #3
0
 /**
  * Categorizes releases.
  *
  * @param string $type  name or searchname | Categorize using the search name or subject.
  * @param string $where Optional "where" query parameter.
  *
  * @return int Quantity of categorized releases.
  * @access public
  */
 public function categorizeRelease($type, $where = '')
 {
     $cat = new Categorize(['Settings' => $this->pdo]);
     $categorized = $total = 0;
     $releases = $this->pdo->queryDirect(sprintf('SELECT id, %s, group_id FROM releases %s', $type, $where));
     if ($releases && $releases->rowCount()) {
         $total = $releases->rowCount();
         foreach ($releases as $release) {
             $catId = $cat->determineCategory($release['group_id'], $release[$type]);
             $this->pdo->queryExec(sprintf('UPDATE releases SET categoryid = %d, iscategorized = 1 WHERE id = %d', $catId, $release['id']));
             $categorized++;
             if ($this->echoCLI) {
                 $this->consoleTools->overWritePrimary('Categorizing: ' . $this->consoleTools->percentString($categorized, $total));
             }
         }
     }
     if ($this->echoCLI !== false && $categorized > 0) {
         echo PHP_EOL;
     }
     return $categorized;
 }
예제 #4
0
    if ($titles instanceof \Traversable) {
        foreach ($titles as $row) {
            $matched = 0;
            $searched = 0;
            $matched = $namefixer->matchPredbFT($row, 1, 1, true, $show);
            //echo "Pre Title " . $row['title'] . " is translated to search string: ";
            //echo $pdo->log->header($matched);
            if ($matched > 0) {
                $searched = 1;
                $counted++;
            } elseif ($matched < 0) {
                $searched = -6;
                echo "*";
            } else {
                $searched = $row['searched'] - 1;
                echo ".";
            }
            $pdo->queryExec(sprintf("UPDATE predb SET searched = %d WHERE id = %d", $searched, $row['preid']));
            if (!isset($argv[2]) || $argv[2] !== 'show') {
                $consoletools->overWritePrimary("Renamed Releases: [" . number_format($counted) . "] " . $consoletools->percentString(++$counter, $total));
            }
        }
    }
    if ($total > 0) {
        echo $pdo->log->header("\nRenamed " . number_format($counted) . " releases in " . $consoletools->convertTime(TIME() - $timestart) . ".");
    } else {
        echo $pdo->log->info("\nNothing to do.");
    }
} else {
    echo $pdo->log->info("No work to process.\n");
}
예제 #5
0
} else {
    $query = sprintf('SELECT max(id) AS id, id AS idx, guid FROM releases GROUP BY name, fromname, group_id,' . $size . 'HAVING COUNT(*) > 1');
}
do {
    $resrel = $pdo->queryDirect($query);
    if ($resrel instanceof \Traversable) {
        $total = $resrel->rowCount();
        echo $pdo->log->header(number_format($total) . " Releases have Duplicates");
        foreach ($resrel as $rowrel) {
            $nzbpath = $nzb->getNZBPath($rowrel['guid']);
            if (isset($argv[3]) && is_dir($argv[3])) {
                $path = $argv[3];
                if (substr($path, strlen($path) - 1) != '/') {
                    $path = $path . "/";
                }
                if (!file_exists($path . $rowrel['guid'] . ".nzb.gz") && file_exists($nzbpath)) {
                    if (@copy($nzbpath, $path . $rowrel['guid'] . ".nzb.gz") !== true) {
                        exit("\n" . $pdo->log->error("\nUnable to write " . $path . $rowrel['guid'] . ".nzb.gz"));
                    }
                }
            }
            if ($releases->deleteSingle(['g' => $rowrel['guid'], 'i' => $rowrel['idx']], $nzb, $ri) !== false) {
                $consoleTools->overWritePrimary('Deleted: ' . number_format(++$count) . " Duplicate Releases");
            }
        }
    }
    $all += $count;
    $count = 0;
    echo "\n\n";
} while ($total > 0);
echo $pdo->log->header("\nDeleted " . number_format($all) . " Duplicate Releases");
예제 #6
0
            $pdo->queryExec("TRUNCATE TABLE movieinfo");
            $pdo->queryExec("TRUNCATE TABLE video_data");
            $pdo->queryExec("TRUNCATE TABLE musicinfo");
            $pdo->queryExec("TRUNCATE TABLE bookinfo");
            $pdo->queryExec("TRUNCATE TABLE release_nfos");
            $pdo->queryExec("TRUNCATE TABLE releaseextrafull");
            $pdo->queryExec("TRUNCATE TABLE xxxinfo");
        }
        echo $pdo->log->header("Resetting all postprocessing");
        $qry = $pdo->queryDirect("SELECT id FROM releases");
        $affected = 0;
        if ($qry instanceof \Traversable) {
            $total = $qry->rowCount();
            foreach ($qry as $releases) {
                $pdo->queryExec(sprintf("\n\t\t\t\t\t\tUPDATE releases\n\t\t\t\t\t\tSET consoleinfoid = NULL, gamesinfo_id = 0, imdbid = NULL, musicinfoid = NULL,\n\t\t\t\t\t\t\tbookinfoid = NULL, rageid = -1, xxxinfo_id = 0, passwordstatus = -1, haspreview = -1,\n\t\t\t\t\t\t\tjpgstatus = 0, videostatus = 0, audiostatus = 0, nfostatus = -1\n\t\t\t\t\t\tWHERE id = %d", $releases['id']));
                $consoletools->overWritePrimary("Resetting Releases:  " . $consoletools->percentString(++$affected, $total));
            }
        }
    }
}
if (isset($argv[1]) && ($argv[1] === "consoles" || $argv[1] === "all")) {
    $ran = true;
    if (isset($argv[3]) && $argv[3] === "truncate") {
        $pdo->queryExec("TRUNCATE TABLE consoleinfo");
    }
    if (isset($argv[2]) && $argv[2] === "true") {
        echo $pdo->log->header("Resetting all Console postprocessing");
        $where = ' WHERE consoleinfoid IS NOT NULL';
    } else {
        echo $pdo->log->header("Resetting all failed Console postprocessing");
        $where = " WHERE consoleinfoid IN (-2, 0) AND categoryid BETWEEN 1000 AND 1999";
예제 #7
0
파일: NameFixer.php 프로젝트: zetas/nZEDb
    public function getPreFileNames($args = [])
    {
        $timestart = time();
        $counter = $counted = 0;
        $limit = $orderby = '';
        $show = isset($args[2]) && $args[2] === 'show' ? 1 : 0;
        if (isset($args[1]) && is_numeric($args[1])) {
            $orderby = "ORDER BY r.id DESC";
            $limit = "LIMIT " . $args[1];
        }
        echo $this->pdo->log->header("\nMatch PreFiles ({$args[1]}) Started at " . date('g:i:s'));
        echo $this->pdo->log->primary("Matching predb filename to cleaned release_files.name.\n");
        $query = $this->pdo->queryDirect(sprintf('
							SELECT r.id AS releaseid, r.name, r.searchname,
								r.group_id, r.categoryid,
								rf.name AS filename
							FROM releases r
							INNER JOIN release_files rf ON r.id = rf.releaseid
							AND rf.name IS NOT NULL
							WHERE r.preid = 0
							GROUP BY r.id
							%s %s', $orderby, $limit));
        if ($query !== false) {
            $total = $query->rowCount();
            if ($total > 0 && $query instanceof \Traversable) {
                echo $this->pdo->log->header("\n" . number_format($total) . ' releases to process.');
                foreach ($query as $row) {
                    $success = $this->matchPredbFiles($row, 1, 1, true, $show);
                    if ($success === 1) {
                        $counted++;
                    }
                    if ($show === 0) {
                        $this->consoletools->overWritePrimary("Renamed Releases: [" . number_format($counted) . "] " . $this->consoletools->percentString(++$counter, $total));
                    }
                }
                echo $this->pdo->log->header("\nRenamed " . number_format($counted) . " releases in " . $this->consoletools->convertTime(TIME() - $timestart) . ".");
            } else {
                echo $this->pdo->log->info("\nNothing to do.");
            }
        }
    }
예제 #8
0
            exit($pdo->log->info("You have no releases in the DB."));
        }
    } else {
        if (isset($argv[1]) && $argv[1] == "reset") {
            $pdo = new Settings();
            $res = $pdo->query("SELECT releases.id, releases.name, releases.fromname, releases.size, groups.name AS gname FROM releases INNER JOIN groups ON releases.group_id = groups.id");
            if (count($res) > 0) {
                echo $pdo->log->header("Going to reset search names, this can take a while.");
                $done = 0;
                $timestart = time();
                $consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]);
                foreach ($res as $row) {
                    $rc = new ReleaseCleaning($pdo);
                    $newname = $rc->releaseCleaner($row['name'], $row['fromname'], $row['size'], $row['gname']);
                    if (is_array($newname)) {
                        $newname = $newname['cleansubject'];
                    }
                    $newname = $pdo->escapeString($newname);
                    $pdo->queryExec(sprintf("UPDATE releases SET searchname = %s where id = %d", $newname, $row['id']));
                    $sphinx->updateRelease($row['id']);
                    $done++;
                    $consoletools->overWritePrimary("Renaming:" . $consoletools->percentString($done, count($res)));
                }
                $timenc = $consoletools->convertTime(TIME() - $timestart);
                echo $pdo->log->header($done . " releases renamed in " . $timenc);
            }
        } else {
            exit($pdo->log->error("\nThis script runs the subject names through namecleaner to create a clean search name, it also recategorizes and runs the releases through namefixer.\n" . "php resetSearchname.php full              ...: To run this, recategorize and refix release names on all releases.\n" . "php resetSearchname.php limited           ...: To run this on releases that have not had their names fixed, then categorizing them.\n" . "php resetSearchname.php reset             ...: To just reset searchnames.\n"));
        }
    }
}
예제 #9
0
파일: PreDb.php 프로젝트: zetas/nZEDb
 /**
  * Matches the hashes within the predb table to release files and subjects (names) which are hashed.
  *
  * @param $time
  * @param $echo
  * @param $cats
  * @param $namestatus
  * @param $show
  *
  * @return int
  */
 public function parseTitles($time, $echo, $cats, $namestatus, $show)
 {
     $namefixer = new NameFixer(['Echo' => $this->echooutput, 'ConsoleTools' => $this->pdo->log, 'Settings' => $this->pdo]);
     $consoletools = new ConsoleTools(['ColorCLI' => $this->pdo->log]);
     $othercats = Category::getCategoryOthersGroup();
     $updated = $checked = 0;
     $tq = '';
     if ($time == 1) {
         $tq = 'AND r.adddate > (NOW() - INTERVAL 3 HOUR) ORDER BY rf.releaseid, rf.size DESC';
     }
     $ct = '';
     if ($cats == 1) {
         $ct = sprintf('AND r.categoryid IN (%s)', $othercats);
     }
     if ($this->echooutput) {
         $te = '';
         if ($time == 1) {
             $te = ' in the past 3 hours';
         }
         echo $this->pdo->log->header('Fixing search names' . $te . " using the predb hash.");
     }
     $regex = "AND (r.ishashed = 1 OR rf.ishashed = 1)";
     if ($cats === 3) {
         $query = sprintf('SELECT r.id AS releaseid, r.name, r.searchname, r.categoryid, r.group_id, ' . 'dehashstatus, rf.name AS filename FROM releases r ' . 'LEFT OUTER JOIN release_files rf ON r.id = rf.releaseid ' . 'WHERE nzbstatus = 1 AND dehashstatus BETWEEN -6 AND 0 AND preid = 0 %s', $regex);
     } else {
         $query = sprintf('SELECT r.id AS releaseid, r.name, r.searchname, r.categoryid, r.group_id, ' . 'dehashstatus, rf.name AS filename FROM releases r ' . 'LEFT OUTER JOIN release_files rf ON r.id = rf.releaseid ' . 'WHERE nzbstatus = 1 AND isrenamed = 0 AND dehashstatus BETWEEN -6 AND 0 %s %s %s', $regex, $ct, $tq);
     }
     $res = $this->pdo->queryDirect($query);
     $total = $res->rowCount();
     echo $this->pdo->log->primary(number_format($total) . " releases to process.");
     if ($res instanceof \Traversable) {
         foreach ($res as $row) {
             if (preg_match('/[a-fA-F0-9]{32,40}/i', $row['name'], $matches)) {
                 $updated = $updated + $namefixer->matchPredbHash($matches[0], $row, $echo, $namestatus, $this->echooutput, $show);
             } else {
                 if (preg_match('/[a-fA-F0-9]{32,40}/i', $row['filename'], $matches)) {
                     $updated = $updated + $namefixer->matchPredbHash($matches[0], $row, $echo, $namestatus, $this->echooutput, $show);
                 }
             }
             if ($show === 2) {
                 $consoletools->overWritePrimary("Renamed Releases: [" . number_format($updated) . "] " . $consoletools->percentString(++$checked, $total));
             }
         }
     }
     if ($echo == 1) {
         echo $this->pdo->log->header("\n" . $updated . " releases have had their names changed out of: " . number_format($checked) . " files.");
     } else {
         echo $this->pdo->log->header("\n" . $updated . " releases could have their names changed. " . number_format($checked) . " files were checked.");
     }
     return $updated;
 }
예제 #10
0
파일: renametopre.php 프로젝트: zetas/nZEDb
function catRelease($type, $where, $echooutput = false)
{
    global $pdo;
    $cat = new Categorize(['Settings' => $pdo]);
    $consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]);
    $relcount = 0;
    echo $pdo->log->primary("SELECT id, " . $type . ", group_id FROM releases " . $where);
    $resrel = $pdo->queryDirect("SELECT id, " . $type . ", group_id FROM releases " . $where);
    $total = $resrel->rowCount();
    if ($total > 0) {
        foreach ($resrel as $rowrel) {
            $catId = $cat->determineCategory($rowrel['group_id'], $rowrel[$type]);
            $pdo->queryExec(sprintf("UPDATE releases SET iscategorized = 1, categoryid = %d WHERE id = %d", $catId, $rowrel['id']));
            $relcount++;
            if ($echooutput) {
                $consoletools->overWritePrimary("Categorizing: " . $consoletools->percentString($relcount, $total));
            }
        }
    }
    if ($echooutput !== false && $relcount > 0) {
        echo "\n";
    }
    return $relcount;
}
예제 #11
0
                    $seconds = TIME() - $time;
                    $nzbsperhour = number_format(round($nzbCount / $seconds * 3600), 0);
                }
                if ($nzbCount >= $maxtoprocess && $maxtoprocess != 0) {
                    $nzbsperhour = number_format(round($nzbCount / $seconds * 3600), 0);
                    exit($pdo->log->header("\nProcessed " . number_format($nzbCount) . " nzbs in " . relativeTime($time) . "\nAveraged " . $nzbsperhour . " imports per hour from " . $path));
                }
                @unlink($nzbFile);
            } else {
                $pdo->queryExec(sprintf("DELETE FROM releases WHERE guid = %s AND postdate = %s AND size = %d", $pdo->escapeString($relguid), $pdo->escapeString($totalsize)));
                echo $pdo->log->error("\nFailed copying NZB, deleting release from DB.\n");
                @unlink($nzbFile);
                flush();
                $importfailed = true;
            }
            $consoleTools->overWritePrimary('Imported ' . "[" . number_format($nzbSkipped) . "] " . number_format($nzbCount) . " NZBs (" . $nzbsperhour . "iph) in " . relativeTime($time));
        }
    }
}
exit($pdo->log->header("\nRunning Time: " . relativeTime($time) . "\n" . "Processed:    " . number_format($nzbCount + $nzbSkipped) . "\n" . "Imported:     " . number_format($nzbCount) . "\n" . "Duplicates:   " . number_format($nzbSkipped)));
/**
 * Compress an imported NZB and store it inside the nzbfiles folder.
 *
 * @param string $relguid    The guid of the release.
 * @param string $nzb        String containing the imported NZB.
 * @param NZB    $NZB
 * @param object $pdo
 *
 * @return bool
 *
 */
예제 #12
0
                     $deleted++;
                 }
             } else {
                 if (isset($res)) {
                     $pdo->queryExec(sprintf("UPDATE releases SET nzbstatus = 1 WHERE id = %s", $res['id']));
                 }
             }
         } else {
             if ($argv[1] === "delete") {
                 @copy($filePath, nZEDb_ROOT . "pooped/" . $guid[1] . ".nzb.gz");
                 unlink($filePath);
                 $deleted++;
             }
         }
         $time = $consoletools->convertTime(time() - $timestart);
         $consoletools->overWritePrimary('Checking NZBs: ' . $deleted . ' nzbs of ' . ++$checked . ' releases checked ' . $couldbe . 'deleted from disk,  Running time: ' . $time);
     }
 }
 echo $pdo->log->header("\n" . number_format($checked) . ' nzbs checked, ' . number_format($deleted) . ' nzbs ' . $couldbe . 'deleted.');
 $timestart = time();
 $checked = $deleted = 0;
 echo $pdo->log->header("Getting List of releases to check against nzbs.");
 $res = $pdo->queryDirect('SELECT id, guid FROM releases');
 if ($res instanceof \Traversable) {
     foreach ($res as $row) {
         $nzbpath = $nzb->getNZBPath($row["guid"]);
         if (!file_exists($nzbpath)) {
             if ($argv[1] === "delete") {
                 @copy($nzbpath, nZEDb_ROOT . "pooped/" . $row["guid"] . ".nzb.gz");
                 $releases->deleteSingle(['g' => $row['guid'], 'i' => $row['id']], $nzb, $releaseImage);
             }
예제 #13
0
function create_guids($live, $delete = false)
{
    $pdo = new Settings();
    $consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]);
    $timestart = TIME();
    $relcount = $deleted = $total = 0;
    $relrecs = false;
    if ($live == "true") {
        $relrecs = $pdo->queryDirect(sprintf("SELECT id, guid FROM releases WHERE nzbstatus = 1 AND nzb_guid IS NULL ORDER BY id DESC"));
    } else {
        if ($live == "limited") {
            $relrecs = $pdo->queryDirect(sprintf("SELECT id, guid FROM releases WHERE nzbstatus = 1 AND nzb_guid IS NULL ORDER BY id DESC LIMIT 10000"));
        }
    }
    if ($relrecs) {
        $total = $relrecs->rowCount();
    }
    if ($total > 0) {
        echo $pdo->log->header("Creating nzb_guids for " . number_format($total) . " releases.");
        $releases = new Releases(['Settings' => $pdo]);
        $nzb = new NZB($pdo);
        $releaseImage = new ReleaseImage($pdo);
        $reccnt = 0;
        if ($relrecs instanceof \Traversable) {
            foreach ($relrecs as $relrec) {
                $reccnt++;
                $nzbpath = $nzb->NZBPath($relrec['guid']);
                if ($nzbpath !== false) {
                    $nzbfile = Utility::unzipGzipFile($nzbpath);
                    if ($nzbfile) {
                        $nzbfile = @simplexml_load_string($nzbfile);
                    }
                    if (!$nzbfile) {
                        if (isset($delete) && $delete == 'delete') {
                            //echo "\n".$nzb->NZBPath($relrec['guid'])." is not a valid xml, deleting release.\n";
                            $releases->deleteSingle(['g' => $relrec['guid'], 'i' => $relrec['id']], $nzb, $releaseImage);
                            $deleted++;
                        }
                        continue;
                    }
                    $binary_names = array();
                    foreach ($nzbfile->file as $file) {
                        $binary_names[] = $file["subject"];
                    }
                    if (count($binary_names) == 0) {
                        if (isset($delete) && $delete == 'delete') {
                            //echo "\n".$nzb->NZBPath($relrec['guid'])." has no binaries, deleting release.\n";
                            $releases->deleteSingle(['g' => $relrec['guid'], 'i' => $relrec['id']], $nzb, $releaseImage);
                            $deleted++;
                        }
                        continue;
                    }
                    asort($binary_names);
                    foreach ($nzbfile->file as $file) {
                        if ($file["subject"] == $binary_names[0]) {
                            $segment = $file->segments->segment;
                            $nzb_guid = md5($segment);
                            $pdo->queryExec("UPDATE releases set nzb_guid = " . $pdo->escapestring($nzb_guid) . " WHERE id = " . $relrec["id"]);
                            $relcount++;
                            $consoletools->overWritePrimary("Created: [" . $deleted . "] " . $consoletools->percentString($reccnt, $total) . " Time:" . $consoletools->convertTimer(TIME() - $timestart));
                            break;
                        }
                    }
                } else {
                    if (isset($delete) && $delete == 'delete') {
                        //echo $pdo->log->primary($nzb->NZBPath($relrec['guid']) . " does not have an nzb, deleting.");
                        $releases->deleteSingle(['g' => $relrec['guid'], 'i' => $relrec['id']], $nzb, $releaseImage);
                    }
                }
            }
        }
        if ($relcount > 0) {
            echo "\n";
        }
        echo $pdo->log->header("Updated " . $relcount . " release(s). This script ran for " . $consoletools->convertTime(TIME() - $timestart));
    } else {
        echo $pdo->log->info('Query time: ' . $consoletools->convertTime(TIME() - $timestart));
        exit($pdo->log->info("No releases are missing the guid."));
    }
}