From fbd48b93cacf01f50e89ec1799db3d8cd716f018 Mon Sep 17 00:00:00 2001 From: Darko Date: Wed, 17 Sep 2014 11:11:49 +0200 Subject: [PATCH] Updated scripts, fixing stuff i previously edited. --- lib/Info.php | 12 ++++--- lib/Pprocess.php | 35 +++++++++--------- lib/ProcessAdditional.php | 74 ++++++++++++++++++++------------------- 3 files changed, 63 insertions(+), 58 deletions(-) diff --git a/lib/Info.php b/lib/Info.php index 30b8b9739..f3142e565 100644 --- a/lib/Info.php +++ b/lib/Info.php @@ -85,17 +85,19 @@ class Info 'Settings' => null, ]; $options += $defaults; + $s = new Sites(); + $this->site = $s->get(); $this->echo = ($options['Echo'] && NN_ECHOCLI); $this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); - $this->nzbs = ($this->site->('maxnfoprocessed') != '') ? (int)$this->site->('maxnfoprocessed') : 100; - $this->maxsize = ($this->site->('maxsizetoprocessnfo') != '') ? (int)$this->site->('maxsizetoprocessnfo') : 100; + $this->nzbs = ($this->site->maxnfoprocessed != '') ? (int)$this->site->maxnfoprocessed : 100; + $this->maxsize = ($this->site->maxsizetoprocessnfo != '') ? (int)$this->site->maxsizetoprocessnfo : 100; $this->maxsize = ($this->maxsize > 0 ? ('AND size < ' . ($this->maxsize * 1073741824)) : ''); - $this->minsize = ($this->site->('minsizetoprocessnfo') != '') ? (int)$this->site->('minsizetoprocessnfo') : 100; + $this->minsize = ($this->site->minsizetoprocessnfo != '') ? (int)$this->site->minsizetoprocessnfo : 100; $this->minsize = ($this->minsize > 0 ? ('AND size > ' . ($this->minsize * 1048576)) : ''); - $this->maxRetries = (int)($this->site->('maxnforetries') >= 0 ? -((int)$this->site->('maxnforetries') + 1) : self::NFO_UNPROC); + $this->maxRetries = (int)($this->site->maxnforetries >= 0 ? -((int)$this->site->maxnforetries + 1) : self::NFO_UNPROC); $this->maxRetries = ($this->maxRetries < -8 ? -8 : $this->maxRetries); - $this->tmpPath = (string)$this->site->('tmpunrarpath'); + $this->tmpPath = (string)$this->site->tmpunrarpath; if (!preg_match('/[\/\\\\]$/', $this->tmpPath)) { $this->tmpPath .= DS; } diff --git a/lib/Pprocess.php b/lib/Pprocess.php index b3e65d85a..922bb06e2 100644 --- a/lib/Pprocess.php +++ b/lib/Pprocess.php @@ -108,9 +108,10 @@ class PProcess $options += $defaults; //\\ Various. - $this->echooutput = ($options['Echo'] && nZEDb_ECHOCLI); + $this->echooutput = ($options['Echo'] && NN_ECHOCLI); //\\ - + $s = new Sites(); + $this->site = $s->get(); //\\ Class instances. $this->pdo = (($options['Settings'] instanceof DB) ? $options['Settings'] : new DB()); $this->groups = (($options['Groups'] instanceof Groups) ? $options['Groups'] : new Groups(['Settings' => $this->pdo])); @@ -122,8 +123,8 @@ class PProcess //\\ //\\ Site settings. - $this->addpar2 = ($this->site->('addpar2') == 0) ? false : true; - $this->alternateNNTP = ($this->site->('alternate_nntp') == 1 ? true : false); + $this->addpar2 = ($this->site->addpar2 == 0) ? false : true; + $this->alternateNNTP = ($this->site->alternate_nntp == 1 ? true : false); //\\ } @@ -156,7 +157,7 @@ class PProcess */ public function processAnime() { - if ($this->site->('lookupanidb') == 1) { + if ($this->site->lookupanidb == 1) { $anidb = new AniDB(['Echo' => $this->echooutput, 'Settings' => $this->pdo]); $anidb->animetitlesUpdate(); $anidb->processAnimeReleases(); @@ -170,7 +171,7 @@ class PProcess */ public function processBooks() { - if ($this->site->('lookupbooks') != 0) { + if ($this->site->lookupbooks != 0) { (new Books(['Echo' => $this->echooutput, 'Settings' => $this->pdo, ]))->processBookReleases(); } } @@ -182,8 +183,8 @@ class PProcess */ public function processConsoles() { - if ($this->site->('lookupgames') != 0) { - (new Console(['Settings' => $this->pdo, 'Echo' => $this->echooutput]))->processConsoleReleases(); + if ($this->site->lookupgames != 0) { + (new Console())->processConsoleReleases(); } } @@ -194,7 +195,7 @@ class PProcess */ public function processGames() { - if ($this->site->('lookupgames') != 0) { + if ($this->site->lookupgames != 0) { (new Games(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processGamesReleases(); } } @@ -211,9 +212,9 @@ class PProcess */ public function processMovies($groupID = '', $guidChar = '', $processMovies = '') { - $processMovies = (is_numeric($processMovies) ? $processMovies : $this->site->('lookupimdb')); + $processMovies = (is_numeric($processMovies) ? $processMovies : $this->site->lookupimdb); if ($processMovies > 0) { - (new Movie(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processMovieReleases($groupID, $guidChar, $processMovies); + (new Film(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processMovieReleases($groupID, $guidChar, $processMovies); } } @@ -224,8 +225,8 @@ class PProcess */ public function processMusic() { - if ($this->site->('lookupmusic') != 0) { - (new Music(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processMusicReleases(); + if ($this->site->lookupmusic != 0) { + (new Music())->processMusicReleases(); } } @@ -240,8 +241,8 @@ class PProcess */ public function processNfos(&$nntp, $groupID = '', $guidChar = '') { - if ($this->site->('lookupnfo') == 1) { - $this->Nfo->processNfoFiles($nntp, $groupID, $guidChar, (int)$this->site->('lookupimdb'), (int)$this->site->('lookuptvrage')); + if ($this->site->lookupnfo == 1) { + $this->Nfo->processNfoFiles($nntp, $groupID, $guidChar, (int)$this->site->lookupimdb, (int)$this->site->lookuptvrage); } } @@ -267,7 +268,7 @@ class PProcess */ public function processTv($groupID = '', $guidChar = '', $processTV = '') { - $processTV = (is_numeric($processTV) ? $processTV : $this->site->('lookuptvrage')); + $processTV = (is_numeric($processTV) ? $processTV : $this->site->lookuptvrage); if ($processTV > 0) { (new TvAnger(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processTvReleases($groupID, $guidChar, $processTV); } @@ -278,7 +279,7 @@ class PProcess */ public function processXXX() { - if ($this->site->('lookupxxx') == 1) { + if ($this->site->lookupxxx == 1) { (new XXX(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processXXXReleases(); } } diff --git a/lib/ProcessAdditional.php b/lib/ProcessAdditional.php index 8b8b5b7be..af4f8f366 100644 --- a/lib/ProcessAdditional.php +++ b/lib/ProcessAdditional.php @@ -315,34 +315,36 @@ Class ProcessAdditional $this->_releaseImage = ($options['ReleaseImage'] instanceof ReleaseImage ? $options['ReleaseImage'] : new ReleaseImage($this->pdo)); $this->_par2Info = new Par2Info(); $this->_nfo = ($options['Nfo'] instanceof Info ? $options['Nfo'] : new Info(['Echo' => $this->_echoCLI, 'Settings' => $this->pdo])); + $s = new Sites(); + $this->site = $s->get(); - $this->_innerFileBlacklist = ($this->site->('innerfileblacklist') == '' ? false : $this->site->('innerfileblacklist')); - $this->_maxNestedLevels = ($this->site->('maxnestedlevels') == 0 ? 3 : $this->site->('maxnestedlevels')); - $this->_extractUsingRarInfo = ($this->site->('extractusingrarinfo') == 0 ? false : true); + $this->_innerFileBlacklist = ($this->site->innerfileblacklist == '' ? false : $this->site->innerfileblacklist); + $this->_maxNestedLevels = ($this->site->maxnestedlevels == 0 ? 3 : $this->site->maxnestedlevels); + $this->_extractUsingRarInfo = ($this->site->extractusingrarinfo == 0 ? false : true); $this->_7zipPath = false; $this->_unrarPath = false; // Pass the binary extractors to ArchiveInfo. $clients = array(); - if ($this->site->('unrarpath') != '') { - $clients += array(ArchiveInfo::TYPE_RAR => $this->site->('unrarpath')); - $this->_unrarPath = $this->site->('unrarpath'); + if ($this->site->unrarpath != '') { + $clients += array(ArchiveInfo::TYPE_RAR => $this->site->unrarpath); + $this->_unrarPath = $this->site->unrarpath; } - if ($this->site->('zippath') != '') { - $clients += array(ArchiveInfo::TYPE_ZIP => $this->site->('zippath')); - $this->_7zipPath = $this->site->('zippath'); + if ($this->site->zippath != '') { + $clients += array(ArchiveInfo::TYPE_ZIP => $this->site->zippath); + $this->_7zipPath = $this->site->zippath; } $this->_archiveInfo->setExternalClients($clients); $this->_hasGNUFile = (Utility::hasCommand('file') === true ? true : false); $this->_killString = '"'; - if ($this->site->('timeoutpath') != '' && $this->site->('timeoutseconds') > 0) { + if ($this->site->timeoutpath != '' && $this->site->timeoutseconds > 0) { $this->_killString = ( - '"' . $this->site->('timeoutpath') . + '"' . $this->site->timeoutpath . '" --foreground --signal=KILL ' . - $this->site->('timeoutseconds') . ' "' + $this->site->timeoutseconds . ' "' ); } @@ -350,48 +352,48 @@ Class ProcessAdditional // Maximum amount of releases to fetch per run. $this->_queryLimit = - ($this->site->('maxaddprocessed') != '') ? (int)$this->site->('maxaddprocessed') : 25; + ($this->site->maxaddprocessed != '') ? (int)$this->site->maxaddprocessed : 25; // Maximum message ID's to download per file type in the NZB (video, jpg, etc). $this->_segmentsToDownload = - ($this->site->('segmentstodownload') != '') ? (int)$this->site->('segmentstodownload') : 2; + ($this->site->segmentstodownload != '') ? (int)$this->site->segmentstodownload : 2; // Maximum message ID's to download for a RAR file. $this->_maximumRarSegments = - ($this->site->('maxpartsprocessed') != '') ? (int)$this->site->('maxpartsprocessed') : 3; + ($this->site->maxpartsprocessed != '') ? (int)$this->site->maxpartsprocessed : 3; // Maximum RAR files to check for a password before stopping. $this->_maximumRarPasswordChecks = - ($this->site->('passchkattempts') != '') ? (int)$this->site->('passchkattempts') : 1; + ($this->site->passchkattempts != '') ? (int)$this->site->passchkattempts : 1; $this->_maximumRarPasswordChecks = ($this->_maximumRarPasswordChecks < 1 ? 1 : $this->_maximumRarPasswordChecks); // Maximum size of releases in GB. $this->_maxSize = - (string)($this->site->('maxsizetopostprocess') != '') ? $this->site->('maxsizetopostprocess') : 100; + (string)($this->site->maxsizetopostprocess != '') ? $this->site->maxsizetopostprocess : 100; $this->_maxSize = ($this->_maxSize === 0 ? '' : 'AND r.size < ' . ($this->_maxSize * 1073741824)); // Minimum size of releases in MB. $this->_minSize = - (string)($this->site->('minsizetopostprocess') != '') ? $this->site->('minsizetopostprocess') : 1; + (string)($this->site->minsizetopostprocess != '') ? $this->site->minsizetopostprocess : 1; $this->_minSize = ($this->_minSize === 0 ? '' : 'AND r.size > ' . ($this->_minSize * 1048576)); // Use the alternate NNTP provider for downloading Message-ID's ? - $this->_alternateNNTP = ($this->site->('alternate_nntp') == 1 ? true : false); + $this->_alternateNNTP = ($this->site->alternate_nntp == 1 ? true : false); - $this->_ffMPEGDuration = ($this->site->('ffmpeg_duration') != '') ? (int)$this->site->('ffmpeg_duration') : 5; + $this->_ffMPEGDuration = ($this->site->ffmpeg_duration != '') ? (int)$this->site->ffmpeg_duration : 5; - $this->_addPAR2Files = ($this->site->('addpar2') === '0') ? false : true; + $this->_addPAR2Files = ($this->site->addpar2 === '0') ? false : true; - $this->_processSample = ($this->site->('ffmpegpath') == '' ? false : true); - $this->_processVideo = ($this->site->('processvideos') == 0) ? false : true; - $this->_processJPGSample = ($this->site->('processjpg') == 0) ? false : true; - $this->_processAudioSample = ($this->site->('processaudiosample') == 0) ? false : true; - $this->_processMediaInfo = ($this->site->('mediainfopath') == '') ? false : true; + $this->_processSample = ($this->site->ffmpegpath == '' ? false : true); + $this->_processVideo = ($this->site->processvideos == 0) ? false : true; + $this->_processJPGSample = ($this->site->processjpg == 0) ? false : true; + $this->_processAudioSample = ($this->site->processaudiosample == 0) ? false : true; + $this->_processMediaInfo = ($this->site->mediainfopath == '') ? false : true; $this->_processAudioInfo = $this->_processMediaInfo; $this->_processPasswords = ( - ((($this->site->('checkpasswordedrar') == 0) ? false : true)) && - (($this->site->('unrarpath') == '') ? false : true) + ((($this->site->checkpasswordedrar == 0) ? false : true)) && + (($this->site->unrarpath == '') ? false : true) ); $this->_audioSavePath = NN_COVERS . 'audiosample' . DS; @@ -455,7 +457,7 @@ Class ProcessAdditional protected function _setMainTempPath(&$groupID = '', &$guidChar) { // Set up the temporary files folder location. - $this->_mainTmpPath = (string)$this->site->('tmpunrarpath'); + $this->_mainTmpPath = (string)$this->site->tmpunrarpath; // Check if it ends with a dir separator. if (!preg_match('/[\/\\\\]$/', $this->_mainTmpPath)) { @@ -1652,7 +1654,7 @@ Class ProcessAdditional // Get the media info for the file. $xmlArray = runCmd( - $this->_killString . $this->site->('mediainfopath') . '" --Output=XML "' . $fileLocation . '"' + $this->_killString . $this->site->mediainfopath . '" --Output=XML "' . $fileLocation . '"' ); if (is_array($xmlArray)) { @@ -1739,7 +1741,7 @@ Class ProcessAdditional // Create an audio sample. runCmd( $this->_killString . - $this->site->('ffmpegpath') . + $this->site->ffmpegpath . '" -t 30 -i "' . $fileLocation . '" -acodec libvorbis -loglevel quiet -y "' . @@ -1842,7 +1844,7 @@ Class ProcessAdditional // Get the real duration of the file. $time = runCmd( $this->_killString . - $this->site->('ffmpegpath') . + $this->site->ffmpegpath . '" -i "' . $videoLocation . '" -vcodec copy -y 2>&1 "' . $tmpVideo . '"', @@ -1888,7 +1890,7 @@ Class ProcessAdditional // Create the image. runCmd( $this->_killString . - $this->site->('ffmpegpath') . + $this->site->ffmpegpath . '" -i "' . $fileLocation . '" -ss ' . ($time === '' ? '00:00:03.00' : $time) . @@ -1979,7 +1981,7 @@ Class ProcessAdditional // Try to get the sample (from the end instead of the start). runCmd( $this->_killString . - $this->site->('ffmpegpath') . + $this->site->ffmpegpath . '" -i "' . $fileLocation . '" -ss ' . $lowestLength . @@ -1996,7 +1998,7 @@ Class ProcessAdditional // If longer than 60 or we could not get the video length, run the old way. runCmd( $this->_killString . - $this->site->('ffmpegpath') . + $this->site->ffmpegpath . '" -i "' . $fileLocation . '" -vcodec libtheora -filter:v scale=320:-1 -t ' . @@ -2070,7 +2072,7 @@ Class ProcessAdditional // Run media info on it. $xmlArray =runCmd( - $this->_killString . $this->site->('mediainfopath') . '" --Output=XML "' . $fileLocation . '"' + $this->_killString . $this->site->mediainfopath . '" --Output=XML "' . $fileLocation . '"' ); // Check if we got it.