Move files around.

This commit is contained in:
Darko
2015-05-28 12:36:00 +02:00
parent a5ea73deec
commit ae0434ac11
1403 changed files with 13 additions and 18 deletions
+44
View File
@@ -0,0 +1,44 @@
<?php
/*
Filesize Fix Script
If after import you have a bunch of zero sized releases run this
Author: lordgnu <lordgnu@me.com>
*/
require_once dirname(__FILE__) . '/../../www/config.php';
use newznab\db\DB;
$db = new DB;
$s = New Sites;
$nzb = new NZB;
$items = $db->query("SELECT ID,guid FROM releases WHERE size = 0");
$total = count($items);
$compl = 0;
echo "Updating file size for " . count($items) . " release(s)\n";
$site = $s->get();
while ($item = array_pop($items))
{
$nzbpath = $nzb->getNZBPath($item['guid'], $site->nzbpath);
ob_start();
@readgzfile($nzbpath);
$nzbfile = ob_get_contents();
ob_end_clean();
$ret = $nzb->nzbFileList($nzbfile);
$filesize = '0';
foreach ($ret as $file) {
$filesize = bcadd($filesize, $file['size']);
}
$db->exec("UPDATE releases SET size = '{$filesize}' WHERE `ID` = '{$item['ID']}' LIMIT 1");
$compl++;
echo sprintf("[%6d / %6d] %0.2f",$compl, $total, ($compl/$total) * 100) . '%' . "\n";
}