mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:08:56 +00:00
removed DELAYED from nzb-import scripts, was creating 0-byte files
This commit is contained in:
+5
-5
@@ -511,6 +511,11 @@ while( $i > 0 )
|
||||
printf("\033[38;5;214m");
|
||||
printf($mask, "Queries","$query_timer","queried");
|
||||
|
||||
//notify monitor that optimize is running
|
||||
if ( ! shell_exec("$_tmux list-panes -t {$array['TMUX_SESSION']}:1 | grep 4: | grep dead") ) {
|
||||
echo "\033[1;41;33mOPTIMIZATION OF THE MYSQL TABLES HAS STARTED, DO NOT STOP THIS SCRIPT!\033[1;0;33m\n\n";
|
||||
}
|
||||
|
||||
//see if tmux.conf needs to be reloaded
|
||||
if ( $_tmux_test != $array['POWERLINE'] ) {
|
||||
if ( $array['POWERLINE'] == "true" ) {
|
||||
@@ -889,11 +894,6 @@ while( $i > 0 )
|
||||
}
|
||||
}
|
||||
|
||||
//notify monitor that optimize is running
|
||||
if ( ! shell_exec("$_tmux list-panes -t {$array['TMUX_SESSION']}:1 | grep 4: | grep dead") ) {
|
||||
echo "\033[1;41;33mOPTIMIZATION OF THE MYSQL TABLES HAS STARTED, DO NOT STOP THIS SCRIPT!\033[1;0;33m\n\n";
|
||||
}
|
||||
|
||||
//check ffmpeg and mediainfo, kill if necessary
|
||||
if ( $array['KILL_PROCESS'] != "0" ) {
|
||||
shell_exec("./check_process.sh mediainfo {$array['KILL_PROCESS']}");
|
||||
|
||||
+3
-3
@@ -79,7 +79,7 @@ if (!isset($groups) || count($groups) == 0) {
|
||||
if ($usenzbname) { //Use the binary names
|
||||
$usename = str_replace('.nzb', '', basename($nzbFile));
|
||||
|
||||
$binarySql = sprintf("INSERT DELAYED INTO binaries (name, fromname, date, xref, totalParts, groupID, binaryhash, dateadded, importname, relname, relpart, reltotalpart, procstat, categoryID, regexID, reqID) values (%s, %s, %s, %s, %s, %s, %s, NOW(), %s, replace(%s, '_', ' '), %d, %d, %d, %s, %d, %s);",
|
||||
$binarySql = sprintf("INSERT INTO binaries (name, fromname, date, xref, totalParts, groupID, binaryhash, dateadded, importname, relname, relpart, reltotalpart, procstat, categoryID, regexID, reqID) values (%s, %s, %s, %s, %s, %s, %s, NOW(), %s, replace(%s, '_', ' '), %d, %d, %d, %s, %d, %s);",
|
||||
$db->escapeString($name), $db->escapeString($fromname), $db->escapeString($date),
|
||||
$db->escapeString($xref), $db->escapeString($totalParts), $db->escapeString($groupID), $db->escapeString($binaryHash), $db->escapeString($nzbFile),
|
||||
$db->escapeString($usename), 1, 1, 5, "null", "null", "null");
|
||||
@@ -87,7 +87,7 @@ if (!isset($groups) || count($groups) == 0) {
|
||||
$transaction = $transaction . $binarySql;
|
||||
|
||||
} else { //Don't use the binary names
|
||||
$binarySql = sprintf("INSERT DELAYED INTO binaries (name, fromname, date, xref, totalParts, groupID, binaryhash, dateadded, importname) values (%s, %s, %s, %s, %s, %s, %s, NOW(), %s);",
|
||||
$binarySql = sprintf("INSERT INTO binaries (name, fromname, date, xref, totalParts, groupID, binaryhash, dateadded, importname) values (%s, %s, %s, %s, %s, %s, %s, NOW(), %s);",
|
||||
$db->escapeString($name), $db->escapeString($fromname), $db->escapeString($date),
|
||||
$db->escapeString($xref), $db->escapeString($totalParts), $db->escapeString($groupID), $db->escapeString($binaryHash), $db->escapeString($nzbFile));
|
||||
|
||||
@@ -99,7 +99,7 @@ if (!isset($groups) || count($groups) == 0) {
|
||||
|
||||
//segments (i.e. parts)
|
||||
if (count($file->segments->segment) > 0) {
|
||||
$partsSql = "INSERT DELAYED INTO parts (binaryID, messageID, number, partnumber, size, dateadded) values ";
|
||||
$partsSql = "INSERT INTO parts (binaryID, messageID, number, partnumber, size, dateadded) values ";
|
||||
foreach ($file->segments->segment as $segment) {
|
||||
$messageId = (string)$segment;
|
||||
$partnumber = $segment->attributes()->number;
|
||||
|
||||
+24
-24
@@ -17,7 +17,7 @@ elseif ($argc == 1)
|
||||
{
|
||||
echo "no arguments specified - php nzb-import.php /path/to/nzb bool_use_filenames\n";
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$using_cli = true;
|
||||
@@ -28,11 +28,11 @@ $browserpostednames = Array();
|
||||
|
||||
if ($using_cli || $page->isPostBack() )
|
||||
{
|
||||
$retval = "";
|
||||
$retval = "";
|
||||
|
||||
//
|
||||
// Via browser, build an array of all the nzb files uploaded into php /tmp location
|
||||
//
|
||||
//
|
||||
if (isset($_FILES["uploadedfiles"]))
|
||||
{
|
||||
foreach ($_FILES["uploadedfiles"]["error"] as $key => $error)
|
||||
@@ -53,13 +53,13 @@ if ($using_cli || $page->isPostBack() )
|
||||
$path = $argv[1];
|
||||
$usenzbname = (isset($argv[2]) && $argv[2] == 'true') ? true : false;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
$strTerminator = "<br />";
|
||||
$path = (isset($_POST["folder"]) ? $_POST["folder"] : "");
|
||||
$usenzbname = (isset($_POST['usefilename']) && $_POST["usefilename"] == 'on') ? true : false;
|
||||
}
|
||||
|
||||
|
||||
if (substr($path, strlen($path) - 1) != '/')
|
||||
$path = $path."/";
|
||||
|
||||
@@ -75,21 +75,21 @@ if ($using_cli || $page->isPostBack() )
|
||||
$retval.= "no groups available in the database, add first.".$strTerminator;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
$nzbCount = 0;
|
||||
|
||||
|
||||
//
|
||||
// read from the path, if no files submitted via the browser
|
||||
//
|
||||
//
|
||||
if (count($filestoprocess) == 0)
|
||||
$filestoprocess = glob($path."*.nzb");
|
||||
$start=date('Y-m-d H:i:s');
|
||||
|
||||
|
||||
foreach($filestoprocess as $nzbFile)
|
||||
{
|
||||
$importfailed = false;
|
||||
$nzb = file_get_contents($nzbFile);
|
||||
|
||||
|
||||
$xml = @simplexml_load_string($nzb);
|
||||
if (!$xml || strtolower($xml->getName()) != 'nzb')
|
||||
{
|
||||
@@ -105,7 +105,7 @@ if ($using_cli || $page->isPostBack() )
|
||||
$fromname = (string)$file->attributes()->poster;
|
||||
$unixdate = (string)$file->attributes()->date;
|
||||
$date = date("Y-m-d H:i:s", (string)$file->attributes()->date);
|
||||
|
||||
|
||||
//groups
|
||||
$groupArr = array();
|
||||
foreach($file->groups->group as $group)
|
||||
@@ -117,39 +117,39 @@ if ($using_cli || $page->isPostBack() )
|
||||
}
|
||||
$groupArr[] = $group;
|
||||
}
|
||||
|
||||
|
||||
if ($groupID != -1)
|
||||
{
|
||||
$xref = implode(': ', $groupArr).':';
|
||||
|
||||
|
||||
$totalParts = sizeof($file->segments->segment);
|
||||
|
||||
|
||||
//insert binary
|
||||
$binaryHash = md5($name.$fromname.$groupID);
|
||||
$binarySql = sprintf("INSERT DELAYED INTO binaries (name, fromname, date, xref, totalParts, groupID, binaryhash, dateadded, importname) values (%s, %s, %s, %s, %s, %s, %s, NOW(), %s)",
|
||||
$binarySql = sprintf("INSERT INTO binaries (name, fromname, date, xref, totalParts, groupID, binaryhash, dateadded, importname) values (%s, %s, %s, %s, %s, %s, %s, NOW(), %s)",
|
||||
$db->escapeString($name), $db->escapeString($fromname), $db->escapeString($date),
|
||||
$db->escapeString($xref), $db->escapeString($totalParts), $db->escapeString($groupID), $db->escapeString($binaryHash), $db->escapeString($nzbFile) );
|
||||
|
||||
|
||||
$binaryId = $db->queryInsert($binarySql);
|
||||
|
||||
|
||||
if ($usenzbname)
|
||||
{
|
||||
$usename = str_replace('.nzb', '', (!$using_cli ? $browserpostednames[$nzbFile] : basename($nzbFile)));
|
||||
|
||||
|
||||
$db->query(sprintf("update binaries set relname = replace(%s, '_', ' '), relpart = %d, reltotalpart = %d, procstat=%d, categoryID=%s, regexID=%d, reqID=%s where ID = %d",
|
||||
$db->escapeString($usename), 1, 1, 5, "null", "null", "null", $binaryId));
|
||||
}
|
||||
|
||||
|
||||
//segments (i.e. parts)
|
||||
if (count($file->segments->segment) > 0)
|
||||
{
|
||||
$partsSql = "INSERT DELAYED INTO parts (binaryID, messageID, number, partnumber, size, dateadded) values ";
|
||||
$partsSql = "INSERT INTO parts (binaryID, messageID, number, partnumber, size, dateadded) values ";
|
||||
foreach($file->segments->segment as $segment)
|
||||
{
|
||||
$messageId = (string)$segment;
|
||||
$partnumber = $segment->attributes()->number;
|
||||
$size = $segment->attributes()->bytes;
|
||||
|
||||
|
||||
$partsSql .= sprintf("(%s, %s, 0, %s, %s, NOW()),",
|
||||
$db->escapeString($binaryId), $db->escapeString($messageId), $db->escapeString($partnumber),
|
||||
$db->escapeString($size));
|
||||
@@ -173,7 +173,7 @@ if ($using_cli || $page->isPostBack() )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!$importfailed)
|
||||
{
|
||||
$nzbCount++;
|
||||
@@ -216,8 +216,8 @@ if ($using_cli || $page->isPostBack() )
|
||||
echo $retval;
|
||||
die();
|
||||
}
|
||||
|
||||
$page->smarty->assign('output', $retval);
|
||||
|
||||
$page->smarty->assign('output', $retval);
|
||||
}
|
||||
|
||||
$page->title = "Import Nzbs";
|
||||
|
||||
Executable
BIN
Binary file not shown.
@@ -324,12 +324,6 @@ export WWW_USER="www-data:www-data"
|
||||
|
||||
###########################################################
|
||||
|
||||
#colors display differently on every monitor, if you are having difficulty seeing a particular
|
||||
#color, set this to true, get the colors number and report is to me, I will remove it
|
||||
export SHOW_COLORS="false"
|
||||
|
||||
###########################################################
|
||||
|
||||
#if you have a ramdisk and would like to monitor it's use, set path here
|
||||
#this is not the same as RAMDISK above, I keep my parts table on a ramdisk
|
||||
export RAMDISK_PATH=""
|
||||
|
||||
+2
-2
@@ -16,8 +16,8 @@ set -g status-bg black
|
||||
set -g status-fg white
|
||||
|
||||
set-option -g status-justify "centre"
|
||||
set-option -g status-left-length 90
|
||||
set-option -g status-right-length 90
|
||||
set-option -g status-left-length 110
|
||||
set-option -g status-right-length 110
|
||||
set-option -g status-left "#(powerline/powerline/powerline.sh left)"
|
||||
set-option -g status-right "#(powerline/powerline/powerline.sh right)"
|
||||
|
||||
|
||||
Executable
+65
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Written by convict
|
||||
import sys, os, shutil
|
||||
import platform, subprocess, re, os, json, urllib2
|
||||
|
||||
def runGit(args):
|
||||
git_locations = ['git']
|
||||
run_dir = os.getcwd()
|
||||
|
||||
if platform.system().lower() == 'darwin':
|
||||
git_locations.append('/usr/local/git/bin/git')
|
||||
|
||||
output = err = None
|
||||
for cur_git in git_locations:
|
||||
cmd = cur_git + ' ' + args
|
||||
try:
|
||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True, cwd=run_dir)
|
||||
output, err = p.communicate()
|
||||
except OSError:
|
||||
print 'Command "%s" did not work. Could not find git.' % cmd
|
||||
continue
|
||||
|
||||
if 'not found' in output or 'not recognized as an internal or external command' in output:
|
||||
print 'Unable to find git with command "%s"' % cmd
|
||||
output = None
|
||||
elif 'fatal:' in output or err:
|
||||
print 'Git returned bad info. Are you sure this is a git installation?'
|
||||
output = None
|
||||
elif output:
|
||||
break
|
||||
return (output, err)
|
||||
|
||||
def gitCurrentVersion():
|
||||
output, err = runGit('rev-parse HEAD')
|
||||
|
||||
if not output:
|
||||
print 'Could not find latest installed version with git.'
|
||||
return None
|
||||
|
||||
current_commit = output.strip()
|
||||
|
||||
if not re.match('^[a-z0-9]+$', current_commit):
|
||||
print 'Git output does not look like a hash, not using it.'
|
||||
return None
|
||||
|
||||
return current_commit
|
||||
|
||||
def latestCommit():
|
||||
url = 'https://api.github.com/repos/jonnyboy/newznab-tmux/commits/dev'
|
||||
result = urllib2.urlopen(url).read()
|
||||
git = json.JSONDecoder().decode(result)
|
||||
return git['sha']
|
||||
|
||||
def commitsBehind():
|
||||
url = 'https://api.github.com/repos/jonnyboy/newznab-tmux/compare/%s...%s' % (gitCurrentVersion(), latestCommit())
|
||||
try:
|
||||
result = urllib2.urlopen(url).read()
|
||||
except urllib2.HTTPError:
|
||||
return None
|
||||
git = json.JSONDecoder().decode(result)
|
||||
return git['total_commits']
|
||||
|
||||
if __name__ == '__main__':
|
||||
print 'You are %s commits behind.' % commitsBehind()
|
||||
Reference in New Issue
Block a user