Add first batch of changes from nZEDb dev-tv branch related to TvRage changes

This commit is contained in:
DariusIII
2015-10-21 13:02:41 +02:00
parent dfe488cd16
commit 5ddb0fc58f
40 changed files with 2280 additions and 2786 deletions
+39 -73
View File
@@ -1,26 +1,25 @@
<?php
namespace newznab\processing;
use \newznab\db\Settings;
use \newznab\processing\post\AniDB;
use \newznab\processing\post\ProcessAdditional;
use newznab\Logger;
use newznab\NameFixer;
use newznab\Groups;
use newznab\Nfo;
use newznab\ReleaseFiles;
use newznab\Category;
use newznab\Books;
use newznab\Category;
use newznab\Console;
use newznab\Movie;
use newznab\TvRage;
use newznab\XXX;
use newznab\Sharing;
use newznab\Games;
use newznab\Groups;
use newznab\Logger;
use newznab\Movie;
use newznab\Music;
use newznab\NNTP;
use newznab\TheTVDB;
use newznab\SpotNab;
use newznab\NameFixer;
use newznab\Nfo;
use newznab\Sharing;
//use newznab\processing\tv\TvRage;
use newznab\processing\tv\TVDB;
use newznab\XXX;
use newznab\ReleaseFiles;
use newznab\db\Settings;
use newznab\processing\post\AniDB;
use newznab\processing\post\ProcessAdditional;
use newznab\utility;
require_once NN_LIBS . 'rarinfo/par2info.php';
@@ -68,12 +67,12 @@ class PostProcess
private $echooutput;
/**
* @var Groups
* @var \newznab\Groups
*/
private $groups;
/**
* @var Nfo
* @var \newznab\Nfo
*/
private $Nfo;
@@ -100,23 +99,21 @@ class PostProcess
];
$options += $defaults;
//\\ Various.
// Various.
$this->echooutput = ($options['Echo'] && NN_ECHOCLI);
//\\
//\\ Class instances.
// Class instances.
$this->pdo = (($options['Settings'] instanceof Settings) ? $options['Settings'] : new Settings());
$this->groups = (($options['Groups'] instanceof Groups) ? $options['Groups'] : new Groups());
$this->groups = (($options['Groups'] instanceof Groups) ? $options['Groups'] : new Groups(['Settings' => $this->pdo]));
$this->_par2Info = new \Par2Info();
$this->debugging = ($options['Logger'] instanceof Logger ? $options['Logger'] : new Logger(['ColorCLI' => $this->pdo->log]));
$this->nameFixer = (($options['NameFixer'] instanceof NameFixer) ? $options['NameFixer'] : new NameFixer(['Echo' => $this->echooutput, 'Settings' => $this->pdo, 'Groups' => $this->groups]));
$this->Nfo = (($options['Nfo'] instanceof Nfo ) ? $options['Nfo'] : new Nfo(['Echo' => $this->echooutput, 'Settings' => $this->pdo]));
$this->Nfo = (($options['Nfo'] instanceof Nfo) ? $options['Nfo'] : new Nfo(['Echo' => $this->echooutput, 'Settings' => $this->pdo]));
$this->releaseFiles = (($options['ReleaseFiles'] instanceof ReleaseFiles) ? $options['ReleaseFiles'] : new ReleaseFiles($this->pdo));
//\\
//\\ Site settings.
// Site settings.
$this->addpar2 = ($this->pdo->getSetting('addpar2') == 0) ? false : true;
$this->alternateNNTP = ($this->pdo->getSetting('alternate_nntp') == 1 ? true : false);
//\\
}
/**
@@ -130,7 +127,6 @@ class PostProcess
{
$this->processAdditional($nntp);
$this->processNfos($nntp);
$this->processSpotnab();
$this->processSharing($nntp);
$this->processMovies();
$this->processMusic();
@@ -138,7 +134,6 @@ class PostProcess
$this->processGames();
$this->processAnime();
$this->processTv();
$this->processTvDB();
$this->processXXX();
$this->processBooks();
}
@@ -194,7 +189,7 @@ class PostProcess
/**
* Lookup imdb if enabled.
*
* @param string $groupID (Optional) id of a group to work on.
* @param string $groupID (Optional) ID of a group to work on.
* @param string $guidChar (Optional) First letter of a release GUID to use to get work.
* @param int|string $processMovies (Optional) 0 Don't process, 1 process all releases,
* 2 process renamed releases only, '' check site setting
@@ -224,8 +219,8 @@ class PostProcess
/**
* Process nfo files.
*
* @param NNTP $nntp
* @param string $groupID (Optional) id of a group to work on.
* @param \newznab\NNTP $nntp
* @param string $groupID (Optional) ID of a group to work on.
* @param string $guidChar (Optional) First letter of a release GUID to use to get work.
*
* @return void
@@ -237,31 +232,10 @@ class PostProcess
}
}
/**
* Process Global IDs
*/
public function processSpotnab()
{
$spotnab = new SpotNab();
$processed = $spotnab->processGID(500);
if ($processed > 0) {
if ($this->echooutput) {
$this->pdo->log->doEcho(
$this->pdo->log->primary('Updating GID in releases table ' . $processed . ' release(s) updated')
);
}
}
$spotnab->auto_post_discovery();
$spotnab->fetch_discovery();
$spotnab->fetch();
$spotnab->post();
$spotnab->auto_clean();
}
/**
* Process comments.
*
* @param NNTP $nntp
* @param \newznab\NNTP $nntp
*/
public function processSharing(&$nntp)
{
@@ -271,7 +245,7 @@ class PostProcess
/**
* Process all TV related releases which will assign their series/episode/rage data.
*
* @param string $groupID (Optional) id of a group to work on.
* @param string $groupID (Optional) ID of a group to work on.
* @param string $guidChar (Optional) First letter of a release GUID to use to get work.
* @param string|int $processTV (Optional) 0 Don't process, 1 process all releases,
* 2 process renamed releases only, '' check site setting
@@ -282,16 +256,8 @@ class PostProcess
{
$processTV = (is_numeric($processTV) ? $processTV : $this->pdo->getSetting('lookuptvrage'));
if ($processTV > 0) {
(new TvRage(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processTvReleases($groupID, $guidChar, $processTV);
}
}
public function processTvDB()
{
if ($this->pdo->getSetting('lookupthetvdb') == 1)
{
$thetvdb = new TheTVDB($this->echooutput);
$thetvdb->processReleases();
(new TVDB(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processTVDB($groupID, $guidChar, $processTV);
//(new TvRage(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processTvRage($groupID, $guidChar, $processTV);
}
}
@@ -310,8 +276,8 @@ class PostProcess
*
* @note Called externally by tmux/bin/update_per_group and update/postprocess.php
*
* @param NNTP $nntp Class NNTP
* @param int|string $groupID (Optional) id of a group to work on.
* @param \newznab\NNTP $nntp Class NNTP
* @param int|string $groupID (Optional) ID of a group to work on.
* @param string $guidChar (Optional) First char of release GUID, can be used to select work.
*
* @return void
@@ -327,9 +293,9 @@ class PostProcess
* @note Called from NZBContents.php
*
* @param string $messageID MessageID from NZB file.
* @param int $relID id of the release.
* @param int $groupID Group id of the release.
* @param NNTP $nntp Class NNTP
* @param int $relID ID of the release.
* @param int $groupID Group ID of the release.
* @param \newznab\NNTP $nntp Class NNTP
* @param int $show Only show result or apply iy.
*
* @return bool
@@ -358,7 +324,7 @@ class PostProcess
$foundName = true;
if (!in_array(
(int)$query['categoryid'],
array(
[
Category::CAT_BOOK_OTHER,
Category::CAT_GAME_OTHER,
Category::CAT_MOVIE_OTHER,
@@ -368,7 +334,7 @@ class PostProcess
Category::CAT_MISC_HASHED,
Category::CAT_XXX_OTHER,
Category::CAT_MISC_OTHER
)
]
)
) {
$foundName = false;
@@ -410,7 +376,7 @@ class PostProcess
$this->pdo->queryOneRow(
sprintf('
SELECT id
FROM releasefiles
FROM release_files
WHERE releaseid = %d
AND name = %s',
$relID,
@@ -439,7 +405,7 @@ class PostProcess
// If we found some files.
if ($filesAdded > 0) {
$this->debugging->log(get_class(), __FUNCTION__, 'Added ' . $filesAdded . ' releasefiles from PAR2 for ' . $query['searchname'], Logger::LOG_INFO);
$this->debugging->log(get_class(), __FUNCTION__, 'Added ' . $filesAdded . ' release_files from PAR2 for ' . $query['searchname'], Logger::LOG_INFO);
// Update the file count with the new file count + old file count.
$this->pdo->queryExec(