mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-09-02 19:28:55 +00:00
Added more info output to script.
This commit is contained in:
+1
-1
@@ -5,7 +5,7 @@ require(WWW_DIR.'/lib/postprocess.php');
|
||||
require_once (WWW_DIR.'/lib/site.php');
|
||||
require_once("../test/ColorCLI.php");
|
||||
|
||||
$version="0.3r618";
|
||||
$version="0.3r619";
|
||||
|
||||
$db = new DB();
|
||||
$s = new Sites();
|
||||
|
||||
@@ -44,15 +44,17 @@ if (isset($argv[1]) && $argv[1] == 'export' && isset($argv[2])) {
|
||||
}
|
||||
|
||||
// Create temp table to allow updating
|
||||
echo $c->info("Creating temporary table");
|
||||
echo $c->info("Creating temporary table.");
|
||||
$db->query('DROP TABLE IF EXISTS tmp_pre');
|
||||
$db->query('CREATE TABLE tmp_pre LIKE prehash');
|
||||
|
||||
// Drop indexes on tmp_pre
|
||||
echo $c->info("Dropping indexes from temporary table.");
|
||||
$db->query('ALTER TABLE tmp_pre DROP INDEX `ix_prehash_md5`, DROP INDEX `ix_prehash_nfo`, DROP INDEX `ix_prehash_predate`, DROP INDEX `ix_prehash_adddate`, DROP INDEX `ix_prehash_source`, DROP INDEX `ix_prehash_title`, DROP INDEX `ix_prehash_requestid`');
|
||||
$db->query('ALTER TABLE tmp_pre ADD COLUMN groupname VARCHAR (255)');
|
||||
|
||||
// Import file into tmp_pre
|
||||
echo $c->info("Importing data into temporary table.");
|
||||
if ($argv[1] == 'remote') {
|
||||
$db->queryDirect("LOAD DATA LOCAL INFILE '" . $path . "' IGNORE INTO TABLE tmp_pre FIELDS TERMINATED BY '\t\t' ENCLOSED BY \"'\" LINES TERMINATED BY '\r\n' (title, nfo, size, category, predate, adddate, source, md5, requestID, groupname)");
|
||||
} else {
|
||||
@@ -60,10 +62,13 @@ if (isset($argv[1]) && $argv[1] == 'export' && isset($argv[2])) {
|
||||
}
|
||||
|
||||
// Insert and update table
|
||||
echo $c->info("Inserting data into" . $table. "table.");
|
||||
$db->queryDirect('INSERT INTO ' . $table . ' (title, nfo, size, category, predate, adddate, source, md5, requestID, groupID) SELECT t.title, t.nfo, t.size, t.category, t.predate, t.adddate, t.source, t.md5, t.requestID, IF(g.ID IS NOT NULL, g.ID, 0) FROM tmp_pre t LEFT OUTER JOIN groups g ON t.groupname = g.name ON DUPLICATE KEY UPDATE prehash.nfo = IF(prehash.nfo is null, t.nfo, prehash.nfo), prehash.size = IF(prehash.size is null, t.size, prehash.size), prehash.category = IF(prehash.category is null, t.category, prehash.category), prehash.requestID = IF(prehash.requestID = 0, t.requestID, prehash.requestID), prehash.groupID = IF(g.ID IS NOT NULL, g.ID, 0)');
|
||||
|
||||
// Drop tmp_pre table
|
||||
echo $c->info("Dropping temporary table");
|
||||
$db->query('DROP TABLE IF EXISTS tmp_pre');
|
||||
echo $c->info("Import complete");
|
||||
} else {
|
||||
exit($c->error("\nThis script can export or import a prehash dump file. You may use the full path, or a relative path.\n"
|
||||
. "For importing, the script insert new rows and update existing matched rows. For databases not on the local system, use remote, else use local.\n"
|
||||
|
||||
Reference in New Issue
Block a user