mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:08:56 +00:00
Merge branch 'dev' into dev-fix-admin-features
This commit is contained in:
@@ -1,3 +1,27 @@
|
||||
2017-06-18 DariusIII
|
||||
* Chg: Improve XXX releases logic
|
||||
* Mrg: Merge PR #145 by Nightah - Admin Menu cleanup
|
||||
2017-06-16 DariusIII
|
||||
* Chg: Catch exception when checking for existing and missing collection tables (irritating message about Base table or view not found)
|
||||
* Chg: Increase xref column in collections and multigroup_collections to 1024 and change classused
|
||||
in xxxinfo table to varchar(20) and empty default value
|
||||
* Chg: Remove getXXXSamples script from tmux loop as it serves no purpose anymore
|
||||
* Chg: Add more debugging output to DbUpdate class and install_nntmux script
|
||||
2017-06-15 DariusIII
|
||||
* Fix: Fix collection regexes testing page
|
||||
2017-06-14 DariusIII
|
||||
* Chg: Use monolog/monolog to handle logging
|
||||
* Chg: Update composer libraries
|
||||
2017-06-09 DariusIII
|
||||
* Chg: Update composer.lock
|
||||
2017-06-06 DariusIII
|
||||
* Chg: Use laravel helpers file and replace getenv with env function
|
||||
* Chg: Update composer.lock
|
||||
2017-06-05 DariusIII
|
||||
* Chg: Update minimum MariaDB version to 10.1
|
||||
* Chg: Add laravel/framework to composer.json for future usage
|
||||
2017-06-02 DariusIII
|
||||
* Chg: Update php-tmdb and php-giantbomb libraries
|
||||
2017-05-28 DariusIII
|
||||
* Chg: Possible fix for videos query in getVideoFromSiteID function
|
||||
2017-05-26 DariusIII
|
||||
|
||||
+22
-22
@@ -24,8 +24,8 @@ if (file_exists(NN_ROOT . '_install/install.lock')) {
|
||||
}
|
||||
|
||||
// Check if user selected right DB type.
|
||||
if (getenv('DB_SYSTEM') !== 'mysql') {
|
||||
ColorCLI::doEcho(ColorCLI::error('Invalid database system. Must be: mysql ; Not: ' . getenv('DB_SYSTEM')));
|
||||
if (env('DB_SYSTEM') !== 'mysql') {
|
||||
ColorCLI::doEcho(ColorCLI::error('Invalid database system. Must be: mysql ; Not: ' . env('DB_SYSTEM')));
|
||||
$error = true;
|
||||
} else {
|
||||
// Connect to the SQL server.
|
||||
@@ -35,13 +35,13 @@ if (getenv('DB_SYSTEM') !== 'mysql') {
|
||||
[
|
||||
'checkVersion' => true,
|
||||
'createDb' => true,
|
||||
'dbhost' => getenv('DB_HOST'),
|
||||
'dbname' => getenv('DB_NAME'),
|
||||
'dbpass' => getenv('DB_PASSWORD'),
|
||||
'dbport' => getenv('PORT'),
|
||||
'dbsock' => getenv('DB_SOCKET'),
|
||||
'dbtype' => getenv('DB_SYSTEM'),
|
||||
'dbuser' => getenv('DB_USER'),
|
||||
'dbhost' => env('DB_HOST'),
|
||||
'dbname' => env('DB_NAME'),
|
||||
'dbpass' => env('DB_PASSWORD'),
|
||||
'dbport' => env('PORT'),
|
||||
'dbsock' => env('DB_SOCKET'),
|
||||
'dbtype' => env('DB_SYSTEM'),
|
||||
'dbuser' => env('DB_USER'),
|
||||
]
|
||||
);
|
||||
$dbConnCheck = true;
|
||||
@@ -78,7 +78,7 @@ if (getenv('DB_SYSTEM') !== 'mysql') {
|
||||
$error = true;
|
||||
ColorCLI::doEcho(ColorCLI::error(
|
||||
'You are using an unsupported version of ' .
|
||||
getenv('DB_SYSTEM') .
|
||||
env('DB_SYSTEM') .
|
||||
' the minimum allowed version is ' .
|
||||
NN_MINIMUM_MYSQL_VERSION
|
||||
)
|
||||
@@ -149,13 +149,13 @@ if (!$error) {
|
||||
}
|
||||
}
|
||||
//Insert admin user into database
|
||||
if (getenv('ADMIN_USER') === '' || getenv('ADMIN_PASS') === '' || getenv('ADMIN_EMAIL') === '') {
|
||||
if (env('ADMIN_USER') === '' || env('ADMIN_PASS') === '' || env('ADMIN_EMAIL') === '') {
|
||||
$error = true;
|
||||
ColorCLI::doEcho(ColorCLI::error('Admin user data cannot be empty! Please edit .env file and fill in admin user details and run this script again!'));
|
||||
exit();
|
||||
}
|
||||
|
||||
switch (getenv('DB_SYSTEM')) {
|
||||
switch (env('DB_SYSTEM')) {
|
||||
case 'mysql':
|
||||
$adapter = 'MySql';
|
||||
break;
|
||||
@@ -167,10 +167,10 @@ switch (getenv('DB_SYSTEM')) {
|
||||
}
|
||||
|
||||
if ($adapter !== null) {
|
||||
if (empty(getenv('DB_SOCKET'))) {
|
||||
$host = empty(getenv('DB_PORT')) ? getenv('DB_HOST') : getenv('DB_HOST') . ':' . getenv('DB_PORT');
|
||||
if (empty(env('DB_SOCKET'))) {
|
||||
$host = empty(env('DB_PORT')) ? env('DB_HOST') : env('DB_HOST') . ':' . env('DB_PORT');
|
||||
} else {
|
||||
$host = getenv('DB_SOCKET');
|
||||
$host = env('DB_SOCKET');
|
||||
}
|
||||
|
||||
lithium\data\Connections::add('default',
|
||||
@@ -178,9 +178,9 @@ if ($adapter !== null) {
|
||||
'type' => 'database',
|
||||
'adapter' => $adapter,
|
||||
'host' => $host,
|
||||
'login' => getenv('DB_USER'),
|
||||
'password' => getenv('DB_PASSWORD'),
|
||||
'database' => getenv('DB_NAME'),
|
||||
'login' => env('DB_USER'),
|
||||
'password' => env('DB_PASSWORD'),
|
||||
'database' => env('DB_NAME'),
|
||||
'encoding' => 'UTF-8',
|
||||
'persistent' => false,
|
||||
]
|
||||
@@ -188,20 +188,20 @@ if ($adapter !== null) {
|
||||
}
|
||||
|
||||
$user = new Users();
|
||||
if (!$user->isValidUsername(getenv('ADMIN_USER'))) {
|
||||
if (!$user->isValidUsername(env('ADMIN_USER'))) {
|
||||
$error = true;
|
||||
} else {
|
||||
$usrCheck = $user->getByUsername(getenv('ADMIN_USER'));
|
||||
$usrCheck = $user->getByUsername(env('ADMIN_USER'));
|
||||
if ($usrCheck) {
|
||||
$error = true;
|
||||
}
|
||||
}
|
||||
if (!$user->isValidEmail(getenv('ADMIN_EMAIL'))) {
|
||||
if (!$user->isValidEmail(env('ADMIN_EMAIL'))) {
|
||||
$error = true;
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$adminCheck = $user->add(getenv('ADMIN_USER'), getenv('ADMIN_PASS'), getenv('ADMIN_EMAIL'), 2, '', '');
|
||||
$adminCheck = $user->add(env('ADMIN_USER'), env('ADMIN_PASS'), env('ADMIN_EMAIL'), 2, '', '');
|
||||
if (!is_numeric($adminCheck)) {
|
||||
$error = true;
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ if (!defined('NN_INSTALLER')) {
|
||||
);
|
||||
}
|
||||
|
||||
switch (getenv('DB_SYSTEM')) {
|
||||
switch (env('DB_SYSTEM')) {
|
||||
case 'mysql':
|
||||
$adapter = 'MySql';
|
||||
break;
|
||||
@@ -101,10 +101,10 @@ if (!defined('NN_INSTALLER')) {
|
||||
}
|
||||
|
||||
if (isset($adapter)) {
|
||||
if (empty(getenv('DB_SOCKET'))) {
|
||||
$host = empty(getenv('DB_PORT')) ? getenv('DB_HOST') : getenv('DB_HOST') . ':' . getenv('DB_PORT');
|
||||
if (empty(env('DB_SOCKET'))) {
|
||||
$host = empty(env('DB_PORT')) ? env('DB_HOST') : env('DB_HOST') . ':' . env('DB_PORT');
|
||||
} else {
|
||||
$host = getenv('DB_SOCKET');
|
||||
$host = env('DB_SOCKET');
|
||||
}
|
||||
|
||||
Connections::add('default',
|
||||
@@ -112,9 +112,9 @@ if (!defined('NN_INSTALLER')) {
|
||||
'type' => 'database',
|
||||
'adapter' => $adapter,
|
||||
'host' => $host,
|
||||
'login' => getenv('DB_USER'),
|
||||
'password' => getenv('DB_PASSWORD'),
|
||||
'database' => getenv('DB_NAME'),
|
||||
'login' => env('DB_USER', 'nntmux'),
|
||||
'password' => env('DB_PASSWORD', 'nntmux'),
|
||||
'database' => env('DB_NAME', 'nntmux'),
|
||||
'encoding' => 'UTF-8',
|
||||
'persistent' => false,
|
||||
]
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use GuzzleHttp\Cookie\SetCookie;
|
||||
use GuzzleHttp\Cookie\CookieJar;
|
||||
use nntmux\ColorCLI;
|
||||
|
||||
if (!function_exists('getRawHtml')) {
|
||||
|
||||
/**
|
||||
* @param $url
|
||||
* @param bool|string $cookie
|
||||
*
|
||||
* @return bool|string
|
||||
*/
|
||||
function getRawHtml($url, $cookie = false)
|
||||
{
|
||||
$response = false;
|
||||
$cookiejar = new CookieJar();
|
||||
$client = new Client();
|
||||
if ($cookie !== false) {
|
||||
$cookieJar = $cookiejar->setCookie(SetCookie::fromString($cookie));
|
||||
$client = new Client(['cookies' => $cookieJar]);
|
||||
}
|
||||
try {
|
||||
$response = $client->get($url)->getBody()->getContents();
|
||||
} catch (RequestException $e) {
|
||||
if ($e->hasResponse()) {
|
||||
if($e->getCode() === 404) {
|
||||
ColorCLI::doEcho(ColorCLI::notice('Data not available on server'));
|
||||
} else if ($e->getCode() === 503) {
|
||||
ColorCLI::doEcho(ColorCLI::notice('Service unavailable'));
|
||||
} else {
|
||||
ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data from server, http error reported: ' . $e->getCode()));
|
||||
}
|
||||
}
|
||||
} catch (\RuntimeException $e) {
|
||||
ColorCLI::doEcho(ColorCLI::notice('Runtime error: ' . $e->getCode()));
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -16,8 +16,8 @@
|
||||
</last>
|
||||
</scripts>
|
||||
<sql>
|
||||
<db>310</db>
|
||||
<file>310</file>
|
||||
<db>311</db>
|
||||
<file>311</file>
|
||||
</sql>
|
||||
</versions>
|
||||
</nntmux>
|
||||
|
||||
@@ -58,7 +58,7 @@ foreach (['anime', 'audio', 'audiosample', 'book', 'console', 'games', 'movies',
|
||||
}
|
||||
|
||||
// Set up covers paths.
|
||||
if (getenv('DB_PASSWORD') !== '') {
|
||||
if (env('DB_PASSWORD') !== '') {
|
||||
$ri = new ReleaseImage();
|
||||
|
||||
$folders[$ri->audSavePath] = [R, W];
|
||||
|
||||
+6
-2
@@ -5,6 +5,10 @@
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"files": [
|
||||
"app/libraries/laravel/framework/src/Illuminate/Support/helpers.php",
|
||||
"app/extensions/helper/helpers.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"nntmux\\": "nntmux/"
|
||||
},
|
||||
@@ -137,10 +141,10 @@
|
||||
"bower-asset/slimScroll": "~1.3.7",
|
||||
"bower-asset/tinymce-builded": "~4.4.3",
|
||||
"unionofrad/lithium": "^1.1.0-beta",
|
||||
"illuminate/filesystem": "^5.4",
|
||||
"monolog/monolog": "^1.22",
|
||||
"aharen/omdbapi": "^2.0",
|
||||
"vlucas/phpdotenv": "^2.4"
|
||||
"vlucas/phpdotenv": "^2.4",
|
||||
"laravel/framework": "^5.4"
|
||||
},
|
||||
|
||||
"require-dev": {
|
||||
|
||||
Generated
+631
-220
File diff suppressed because it is too large
Load Diff
@@ -53,7 +53,7 @@ if ($handle) {
|
||||
if (trim($match['table']) === 'collections') {
|
||||
$tables = $pdo->query("SHOW TABLES");
|
||||
foreach ($tables as $row) {
|
||||
$tbl = $row['tables_in_' . getenv('DB_NAME')];
|
||||
$tbl = $row['tables_in_' . env('DB_NAME')];
|
||||
if (preg_match('/collections_\d+/', $tbl)) {
|
||||
$check = $pdo->checkColumnIndex($tbl, $column);
|
||||
if (!isset($check_collections['key_name'])) {
|
||||
@@ -67,7 +67,7 @@ if ($handle) {
|
||||
} else if (trim($match['table']) === 'binaries') {
|
||||
$tables = $pdo->query("SHOW TABLES");
|
||||
foreach ($tables as $row) {
|
||||
$tbl = $row['tables_in_' . getenv('DB_NAME')];
|
||||
$tbl = $row['tables_in_' . env('DB_NAME')];
|
||||
if (preg_match('/binaries_\d+/', $tbl)) {
|
||||
$checkBinaries = $pdo->checkColumnIndex($tbl, $column);
|
||||
if (!isset($checkBinaries['key_name'])) {
|
||||
@@ -81,7 +81,7 @@ if ($handle) {
|
||||
} else if (trim($match['table']) === 'parts') {
|
||||
$tables = $pdo->query("SHOW TABLES");
|
||||
foreach ($tables as $row) {
|
||||
$tbl = $row['tables_in_' . getenv('DB_NAME')];
|
||||
$tbl = $row['tables_in_' . env('DB_NAME')];
|
||||
if (preg_match('/parts_\d+/', $tbl)) {
|
||||
$checkParts = $pdo->checkColumnIndex($tbl, $column);
|
||||
if (!isset($checkParts['key_name'])) {
|
||||
@@ -95,7 +95,7 @@ if ($handle) {
|
||||
} else if (trim($match['table']) === 'missed_parts') {
|
||||
$tables = $pdo->query("SHOW TABLES");
|
||||
foreach ($tables as $row) {
|
||||
$tbl = $row['tables_in_' . getenv('DB_NAME')];
|
||||
$tbl = $row['tables_in_' . env('DB_NAME')];
|
||||
if (preg_match('/partrepair_\d+/', $tbl)) {
|
||||
$checkPartRepair = $pdo->checkColumnIndex($tbl, $column);
|
||||
if (!isset($checkPartRepair['key_name'])) {
|
||||
|
||||
@@ -32,14 +32,14 @@ function builddefaultsfile()
|
||||
//generate file contents
|
||||
$filetext = "[mysqldump]"
|
||||
."\n"
|
||||
."user = " . getenv('DB_USER')
|
||||
."user = " . env('DB_USER')
|
||||
."\n"
|
||||
."password = " . getenv('DB_PASSWORD')
|
||||
."password = " . env('DB_PASSWORD')
|
||||
."\n[mysql]"
|
||||
."\n"
|
||||
."user = " . getenv('DB_USER')
|
||||
."user = " . env('DB_USER')
|
||||
."\n"
|
||||
."password = " . getenv('DB_PASSWORD');
|
||||
."password = " . env('DB_PASSWORD');
|
||||
|
||||
$filehandle = fopen("mysql-defaults.txt", "w+");
|
||||
if(!$filehandle) {
|
||||
@@ -51,14 +51,14 @@ function builddefaultsfile()
|
||||
}
|
||||
}
|
||||
|
||||
$dbhost = getenv('DB_HOST');
|
||||
$dbport = getenv('DB_PORT');
|
||||
$dbsocket = getenv('DB_SOCKET');
|
||||
$dbuser = getenv('DB_USER');
|
||||
$dbpass = getenv('DB_PASSWORD');
|
||||
$dbname = getenv(getenv('DB_NAME'));
|
||||
$dbhost = env('DB_HOST');
|
||||
$dbport = env('DB_PORT');
|
||||
$dbsocket = env('DB_SOCKET');
|
||||
$dbuser = env('DB_USER');
|
||||
$dbpass = env('DB_PASSWORD');
|
||||
$dbname = env(env('DB_NAME'));
|
||||
|
||||
if (getenv('DB_SOCKET') !== '') {
|
||||
if (env('DB_SOCKET') !== '') {
|
||||
$use = "-S $dbsocket";
|
||||
} else {
|
||||
$use = "-P$dbport";
|
||||
@@ -88,7 +88,7 @@ if((isset($argv[1]) && $argv[1] == "db") && (isset($argv[2]) && $argv[2] == "dum
|
||||
$sql = "SHOW tables";
|
||||
$tables = $pdo->query($sql);
|
||||
foreach($tables as $row) {
|
||||
$tbl = $row['Tables_in_'. getenv('DB_NAME')];
|
||||
$tbl = $row['Tables_in_'. env('DB_NAME')];
|
||||
$filename = $argv[3]."/".$tbl.".gz";
|
||||
echo $pdo->log->header("Dumping $tbl.");
|
||||
if (file_exists($filename)) {
|
||||
@@ -102,7 +102,7 @@ if((isset($argv[1]) && $argv[1] == "db") && (isset($argv[2]) && $argv[2] == "dum
|
||||
$tables = $pdo->query($sql);
|
||||
$pdo->queryExec("SET FOREIGN_KEY_CHECKS=0");
|
||||
foreach($tables as $row) {
|
||||
$tbl = $row['Tables_in_'.getenv('DB_NAME')];
|
||||
$tbl = $row['Tables_in_'.env('DB_NAME')];
|
||||
$filename = $argv[3]."/".$tbl.".gz";
|
||||
if (file_exists($filename)) {
|
||||
echo $pdo->log->header("Restoring $tbl.");
|
||||
@@ -138,7 +138,7 @@ if((isset($argv[1]) && $argv[1] == "db") && (isset($argv[2]) && $argv[2] == "dum
|
||||
$sql = "SHOW tables";
|
||||
$tables = $pdo->query($sql);
|
||||
foreach($tables as $row) {
|
||||
$tbl = $row['Tables_in_'.getenv('DB_NAME')];
|
||||
$tbl = $row['Tables_in_'.env('DB_NAME')];
|
||||
$filename = $argv[3].$tbl.".csv";
|
||||
echo $pdo->log->header("Dumping $tbl.");
|
||||
if (file_exists($filename)) {
|
||||
@@ -151,7 +151,7 @@ if((isset($argv[1]) && $argv[1] == "db") && (isset($argv[2]) && $argv[2] == "dum
|
||||
$tables = $pdo->query($sql);
|
||||
$pdo->queryExec("SET FOREIGN_KEY_CHECKS=0");
|
||||
foreach($tables as $row) {
|
||||
$tbl = $row['Tables_in_'.getenv('DB_NAME')];
|
||||
$tbl = $row['Tables_in_'.env('DB_NAME')];
|
||||
$filename = $argv[3].$tbl.".csv";
|
||||
if (file_exists($filename)) {
|
||||
echo $pdo->log->header("Restoring $tbl.");
|
||||
|
||||
@@ -27,7 +27,7 @@ if ($argc == 1 || $argv[1] != 'true') {
|
||||
exit($pdo->log->error("\nThis script will rename every table column to lowercase that is not already lowercase.\nTo run:\nphp $argv[0] true\n"));
|
||||
}
|
||||
|
||||
$database = getenv('DB_NAME');
|
||||
$database = env('DB_NAME');
|
||||
|
||||
$count = 0;
|
||||
$list = $pdo->query("SELECT TABLE_NAME, COLUMN_NAME, UPPER(COLUMN_TYPE), EXTRA FROM information_schema.columns WHERE table_schema = '" . $database . "'");
|
||||
|
||||
@@ -20,7 +20,7 @@ $table_data = "SELECT TABLE_NAME AS 'Table', TABLE_ROWS AS 'Rows', "
|
||||
. "((INDEX_LENGTH) / POWER(1024,2)) AS 'index', "
|
||||
. "((DATA_FREE) / POWER(1024,2)) AS 'free', "
|
||||
. "((DATA_LENGTH + INDEX_LENGTH) / POWER(1024,2)) AS 'total' "
|
||||
. "FROM information_schema.TABLES WHERE information_schema.TABLES.table_schema = '" . getenv('DB_NAME') . "' "
|
||||
. "FROM information_schema.TABLES WHERE information_schema.TABLES.table_schema = '" . env('DB_NAME') . "' "
|
||||
. "ORDER BY (DATA_LENGTH + INDEX_LENGTH) DESC";
|
||||
|
||||
$run = $pdo->queryDirect($table_data);
|
||||
|
||||
@@ -323,8 +323,12 @@ function charCheck($char)
|
||||
*/
|
||||
function collectionCheck(&$pdo, $groupID)
|
||||
{
|
||||
if ($pdo->queryOneRow(sprintf('SELECT id FROM collections_%d LIMIT 1', $groupID)) === false) {
|
||||
exit();
|
||||
try {
|
||||
if ($pdo->queryOneRow(sprintf('SELECT id FROM collections_%d LIMIT 1', $groupID)) === false) {
|
||||
exit();
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
$e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ $runVar['paths']['misc'] = NN_MISC;
|
||||
$runVar['paths']['cli'] = NN_ROOT . 'cli/';
|
||||
$runVar['paths']['scraper'] = NN_MISC . 'IRCScraper' . DS . 'scrape.php';
|
||||
|
||||
$db_name = getenv('DB_NAME');
|
||||
$dbtype = getenv('DB_SYSTEM');
|
||||
$db_name = env('DB_NAME');
|
||||
$dbtype = env('DB_SYSTEM');
|
||||
$tmux = $tRun->get('niceness');
|
||||
|
||||
$tmux_niceness = $tmux->niceness ?? 2;
|
||||
|
||||
@@ -37,9 +37,9 @@ $bool = array(
|
||||
'false'
|
||||
);
|
||||
|
||||
if (!isset($argv[1]) || !in_array($argv[1], $args) || !isset($argv[2]) || !in_array($argv[2], $bool)) {
|
||||
if (!isset($argv[1]) || !in_array($argv[1], $args, false) || !isset($argv[2]) || !in_array($argv[2], $bool, false)) {
|
||||
exit(
|
||||
$pdo->log->error(
|
||||
\nntmux\ColorCLI::error(
|
||||
"\nIncorrect arguments.\n"
|
||||
. "The second argument (true/false) determines wether to echo or not.\n\n"
|
||||
. "php postprocess.php all true ...: Does all the types of post processing.\n"
|
||||
@@ -65,12 +65,12 @@ if (!isset($argv[1]) || !in_array($argv[1], $args) || !isset($argv[2]) || !in_ar
|
||||
$nntp = null;
|
||||
if ($args[$argv[1]] === true) {
|
||||
$nntp = new NNTP(['Settings' => $pdo]);
|
||||
if ((Settings::value('..alternate_nntp') == 1 ? $nntp->doConnect(true, true) : $nntp->doConnect()) !== true) {
|
||||
exit($pdo->log->error("Unable to connect to usenet." . PHP_EOL));
|
||||
if ((Settings::value('..alternate_nntp') === 1 ? $nntp->doConnect(true, true) : $nntp->doConnect()) !== true) {
|
||||
exit($pdo->log->error('Unable to connect to usenet.' . PHP_EOL));
|
||||
}
|
||||
}
|
||||
|
||||
$postProcess = new PostProcess(['Settings' => $pdo, 'Echo' => ($argv[2] === 'true' ? true : false)]);
|
||||
$postProcess = new PostProcess(['Settings' => $pdo, 'Echo' => $argv[2] === 'true' ? true : false]);
|
||||
|
||||
$charArray = ['a','b','c','d','e','f','0','1','2','3','4','5','6','7','8','9'];
|
||||
|
||||
@@ -87,7 +87,7 @@ switch ($argv[1]) {
|
||||
}
|
||||
break;
|
||||
case 'additional':
|
||||
$postProcess->processAdditional($nntp, '', (isset($argv[3]) && in_array($argv[3], $charArray) ? $argv[3] : ''));
|
||||
$postProcess->processAdditional($nntp, '', (isset($argv[3]) && in_array($argv[3], $charArray, false) ? $argv[3] : ''));
|
||||
break;
|
||||
case 'amazon':
|
||||
$postProcess->processBooks();
|
||||
@@ -109,10 +109,10 @@ switch ($argv[1]) {
|
||||
$postProcess->processGames();
|
||||
break;
|
||||
case 'nfo':
|
||||
$postProcess->processNfos($nntp, '', (isset($argv[3]) && in_array($argv[3], $charArray) ? $argv[3] : ''));
|
||||
$postProcess->processNfos($nntp, '', (isset($argv[3]) && in_array($argv[3], $charArray, false) ? $argv[3] : ''));
|
||||
break;
|
||||
case 'movies':
|
||||
$postProcess->processMovies('', (isset($argv[3]) && in_array($argv[3], $charArray) ? $argv[3] : ''));
|
||||
$postProcess->processMovies('', (isset($argv[3]) && in_array($argv[3], $charArray, false) ? $argv[3] : ''));
|
||||
break;
|
||||
case 'music':
|
||||
$postProcess->processMusic();
|
||||
@@ -126,7 +126,7 @@ switch ($argv[1]) {
|
||||
$postProcess->processSpotnab();
|
||||
break;
|
||||
case 'tv':
|
||||
$postProcess->processTv('', (isset($argv[3]) && in_array($argv[3], $charArray) ? $argv[3] : ''));
|
||||
$postProcess->processTv('', (isset($argv[3]) && in_array($argv[3], $charArray, false) ? $argv[3] : ''));
|
||||
break;
|
||||
case 'xxx':
|
||||
$postProcess->processXXX();
|
||||
|
||||
-413
@@ -1,413 +0,0 @@
|
||||
<?php
|
||||
namespace nntmux;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use nntmux\db\DB;
|
||||
use nntmux\utility\Utility;
|
||||
|
||||
|
||||
/**
|
||||
* Class adultdvdempire
|
||||
*/
|
||||
class ADE
|
||||
{
|
||||
/**
|
||||
* If a direct link is given parse it rather then search
|
||||
* @var string
|
||||
*/
|
||||
public $directLink = '';
|
||||
|
||||
/**
|
||||
* If a string is found do call back.
|
||||
* @var bool
|
||||
*/
|
||||
public $found = false;
|
||||
|
||||
/**
|
||||
* Search keyword
|
||||
* @var string
|
||||
*/
|
||||
public $searchTerm = '';
|
||||
|
||||
/**
|
||||
* Define ADE Url here
|
||||
*/
|
||||
const ADE = 'http://www.adultdvdempire.com';
|
||||
|
||||
/**
|
||||
* Direct Url returned in getAll method
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_directUrl = "";
|
||||
|
||||
/**
|
||||
* If a url is found that matches the keyword
|
||||
*
|
||||
*/
|
||||
protected $_urlFound;
|
||||
|
||||
/**
|
||||
* Sets the title in the getAll method
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_title = "";
|
||||
|
||||
/** Trailing urls */
|
||||
protected $_dvdQuery = '/dvd/search?q=';
|
||||
protected $_scenes = '/scenes';
|
||||
protected $_boxCover = '/boxcover';
|
||||
protected $_backCover = '/backcover';
|
||||
protected $_reviews = '/reviews';
|
||||
protected $_trailers = '/trailers';
|
||||
|
||||
|
||||
protected $_url;
|
||||
protected $_response;
|
||||
protected $_res = [];
|
||||
protected $_tmpResponse;
|
||||
protected $_html;
|
||||
protected $_edithtml;
|
||||
protected $_ch;
|
||||
|
||||
/**
|
||||
* @var Client
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* @var DB
|
||||
*/
|
||||
protected $pdo;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->_html = new \simple_html_dom();
|
||||
$this->_edithtml = new \simple_html_dom();
|
||||
$this->client = new Client();
|
||||
$this->pdo = new DB();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Remove from memory if they were not removed
|
||||
*
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
$this->_html->clear();
|
||||
$this->_edithtml->clear();
|
||||
unset($this->_response, $this->_tmpResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Trailer Movies
|
||||
* @return array - url, streamid, basestreamingurl
|
||||
*/
|
||||
public function trailers()
|
||||
{
|
||||
$this->getUrl($this->_trailers . $this->_urlFound);
|
||||
$this->_html->load($this->_response);
|
||||
if (preg_match("/(\"|')(?P<swf>[^\"']+.swf)(\"|')/i", $this->_response, $matches)) {
|
||||
$this->_res['trailers']['url'] = self::ADE . trim(trim($matches['swf']), '"');
|
||||
if (preg_match('#(?:streamID:\s\")(?P<streamid>[0-9A-Z]+)(?:\")#',
|
||||
$this->_response,
|
||||
$matches)
|
||||
) {
|
||||
$this->_res['trailers']['streamid'] = trim($matches['streamid']);
|
||||
}
|
||||
if (preg_match('#(?:BaseStreamingUrl:\s\")(?P<baseurl>[\d]+.[\d]+.[\d]+.[\d]+)(?:\")#',
|
||||
$this->_response,
|
||||
$matches)
|
||||
) {
|
||||
$this->_res['trailers']['baseurl'] = $matches['baseurl'];
|
||||
}
|
||||
}
|
||||
unset($matches);
|
||||
$this->_html->clear();
|
||||
|
||||
return $this->_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets cover images for the xxx release
|
||||
* @return array - Boxcover and backcover
|
||||
*/
|
||||
public function covers()
|
||||
{
|
||||
if ($ret = $this->_html->find('div#Boxcover, img[itemprop=image]', 1)) {
|
||||
$this->_res['boxcover'] = preg_replace('/m\.jpg/', 'h.jpg', $ret->src);
|
||||
$this->_res['backcover'] = preg_replace('/m\.jpg/', 'bh.jpg', $ret->src);
|
||||
}
|
||||
|
||||
return $this->_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sypnosis and tagline
|
||||
*
|
||||
* @param bool $tagline - Include tagline? true/false
|
||||
*
|
||||
* @return array - plot,tagline
|
||||
*/
|
||||
public function sypnosis($tagline = false)
|
||||
{
|
||||
if ($tagline === true) {
|
||||
$ret = $this->_html->find('p.Tagline', 0);
|
||||
if (!empty($ret->plaintext)) {
|
||||
$this->_res['tagline'] = trim($ret->plaintext);
|
||||
}
|
||||
}
|
||||
if ($ret = @$this->_html->find('p.Tagline', 0)->next_sibling()->next_sibling()) {
|
||||
$this->_res['sypnosis'] = trim($ret->innertext);
|
||||
}
|
||||
|
||||
return $this->_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cast members and/or awards
|
||||
*
|
||||
* @param bool $awards - Include Awards? true/false
|
||||
*
|
||||
* @return array - cast, awards
|
||||
*/
|
||||
public function cast($awards = false)
|
||||
{
|
||||
$this->_tmpResponse = str_ireplace('Section Cast', 'scast', $this->_response);
|
||||
$this->_edithtml->load($this->_tmpResponse);
|
||||
|
||||
|
||||
if ($ret = $this->_edithtml->find('div[class=scast]', 0)) {
|
||||
$this->_tmpResponse = trim($ret->outertext);
|
||||
$ret = $this->_edithtml->load($this->_tmpResponse);
|
||||
foreach ($ret->find('a.PerformerName') as $a) {
|
||||
if ($a->plaintext !== '(bio)' && $a->plaintext !== '(interview)') {
|
||||
$this->_res['cast'][] = trim($a->plaintext);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($awards === true) {
|
||||
if ($ret->find('ul', 1)) {
|
||||
foreach ($ret->find('ul', 1)->find('li, strong') as $li) {
|
||||
$this->_res['awards'][] = trim($li->plaintext);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->_edithtml->clear();
|
||||
unset($ret, $this->_tmpResponse);
|
||||
|
||||
return $this->_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Genres, if exists return array else return false
|
||||
* @return mixed array - Genres
|
||||
*/
|
||||
public function genres()
|
||||
{
|
||||
$genres = [];
|
||||
$this->_tmpResponse = str_ireplace('Section Categories', 'scat', $this->_response);
|
||||
$this->_edithtml->load($this->_tmpResponse);
|
||||
if ($ret = $this->_edithtml->find('div[class=scat]', 0)) {
|
||||
$ret = $ret->find('p', 0);
|
||||
$this->_tmpResponse = trim($ret->outertext);
|
||||
$ret = $this->_edithtml->load($this->_tmpResponse);
|
||||
|
||||
foreach ($ret->find('a') as $categories) {
|
||||
$categories = trim($categories->plaintext);
|
||||
if (strpos($categories, ',') !== false) {
|
||||
$genres = explode(',', $categories);
|
||||
$genres = array_map('trim', $genres);
|
||||
} else {
|
||||
$genres[] = $categories;
|
||||
}
|
||||
}
|
||||
if (is_array($genres)) {
|
||||
$this->_res['genres'] = array_unique($genres);
|
||||
}
|
||||
}
|
||||
$this->_edithtml->clear();
|
||||
unset($this->_tmpResponse, $ret);
|
||||
return $this->_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Product Information and/or Features
|
||||
*
|
||||
* @param bool $features Include features? true/false
|
||||
*
|
||||
* @return array - ProductInfo/Extras = features
|
||||
*/
|
||||
public function productInfo($features = false)
|
||||
{
|
||||
$dofeature = null;
|
||||
$this->_tmpResponse = str_ireplace('Section ProductInfo', 'spdinfo', $this->_response);
|
||||
$this->_edithtml->load($this->_tmpResponse);
|
||||
if ($ret = $this->_edithtml->find('div[class=spdinfo]', 0)) {
|
||||
$this->_tmpResponse = trim($ret->outertext);
|
||||
$ret = $this->_edithtml->load($this->_tmpResponse);
|
||||
foreach ($ret->find("text") as $strong) {
|
||||
if (trim($strong->innertext) === 'Features') {
|
||||
$dofeature = true;
|
||||
}
|
||||
if ($dofeature !== true) {
|
||||
if (trim($strong->innertext) !== ' ') {
|
||||
$this->_res['productinfo'][] = trim($strong->innertext);
|
||||
}
|
||||
} else {
|
||||
if ($features === true) {
|
||||
$this->_res['extras'][] = trim($strong->innertext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
array_shift($this->_res['productinfo']);
|
||||
array_shift($this->_res['productinfo']);
|
||||
$this->_res['productinfo'] = array_chunk($this->_res['productinfo'], 2, false);
|
||||
}
|
||||
$this->_edithtml->clear();
|
||||
unset($this->_tmpResponse, $ret);
|
||||
|
||||
return $this->_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the direct link information and returns it
|
||||
* @return array|bool
|
||||
*/
|
||||
public function getDirect()
|
||||
{
|
||||
if (!empty($this->directLink) && $this->getUrl() !== false) {
|
||||
$this->_html->load($this->_response);
|
||||
return $this->getAll();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Searches xxx name.
|
||||
* @return bool - True if releases has 90% match, else false
|
||||
*/
|
||||
public function search()
|
||||
{
|
||||
if (empty($this->searchTerm)) {
|
||||
return false;
|
||||
}
|
||||
if ($this->getUrl($this->_dvdQuery . rawurlencode($this->searchTerm)) === false) {
|
||||
return false;
|
||||
} else {
|
||||
$this->_html->load($this->_response);
|
||||
if ($ret = $this->_html->find('a.boxcover', 0)) {
|
||||
$title = $ret->title;
|
||||
$title = str_replace('/XXX/', '', $title);
|
||||
$title = preg_replace('/\(.*?\)|[-._]/', ' ', $title);
|
||||
$ret = (string)trim($ret->href);
|
||||
similar_text(strtolower($this->searchTerm), strtolower($title), $p);
|
||||
if ($p >= 90) {
|
||||
$this->found = true;
|
||||
$this->_urlFound = $ret;
|
||||
$this->_directUrl = self::ADE . $ret;
|
||||
$this->_title = trim($title);
|
||||
unset($ret);
|
||||
$this->_html->clear();
|
||||
$this->getUrl($this->_urlFound);
|
||||
$this->_html->load($this->_response);
|
||||
} else {
|
||||
$this->found = false;
|
||||
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets raw html content using adeurl and any trailing url.
|
||||
*
|
||||
* @param string $trailing - required
|
||||
*
|
||||
* @return bool - true if page has content
|
||||
*/
|
||||
private function getUrl($trailing = "")
|
||||
{
|
||||
if (!empty($trailing)) {
|
||||
try {
|
||||
$this->_response = $this->client->get(self::ADE . $trailing)->getBody()->getContents();
|
||||
} catch (RequestException $e) {
|
||||
if ($e->hasResponse()) {
|
||||
if($e->getCode() === 404) {
|
||||
ColorCLI::doEcho(ColorCLI::notice('Data not available on ADE server'));
|
||||
} else if ($e->getCode() === 503) {
|
||||
ColorCLI::doEcho(ColorCLI::notice('ADE service unavailable'));
|
||||
} else {
|
||||
ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data from ADE, http error reported: ' . $e->getCode()));
|
||||
}
|
||||
}
|
||||
} catch (\RuntimeException $e) {
|
||||
ColorCLI::doEcho(ColorCLI::notice('Runtime error: ' . $e->getCode()));
|
||||
}
|
||||
}
|
||||
if (!empty($this->directLink)) {
|
||||
try {
|
||||
$this->_response = $this->client->get($this->directLink)->getBody()->getContents();
|
||||
$this->directLink = '';
|
||||
} catch (RequestException $e) {
|
||||
if ($e->hasResponse()) {
|
||||
if($e->getCode() === 404) {
|
||||
ColorCLI::doEcho(ColorCLI::notice('Data not available on ADE server'));
|
||||
} else if ($e->getCode() === 503) {
|
||||
ColorCLI::doEcho(ColorCLI::notice('ADE service unavailable'));
|
||||
} else {
|
||||
ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data from ADE, http error reported: ' . $e->getCode()));
|
||||
}
|
||||
}
|
||||
} catch (\RuntimeException $e) {
|
||||
ColorCLI::doEcho(ColorCLI::notice('Runtime error: ' . $e->getCode()));
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->_response) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->_response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets All Information from the methods
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAll()
|
||||
{
|
||||
$results = [];
|
||||
if (!empty($this->_directUrl)) {
|
||||
$results['directurl'] = $this->_directUrl;
|
||||
$results['title'] = $this->_title;
|
||||
}
|
||||
if (is_array($this->sypnosis(true))) {
|
||||
$results = array_merge($results, $this->sypnosis(true));
|
||||
}
|
||||
if (is_array($this->productInfo(true))) {
|
||||
$results = array_merge($results, $this->productInfo(true));
|
||||
}
|
||||
if (is_array($this->cast(true))) {
|
||||
$results = array_merge($results, $this->cast(true));
|
||||
}
|
||||
if (is_array($this->genres())) {
|
||||
$results = array_merge($results, $this->genres());
|
||||
}
|
||||
if (is_array($this->covers())) {
|
||||
$results = array_merge($results, $this->covers());
|
||||
}
|
||||
if (is_array($this->trailers())) {
|
||||
$results = array_merge($results, $this->trailers());
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
-406
@@ -1,406 +0,0 @@
|
||||
<?php
|
||||
namespace nntmux;
|
||||
|
||||
use GuzzleHttp\Cookie\CookieJar;
|
||||
use GuzzleHttp\Cookie\SetCookie;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use GuzzleHttp\Client;
|
||||
use nntmux\db\DB;
|
||||
|
||||
class AEBN
|
||||
{
|
||||
/**
|
||||
* Cookie File location used in curl
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $cookie = "";
|
||||
|
||||
/**
|
||||
* Keyword to search
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $searchTerm = "";
|
||||
|
||||
/**
|
||||
* Url Constants used within this class
|
||||
*/
|
||||
const AEBNGURL = 'http://gay.theater.aebn.net';
|
||||
const AEBNSURL = 'http://straight.theater.aebn.net';
|
||||
const IF18 = 'http://straight.theater.aebn.net/dispatcher/frontDoor?genreId=101&theaterId=13992&locale=en&refid=AEBN-000001';
|
||||
const TRAILINGSEARCH = '/dispatcher/fts?theaterId=13992&genreId=101&locale=en&count=30&imageType=Large&targetSearchMode=basic&isAdvancedSearch=false&isFlushAdvancedSearchCriteria=false&sortType=Relevance&userQuery=title%3A+%2B';
|
||||
const TRAILERURL = '/dispatcher/previewPlayer?locale=en&theaterId=13992&genreId=101&movieId=';
|
||||
|
||||
/**
|
||||
* Sets the current site to search
|
||||
* @var string
|
||||
*/
|
||||
protected $_currentSite = 'straight';
|
||||
|
||||
/**
|
||||
* Direct Url in getAll method
|
||||
* @var string
|
||||
*/
|
||||
protected $_directUrl = '';
|
||||
|
||||
/**
|
||||
* Simple Html Dom Object
|
||||
* @var \simple_html_dom
|
||||
*/
|
||||
protected $_html;
|
||||
|
||||
/**
|
||||
* @var Client
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* @var DB
|
||||
*/
|
||||
protected $pdo;
|
||||
|
||||
/**
|
||||
* Post Parameters to use with curl
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_postParams = [];
|
||||
|
||||
/**
|
||||
* Raw Html response from curl
|
||||
*
|
||||
*/
|
||||
protected $_response;
|
||||
|
||||
/**
|
||||
* Returned results in all methods except search/geturl
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_res = [
|
||||
'backcover' => [],
|
||||
'boxcover' => [],
|
||||
'cast' => [],
|
||||
'director' => [],
|
||||
'genres' => [],
|
||||
'productinfo' => [],
|
||||
'synopsis' => [],
|
||||
'trailers' => ['url' =>[]],
|
||||
];
|
||||
|
||||
/**
|
||||
* If searchTerm is found
|
||||
* @var bool
|
||||
*/
|
||||
protected $_searchFound = false;
|
||||
|
||||
/**
|
||||
* Sets title in getAll method
|
||||
* @var string
|
||||
*/
|
||||
protected $_title = '';
|
||||
|
||||
/**
|
||||
* Trailing Url
|
||||
* @var string
|
||||
*/
|
||||
protected $_trailUrl = '';
|
||||
|
||||
/**
|
||||
* Used in __construct
|
||||
* @var array - straight, gay
|
||||
*/
|
||||
protected $_whichSite = [];
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Sets the variables that used throughout the class
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->_whichSite = ['straight' => self::AEBNSURL, 'gay' => self::AEBNGURL];
|
||||
$this->_html = new \simple_html_dom();
|
||||
$this->client = new Client();
|
||||
$this->cookiejar = new CookieJar();
|
||||
$this->pdo = new DB();
|
||||
if (!empty($this->cookie)) {
|
||||
$cookieJar = $this->cookiejar->setCookie(SetCookie::fromString($this->cookie));
|
||||
$this->client = new Client(['cookies' => $cookieJar]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If they arent' removed from memory. Force them.
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
$this->_html->clear();
|
||||
unset($this->_response, $this->_res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Trailer URL .. will be processed in XXX insertswf
|
||||
*
|
||||
* @return array|bool
|
||||
*/
|
||||
public function trailers()
|
||||
{
|
||||
$ret = $this->_html->find('a[itemprop=trailer]', 0);
|
||||
if (preg_match('/movieId=(?<movieid>\d+)&/', trim($ret->href), $matches)) {
|
||||
$movieid = $matches['movieid'];
|
||||
$this->_res['trailers']['url'] = $this->_whichSite[$this->_currentSite] . self::TRAILERURL . $movieid;
|
||||
}
|
||||
|
||||
return $this->_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the front and back cover of the box
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function covers()
|
||||
{
|
||||
if ($ret = $this->_html->find('div#md-boxCover, img[itemprop=thumbnailUrl]', 1)) {
|
||||
$ret = trim($ret->src);
|
||||
if (strpos($ret, '//') === 0) {
|
||||
$ret = 'http:' . $ret;
|
||||
}
|
||||
$this->_res['boxcover'] = str_ireplace('160w.jpg', 'xlf.jpg', $ret);
|
||||
$this->_res['backcover'] = str_ireplace('160w.jpg', 'xlb.jpg', $ret);
|
||||
}
|
||||
return $this->_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Genres "Categories".
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function genres()
|
||||
{
|
||||
if ($ret = $this->_html->find('div.md-detailsCategories', 0)) {
|
||||
foreach ($ret->find('a[itemprop=genre]') as $genre) {
|
||||
$this->_res['genres'][] = trim($genre->plaintext);
|
||||
}
|
||||
}
|
||||
$this->_res['genres'] = array_unique($this->_res['genres']);
|
||||
return $this->_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Cast Members "Stars" and Director if any
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function cast()
|
||||
{
|
||||
if ($ret = $this->_html->find('div.starsFull', 0)) {
|
||||
foreach ($ret->find('span[itemprop=name]') as $star) {
|
||||
$this->_res['cast'][] = trim($star->plaintext);
|
||||
}
|
||||
} else {
|
||||
if ($ret = $this->_html->find('div.detailsLink', 0)) {
|
||||
foreach ($ret->find('span') as $star) {
|
||||
if (strpos($star->plaintext, '/More/') !== false && strpos($star->plaintext, '/Stars/') !== false) {
|
||||
$this->_res['cast'][] = trim($star->plaintext);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the product information
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function productInfo()
|
||||
{
|
||||
if ($ret = $this->_html->find('div#md-detailsLeft', 0)) {
|
||||
foreach ($ret->find('div') as $div) {
|
||||
foreach ($div->find('span') as $span) {
|
||||
$span->plaintext = rawurldecode($span->plaintext);
|
||||
$span->plaintext = preg_replace('/ /', '', $span->plaintext);
|
||||
$this->_res['productinfo'][] = trim($span->plaintext);
|
||||
}
|
||||
}
|
||||
if (false !== $key = array_search('Running Time:', $this->_res['productinfo'])) {
|
||||
unset($this->_res['productinfo'][$key + 2]);
|
||||
}
|
||||
if (false !== $key = array_search("Director:", $this->_res['productinfo'])) {
|
||||
$this->_res['director'] = $this->_res['productinfo'][$key + 1];
|
||||
unset($this->_res['productinfo'][$key], $this->_res['productinfo'][$key + 1]);
|
||||
}
|
||||
$this->_res['productinfo'] = array_chunk($this->_res['productinfo'], 2, false);
|
||||
}
|
||||
|
||||
return $this->_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the synopsis "plot"
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
*/
|
||||
public function synopsis()
|
||||
{
|
||||
if ($ret = $this->_html->find('span[itemprop=about]', 0)) {
|
||||
if ($ret === null) {
|
||||
if ($ret = $this->_html->find('div.movieDetailDescription', 0)) {
|
||||
$this->_res['synopsis'] = trim($ret->plaintext);
|
||||
$this->_res['synopsis'] = preg_replace('/Description:\s/', "", $this->_res['plot']);
|
||||
}
|
||||
} else {
|
||||
$this->_res['synopsis'] = trim($ret->plaintext);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches for a XXX name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function search()
|
||||
{
|
||||
if (empty($this->searchTerm)) {
|
||||
return false;
|
||||
}
|
||||
$this->_trailUrl = self::TRAILINGSEARCH . urlencode($this->searchTerm);
|
||||
if ($this->getUrl($this->_currentSite) === false) {
|
||||
return false;
|
||||
} else {
|
||||
if ($count = count($this->_html->find('div.movie'))) {
|
||||
$i = 1;
|
||||
foreach ($this->_html->find('div.movie') as $movie) {
|
||||
$string = 'a#FTSMovieSearch_link_title_detail_' . $i;
|
||||
if ($ret = $movie->find($string, 0)) {
|
||||
$title = str_replace('/XXX/', '', $ret->title);
|
||||
$title = preg_replace('/\(.*?\)|[-._]/', ' ', $title);
|
||||
$title = trim($title);
|
||||
similar_text(strtolower($this->searchTerm), strtolower($title), $p);
|
||||
if ($p >= 90) {
|
||||
$this->_title = trim($ret->title);
|
||||
$this->_trailUrl = html_entity_decode($ret->href);
|
||||
$this->_directUrl = $this->_whichSite[$this->_currentSite] . $this->_trailUrl;
|
||||
$this->getUrl($this->_currentSite);
|
||||
return true;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
if ($i === $count || $count === 0) {
|
||||
if ($this->_currentSite === 'gay') {
|
||||
return false;
|
||||
}
|
||||
$this->_currentSite = 'gay';
|
||||
$this->search();
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all the information
|
||||
*
|
||||
* @return array|bool
|
||||
*/
|
||||
public function getAll()
|
||||
{
|
||||
$results = [];
|
||||
if (!empty($this->_directUrl)) {
|
||||
$results['title'] = $this->_title;
|
||||
$results['directurl'] = $this->_directUrl;
|
||||
}
|
||||
if (is_array($this->synopsis())) {
|
||||
$results = array_merge($results, $this->synopsis());
|
||||
}
|
||||
if (is_array($this->productInfo())) {
|
||||
$results = array_merge($results, $this->productInfo());
|
||||
}
|
||||
if (is_array($this->cast())) {
|
||||
$results = array_merge($results, $this->cast());
|
||||
}
|
||||
if (is_array($this->genres())) {
|
||||
$results = array_merge($results, $this->genres());
|
||||
}
|
||||
$covers = $this->covers();
|
||||
if (is_array($covers)) {
|
||||
$results = array_merge($results, $covers);
|
||||
}
|
||||
if (is_array($this->trailers())) {
|
||||
$results = array_merge($results, $this->trailers());
|
||||
}
|
||||
if (empty($results) === true) {
|
||||
return false;
|
||||
} else {
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Raw html of webpage
|
||||
*
|
||||
* @param string $site
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function getUrl($site = 'straight')
|
||||
{
|
||||
if (!empty($this->_trailUrl)) {
|
||||
try {
|
||||
$this->_response = $this->client->get($this->_whichSite[$site] . $this->_trailUrl)->getBody()->getContents();
|
||||
} catch (RequestException $e) {
|
||||
if ($e->hasResponse()) {
|
||||
if($e->getCode() === 404) {
|
||||
ColorCLI::doEcho(ColorCLI::notice('Data not available on AEBN server'));
|
||||
} else if ($e->getCode() === 503) {
|
||||
ColorCLI::doEcho(ColorCLI::notice('AEBN service unavailable'));
|
||||
} else {
|
||||
ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data from AEBN, http error reported: ' . $e->getCode()));
|
||||
}
|
||||
}
|
||||
} catch (\RuntimeException $e) {
|
||||
ColorCLI::doEcho(ColorCLI::notice('Runtime error: ' . $e->getCode()));
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
$this->_response = $this->client->get(self::IF18)->getBody()->getContents();
|
||||
} catch (RequestException $e) {
|
||||
if ($e->hasResponse()) {
|
||||
if($e->getCode() === 404) {
|
||||
ColorCLI::doEcho(ColorCLI::notice('Data not available on AEBN server'));
|
||||
} else if ($e->getCode() === 503) {
|
||||
ColorCLI::doEcho(ColorCLI::notice('AEBN service unavailable'));
|
||||
} else {
|
||||
ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data from AEBN, http error reported: ' . $e->getCode()));
|
||||
}
|
||||
}
|
||||
} catch (\RuntimeException $e) {
|
||||
ColorCLI::doEcho(ColorCLI::notice('Runtime error: ' . $e->getCode()));
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->_response) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->_html->load($this->_response);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -103,9 +103,9 @@ class DnzbFailures
|
||||
*
|
||||
* @param string $guid
|
||||
* @param string $userid
|
||||
* @return string
|
||||
* @return string|array
|
||||
*/
|
||||
public function getAlternate($guid, $userid): string
|
||||
public function getAlternate($guid, $userid)
|
||||
{
|
||||
$rel = $this->pdo->queryOneRow(
|
||||
sprintf('
|
||||
|
||||
-192
@@ -1,192 +0,0 @@
|
||||
<?php
|
||||
namespace nntmux;
|
||||
|
||||
use nntmux\utility\Utility;
|
||||
|
||||
class IAFD
|
||||
{
|
||||
public $classUsed = '';
|
||||
public $cookie = '';
|
||||
public $directUrl;
|
||||
public $searchTerm = '';
|
||||
public $title = '';
|
||||
|
||||
const ADE = 'Adult DVD Empire';
|
||||
const ADM = 'AdultDVDMarketplace';
|
||||
const IAFDSEARCHURL = 'http://www.iafd.com/results.asp?searchtype=title&searchstring=';
|
||||
const IAFDURL = 'http://www.iafd.com';
|
||||
|
||||
protected $_dvdFound = false;
|
||||
protected $_doSearch = false;
|
||||
protected $_getRedirect;
|
||||
protected $_html;
|
||||
protected $_res = [];
|
||||
protected $_response;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->_html = new \simple_html_dom();
|
||||
if (!empty($this->cookie)) {
|
||||
@$this->getUrl();
|
||||
}
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
$this->_html->clear();
|
||||
unset($this->response, $this->res);
|
||||
}
|
||||
|
||||
public function findme()
|
||||
{
|
||||
if ($this->search() === true) {
|
||||
if ($this->_html->find('div#commerce', 0)) {
|
||||
foreach ($this->_html->find('div#commerce') as $e) {
|
||||
foreach ($e->find('h4, p.item') as $h4) {
|
||||
//echo ($h4->innertext) ."\n";
|
||||
if (trim($h4->plaintext) === 'DVD') {
|
||||
$this->_dvdFound = true;
|
||||
$h4 = null;
|
||||
}
|
||||
if ($this->_dvdFound === true && isset($h4)) {
|
||||
foreach ($h4->find('a') as $alink) {
|
||||
$compare = trim($alink->innertext);
|
||||
if ($compare === self::ADE && !empty($compare)) {
|
||||
$this->classUsed = 'ade';
|
||||
$this->_getRedirect = self::IAFDURL . trim($alink->href);
|
||||
$this->directUrl = $this->getUrl();
|
||||
$this->directUrl = preg_replace('/\?(.*)/', '', $this->directUrl);
|
||||
$this->_dvdFound = false;
|
||||
break;
|
||||
}
|
||||
if ($compare === self::ADM && !empty($compare)) {
|
||||
$this->classUsed = 'adm';
|
||||
$this->_getRedirect = self::IAFDURL . trim($alink->href);
|
||||
$this->directUrl = $this->getUrl();
|
||||
$this->directUrl = preg_replace('/\?(.*)/',
|
||||
'',
|
||||
$this->directUrl);
|
||||
$this->_dvdFound = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (empty($this->classUsed)) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private function search()
|
||||
{
|
||||
|
||||
if (empty($this->searchTerm)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->_doSearch = true;
|
||||
|
||||
if ($this->getUrl() === false) {
|
||||
return false;
|
||||
} else {
|
||||
$firsttitle = null;
|
||||
$secondtitle = null;
|
||||
if ($ret = $this->_html->find('div#moviedata, h2, dt', 0)) {
|
||||
if ($ret->find('h2', 0)) {
|
||||
$firsttitle = $ret->find('h2', 0)->innertext;
|
||||
if (preg_match('/Movie Titles/', $firsttitle)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ($ret->find('dt', 0)) {
|
||||
$secondtitle = $ret->find('dd', 0)->innertext;
|
||||
}
|
||||
unset($ret);
|
||||
if (isset($secondtitle) || isset($firsttitle)) {
|
||||
$firsttitle = preg_replace('/\(([\d]+)\)/', '', $firsttitle);
|
||||
$firsttitle = str_replace('/XXX/', '', $firsttitle);
|
||||
$firsttitle = preg_replace('/\(.*?\)|[-._]/', '', $firsttitle);
|
||||
$secondtitle = preg_replace('/\(([\d]+)\)/', '', $secondtitle);
|
||||
$secondtitle = str_replace('/XXX/', '', $secondtitle);
|
||||
$secondtitle = preg_replace('/\(.*?\)|[-._]/', '', $secondtitle);
|
||||
similar_text(strtolower($this->searchTerm), strtolower(trim($firsttitle)), $p);
|
||||
if ($p >= 90) {
|
||||
$this->title = trim($firsttitle);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
similar_text(strtolower($this->searchTerm),
|
||||
strtolower(trim($secondtitle)), $p);
|
||||
if ($p >= 90) {
|
||||
$this->title = trim($secondtitle);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getUrl()
|
||||
{
|
||||
if ($this->_doSearch === true) {
|
||||
$ch = curl_init(self::IAFDSEARCHURL . urlencode($this->searchTerm));
|
||||
} else {
|
||||
if (empty($this->_getRedirect)) {
|
||||
$ch = curl_init(self::IAFDURL);
|
||||
} else {
|
||||
$ch = curl_init($this->_getRedirect);
|
||||
}
|
||||
}
|
||||
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
curl_setopt($ch, CURLOPT_VERBOSE, 0);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1944.0 Safari/537.36');
|
||||
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
|
||||
|
||||
if (!empty($this->cookie)) {
|
||||
curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookie);
|
||||
curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookie);
|
||||
}
|
||||
|
||||
curl_setopt_array($ch, Utility::curlSslContextOptions());
|
||||
$this->_response = curl_exec($ch);
|
||||
|
||||
if (!empty($this->_getRedirect)) {
|
||||
$this->_getRedirect = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
|
||||
curl_close($ch);
|
||||
return $this->_getRedirect;
|
||||
}
|
||||
|
||||
if (!$this->_response) {
|
||||
curl_close($ch);
|
||||
|
||||
return false;
|
||||
}
|
||||
curl_close($ch);
|
||||
|
||||
if ($this->_doSearch === true) {
|
||||
$this->_html->load($this->_response);
|
||||
$this->_doSearch = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+16
-200
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
namespace nntmux;
|
||||
|
||||
use Monolog\Logger as MonoLogger;
|
||||
use Monolog\Handler\StreamHandler;
|
||||
/**
|
||||
* Show log message to CLI/Web and log it to a file.
|
||||
* Turn these on in automated.config.php
|
||||
@@ -48,11 +51,9 @@ class Logger
|
||||
private $severity = '';
|
||||
|
||||
/**
|
||||
* Class instance of colorCLI
|
||||
* @var object
|
||||
* @access private
|
||||
* @var MonoLogger
|
||||
*/
|
||||
private $colorCLI;
|
||||
private $logger;
|
||||
|
||||
/**
|
||||
* Should we echo to CLI or web?
|
||||
@@ -168,6 +169,8 @@ class Logger
|
||||
*
|
||||
* @access public
|
||||
* @throws LoggerException
|
||||
* @throws \Exception
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function __construct(array $options = [])
|
||||
{
|
||||
@@ -182,8 +185,6 @@ class Logger
|
||||
];
|
||||
$options += $defaults;
|
||||
|
||||
$this->colorCLI = ($options['ColorCLI'] instanceof ColorCLI ? $options['ColorCLI'] : new ColorCLI());
|
||||
|
||||
$this->getSettings();
|
||||
|
||||
$this->currentLogFolder = (
|
||||
@@ -198,21 +199,12 @@ class Logger
|
||||
: $this->currentLogName
|
||||
) . '.log';
|
||||
|
||||
$this->setLogFile();
|
||||
|
||||
$this->outputCLI = (strtolower(PHP_SAPI) === 'cli');
|
||||
$this->isWindows = (strtolower(substr(PHP_OS, 0, 3)) === 'win');
|
||||
$this->isWindows = stripos(PHP_OS, 'win') === 0;
|
||||
$this->timeStart = time();
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the log file resource.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
$this->closeFile();
|
||||
$this->logger = new MonoLogger('nntmux');
|
||||
$this->logger->pushHandler(new StreamHandler($this->currentLogFolder . $this->currentLogName, MonoLogger::DEBUG));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -283,17 +275,14 @@ class Logger
|
||||
round(
|
||||
$actualUsage
|
||||
/
|
||||
pow(
|
||||
1024,
|
||||
($i =
|
||||
(1024 ** ($i =
|
||||
floor(
|
||||
log(
|
||||
$actualUsage,
|
||||
1024
|
||||
)
|
||||
)
|
||||
)
|
||||
), 2
|
||||
)), 2
|
||||
)
|
||||
), 4, '~~~', STR_PAD_LEFT
|
||||
) .
|
||||
@@ -353,13 +342,14 @@ class Logger
|
||||
*
|
||||
* @param string $folder Folder where the log should be stored.
|
||||
* @param string $fileName Name of the file (must be alphanumeric and contain no file extensions).
|
||||
*
|
||||
* @access public
|
||||
* @throws \nntmux\LoggerException
|
||||
*/
|
||||
public function changeLogFileLocation($folder, $fileName)
|
||||
{
|
||||
$this->currentLogFolder = $folder;
|
||||
$this->currentLogName = $fileName;
|
||||
$this->setLogFile();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -382,34 +372,6 @@ class Logger
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the path and name for the log file.
|
||||
*
|
||||
* @throws LoggerException
|
||||
* @access private
|
||||
*/
|
||||
private function setLogFile()
|
||||
{
|
||||
// Only run this if NN_LOGGING is on.
|
||||
if (!NN_LOGGING) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->closeFile();
|
||||
|
||||
$this->logPath = $this->currentLogFolder . $this->currentLogName;
|
||||
|
||||
if (!is_dir($this->currentLogFolder)) {
|
||||
$this->createFolder();
|
||||
}
|
||||
|
||||
$this->initiateLog();
|
||||
|
||||
// Check if we need to rotate the log if it exceeds max size..
|
||||
$this->rotateLog();
|
||||
|
||||
$this->openFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get/set all settings.
|
||||
@@ -430,34 +392,6 @@ class Logger
|
||||
$this->currentLogFolder = $paths['LogFolder'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the file resource.
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
private function closeFile()
|
||||
{
|
||||
if (is_resource($this->resource)) {
|
||||
@fclose($this->resource);
|
||||
}
|
||||
$this->resource = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the log file.
|
||||
*
|
||||
* @throws LoggerException
|
||||
*/
|
||||
private function openFile()
|
||||
{
|
||||
if (!is_resource($this->resource)) {
|
||||
$this->resource = @fopen($this->logPath, 'ab');
|
||||
|
||||
if (!$this->resource) {
|
||||
throw new LoggerException('Unable to open log file ' . $this->logPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message to file.
|
||||
@@ -471,17 +405,7 @@ class Logger
|
||||
return;
|
||||
}
|
||||
|
||||
clearstatcache(true, $this->logPath);
|
||||
|
||||
// Check if we should rotate the logs.
|
||||
$this->rotateLog();
|
||||
|
||||
// If another process deleted the file, try to re-open it.
|
||||
if (!is_file($this->logPath)) {
|
||||
$this->setLogFile();
|
||||
}
|
||||
|
||||
@fwrite($this->resource, $this->logMessage . PHP_EOL);
|
||||
$this->logger->info($this->logMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -502,114 +426,6 @@ class Logger
|
||||
return $this->dateCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the log folder exists, if not create it.
|
||||
*
|
||||
* @access private
|
||||
* @throws LoggerException
|
||||
*/
|
||||
private function createFolder()
|
||||
{
|
||||
// Check if the log folder exists, create it if not.
|
||||
if (!is_dir($this->currentLogFolder)) {
|
||||
$old = umask(0777);
|
||||
if (!mkdir($this->currentLogFolder)) {
|
||||
throw new LoggerException('Unable to create log file folder ' . $this->currentLogFolder);
|
||||
}
|
||||
chmod($this->currentLogFolder, 0777);
|
||||
umask($old);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initiate a log file.
|
||||
*
|
||||
* @access private
|
||||
* @throws LoggerException
|
||||
*/
|
||||
private function initiateLog()
|
||||
{
|
||||
if (!is_file($this->logPath)) {
|
||||
if (!file_put_contents(
|
||||
$this->logPath,
|
||||
'[' . $this->getDate() . '] [INIT] [Initiating new log file.]' . PHP_EOL)
|
||||
) {
|
||||
throw new LoggerException('Unable to create new log file ' . $this->logPath);
|
||||
}
|
||||
chmod($this->logPath, 0664);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotate log file if it exceeds a certain size.
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
private function rotateLog()
|
||||
{
|
||||
// Check if we need to rotate the log if it exceeds max size..
|
||||
$logSize = filesize($this->logPath);
|
||||
if ($logSize === false) {
|
||||
return;
|
||||
} else if ($logSize >= ($this->maxLogSize * 1024 * 1024)) {
|
||||
$this->closeFile();
|
||||
$this->compressLog();
|
||||
$this->initiateLog();
|
||||
$this->pruneLogs();
|
||||
$this->openFile();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compress the old log using GZip.
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
private function compressLog()
|
||||
{
|
||||
$handle = @fopen($this->logPath, 'rb');
|
||||
$zipHandle = @gzopen(str_replace('.log', '', $this->logPath) . '.' . time() . '.gz', 'w6');
|
||||
if (!$handle || !$zipHandle) {
|
||||
return;
|
||||
}
|
||||
|
||||
while (!feof($handle)) {
|
||||
$data = @fread($handle, 32768);
|
||||
@gzwrite($zipHandle, $data);
|
||||
}
|
||||
|
||||
@fclose($handle);
|
||||
@gzclose($zipHandle);
|
||||
|
||||
// Delete the original uncompressed log file.
|
||||
unlink($this->logPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete old logs (if we have more than $this->maxLogs).
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
private function pruneLogs()
|
||||
{
|
||||
// Get all the logs with the name.
|
||||
$logs = glob(str_replace('.log', '', $this->logPath) . '.[0-9]*.gz');
|
||||
|
||||
// If there are no old logs or less than maxLogs return false.
|
||||
if (!$logs || (count($logs) < $this->maxLogs)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Sort the logs alphabetically, so the oldest ones are at the top, the new at the bottom.
|
||||
asort($logs);
|
||||
|
||||
// Remove all new logs from array (all elements under the last 51 elements of the array).
|
||||
array_splice($logs, -$this->maxLogs+1);
|
||||
|
||||
// Delete all the logs left in the array.
|
||||
array_map('unlink', $logs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Echo log message to CLI or web.
|
||||
*
|
||||
@@ -623,7 +439,7 @@ class Logger
|
||||
|
||||
// Check if this is CLI or web.
|
||||
if ($this->outputCLI) {
|
||||
echo $this->colorCLI->debug($this->logMessage);
|
||||
ColorCLI::doEcho(ColorCLI::debug($this->logMessage));
|
||||
} else {
|
||||
echo '<pre>' . $this->logMessage . '</pre><br />';
|
||||
}
|
||||
|
||||
+13
-12
@@ -16,13 +16,13 @@ class Logging
|
||||
private $newLine;
|
||||
|
||||
/**
|
||||
* @var object DB Class instance.
|
||||
* @var DB Class instance.
|
||||
* @access public
|
||||
*/
|
||||
public $pdo;
|
||||
|
||||
/**
|
||||
* @var object Class instance.
|
||||
* @var ColorCLI
|
||||
* @access public
|
||||
*/
|
||||
public $colorCLI;
|
||||
@@ -51,7 +51,7 @@ class Logging
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function get()
|
||||
public function get(): array
|
||||
{
|
||||
return $this->pdo->query('SELECT * FROM logging');
|
||||
}
|
||||
@@ -63,28 +63,29 @@ class Logging
|
||||
* @param string $host
|
||||
*
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function LogBadPasswd($username = '', $host = '')
|
||||
public function LogBadPasswd($username = '', $host = ''): void
|
||||
{
|
||||
// If logggingopt is = 0, then we do nothing, 0 = logging off.
|
||||
$loggingOpt = Settings::value('site.main.loggingopt');
|
||||
$logFile = Settings::value('site.main.logfile');
|
||||
if ($loggingOpt == '1') {
|
||||
if ((int)$loggingOpt === 1) {
|
||||
$this->pdo->queryInsert(sprintf('INSERT INTO logging (time, username, host) VALUES (NOW(), %s, %s)',
|
||||
$this->pdo->escapeString($username), $this->pdo->escapeString($host)));
|
||||
} else if ($loggingOpt == '2') {
|
||||
} else if ((int)$loggingOpt === 2) {
|
||||
$this->pdo->queryInsert(sprintf('INSERT INTO logging (time, username, host) VALUES (NOW(), %s, %s)',
|
||||
$this->pdo->escapeString($username), $this->pdo->escapeString($host)));
|
||||
$logData = date('M d H:i:s ') . "Login Failed for " . $username . " from " . $host . "." .
|
||||
$logData = date('M d H:i:s ') . 'Login Failed for ' . $username . ' from ' . $host . '.' .
|
||||
$this->newLine;
|
||||
if (!empty($logFile)) {
|
||||
if ($logFile !== null) {
|
||||
file_put_contents($logFile, $logData, FILE_APPEND);
|
||||
}
|
||||
} else if ($loggingOpt == '3') {
|
||||
} else if ((int)$loggingOpt === 3) {
|
||||
$logData = date('M d H:i:s ') . 'Login Failed for ' . $username . ' from ' . $host . '.' . $this->newLine;
|
||||
if (!empty($logFile)) {
|
||||
if ($logFile !== null) {
|
||||
file_put_contents($logFile, $logData, FILE_APPEND);
|
||||
}
|
||||
}
|
||||
@@ -95,7 +96,7 @@ class Logging
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function getTopCombined()
|
||||
public function getTopCombined(): array
|
||||
{
|
||||
return $this->pdo->query('SELECT MAX(time) AS time, username, host, COUNT(host) AS count FROM logging GROUP BY host, username ORDER BY count DESC LIMIT 10');
|
||||
}
|
||||
@@ -105,7 +106,7 @@ class Logging
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function getTopIPs()
|
||||
public function getTopIPs(): array
|
||||
{
|
||||
return $this->pdo->query('SELECT MAX(time) AS time, host, COUNT(host) AS count FROM logging GROUP BY host ORDER BY count DESC LIMIT 10');
|
||||
}
|
||||
|
||||
+16
-16
@@ -148,7 +148,7 @@ class NNTP extends \Net_NNTP_Client
|
||||
public function doConnect($compression = true, $alternate = false)
|
||||
{
|
||||
if (// (Alternate is wanted, AND current server is alt, OR Alternate is not wanted AND current is main.) AND
|
||||
(($alternate && $this->_currentServer === getenv('NNTP_SERVER_A')) || (!$alternate && $this->_currentServer === getenv('NNTP_SERVER'))) &&
|
||||
(($alternate && $this->_currentServer === env('NNTP_SERVER_A')) || (!$alternate && $this->_currentServer === env('NNTP_SERVER'))) &&
|
||||
// Don't reconnect to usenet if:
|
||||
// We are already connected to usenet.
|
||||
parent::_isConnected()
|
||||
@@ -163,19 +163,19 @@ class NNTP extends \Net_NNTP_Client
|
||||
|
||||
// Set variables to connect based on if we are using the alternate provider or not.
|
||||
if (!$alternate) {
|
||||
$sslEnabled = getenv('NNTP_SSLENABLED') ? true : false;
|
||||
$this->_currentServer = getenv('NNTP_SERVER');
|
||||
$this->_currentPort = getenv('NNTP_PORT');
|
||||
$userName = getenv('NNTP_USERNAME');
|
||||
$password = getenv('NNTP_PASSWORD');
|
||||
$socketTimeout = !empty(getenv('NNTP_SOCKET_TIMEOUT')) ? getenv('NNTP_SOCKET_TIMEOUT') : $this->_socketTimeout;
|
||||
$sslEnabled = env('NNTP_SSLENABLED') ? true : false;
|
||||
$this->_currentServer = env('NNTP_SERVER');
|
||||
$this->_currentPort = env('NNTP_PORT');
|
||||
$userName = env('NNTP_USERNAME');
|
||||
$password = env('NNTP_PASSWORD');
|
||||
$socketTimeout = !empty(env('NNTP_SOCKET_TIMEOUT')) ? env('NNTP_SOCKET_TIMEOUT') : $this->_socketTimeout;
|
||||
} else {
|
||||
$sslEnabled = getenv('NNTP_SSLENABLED_A') ? true : false;
|
||||
$this->_currentServer = getenv('NNTP_SERVER_A');
|
||||
$this->_currentPort = getenv('NNTP_PORT_A');
|
||||
$userName = getenv('NNTP_USERNAME_A');
|
||||
$password = getenv('NNTP_PASSWORD_A');
|
||||
$socketTimeout = !empty(getenv('NNTP_SOCKET_TIMEOUT_A')) ? getenv('NNTP_SOCKET_TIMEOUT_A') : $this->_socketTimeout;
|
||||
$sslEnabled = env('NNTP_SSLENABLED_A') ? true : false;
|
||||
$this->_currentServer = env('NNTP_SERVER_A');
|
||||
$this->_currentPort = env('NNTP_PORT_A');
|
||||
$userName = env('NNTP_USERNAME_A');
|
||||
$password = env('NNTP_PASSWORD_A');
|
||||
$socketTimeout = !empty(env('NNTP_SOCKET_TIMEOUT_A')) ? env('NNTP_SOCKET_TIMEOUT_A') : $this->_socketTimeout;
|
||||
}
|
||||
|
||||
$enc = ($sslEnabled ? ' (ssl)' : ' (non-ssl)');
|
||||
@@ -581,7 +581,7 @@ class NNTP extends \Net_NNTP_Client
|
||||
if ($alternate === true) {
|
||||
if ($aConnected === false) {
|
||||
// Check if the current connected server is the alternate or not.
|
||||
if ($this->_currentServer === getenv('NNTP_SERVER')) {
|
||||
if ($this->_currentServer === env('NNTP_SERVER')) {
|
||||
// It's the main so connect to the alternate.
|
||||
$aConnected = $nntp->doConnect(true, true);
|
||||
} else {
|
||||
@@ -1483,13 +1483,13 @@ class NNTP extends \Net_NNTP_Client
|
||||
$retVal = true;
|
||||
} else {
|
||||
switch ($this->_currentServer) {
|
||||
case getenv('NNTP_SERVER'):
|
||||
case env('NNTP_SERVER'):
|
||||
if (is_resource($this->_socket)) {
|
||||
$this->doQuit(true);
|
||||
}
|
||||
$retVal = $this->doConnect();
|
||||
break;
|
||||
case getenv('NNTP_SERVER_A'):
|
||||
case env('NNTP_SERVER_A'):
|
||||
if (is_resource($this->_socket)) {
|
||||
$this->doQuit(true);
|
||||
}
|
||||
|
||||
+4
-4
@@ -90,12 +90,12 @@ class Tmux
|
||||
public function getConnectionsInfo($constants)
|
||||
{
|
||||
$runVar['connections']['port_a'] = $runVar['connections']['host_a'] = $runVar['connections']['ip_a'] = false;
|
||||
$runVar['connections']['port'] = getenv('NNTP_PORT');
|
||||
$runVar['connections']['host'] = getenv('NNTP_SERVER');
|
||||
$runVar['connections']['port'] = env('NNTP_PORT');
|
||||
$runVar['connections']['host'] = env('NNTP_SERVER');
|
||||
$runVar['connections']['ip'] = gethostbyname($runVar['connections']['host']);
|
||||
if ($constants['alternate_nntp'] === '1') {
|
||||
$runVar['connections']['port_a'] = getenv('NNTP_PORT_A');
|
||||
$runVar['connections']['host_a'] = getenv('NNTP_SERVER_A');
|
||||
$runVar['connections']['port_a'] = env('NNTP_PORT_A');
|
||||
$runVar['connections']['host_a'] = env('NNTP_SERVER_A');
|
||||
$runVar['connections']['ip_a'] = gethostbyname($runVar['connections']['host_a']);
|
||||
}
|
||||
return $runVar['connections'];
|
||||
|
||||
+1
-2
@@ -229,8 +229,7 @@ class TmuxRun extends Tmux
|
||||
|
||||
$log = $this->writelog($runVar['panes']['two'][2]);
|
||||
shell_exec("tmux respawnp -t{$runVar['constants']['tmux_session']}:2.2 ' \
|
||||
{$runVar['commands']['_phpn']} {$runVar['paths']['misc']}update/postprocess.php amazon true $log; \
|
||||
{$runVar['commands']['_php']} {$runVar['paths']['misc']}testing/PostProc/getXXXSamples.php true 100 $log; date +\"{$this->_dateFormat}\"; {$runVar['commands']['_sleep']} {$runVar['settings']['post_timer_amazon']}' 2>&1 1> /dev/null"
|
||||
{$runVar['commands']['_phpn']} {$runVar['paths']['misc']}update/postprocess.php amazon true $log; date +\"{$this->_dateFormat}\"; {$runVar['commands']['_sleep']} {$runVar['settings']['post_timer_amazon']}' 2>&1 1> /dev/null"
|
||||
);
|
||||
break;
|
||||
case $runVar['settings']['post_amazon'] == 1 && $runVar['settings']['processbooks'] == 0
|
||||
|
||||
+282
-283
@@ -4,6 +4,11 @@ namespace nntmux;
|
||||
|
||||
use app\models\Settings;
|
||||
use nntmux\db\DB;
|
||||
use nntmux\processing\adult\AEBN;
|
||||
use nntmux\processing\adult\ADM;
|
||||
use nntmux\processing\adult\ADE;
|
||||
use nntmux\processing\adult\Hotmovies;
|
||||
use nntmux\processing\adult\Popporn;
|
||||
|
||||
|
||||
/**
|
||||
@@ -73,6 +78,8 @@ class XXX
|
||||
|
||||
/**
|
||||
* @param array $options Echo to cli / Class instances.
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct(array $options = [])
|
||||
{
|
||||
@@ -409,288 +416,6 @@ class XXX
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch xxx info for the movie.
|
||||
*
|
||||
* @param $xxxmovie
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function updateXXXInfo($xxxmovie): bool
|
||||
{
|
||||
|
||||
$res = false;
|
||||
$this->whichclass = '';
|
||||
|
||||
$iafd = new IAFD();
|
||||
$iafd->searchTerm = $xxxmovie;
|
||||
|
||||
if ($iafd->findme() !== false) {
|
||||
|
||||
switch ($iafd->classUsed) {
|
||||
case 'ade':
|
||||
$mov = new ADE();
|
||||
$mov->directLink = (string)$iafd->directUrl;
|
||||
$res = $mov->getDirect();
|
||||
$res['title'] = $iafd->title;
|
||||
$res['directurl'] = (string)$iafd->directUrl;
|
||||
$this->whichclass = $iafd->classUsed;
|
||||
ColorCLI::doEcho(ColorCLI::primary('Fetching XXX info from IAFD -> Adult DVD Empire'));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($res === false) {
|
||||
|
||||
$this->whichclass = 'aebn';
|
||||
$mov = new AEBN();
|
||||
$mov->cookie = $this->cookie;
|
||||
$mov->searchTerm = $xxxmovie;
|
||||
$res = $mov->search();
|
||||
|
||||
if ($res === false) {
|
||||
$this->whichclass = 'ade';
|
||||
$mov = new ADE();
|
||||
$mov->searchTerm = $xxxmovie;
|
||||
$res = $mov->search();
|
||||
}
|
||||
|
||||
if ($res === false) {
|
||||
$this->whichclass = 'pop';
|
||||
$mov = new Popporn();
|
||||
$mov->cookie = $this->cookie;
|
||||
$mov->searchTerm = $xxxmovie;
|
||||
$res = $mov->search();
|
||||
}
|
||||
|
||||
// Last in list as it doesn't have trailers
|
||||
if ($res === false) {
|
||||
$this->whichclass = 'adm';
|
||||
$mov = new ADM();
|
||||
$mov->cookie = $this->cookie;
|
||||
$mov->searchTerm = $xxxmovie;
|
||||
$res = $mov->search();
|
||||
}
|
||||
|
||||
|
||||
// If a result is true getAll information.
|
||||
if ($res !== false) {
|
||||
if ($this->echooutput) {
|
||||
|
||||
switch ($this->whichclass) {
|
||||
case 'aebn':
|
||||
$fromstr = 'Adult Entertainment Broadcast Network';
|
||||
break;
|
||||
case 'ade':
|
||||
$fromstr = 'Adult DVD Empire';
|
||||
break;
|
||||
case 'pop':
|
||||
$fromstr = 'PopPorn';
|
||||
break;
|
||||
case 'adm':
|
||||
$fromstr = 'Adult DVD Marketplace';
|
||||
break;
|
||||
default:
|
||||
$fromstr = null;
|
||||
}
|
||||
ColorCLI::doEcho(ColorCLI::primary('Fetching XXX info from: ' . $fromstr));
|
||||
}
|
||||
$res = $mov->getAll();
|
||||
} else {
|
||||
// Nothing was found, go ahead and set to -2
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
$res['cast'] = !empty($res['cast']) ? implode(',', $res['cast']) : '';
|
||||
$res['genres'] = !empty($res['genres']) ? $this->getGenreID($res['genres']) : '';
|
||||
|
||||
$mov = [
|
||||
'trailers' => !empty($res['trailers']) ? serialize($res['trailers']) : '',
|
||||
'extras' => !empty($res['extras']) ? serialize($res['extras']) : '',
|
||||
'productinfo' => !empty($res['productinfo']) ? serialize($res['productinfo']) : '',
|
||||
'backdrop' => !empty($res['backcover']) ? $res['backcover'] : 0,
|
||||
'cover' => !empty($res['boxcover']) ? $res['boxcover'] : 0,
|
||||
'title' => !empty($res['title']) ? html_entity_decode($res['title'], ENT_QUOTES, 'UTF-8') : '',
|
||||
'plot' => !empty($res['sypnosis']) ? html_entity_decode($res['sypnosis'], ENT_QUOTES, 'UTF-8') : '',
|
||||
'tagline' => !empty($res['tagline']) ? html_entity_decode($res['tagline'], ENT_QUOTES, 'UTF-8') : '',
|
||||
'genre' => !empty($res['genres']) ? html_entity_decode($res['genres'], ENT_QUOTES, 'UTF-8') : '',
|
||||
'director' => !empty($res['director']) ? html_entity_decode($res['director'], ENT_QUOTES, 'UTF-8') : '',
|
||||
'actors' => !empty($res['cast']) ? html_entity_decode($res['cast'], ENT_QUOTES, 'UTF-8') : '',
|
||||
'directurl' => !empty($res['directurl']) ? html_entity_decode($res['directurl'], ENT_QUOTES, 'UTF-8') : '',
|
||||
'classused' => $this->whichclass
|
||||
];
|
||||
|
||||
$check = $this->pdo->queryOneRow(sprintf('SELECT id FROM xxxinfo WHERE title = %s', $this->pdo->escapeString($mov['title'])));
|
||||
$xxxID = 0;
|
||||
if (isset($check['id'])) {
|
||||
$xxxID = $check['id'];
|
||||
}
|
||||
|
||||
// Update Current XXX Information - getXXXCovers.php
|
||||
if ($xxxID > 0) {
|
||||
$this->update($check['id'], $mov['title'], $mov['tagline'], $mov['plot'], $mov['genre'], $mov['director'], $mov['actors'], $mov['extras'], $mov['productinfo'], $mov['trailers'], $mov['directurl'], $mov['classused']);
|
||||
$xxxID = $check['id'];
|
||||
|
||||
// BoxCover.
|
||||
if (isset($mov['cover'])) {
|
||||
$mov['cover'] = $this->releaseImage->saveImage($xxxID . '-cover', $mov['cover'], $this->imgSavePath);
|
||||
}
|
||||
|
||||
// BackCover.
|
||||
if (isset($mov['backdrop'])) {
|
||||
$mov['backdrop'] = $this->releaseImage->saveImage($xxxID . '-backdrop', $mov['backdrop'], $this->imgSavePath, 1920, 1024);
|
||||
}
|
||||
|
||||
$this->pdo->queryExec(sprintf('UPDATE xxxinfo SET cover = %d, backdrop = %d WHERE id = %d', $mov['cover'], $mov['backdrop'], $xxxID));
|
||||
|
||||
} else {
|
||||
$xxxID = -2;
|
||||
}
|
||||
|
||||
// Insert New XXX Information
|
||||
if ($check === false) {
|
||||
$xxxID = $this->pdo->queryInsert(
|
||||
sprintf('
|
||||
INSERT INTO xxxinfo
|
||||
(title, tagline, plot, genre, director, actors, extras, productinfo, trailers, directurl, classused, cover, backdrop, createddate, updateddate)
|
||||
VALUES
|
||||
(%s, %s, COMPRESS(%s), %s, %s, %s, %s, %s, %s, %s, %s, 0, 0, NOW(), NOW())',
|
||||
$this->pdo->escapeString($mov['title']),
|
||||
$this->pdo->escapeString($mov['tagline']),
|
||||
$this->pdo->escapeString($mov['plot']),
|
||||
$this->pdo->escapeString(substr($mov['genre'], 0, 64)),
|
||||
$this->pdo->escapeString($mov['director']),
|
||||
$this->pdo->escapeString($mov['actors']),
|
||||
$this->pdo->escapeString($mov['extras']),
|
||||
$this->pdo->escapeString($mov['productinfo']),
|
||||
$this->pdo->escapeString($mov['trailers']),
|
||||
$this->pdo->escapeString($mov['directurl']),
|
||||
$this->pdo->escapeString($mov['classused'])
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::doEcho(
|
||||
ColorCLI::headerOver(($xxxID !== false ? 'Added/updated XXX movie: ' . ColorCLI::primary($mov['title']) : 'Nothing to update for XXX movie: ' . ColorCLI::primary($mov['title'])))
|
||||
);
|
||||
}
|
||||
|
||||
return $xxxID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process XXX releases where xxxinfo is 0
|
||||
*
|
||||
*/
|
||||
public function processXXXReleases(): void
|
||||
{
|
||||
$res = $this->pdo->query(sprintf('
|
||||
SELECT r.searchname, r.id
|
||||
FROM releases r
|
||||
WHERE r.nzbstatus = 1
|
||||
AND r.xxxinfo_id = 0
|
||||
%s
|
||||
LIMIT %d',
|
||||
$this->catWhere,
|
||||
$this->movieqty
|
||||
)
|
||||
);
|
||||
$movieCount = count($res);
|
||||
|
||||
if ($movieCount > 0) {
|
||||
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::doEcho(ColorCLI::header('Processing ' . $movieCount . ' XXX releases.'));
|
||||
}
|
||||
|
||||
// Loop over releases.
|
||||
foreach ($res as $arr) {
|
||||
|
||||
$idcheck = -2;
|
||||
|
||||
// Try to get a name.
|
||||
if ($this->parseXXXSearchName($arr['searchname']) !== false) {
|
||||
$check = $this->checkXXXInfoExists($this->currentTitle);
|
||||
if ($check === false) {
|
||||
$this->currentRelID = $arr['id'];
|
||||
$movieName = $this->currentTitle;
|
||||
if ($this->debug && $this->echooutput) {
|
||||
ColorCLI::doEcho('DB name: ' . $arr['searchname'], true);
|
||||
}
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::doEcho(ColorCLI::primaryOver('Looking up: ') . ColorCLI::headerOver($movieName), true);
|
||||
}
|
||||
|
||||
$idcheck = $this->updateXXXInfo($movieName);
|
||||
} else {
|
||||
$idcheck = (int)$check['id'];
|
||||
}
|
||||
} else {
|
||||
ColorCLI::doEcho('.', true);
|
||||
}
|
||||
$this->pdo->queryExec(sprintf('UPDATE releases SET xxxinfo_id = %d WHERE id = %d %s', $idcheck, $arr['id'], $this->catWhere));
|
||||
}
|
||||
} elseif ($this->echooutput) {
|
||||
ColorCLI::doEcho(ColorCLI::header('No xxx releases to process.'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks xxxinfo to make sure releases exist
|
||||
*
|
||||
* @param $releaseName
|
||||
*
|
||||
* @return array|bool
|
||||
*/
|
||||
protected function checkXXXInfoExists($releaseName)
|
||||
{
|
||||
return $this->pdo->queryOneRow(sprintf('SELECT id, title FROM xxxinfo WHERE title %s', $this->pdo->likeString($releaseName, false, true)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans up a searchname to make it easier to scrape.
|
||||
*
|
||||
* @param string $releaseName
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function parseXXXSearchName($releaseName): bool
|
||||
{
|
||||
$name = '';
|
||||
$followingList = '[^\w]((2160|1080|480|720)(p|i)|AC3D|Directors([^\w]CUT)?|DD5\.1|(DVD|BD|BR)(Rip)?|BluRay|divx|HDTV|iNTERNAL|LiMiTED|(Real\.)?Proper|RE(pack|Rip)|Sub\.?(fix|pack)|Unrated|WEB-DL|(x|H)[-._ ]?264|xvid|[Dd][Ii][Ss][Cc](\d+|\s*\d+|\.\d+)|XXX|BTS|DirFix|Trailer|WEBRiP|NFO|(19|20)\d\d)[^\w]';
|
||||
|
||||
if (preg_match('/([^\w]{2,})?(?P<name>[\w .-]+?)' . $followingList . '/i', $releaseName, $matches)) {
|
||||
$name = $matches['name'];
|
||||
}
|
||||
|
||||
// Check if we got something.
|
||||
if ($name !== '') {
|
||||
|
||||
// If we still have any of the words in $followingList, remove them.
|
||||
$name = preg_replace('/' . $followingList . '/i', ' ', $name);
|
||||
// Remove periods, underscored, anything between parenthesis.
|
||||
$name = preg_replace('/\(.*?\)|[-._]/i', ' ', $name);
|
||||
// Finally remove multiple spaces and trim leading spaces.
|
||||
$name = trim(preg_replace('/\s{2,}/', ' ', $name));
|
||||
// Remove Private Movies {d} from name better matching.
|
||||
$name = trim(preg_replace('/^Private\s(Specials|Blockbusters|Blockbuster|Sports|Gold|Lesbian|Movies|Classics|Castings|Fetish|Stars|Pictures|XXX|Private|Black\sLabel|Black)\s\d+/i', '', $name));
|
||||
// Remove Foreign Words at the end of the name.
|
||||
$name = trim(preg_replace('/(brazilian|chinese|croatian|danish|deutsch|dutch|estonian|flemish|finnish|french|german|greek|hebrew|icelandic|italian|latin|nordic|norwegian|polish|portuguese|japenese|japanese|russian|serbian|slovenian|spanish|spanisch|swedish|thai|turkish)$/i', '', $name));
|
||||
|
||||
// Check if the name is long enough and not just numbers and not file (d) of (d) and does not contain Episodes and any dated 00.00.00 which are site rips..
|
||||
if (strlen($name) > 5 && !preg_match('/^\d+$/', $name) && !preg_match('/( File \d+ of \d+|\d+.\d+.\d+)/', $name) && !preg_match('/(E\d+)/', $name) && !preg_match('/\d\d\.\d\d.\d\d/', $name)) {
|
||||
$this->currentTitle = $name;
|
||||
|
||||
return true;
|
||||
}
|
||||
ColorCLI::doEcho('.', false);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all genres for search-filter.tpl
|
||||
*
|
||||
@@ -749,7 +474,7 @@ class XXX
|
||||
*
|
||||
* @return string - If array .. 1,2,3,4 if string .. 1
|
||||
*/
|
||||
private function getGenreID($arr): string
|
||||
protected function getGenreID($arr): string
|
||||
{
|
||||
$ret = null;
|
||||
|
||||
@@ -825,4 +550,278 @@ class XXX
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $movie
|
||||
*
|
||||
* @return false|int|string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function updateXXXInfo($movie)
|
||||
{
|
||||
$cover = $backdrop = 0;
|
||||
$xxxID = -2;
|
||||
$this->whichclass = 'aebn';
|
||||
$mov = new AEBN();
|
||||
$mov->cookie = $this->cookie;
|
||||
ColorCLI::doEcho(ColorCLI::info('Checking AEBN for movie info'));
|
||||
$res = $mov->processSite($movie);
|
||||
|
||||
if ($res === false) {
|
||||
$this->whichclass = 'ade';
|
||||
$mov = new ADE();
|
||||
ColorCLI::doEcho(ColorCLI::info('Checking ADE for movie info'));
|
||||
$res = $mov->processSite($movie);
|
||||
}
|
||||
|
||||
if ($res === false) {
|
||||
$this->whichclass = 'pop';
|
||||
$mov = new Popporn();
|
||||
$mov->cookie = $this->cookie;
|
||||
ColorCLI::doEcho(ColorCLI::info('Checking PopPorn for movie info'));
|
||||
$res = $mov->processSite($movie);
|
||||
}
|
||||
|
||||
if ($res === false) {
|
||||
$this->whichclass = 'hotm';
|
||||
$mov = new Hotmovies();
|
||||
$mov->cookie = $this->cookie;
|
||||
ColorCLI::doEcho(ColorCLI::info('Checking HotMovies for movie info'));
|
||||
$res = $mov->processSite($movie);
|
||||
}
|
||||
|
||||
// Last in list as it doesn't have trailers
|
||||
if ($res === false) {
|
||||
$this->whichclass = 'adm';
|
||||
$mov = new ADM();
|
||||
$mov->cookie = $this->cookie;
|
||||
ColorCLI::doEcho(ColorCLI::info('Checking ADM for movie info'));
|
||||
$res = $mov->processSite($movie);
|
||||
}
|
||||
|
||||
|
||||
// If a result is true getAll information.
|
||||
if ($res) {
|
||||
if ($this->echooutput) {
|
||||
|
||||
switch ($this->whichclass) {
|
||||
case 'aebn':
|
||||
$fromstr = 'Adult Entertainment Broadcast Network';
|
||||
break;
|
||||
case 'ade':
|
||||
$fromstr = 'Adult DVD Empire';
|
||||
break;
|
||||
case 'pop':
|
||||
$fromstr = 'PopPorn';
|
||||
break;
|
||||
case 'adm':
|
||||
$fromstr = 'Adult DVD Marketplace';
|
||||
break;
|
||||
case 'hotm':
|
||||
$fromstr = 'HotMovies';
|
||||
break;
|
||||
default:
|
||||
$fromstr = '';
|
||||
}
|
||||
ColorCLI::doEcho(ColorCLI::primary('Fetching XXX info from: ' . $fromstr));
|
||||
}
|
||||
$res = $mov->getAll();
|
||||
} else {
|
||||
// Nothing was found, go ahead and set to -2
|
||||
return -2;
|
||||
}
|
||||
|
||||
$res['cast'] = !empty($res['cast']) ? implode(',', $res['cast']) : '';
|
||||
$res['genres'] = !empty($res['genres']) ? $this->getGenreID($res['genres']) : '';
|
||||
|
||||
$mov = [
|
||||
'trailers' => !empty($res['trailers']) ? serialize($res['trailers']) : '',
|
||||
'extras' => !empty($res['extras']) ? serialize($res['extras']) : '',
|
||||
'productinfo' => !empty($res['productinfo']) ? serialize($res['productinfo']) : '',
|
||||
'backdrop' => !empty($res['backcover']) ? $res['backcover'] : 0,
|
||||
'cover' => !empty($res['boxcover']) ? $res['boxcover'] : 0,
|
||||
'title' => !empty($res['title']) ? html_entity_decode($res['title'], ENT_QUOTES, 'UTF-8') : '',
|
||||
'plot' => !empty($res['synopsis']) ? html_entity_decode($res['synopsis'], ENT_QUOTES, 'UTF-8') : '',
|
||||
'tagline' => !empty($res['tagline']) ? html_entity_decode($res['tagline'], ENT_QUOTES, 'UTF-8') : '',
|
||||
'genre' => !empty($res['genres']) ? html_entity_decode($res['genres'], ENT_QUOTES, 'UTF-8') : '',
|
||||
'director' => !empty($res['director']) ? html_entity_decode($res['director'], ENT_QUOTES, 'UTF-8') : '',
|
||||
'actors' => !empty($res['cast']) ? html_entity_decode($res['cast'], ENT_QUOTES, 'UTF-8') : '',
|
||||
'directurl' => !empty($res['directurl']) ? html_entity_decode($res['directurl'], ENT_QUOTES, 'UTF-8') : '',
|
||||
'classused' => $this->whichclass
|
||||
];
|
||||
|
||||
$check = $this->pdo->queryOneRow(sprintf('SELECT id FROM xxxinfo WHERE title = %s', $this->pdo->escapeString($mov['title'])));
|
||||
|
||||
if ($check['id'] > 0) {
|
||||
|
||||
$xxxID = $check['id'];
|
||||
|
||||
// Update BoxCover.
|
||||
if (!empty($mov['cover'])) {
|
||||
$cover = $this->releaseImage->saveImage($xxxID . '-cover', $mov['cover'], $this->imgSavePath);
|
||||
}
|
||||
|
||||
// BackCover.
|
||||
if (!empty($mov['backdrop'])) {
|
||||
$backdrop = $this->releaseImage->saveImage($xxxID . '-backdrop', $mov['backdrop'], $this->imgSavePath, 1920, 1024);
|
||||
}
|
||||
|
||||
// Update Current XXX Information
|
||||
$this->update($check['id'], $mov['title'], $mov['tagline'], $mov['plot'], $mov['genre'], $mov['director'], $mov['actors'], $mov['extras'], $mov['productinfo'], $mov['trailers'], $mov['directurl'], $mov['classused'], $cover, $backdrop);
|
||||
}
|
||||
|
||||
// Insert New XXX Information
|
||||
if ($check === false) {
|
||||
$xxxID = $this->pdo->queryInsert(
|
||||
sprintf('
|
||||
INSERT INTO xxxinfo
|
||||
(title, tagline, plot, genre, director, actors, extras, productinfo, trailers, directurl, classused, createddate, updateddate)
|
||||
VALUES
|
||||
(%s, %s, COMPRESS(%s), %s, %s, %s, %s, %s, %s, %s, %s, NOW(), NOW())',
|
||||
$this->pdo->escapeString($mov['title']),
|
||||
$this->pdo->escapeString($mov['tagline']),
|
||||
$this->pdo->escapeString($mov['plot']),
|
||||
$this->pdo->escapeString(substr($mov['genre'], 0, 64)),
|
||||
$this->pdo->escapeString($mov['director']),
|
||||
$this->pdo->escapeString($mov['actors']),
|
||||
$this->pdo->escapeString($mov['extras']),
|
||||
$this->pdo->escapeString($mov['productinfo']),
|
||||
$this->pdo->escapeString($mov['trailers']),
|
||||
$this->pdo->escapeString($mov['directurl']),
|
||||
$this->pdo->escapeString($mov['classused'])
|
||||
)
|
||||
);
|
||||
// Update BoxCover.
|
||||
if (!empty($mov['cover'])) {
|
||||
$cover = $this->releaseImage->saveImage($xxxID . '-cover', $mov['cover'], $this->imgSavePath);
|
||||
}
|
||||
|
||||
// BackCover.
|
||||
if (!empty($mov['backdrop'])) {
|
||||
$backdrop = $this->releaseImage->saveImage($xxxID . '-backdrop', $mov['backdrop'], $this->imgSavePath, 1920, 1024);
|
||||
}
|
||||
|
||||
$this->pdo->queryExec(sprintf('UPDATE xxxinfo SET cover = %d, backdrop = %d WHERE id = %d', $cover, $backdrop, $xxxID));
|
||||
}
|
||||
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::doEcho(
|
||||
ColorCLI::headerOver(($xxxID !== false ? 'Added/updated XXX movie: ' . ColorCLI::primary($mov['title']) : 'Nothing to update for XXX movie: ' . ColorCLI::primary($mov['title'])))
|
||||
);
|
||||
}
|
||||
|
||||
return $xxxID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process XXX releases where xxxinfo is 0
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function processXXXReleases(): void
|
||||
{
|
||||
$res = $this->pdo->query(sprintf('
|
||||
SELECT r.searchname, r.id
|
||||
FROM releases r
|
||||
WHERE r.nzbstatus = 1
|
||||
AND r.xxxinfo_id = 0
|
||||
%s
|
||||
LIMIT %d',
|
||||
$this->catWhere,
|
||||
$this->movieqty
|
||||
)
|
||||
);
|
||||
$movieCount = count($res);
|
||||
|
||||
if ($movieCount > 0) {
|
||||
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::doEcho(ColorCLI::header('Processing ' . $movieCount . ' XXX releases.'));
|
||||
}
|
||||
|
||||
// Loop over releases.
|
||||
foreach ($res as $arr) {
|
||||
|
||||
$idcheck = -2;
|
||||
|
||||
// Try to get a name.
|
||||
if ($this->parseXXXSearchName($arr['searchname']) !== false) {
|
||||
$check = $this->checkXXXInfoExists($this->currentTitle);
|
||||
if ($check === false) {
|
||||
$this->currentRelID = $arr['id'];
|
||||
if ($this->debug && $this->echooutput) {
|
||||
ColorCLI::doEcho('DB name: ' . $arr['searchname'], true);
|
||||
}
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::doEcho(ColorCLI::primaryOver('Looking up: ') . ColorCLI::headerOver($this ->currentTitle), true);
|
||||
}
|
||||
|
||||
ColorCLI::doEcho(ColorCLI::info('Local match not found, checking web!'), true);
|
||||
$idcheck = $this->updateXXXInfo($this->currentTitle);
|
||||
} else {
|
||||
ColorCLI::doEcho(ColorCLI::info('Local match found for XXX Movie: ' . ColorCLI::headerOver($this->currentTitle)), true);
|
||||
$idcheck = (int)$check['id'];
|
||||
}
|
||||
} else {
|
||||
ColorCLI::doEcho('.', true);
|
||||
}
|
||||
$this->pdo->queryExec(sprintf('UPDATE releases SET xxxinfo_id = %d WHERE id = %d %s', $idcheck, $arr['id'], $this->catWhere));
|
||||
}
|
||||
} elseif ($this->echooutput) {
|
||||
ColorCLI::doEcho(ColorCLI::header('No xxx releases to process.'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks xxxinfo to make sure releases exist
|
||||
*
|
||||
* @param $releaseName
|
||||
*
|
||||
* @return array|bool
|
||||
*/
|
||||
protected function checkXXXInfoExists($releaseName)
|
||||
{
|
||||
return $this->pdo->queryOneRow(sprintf('SELECT id, title FROM xxxinfo WHERE title %s', $this->pdo->likeString($releaseName, false, true)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans up a searchname to make it easier to scrape.
|
||||
*
|
||||
* @param string $releaseName
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function parseXXXSearchName($releaseName): bool
|
||||
{
|
||||
$name = '';
|
||||
$followingList = '[^\w]((2160|1080|480|720)(p|i)|AC3D|Directors([^\w]CUT)?|DD5\.1|(DVD|BD|BR)(Rip)?|BluRay|divx|HDTV|iNTERNAL|LiMiTED|(Real\.)?Proper|RE(pack|Rip)|Sub\.?(fix|pack)|Unrated|WEB-DL|(x|H)[-._ ]?264|xvid|[Dd][Ii][Ss][Cc](\d+|\s*\d+|\.\d+)|XXX|BTS|DirFix|Trailer|WEBRiP|NFO|(19|20)\d\d)[^\w]';
|
||||
|
||||
if (preg_match('/([^\w]{2,})?(?P<name>[\w .-]+?)' . $followingList . '/i', $releaseName, $matches)) {
|
||||
$name = $matches['name'];
|
||||
}
|
||||
|
||||
// Check if we got something.
|
||||
if ($name !== '') {
|
||||
|
||||
// If we still have any of the words in $followingList, remove them.
|
||||
$name = preg_replace('/' . $followingList . '/i', ' ', $name);
|
||||
// Remove periods, underscored, anything between parenthesis.
|
||||
$name = preg_replace('/\(.*?\)|[-._]/i', ' ', $name);
|
||||
// Finally remove multiple spaces and trim leading spaces.
|
||||
$name = trim(preg_replace('/\s{2,}/', ' ', $name));
|
||||
// Remove Private Movies {d} from name better matching.
|
||||
$name = trim(preg_replace('/^Private\s(Specials|Blockbusters|Blockbuster|Sports|Gold|Lesbian|Movies|Classics|Castings|Fetish|Stars|Pictures|XXX|Private|Black\sLabel|Black)\s\d+/i', '', $name));
|
||||
// Remove Foreign Words at the end of the name.
|
||||
$name = trim(preg_replace('/(brazilian|chinese|croatian|danish|deutsch|dutch|estonian|flemish|finnish|french|german|greek|hebrew|icelandic|italian|latin|nordic|norwegian|polish|portuguese|japenese|japanese|russian|serbian|slovenian|spanish|spanisch|swedish|thai|turkish)$/i', '', $name));
|
||||
|
||||
// Check if the name is long enough and not just numbers and not file (d) of (d) and does not contain Episodes and any dated 00.00.00 which are site rips..
|
||||
if (strlen($name) > 5 && !preg_match('/^\d+$/', $name) && !preg_match('/( File \d+ of \d+|\d+.\d+.\d+)/', $name) && !preg_match('/(E\d+)/', $name) && !preg_match('/\d\d\.\d\d.\d\d/', $name)) {
|
||||
$this->currentTitle = $name;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
define('NN_MINIMUM_PHP_VERSION', '7.1.0');
|
||||
define('NN_MINIMUM_MYSQL_VERSION', '5.6');
|
||||
define('NN_MINIMUM_MARIA_VERSION', '10.0');
|
||||
define('NN_MINIMUM_MARIA_VERSION', '10.1');
|
||||
|
||||
define('DS', DIRECTORY_SEPARATOR);
|
||||
|
||||
|
||||
+7
-7
@@ -112,13 +112,13 @@ class DB extends \PDO
|
||||
'checkVersion' => false,
|
||||
'createDb' => false, // create dbname if it does not exist?
|
||||
'ct' => new ConsoleTools(),
|
||||
'dbhost' => getenv('DB_HOST'),
|
||||
'dbname' => getenv('DB_NAME'),
|
||||
'dbpass' => getenv('DB_PASSWORD'),
|
||||
'dbport' => getenv('DB_PORT'),
|
||||
'dbsock' => getenv('DB_SOCKET'),
|
||||
'dbtype' => getenv('DB_SYSTEM'),
|
||||
'dbuser' => getenv('DB_USER'),
|
||||
'dbhost' => env('DB_HOST', '127.0.0.1'),
|
||||
'dbname' => env('DB_NAME', 'nntmux'),
|
||||
'dbpass' => env('DB_PASSWORD', 'nntmux'),
|
||||
'dbport' => env('DB_PORT', '3306'),
|
||||
'dbsock' => env('DB_SOCKET'),
|
||||
'dbtype' => env('DB_SYSTEM','mysql'),
|
||||
'dbuser' => env('DB_USER', 'nntmux'),
|
||||
'log' => new ColorCLI(),
|
||||
'persist' => false,
|
||||
];
|
||||
|
||||
+15
-4
@@ -84,6 +84,7 @@ class DbUpdate
|
||||
public function loadTables(array $options = [])
|
||||
{
|
||||
$defaults = [
|
||||
'enclosedby' => null,
|
||||
'ext' => 'tsv',
|
||||
'files' => [],
|
||||
'path' => NN_RES . 'db' . DS . 'schema' . DS . 'data',
|
||||
@@ -96,8 +97,10 @@ class DbUpdate
|
||||
$files = empty($options['files']) ? Utility::getDirFiles($options) : $options['files'];
|
||||
natsort($files);
|
||||
$local = $this->pdo->isLocalDb() ? '' : 'LOCAL ';
|
||||
$enclosedby = empty($options['enclosedby']) ? '' : 'OPTIONALLY ENCLOSED BY "' .
|
||||
$options['enclosedby'] . '"';
|
||||
$sql = 'LOAD DATA ' .
|
||||
$local . 'INFILE "%s" IGNORE INTO TABLE `%s` FIELDS TERMINATED BY "\t" OPTIONALLY ENCLOSED BY "\"" LINES TERMINATED BY "\n" IGNORE 1 LINES (%s)';
|
||||
$local . 'INFILE "%s" IGNORE INTO TABLE `%s` FIELDS TERMINATED BY "\t" ' . $enclosedby . 'LINES TERMINATED BY "\n" IGNORE 1 LINES (%s)';
|
||||
foreach ($files as $file) {
|
||||
if ($show === true) {
|
||||
echo "File: $file\n";
|
||||
@@ -107,7 +110,7 @@ class DbUpdate
|
||||
if (preg_match($options['regex'], $file, $matches)) {
|
||||
$table = $matches['table'];
|
||||
// Get the first line of the file which holds the columns used.
|
||||
$handle = @fopen($file, "r");
|
||||
$handle = @fopen($file, 'rb');
|
||||
if (is_resource($handle)) {
|
||||
$line = fgets($handle);
|
||||
fclose($handle);
|
||||
@@ -118,12 +121,20 @@ class DbUpdate
|
||||
$fields = trim($line);
|
||||
|
||||
if ($show === true) {
|
||||
echo "Inserting data into table: '$table'\n";
|
||||
ColorCLI::doEcho(ColorCLI::info('Inserting data into table: ' . $table));
|
||||
}
|
||||
if (Utility::isWin()) {
|
||||
$file = str_replace("\\", '\/', $file);
|
||||
}
|
||||
$this->pdo->exec(sprintf($sql, $file, $table, $fields));
|
||||
$this->pdo->queryExec(sprintf($sql, $file, $table, $fields));
|
||||
if ($table !== 'settings') {
|
||||
$success = $this->pdo->query(sprintf('SELECT COUNT(id) AS num FROM %s', $table));
|
||||
if (empty($success[0]['num'])) {
|
||||
ColorCLI::doEcho(ColorCLI::error('Failed to insert data into table: ' . $table));
|
||||
} else {
|
||||
ColorCLI::doEcho(ColorCLI::notice('Successfully inserted data into ' . $table . ' table'));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
exit("Failed to open file: '$file'\n");
|
||||
}
|
||||
|
||||
@@ -597,8 +597,12 @@ class Forking extends \fork_daemon
|
||||
|
||||
if ($groups instanceof \Traversable) {
|
||||
foreach ($groups as $group) {
|
||||
if ($this->pdo->queryOneRow(sprintf('SELECT id FROM collections_%d LIMIT 1', $group['id'])) !== false) {
|
||||
$this->work[] = ['id' => $group['id']];
|
||||
try {
|
||||
if ($this->pdo->queryOneRow(sprintf('SELECT id FROM collections_%d LIMIT 1', $group['id'])) !== false) {
|
||||
$this->work[] = ['id' => $group['id']];
|
||||
}
|
||||
} catch (\PDOException $e) {
|
||||
$e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,28 +3,34 @@ namespace nntmux\processing;
|
||||
|
||||
use app\models\Settings;
|
||||
use dariusiii\rarinfo\Par2Info;
|
||||
use nntmux\ADE;
|
||||
use nntmux\ADM;
|
||||
use nntmux\AEBN;
|
||||
use nntmux\Books;
|
||||
use nntmux\Category;
|
||||
use nntmux\ColorCLI;
|
||||
use nntmux\Console;
|
||||
use nntmux\Games;
|
||||
use nntmux\Groups;
|
||||
use nntmux\Hotmovies;
|
||||
use nntmux\Logger;
|
||||
use nntmux\Movie;
|
||||
use nntmux\Music;
|
||||
use nntmux\NameFixer;
|
||||
use nntmux\Nfo;
|
||||
use nntmux\Popporn;
|
||||
use nntmux\Sharing;
|
||||
use nntmux\processing\adult\AdultMovies;
|
||||
use nntmux\processing\tv\TVDB;
|
||||
use nntmux\processing\tv\TVMaze;
|
||||
use nntmux\processing\tv\TMDB;
|
||||
use nntmux\processing\tv\TraktTv;
|
||||
use nntmux\XXX;
|
||||
use nntmux\ReleaseFiles;
|
||||
use nntmux\db\DB;
|
||||
use nntmux\processing\post\AniDB;
|
||||
use nntmux\processing\post\ProcessAdditional;
|
||||
use nntmux\SpotNab;
|
||||
use nntmux\XXX;
|
||||
|
||||
class PostProcess
|
||||
{
|
||||
@@ -254,12 +260,13 @@ 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 $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,
|
||||
* @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
|
||||
*
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function processTv($groupID = '', $guidChar = '', $processTV = '')
|
||||
{
|
||||
@@ -295,6 +302,8 @@ class PostProcess
|
||||
|
||||
/**
|
||||
* Lookup xxx if enabled.
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function processXXX()
|
||||
{
|
||||
|
||||
Executable
+284
@@ -0,0 +1,284 @@
|
||||
<?php
|
||||
namespace nntmux\processing\adult;
|
||||
|
||||
/**
|
||||
* Class adultdvdempire
|
||||
*/
|
||||
class ADE extends AdultMovies
|
||||
{
|
||||
/**
|
||||
* If a direct link is given parse it rather then search
|
||||
* @var string
|
||||
*/
|
||||
public $directLink = '';
|
||||
|
||||
/**
|
||||
* If a string is found do call back.
|
||||
* @var bool
|
||||
*/
|
||||
public $found = false;
|
||||
|
||||
/**
|
||||
* Search keyword
|
||||
* @var string
|
||||
*/
|
||||
public $searchTerm = '';
|
||||
|
||||
/**
|
||||
* Define ADE Url here
|
||||
*/
|
||||
const ADE = 'http://www.adultdvdempire.com';
|
||||
|
||||
/**
|
||||
* Direct Url returned in getAll method
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_directUrl = '';
|
||||
|
||||
/**
|
||||
* If a url is found that matches the keyword
|
||||
*
|
||||
*/
|
||||
protected $_urlFound;
|
||||
|
||||
/**
|
||||
* Sets the title in the getAll method
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_title = '';
|
||||
|
||||
/** Trailing urls */
|
||||
protected $_dvdQuery = '/dvd/search?q=';
|
||||
protected $_scenes = '/scenes';
|
||||
protected $_boxCover = '/boxcover';
|
||||
protected $_backCover = '/backcover';
|
||||
protected $_reviews = '/reviews';
|
||||
protected $_trailers = '/trailers';
|
||||
|
||||
|
||||
protected $_url;
|
||||
protected $_response;
|
||||
protected $_res = [];
|
||||
protected $_tmpResponse;
|
||||
protected $_html;
|
||||
protected $_edithtml;
|
||||
protected $_ch;
|
||||
|
||||
public function __construct(array $options = [])
|
||||
{
|
||||
parent::__construct($options);
|
||||
$this->_html = new \simple_html_dom();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Trailer Movies
|
||||
* @return array - url, streamid, basestreamingurl
|
||||
*/
|
||||
public function trailers()
|
||||
{
|
||||
$this->_response = getRawHtml(self::ADE . $this->_trailers . $this->_directUrl);
|
||||
$this->_html->load($this->_response);
|
||||
if (preg_match("/(\"|')(?P<swf>[^\"']+.swf)(\"|')/i", $this->_response, $matches)) {
|
||||
$this->_res['trailers']['url'] = self::ADE . trim(trim($matches['swf']), '"');
|
||||
if (preg_match('#(?:streamID:\s\")(?P<streamid>[0-9A-Z]+)(?:\")#',
|
||||
$this->_response,
|
||||
$matches)
|
||||
) {
|
||||
$this->_res['trailers']['streamid'] = trim($matches['streamid']);
|
||||
}
|
||||
if (preg_match('#(?:BaseStreamingUrl:\s\")(?P<baseurl>[\d]+.[\d]+.[\d]+.[\d]+)(?:\")#',
|
||||
$this->_response,
|
||||
$matches)
|
||||
) {
|
||||
$this->_res['trailers']['baseurl'] = $matches['baseurl'];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets cover images for the xxx release
|
||||
* @return array - Boxcover and backcover
|
||||
*/
|
||||
public function covers()
|
||||
{
|
||||
if ($ret = $this->_html->find('div#Boxcover, img[itemprop=image]', 1)) {
|
||||
$this->_res['boxcover'] = preg_replace('/m\.jpg/', 'h.jpg', $ret->src);
|
||||
$this->_res['backcover'] = preg_replace('/m\.jpg/', 'bh.jpg', $ret->src);
|
||||
}
|
||||
|
||||
return $this->_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the synopsis
|
||||
*
|
||||
* @return array - plot
|
||||
*/
|
||||
public function synopsis()
|
||||
{
|
||||
$ret = $this->_html->find('meta[name=og:description]', 0)->content;
|
||||
if ($ret !== false) {
|
||||
$this->_res['synopsis'] = trim($ret);
|
||||
}
|
||||
|
||||
return $this->_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cast members and/or awards
|
||||
*
|
||||
*
|
||||
* @return array - cast, awards
|
||||
*/
|
||||
public function cast()
|
||||
{
|
||||
foreach ($this->_html->find('a.PerformerName') as $a) {
|
||||
if ($a->plaintext !== '(bio)' && $a->plaintext !== '(interview)') {
|
||||
$this->_res['cast'][] = trim($a->innertext);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Genres, if exists return array else return false
|
||||
* @return mixed array - Genres
|
||||
*/
|
||||
public function genres()
|
||||
{
|
||||
$genres = [];
|
||||
$ret = $this->_html->find('h2[border-bottom-site-default]');
|
||||
foreach ($ret as $categories) {
|
||||
$cats = $categories->find('a[label]');
|
||||
foreach ($cats as $c) {
|
||||
$categories = trim($c);
|
||||
if (strpos($categories, ',') !== false) {
|
||||
$genres = explode(',', $categories);
|
||||
$genres = array_map('trim', $genres);
|
||||
} else {
|
||||
$genres[] = $categories;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_array($genres)) {
|
||||
$this->_res['genres'] = array_unique($genres);
|
||||
}
|
||||
return $this->_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Product Information and/or Features
|
||||
*
|
||||
* @param bool $features Include features? true/false
|
||||
*
|
||||
* @return array - ProductInfo/Extras = features
|
||||
*/
|
||||
public function productInfo($features = false)
|
||||
{
|
||||
$dofeature = null;
|
||||
$this->_tmpResponse = str_ireplace('Section ProductInfo', 'spdinfo', $this->_response);
|
||||
$this->_html->load($this->_tmpResponse);
|
||||
if ($ret = $this->_html->find('div[class=spdinfo]', 0)) {
|
||||
$this->_tmpResponse = trim($ret->outertext);
|
||||
$ret = $this->_html->load($this->_tmpResponse);
|
||||
foreach ($ret->find("text") as $strong) {
|
||||
if (trim($strong->innertext) === 'Features') {
|
||||
$dofeature = true;
|
||||
}
|
||||
if ($dofeature !== true) {
|
||||
if (trim($strong->innertext) !== ' ') {
|
||||
$this->_res['productinfo'][] = trim($strong->innertext);
|
||||
}
|
||||
} else {
|
||||
if ($features === true) {
|
||||
$this->_res['extras'][] = trim($strong->innertext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
array_shift($this->_res['productinfo']);
|
||||
array_shift($this->_res['productinfo']);
|
||||
$this->_res['productinfo'] = array_chunk($this->_res['productinfo'], 2, false);
|
||||
}
|
||||
|
||||
return $this->_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches xxx name.
|
||||
*
|
||||
* @param string $movie
|
||||
*
|
||||
* @return bool - True if releases has 90% match, else false
|
||||
*/
|
||||
public function processSite($movie): bool
|
||||
{
|
||||
if (empty($movie)) {
|
||||
return false;
|
||||
}
|
||||
$this->_response = getRawHtml(self::ADE . $this->_dvdQuery . rawurlencode($movie));
|
||||
if ($this->_response !== false) {
|
||||
$this->_html->load($this->_response);
|
||||
if ($res = $this->_html->find('a[class=boxcover]')) {
|
||||
foreach ($res as $ret) {
|
||||
$title = $ret->title;
|
||||
$title = str_replace('/XXX/', '', $title);
|
||||
$title = preg_replace('/\(.*?\)|[-._]/', ' ', $title);
|
||||
$url = (string)trim($ret->href);
|
||||
similar_text(strtolower($movie), strtolower($title), $p);
|
||||
if ($p >= 90) {
|
||||
$this->_directUrl = self::ADE . $url;
|
||||
$this->_title = trim($title);
|
||||
$this->_html->clear();
|
||||
unset($this->_response);
|
||||
$this->_response = getRawHtml($this->_directUrl);
|
||||
$this->_html->load($this->_response);
|
||||
return true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets All Information from the methods
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getAll()
|
||||
{
|
||||
$results = [];
|
||||
if (!empty($this->_directUrl)) {
|
||||
$results['directurl'] = $this->_directUrl;
|
||||
$results['title'] = $this->_title;
|
||||
}
|
||||
if (is_array($this->synopsis())) {
|
||||
$results = array_merge($results, $this->synopsis());
|
||||
}
|
||||
if (is_array($this->productInfo(true))) {
|
||||
$results = array_merge($results, $this->productInfo(true));
|
||||
}
|
||||
if (is_array($this->cast())) {
|
||||
$results = array_merge($results, $this->cast());
|
||||
}
|
||||
if (is_array($this->genres())) {
|
||||
$results = array_merge($results, $this->genres());
|
||||
}
|
||||
if (is_array($this->covers())) {
|
||||
$results = array_merge($results, $this->covers());
|
||||
}
|
||||
if (is_array($this->trailers())) {
|
||||
$results = array_merge($results, $this->trailers());
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,9 @@
|
||||
<?php
|
||||
namespace nntmux;
|
||||
namespace nntmux\processing\adult;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Cookie\CookieJar;
|
||||
use GuzzleHttp\Cookie\SetCookie;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use nntmux\db\DB;
|
||||
use nntmux\utility\Utility;
|
||||
|
||||
class ADM
|
||||
class ADM extends AdultMovies
|
||||
{
|
||||
/**
|
||||
* Override if 18 years+ or older
|
||||
@@ -50,21 +45,6 @@ class ADM
|
||||
*/
|
||||
protected $_html;
|
||||
|
||||
/**
|
||||
* @var Client
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* @var DB
|
||||
*/
|
||||
protected $pdo;
|
||||
|
||||
/**
|
||||
* POST Paramaters for getUrl Method
|
||||
*/
|
||||
protected $_postParams;
|
||||
|
||||
/**
|
||||
* Results returned from each method
|
||||
*
|
||||
@@ -90,16 +70,11 @@ class ADM
|
||||
*/
|
||||
protected $_title = '';
|
||||
|
||||
public function __construct()
|
||||
public function __construct(array $options = [])
|
||||
{
|
||||
parent::__construct($options);
|
||||
$this->_html = new \simple_html_dom();
|
||||
$this->client = new Client();
|
||||
$this->cookiejar = new CookieJar();
|
||||
$this->pdo = new DB();
|
||||
if (!empty($this->cookie)) {
|
||||
$cookieJar = $this->cookiejar->setCookie(SetCookie::fromString($this->cookie));
|
||||
$this->client = new Client(['cookies' => $cookieJar]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,7 +90,7 @@ class ADM
|
||||
* Get Box Cover Images
|
||||
* @return array - boxcover,backcover
|
||||
*/
|
||||
public function covers()
|
||||
protected function covers()
|
||||
{
|
||||
$baseUrl = 'http://www.adultdvdmarketplace.com/';
|
||||
if ($ret = $this->_html->find('a[rel=fancybox-button]', 0)) {
|
||||
@@ -133,9 +108,10 @@ class ADM
|
||||
|
||||
/**
|
||||
* Gets the synopsis
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function synopsis()
|
||||
protected function synopsis()
|
||||
{
|
||||
$this->_res['synopsis'] = 'N/A';
|
||||
foreach ($this->_html->find('h3') as $heading) {
|
||||
@@ -148,12 +124,12 @@ class ADM
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Product Informtion and Director
|
||||
* Get Product Information and Director
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function productInfo()
|
||||
protected function productInfo()
|
||||
{
|
||||
|
||||
foreach ($this->_html->find('ul.list-unstyled li') as $li) {
|
||||
@@ -177,7 +153,7 @@ class ADM
|
||||
* Gets the cast members
|
||||
* @return array
|
||||
*/
|
||||
public function cast()
|
||||
protected function cast()
|
||||
{
|
||||
$cast = [];
|
||||
foreach ($this->_html->find('h3') as $heading) {
|
||||
@@ -198,10 +174,10 @@ class ADM
|
||||
* Gets categories
|
||||
* @return array
|
||||
*/
|
||||
public function genres()
|
||||
protected function genres()
|
||||
{
|
||||
$genres = [];
|
||||
foreach ($this->_html->find('ul.list-unstyled li') as $li) {
|
||||
foreach ($this->_html->find('ul.list-unstyled') as $li) {
|
||||
$category = explode(':', $li->plaintext);
|
||||
if (trim($category[0]) === 'Category') {
|
||||
$genre = explode(',', $category[1]);
|
||||
@@ -217,14 +193,19 @@ class ADM
|
||||
|
||||
/**
|
||||
* Searches for match against searchterm
|
||||
*
|
||||
* @param $movie
|
||||
*
|
||||
* @return bool - true if search = 100%
|
||||
*/
|
||||
public function search()
|
||||
public function processSite($movie)
|
||||
{
|
||||
$result = false;
|
||||
if (!empty($this->searchTerm)) {
|
||||
$this->_trailUrl = self::TRAILINGSEARCH . urlencode($this->searchTerm);
|
||||
if ($this->getUrl() !== false) {
|
||||
if (!empty($movie)) {
|
||||
$this->_trailUrl = self::TRAILINGSEARCH . urlencode($movie);
|
||||
$this->_response = getRawHtml(self::ADMURL . $this->_trailUrl, $this->cookie);
|
||||
if ($this->_response !== false) {
|
||||
$this->_html->load($this->_response);
|
||||
if ($ret = $this->_html->find('img[rel=license]')) {
|
||||
if (count($ret) > 0) {
|
||||
foreach ($this->_html->find('img[rel=license]') as $ret) {
|
||||
@@ -232,23 +213,26 @@ class ADM
|
||||
$title = trim($ret->alt, '"');
|
||||
$title = str_replace('/XXX/', '', $title);
|
||||
$comparetitle = preg_replace('/[\W]/', '', $title);
|
||||
$comparesearch = preg_replace('/[\W]/', '', $this->searchTerm);
|
||||
$comparesearch = preg_replace('/[\W]/', '', $movie);
|
||||
similar_text($comparetitle, $comparesearch, $p);
|
||||
if ($p === 100) {
|
||||
if ($p >= 90) {
|
||||
if (preg_match('/\/(?<sku>\d+)\.jpg/i', $ret->src, $matches)) {
|
||||
$this->_title = trim($title);
|
||||
$this->_trailUrl = '/dvd_view_' . (string)$matches['sku'] . '.html';
|
||||
$this->_directUrl = self::ADMURL . $this->_trailUrl;
|
||||
$this->_html->clear();
|
||||
unset($this->_response);
|
||||
$this->_response = getRawHtml($this->_directUrl, $this->cookie);
|
||||
$this->_html->load($this->_response);
|
||||
$result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$result = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -256,7 +240,7 @@ class ADM
|
||||
* Gets all information
|
||||
* @return array
|
||||
*/
|
||||
public function getAll()
|
||||
protected function getAll()
|
||||
{
|
||||
$results = [];
|
||||
if (!empty($this->_directUrl)) {
|
||||
@@ -288,52 +272,10 @@ class ADM
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Raw html of webpage
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function getUrl()
|
||||
protected function trailers()
|
||||
{
|
||||
if (!empty($this->_trailUrl)) {
|
||||
try {
|
||||
$this->_response = $this->client->get(self::ADMURL . $this->_trailUrl)->getBody()->getContents();
|
||||
} catch (RequestException $e) {
|
||||
if ($e->hasResponse()) {
|
||||
if($e->getCode() === 404) {
|
||||
ColorCLI::doEcho(ColorCLI::notice('Data not available on ADM server'));
|
||||
} else if ($e->getCode() === 503) {
|
||||
ColorCLI::doEcho(ColorCLI::notice('ADM Service unavailable'));
|
||||
} else {
|
||||
ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data from ADM, http error reported: ' . $e->getCode()));
|
||||
}
|
||||
}
|
||||
} catch (\RuntimeException $e) {
|
||||
ColorCLI::doEcho(ColorCLI::notice('Runtime error: ' . $e->getCode()));
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
$this->_response = $this->client->get(self::IF18)->getBody()->getContents();
|
||||
} catch (RequestException $e) {
|
||||
if ($e->hasResponse()) {
|
||||
if($e->getCode() === 404) {
|
||||
ColorCLI::doEcho(ColorCLI::notice('Data not available on ADM server'));
|
||||
} else if ($e->getCode() === 503) {
|
||||
ColorCLI::doEcho(ColorCLI::notice('ADM service unavailable'));
|
||||
} else {
|
||||
ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data from ADM, http error reported: ' . $e->getCode()));
|
||||
}
|
||||
}
|
||||
} catch (\RuntimeException $e) {
|
||||
ColorCLI::doEcho(ColorCLI::notice('Runtime error: ' . $e->getCode()));
|
||||
}
|
||||
}
|
||||
// TODO: Implement trailers() method.
|
||||
|
||||
if (!$this->_response) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->_html->load($this->_response);
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Executable
+293
@@ -0,0 +1,293 @@
|
||||
<?php
|
||||
|
||||
namespace nntmux\processing\adult;
|
||||
|
||||
class AEBN extends AdultMovies
|
||||
{
|
||||
/**
|
||||
* Keyword to search
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $searchTerm = '';
|
||||
|
||||
/**
|
||||
* Url Constants used within this class
|
||||
*/
|
||||
const AEBNSURL = 'http://straight.theater.aebn.net';
|
||||
const IF18 = 'http://straight.theater.aebn.net/dispatcher/frontDoor?genreId=101&theaterId=13992&locale=en&refid=AEBN-000001';
|
||||
const TRAILINGSEARCH = '/dispatcher/fts?theaterId=13992&genreId=101&locale=en&count=30&imageType=Large&targetSearchMode=basic&isAdvancedSearch=false&isFlushAdvancedSearchCriteria=false&sortType=Relevance&userQuery=title%3A+%2B';
|
||||
const TRAILERURL = '/dispatcher/previewPlayer?locale=en&theaterId=13992&genreId=101&movieId=';
|
||||
|
||||
/**
|
||||
* Direct Url in getAll method
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_directUrl = '';
|
||||
|
||||
/**
|
||||
* Simple Html Dom Object
|
||||
*
|
||||
* @var \simple_html_dom
|
||||
*/
|
||||
protected $_html;
|
||||
|
||||
/**
|
||||
* Raw Html response from curl
|
||||
*
|
||||
*/
|
||||
protected $_response;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_trailerUrl = '';
|
||||
|
||||
/**
|
||||
* Returned results in all methods except search/geturl
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_res = [
|
||||
'backcover' => [],
|
||||
'boxcover' => [],
|
||||
'cast' => [],
|
||||
'director' => [],
|
||||
'genres' => [],
|
||||
'productinfo' => [],
|
||||
'synopsis' => [],
|
||||
'trailers' => ['url' => []],
|
||||
];
|
||||
|
||||
/**
|
||||
* Sets title in getAll method
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_title = '';
|
||||
|
||||
|
||||
/**
|
||||
* Sets the variables that used throughout the class
|
||||
*
|
||||
* @param array $options
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct(array $options = [])
|
||||
{
|
||||
parent::__construct($options);
|
||||
$this->_html = new \simple_html_dom();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Trailer URL .. will be processed in XXX insertswf
|
||||
*
|
||||
* @return array|bool
|
||||
*/
|
||||
protected function trailers()
|
||||
{
|
||||
$ret = $this->_html->find('a[itemprop=trailer]', 0);
|
||||
if (!empty($ret) && preg_match('/movieId=(?<movieid>\d+)&/', trim($ret->href), $matches)) {
|
||||
$movieid = $matches['movieid'];
|
||||
$this->_res['trailers']['url'] = self::AEBNSURL . self::TRAILERURL . $movieid;
|
||||
}
|
||||
|
||||
return $this->_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the front and back cover of the box
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function covers()
|
||||
{
|
||||
$ret = $this->_html->find('div#md-boxCover, img[itemprop=thumbnailUrl]', 1);
|
||||
if ($ret !== false) {
|
||||
$ret = trim($ret->src);
|
||||
if (strpos($ret, '//') === 0) {
|
||||
$ret = 'http:' . $ret;
|
||||
}
|
||||
$this->_res['boxcover'] = str_ireplace('160w.jpg', 'xlf.jpg', $ret);
|
||||
$this->_res['backcover'] = str_ireplace('160w.jpg', 'xlb.jpg', $ret);
|
||||
}
|
||||
|
||||
return $this->_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Genres "Categories".
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function genres()
|
||||
{
|
||||
if ($ret = $this->_html->find('div.md-detailsCategories', 0)) {
|
||||
foreach ($ret->find('a[itemprop=genre]') as $genre) {
|
||||
$this->_res['genres'][] = trim($genre->plaintext);
|
||||
}
|
||||
}
|
||||
if (!empty($this->_res['genres'])) {
|
||||
$this->_res['genres'] = array_unique($this->_res['genres']);
|
||||
}
|
||||
return $this->_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Cast Members "Stars" and Director if any
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function cast()
|
||||
{
|
||||
$this->_res = false;
|
||||
if ($ret = $this->_html->find('div.starsFull', 0)) {
|
||||
foreach ($ret->find('span[itemprop=name]') as $star) {
|
||||
$this->_res['cast'][] = trim($star->plaintext);
|
||||
}
|
||||
} else {
|
||||
if ($ret = $this->_html->find('div.detailsLink', 0)) {
|
||||
foreach ($ret->find('span') as $star) {
|
||||
if (strpos($star->plaintext, '/More/') !== false && strpos($star->plaintext, '/Stars/') !== false) {
|
||||
$this->_res['cast'][] = trim($star->plaintext);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the product information
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function productInfo()
|
||||
{
|
||||
if ($ret = $this->_html->find('div#md-detailsLeft', 0)) {
|
||||
foreach ($ret->find('div') as $div) {
|
||||
foreach ($div->find('span') as $span) {
|
||||
$span->plaintext = rawurldecode($span->plaintext);
|
||||
$span->plaintext = preg_replace('/ /', '', $span->plaintext);
|
||||
$this->_res['productinfo'][] = trim($span->plaintext);
|
||||
}
|
||||
}
|
||||
if (false !== $key = array_search('Running Time:', $this->_res['productinfo'], false)) {
|
||||
unset($this->_res['productinfo'][$key + 2]);
|
||||
}
|
||||
if (false !== $key = array_search('Director:' , $this->_res['productinfo'], false)) {
|
||||
$this->_res['director'] = $this->_res['productinfo'][$key + 1];
|
||||
unset($this->_res['productinfo'][$key], $this->_res['productinfo'][$key + 1]);
|
||||
}
|
||||
$this->_res['productinfo'] = array_chunk($this->_res['productinfo'], 2, false);
|
||||
}
|
||||
|
||||
return $this->_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the synopsis "plot"
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
*/
|
||||
protected function synopsis()
|
||||
{
|
||||
if ($ret = $this->_html->find('span[itemprop=about]', 0)) {
|
||||
if ($ret === null) {
|
||||
if ($ret = $this->_html->find('div.movieDetailDescription', 0)) {
|
||||
$this->_res['synopsis'] = preg_replace('/Description:\s/', '', $this->_res['plot']);
|
||||
}
|
||||
} else {
|
||||
$this->_res['synopsis'] = trim($ret->plaintext);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches for a XXX name
|
||||
*
|
||||
* @param string $movie
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function processSite($movie): bool
|
||||
{
|
||||
if (empty($movie)) {
|
||||
return false;
|
||||
}
|
||||
$this->_trailerUrl = self::TRAILINGSEARCH . urlencode($movie);
|
||||
$this->_response = getRawHtml(self::AEBNSURL . $this->_trailerUrl, $this->cookie);
|
||||
if ($this->_response !== false) {
|
||||
$this->_html->load($this->_response);
|
||||
$i = 1;
|
||||
foreach ($this->_html->find('div.movie') as $mov) {
|
||||
$string = 'a#FTSMovieSearch_link_title_detail_' . $i;
|
||||
if ($ret = $mov->find($string, 0)) {
|
||||
$title = str_replace('/XXX/', '', $ret->title);
|
||||
$title = preg_replace('/\(.*?\)|[-._]/', ' ', $title);
|
||||
$title = trim($title);
|
||||
similar_text(strtolower($movie), strtolower($title), $p);
|
||||
if ($p >= 90) {
|
||||
$this->_title = trim($ret->title);
|
||||
$this->_trailerUrl = html_entity_decode($ret->href);
|
||||
$this->_directUrl = self::AEBNSURL . $this->_trailerUrl;
|
||||
$this->_html->clear();
|
||||
unset($this->_response);
|
||||
$this->_response = getRawHtml(self::AEBNSURL . $this->_trailerUrl, $this->cookie);
|
||||
$this->_html->load($this->_response);
|
||||
|
||||
return true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all the information
|
||||
*
|
||||
* @return array|bool
|
||||
*/
|
||||
protected function getAll()
|
||||
{
|
||||
$results = [];
|
||||
if (!empty($this->_directUrl)) {
|
||||
$results['title'] = $this->_title;
|
||||
$results['directurl'] = $this->_directUrl;
|
||||
}
|
||||
if (is_array($this->synopsis())) {
|
||||
$results = array_merge($results, $this->synopsis());
|
||||
}
|
||||
if (is_array($this->productInfo())) {
|
||||
$results = array_merge($results, $this->productInfo());
|
||||
}
|
||||
if (is_array($this->cast())) {
|
||||
$results = array_merge($results, $this->cast());
|
||||
}
|
||||
if (is_array($this->genres())) {
|
||||
$results = array_merge($results, $this->genres());
|
||||
}
|
||||
$covers = $this->covers();
|
||||
if (is_array($covers)) {
|
||||
$results = array_merge($results, $covers);
|
||||
}
|
||||
if (is_array($this->trailers())) {
|
||||
$results = array_merge($results, $this->trailers());
|
||||
}
|
||||
if (empty($results)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace nntmux\processing\adult;
|
||||
|
||||
use nntmux\XXX;
|
||||
|
||||
abstract class AdultMovies extends XXX
|
||||
{
|
||||
const PROCESS_AEBN = 0; // Process AEBN First
|
||||
const PROCESS_ADE = -1; // Process ADE Second
|
||||
const PROCESS_POPPORN = -2; // Process POPPORN Third
|
||||
const PROCESS_HOTMOVIES = -3; // Process HOTMOVIES Fourth
|
||||
const PROCESS_ADM = -4; // Process ADM Fifth
|
||||
const NO_MATCH_FOUND = -6; // Failed All Methods
|
||||
const FAILED_PARSE = -100; // Failed Parsing
|
||||
|
||||
/**
|
||||
* AdultMovies constructor.
|
||||
*
|
||||
* @param array $options
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct(array $options = [])
|
||||
{
|
||||
parent::__construct($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
abstract protected function productInfo();
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
abstract protected function covers();
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
abstract protected function synopsis();
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
abstract protected function cast();
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
abstract protected function genres();
|
||||
|
||||
/**
|
||||
* @param string $movie
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
abstract protected function processSite($movie);
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
abstract protected function getAll();
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
abstract protected function trailers();
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
namespace nntmux;
|
||||
|
||||
class Hotmovies
|
||||
namespace nntmux\processing\adult;
|
||||
|
||||
class Hotmovies extends AdultMovies
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -17,7 +18,7 @@ class Hotmovies
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $searchTerm = '';
|
||||
protected $searchTerm = '';
|
||||
/**
|
||||
* Define a cookie location
|
||||
*
|
||||
@@ -78,86 +79,23 @@ class Hotmovies
|
||||
*/
|
||||
protected $_title = '';
|
||||
|
||||
|
||||
|
||||
public function __construct()
|
||||
/**
|
||||
* Hotmovies constructor.
|
||||
*
|
||||
* @param array $options
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct(array $options = [])
|
||||
{
|
||||
parent::__construct($options);
|
||||
$this->_html = new \simple_html_dom();
|
||||
|
||||
// Set a cookie to override +18 warning.
|
||||
if (!empty($this->cookie)) {
|
||||
@$this->getUrl();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove from memory if it still exists
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get Raw html of webpage
|
||||
*
|
||||
* @param bool $usepost
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function getUrl($usepost = false)
|
||||
protected function trailers()
|
||||
{
|
||||
if (!empty($this->_getLink)) {
|
||||
$ch = curl_init($this->_getLink);
|
||||
} else {
|
||||
$ch = curl_init(self::HMURL);
|
||||
}
|
||||
if (!empty($this->directLink)) {
|
||||
$ch = curl_init($this->directLink);
|
||||
$this->directLink = '';
|
||||
}
|
||||
if ($usepost === true){
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->_postParams);
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
curl_setopt($ch, CURLOPT_VERBOSE, 0);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1944.0 Safari/537.36');
|
||||
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
|
||||
if (!empty($this->cookie)) {
|
||||
curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookie);
|
||||
curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookie);
|
||||
}
|
||||
$this->_response = curl_exec($ch);
|
||||
if (!$this->_response) {
|
||||
curl_close($ch);
|
||||
// TODO: Implement trailers() method.
|
||||
|
||||
return false;
|
||||
}
|
||||
$this->_html->load($this->_response);
|
||||
curl_close($ch);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
$this->_html->clear();
|
||||
unset($this->_response, $this->_res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Directly gets the link if directlink is set, and parses it.
|
||||
*
|
||||
* @return bool|array
|
||||
*/
|
||||
public function getDirect()
|
||||
{
|
||||
if (!empty($this->directLink)) {
|
||||
if ($this->getUrl() === false) {
|
||||
return false;
|
||||
} else {
|
||||
return $this->getAll();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -165,15 +103,15 @@ class Hotmovies
|
||||
* Gets all information
|
||||
* @return bool|array
|
||||
*/
|
||||
public function getAll()
|
||||
protected function getAll()
|
||||
{
|
||||
$results = [];
|
||||
if (!empty($this->_directUrl)) {
|
||||
$results['title'] = $this->_title;
|
||||
$results['directurl'] = $this->_directUrl;
|
||||
}
|
||||
if (is_array($this->sypnosis())) {
|
||||
$results = array_merge($results, $this->sypnosis());
|
||||
if (is_array($this->synopsis())) {
|
||||
$results = array_merge($results, $this->synopsis());
|
||||
}
|
||||
if (is_array($this->productInfo())) {
|
||||
$results = array_merge($results, $this->productInfo());
|
||||
@@ -188,24 +126,26 @@ class Hotmovies
|
||||
$results = array_merge($results, $this->covers());
|
||||
}
|
||||
|
||||
if (empty($results) === true){
|
||||
if (empty($results)) {
|
||||
return false;
|
||||
}else{
|
||||
return $results;
|
||||
}
|
||||
|
||||
return $results;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sypnosis
|
||||
* Gets the synopsis
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function sypnosis()
|
||||
protected function synopsis(): array
|
||||
{
|
||||
$this->_res['synopsis'] = 'N/A';
|
||||
if ($this->_html->find('.desc_link', 0)) {
|
||||
preg_match('/var descfullcontent = (?<content>.*)/', $this->_response,$matches);
|
||||
if (is_array($matches)) {
|
||||
$this->_res['sypnosis'] = rawurldecode($matches['content']);
|
||||
$ret = $this->_html->find('.video_description', 0);
|
||||
if ($ret !== false) {
|
||||
$this->_res['synopsis'] = trim($ret->innertext);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,18 +156,14 @@ class Hotmovies
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function productInfo()
|
||||
protected function productInfo(): array
|
||||
{
|
||||
$studio = false;
|
||||
$director = false;
|
||||
if ($ret = $this->_html->find('div.page_video_info', 0)) {
|
||||
foreach ($ret->find('text') as $e) {
|
||||
$e = trim($e->innertext);
|
||||
$rArray = [
|
||||
',',
|
||||
'...',
|
||||
' :'
|
||||
];
|
||||
$rArray = [',', '...', ' :'];
|
||||
$e = str_replace($rArray, '', $e);
|
||||
if (stripos($e, 'Studio:') !== false) {
|
||||
$studio = true;
|
||||
@@ -267,15 +203,16 @@ class Hotmovies
|
||||
/**
|
||||
* Gets the cast members and director
|
||||
*
|
||||
*@return array
|
||||
* @return array
|
||||
*/
|
||||
public function cast()
|
||||
protected function cast()
|
||||
{
|
||||
$cast = null;
|
||||
if ($this->_html->find('a[itemprop=actor]')) {
|
||||
foreach ($this->_html->find('a[itemprop=actor]') as $e) {
|
||||
$cast = [];
|
||||
if ($this->_html->find('.stars bottom_margin')) {
|
||||
file_put_contents('hm_cast.txt', $this->_html->find('.stars bottom_margin'));
|
||||
foreach ($this->_html->find('a[title]') as $e) {
|
||||
$e = trim($e->title);
|
||||
$e = preg_replace('/\((.*)\)/','',$e);
|
||||
$e = preg_replace('/\((.*)\)/', '', $e);
|
||||
$cast[] = trim($e);
|
||||
}
|
||||
$this->_res['cast'] = $cast;
|
||||
@@ -288,22 +225,20 @@ class Hotmovies
|
||||
/**
|
||||
* Gets categories
|
||||
*
|
||||
*@return array
|
||||
* @return array
|
||||
*/
|
||||
public function genres()
|
||||
protected function genres()
|
||||
{
|
||||
$genres = [];
|
||||
if ($ret = $this->_html->find('div.categories',0)) {
|
||||
foreach ($ret->find('a') as $e) {
|
||||
if (strpos($e->title, '->') !== false) {
|
||||
$e = explode('->',$e->plaintext);
|
||||
if (strpos($e->title, ' -> ') !== false) {
|
||||
$e = explode(' -> ',$e->plaintext);
|
||||
$genres[] = trim($e[1]);
|
||||
}
|
||||
}
|
||||
$this->_res['genres'] = $genres;
|
||||
|
||||
}
|
||||
|
||||
return $this->_res;
|
||||
}
|
||||
|
||||
@@ -311,12 +246,12 @@ class Hotmovies
|
||||
* Get Box Cover Images
|
||||
* @return bool|array - boxcover,backcover
|
||||
*/
|
||||
public function covers()
|
||||
protected function covers()
|
||||
{
|
||||
if ($ret = $this->_html->find('div#large_cover, img#cover', 1)) {
|
||||
$this->_res['boxcover'] = trim($ret->src);
|
||||
$this->_res['backcover'] = str_ireplace('.cover', '.back', trim($ret->src));
|
||||
}else{
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -324,45 +259,53 @@ class Hotmovies
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches for match against searchterm
|
||||
* @return bool, true if search >= 90%
|
||||
* Searches for match against xxx movie name
|
||||
*
|
||||
* @param string $movie
|
||||
*
|
||||
* @return bool , true if search >= 90%
|
||||
*/
|
||||
public function search()
|
||||
public function processSite($movie): bool
|
||||
{
|
||||
if (empty($this->searchTerm)) {
|
||||
if (empty($movie)) {
|
||||
return false;
|
||||
}
|
||||
$this->_getLink = self::HMURL . self::TRAILINGSEARCH . urlencode($this->searchTerm) . self::EXTRASEARCH;
|
||||
if ($this->getUrl() === false) {
|
||||
return false;
|
||||
} else {
|
||||
$this->_response = false;
|
||||
$this->_getLink = self::HMURL . self::TRAILINGSEARCH . urlencode($movie) . self::EXTRASEARCH;
|
||||
$this->_response = getRawHtml($this->_getLink, $this->cookie);
|
||||
if ($this->_response !== false) {
|
||||
$this->_html->load($this->_response);
|
||||
if ($ret = $this->_html->find('h3[class=title]', 0)) {
|
||||
if ($ret->find('a[title]',0)){
|
||||
if ($ret->find('a[title]', 0)) {
|
||||
$ret = $ret->find('a[title]', 0);
|
||||
$title = trim($ret->title);
|
||||
$title = str_replace('/XXX/', '', $title);
|
||||
$title = preg_replace('/\(.*?\)|[-._]/', ' ', $title);
|
||||
$this->_getLink = trim($ret->href);
|
||||
$this->_directUrl = trim($ret->href);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
if (!empty($title)) {
|
||||
similar_text($this->searchTerm, $title, $p);
|
||||
if ($p >= 90) {
|
||||
$this->_title = $title;
|
||||
// 90$ match found, load the url to start parsing
|
||||
$this->getUrl();
|
||||
unset($ret);
|
||||
if (!empty($title)) {
|
||||
similar_text($movie, $title, $p);
|
||||
if ($p >= 90) {
|
||||
$this->_title = $title;
|
||||
$this->_getLink = trim($ret->href);
|
||||
$this->_directUrl = trim($ret->href);
|
||||
$this->_html->clear();
|
||||
unset($this->_response);
|
||||
if ($this->_getLink !== false) {
|
||||
$this->_response = getRawHtml($this->_getLink, $this->cookie);
|
||||
$this->_html->load($this->_response);
|
||||
} else {
|
||||
$this->_response = getRawHtml($this->_directUrl, $this->cookie);
|
||||
$this->_html->load($this->_response);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,37 +1,37 @@
|
||||
<?php
|
||||
namespace nntmux;
|
||||
namespace nntmux\processing\adult;
|
||||
|
||||
use nntmux\utility\Utility;
|
||||
|
||||
class Popporn
|
||||
class Popporn extends AdultMovies
|
||||
{
|
||||
|
||||
/**
|
||||
* Define a cookie file location for curl
|
||||
* @var string string
|
||||
*/
|
||||
public $cookie = "";
|
||||
public $cookie = '';
|
||||
|
||||
/**
|
||||
* Set this for what you are searching for.
|
||||
* @var string
|
||||
*/
|
||||
public $searchTerm = "";
|
||||
public $searchTerm = '';
|
||||
|
||||
/**
|
||||
* Override if 18 years+ or older
|
||||
* Define Popporn url
|
||||
* Needed Search Queries Constant
|
||||
*/
|
||||
const IF18 = "http://www.popporn.com/popporn/4";
|
||||
const POPURL = "http://www.popporn.com";
|
||||
const TRAILINGSEARCH = "/results/index.cfm?v=4&g=0&searchtext=";
|
||||
const IF18 = 'http://www.popporn.com/popporn/4';
|
||||
const POPURL = 'http://www.popporn.com';
|
||||
const TRAILINGSEARCH = '/results/index.cfm?v=4&g=0&searchtext=';
|
||||
|
||||
/**
|
||||
* Sets the directurl for the return results array
|
||||
* @var string
|
||||
*/
|
||||
protected $_directUrl = "";
|
||||
protected $_directUrl = '';
|
||||
|
||||
/**
|
||||
* Simple Html Dom Object
|
||||
@@ -40,11 +40,6 @@ class Popporn
|
||||
*/
|
||||
protected $_html;
|
||||
|
||||
/**
|
||||
* POST Paramaters for Trailers Method
|
||||
*/
|
||||
protected $_postParams;
|
||||
|
||||
/**
|
||||
* Curl Raw Html
|
||||
*/
|
||||
@@ -62,44 +57,32 @@ class Popporn
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_title = "";
|
||||
protected $_title = '';
|
||||
|
||||
/**
|
||||
* Add this to popurl to get results
|
||||
* @var string
|
||||
*/
|
||||
protected $_trailUrl = "";
|
||||
protected $_trailUrl = '';
|
||||
|
||||
public function __construct()
|
||||
public function __construct(array $options = [])
|
||||
{
|
||||
parent::__construct($options);
|
||||
$this->_html = new \simple_html_dom();
|
||||
if (isset($this->cookie)) {
|
||||
$this->getUrl();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove from memory.
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
$this->_html->clear();
|
||||
unset($this->_response);
|
||||
unset($this->_res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Box Cover Images
|
||||
* @return array - boxcover,backcover
|
||||
*/
|
||||
public function covers()
|
||||
public function covers(): array
|
||||
{
|
||||
if ($ret = $this->_html->find('div[id=box-art], a[rel=box-art]', 1)) {
|
||||
$this->_res['boxcover'] = trim($ret->href);
|
||||
if (stristr(trim($ret->href), "_aa")) {
|
||||
$this->_res['backcover'] = str_ireplace("_aa", "_bb", trim($ret->href));
|
||||
if (false !== stripos(trim($ret->href), '_aa')) {
|
||||
$this->_res['backcover'] = str_ireplace('_aa', '_bb', trim($ret->href));
|
||||
} else {
|
||||
$this->_res['backcover'] = str_ireplace(".jpg", "_b.jpg", trim($ret->href));
|
||||
$this->_res['backcover'] = str_ireplace('.jpg', '_b.jpg', trim($ret->href));
|
||||
}
|
||||
} else {
|
||||
if ($ret = $this->_html->find('img.front', 0)) {
|
||||
@@ -114,20 +97,20 @@ class Popporn
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sypnosis
|
||||
* Gets the synopsis
|
||||
* @return array|bool
|
||||
*/
|
||||
public function sypnosis()
|
||||
public function synopsis()
|
||||
{
|
||||
if ($ret = $this->_html->find('div[id=product-info] ,h3[class=highlight]', 1)) {
|
||||
if ($ret->next_sibling()->plaintext) {
|
||||
if (!stristr(trim($ret->next_sibling()->plaintext), "POPPORN EXCLUSIVE")) {
|
||||
$this->_res['sypnosis'] = trim($ret->next_sibling()->plaintext);
|
||||
$this->_res['synopsis'] = trim($ret->next_sibling()->plaintext);
|
||||
} else {
|
||||
if ($ret->next_sibling()->next_sibling()) {
|
||||
$this->_res['sypnosis'] = trim($ret->next_sibling()->next_sibling()->next_sibling()->plaintext);
|
||||
$this->_res['synopsis'] = trim($ret->next_sibling()->next_sibling()->next_sibling()->plaintext);
|
||||
} else {
|
||||
$this->_res['sypnosis'] = "N/A";
|
||||
$this->_res['synopsis'] = 'N/A';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -144,19 +127,19 @@ class Popporn
|
||||
{
|
||||
if ($ret = $this->_html->find('input#thickbox-trailer-link', 0)) {
|
||||
$ret->value = trim($ret->value);
|
||||
$ret->value = str_replace("..", "", $ret->value);
|
||||
$ret->value = str_replace('..', '', $ret->value);
|
||||
$tmprsp = $this->_response;
|
||||
$this->_trailUrl = $ret->value;
|
||||
$this->getUrl();
|
||||
$this->getRawHtml();
|
||||
if (preg_match_all('/productID="\+(?<id>[0-9]+),/', $this->_response, $matches)) {
|
||||
$productid = $matches['id'][0];
|
||||
$random = ((float)rand() / (float)getrandmax()) * 5400000000000000;
|
||||
$this->_trailUrl = "/com/tlavideo/vod/FlvAjaxSupportService.cfc?random=" . $random;
|
||||
$this->_postParams = "method=pipeStreamLoc&productID=" . $productid;
|
||||
$this->getUrl(true);
|
||||
$this->_trailUrl = '/com/tlavideo/vod/FlvAjaxSupportService.cfc?random=' . $random;
|
||||
$this->_postParams = 'method=pipeStreamLoc&productID=' . $productid;
|
||||
$this->getRawHtml(true);
|
||||
$ret = json_decode(json_decode($this->_response, true), true);
|
||||
$this->_res['trailers']['baseurl'] = self::POPURL . "/flashmediaserver/trailerPlayer.swf";
|
||||
$this->_res['trailers']['flashvars'] = "subscribe=false&image=&file=" . self::POPURL . "/" . $ret['LOC'] . "&autostart=false";
|
||||
$this->_res['trailers']['baseurl'] = self::POPURL . '/flashmediaserver/trailerPlayer.swf';
|
||||
$this->_res['trailers']['flashvars'] = 'subscribe=false&image=&file=' . self::POPURL . '/' . $ret['LOC'] . '&autostart=false';
|
||||
unset($this->_response);
|
||||
$this->_response = $tmprsp;
|
||||
}
|
||||
@@ -178,14 +161,14 @@ class Popporn
|
||||
if ($ret = $this->_html->find('div#lside', 0)) {
|
||||
foreach ($ret->find("text") as $e) {
|
||||
$e = trim($e->innertext);
|
||||
$e = str_replace(",", "", $e);
|
||||
$e = str_replace("...", "", $e);
|
||||
$e = str_replace(" ", "", $e);
|
||||
if (stristr($e, "Country:")) {
|
||||
$e = str_replace(',', '', $e);
|
||||
$e = str_replace('...', '', $e);
|
||||
$e = str_replace(' ', '', $e);
|
||||
if (stristr($e, 'Country:')) {
|
||||
$country = true;
|
||||
}
|
||||
if ($country === true) {
|
||||
if (!stristr($e, "addthis_config")) {
|
||||
if (!stristr($e, 'addthis_config')) {
|
||||
if (!empty($e)) {
|
||||
$this->_res['productinfo'][] = $e;
|
||||
}
|
||||
@@ -204,11 +187,11 @@ class Popporn
|
||||
foreach ($this->_html->find('ul.stock-information') as $ul) {
|
||||
foreach ($ul->find('li') as $e) {
|
||||
$e = trim($e->plaintext);
|
||||
if ($e == "Features:") {
|
||||
if ($e == 'Features:') {
|
||||
$features = true;
|
||||
$e = null;
|
||||
}
|
||||
if ($features == true) {
|
||||
if ($features === true) {
|
||||
if (!empty($e)) {
|
||||
$this->_res['extras'][] = $e;
|
||||
}
|
||||
@@ -231,16 +214,16 @@ class Popporn
|
||||
$director = false;
|
||||
$er = [];
|
||||
if ($ret = $this->_html->find('div#lside', 0)) {
|
||||
foreach ($ret->find("text") as $e) {
|
||||
foreach ($ret->find('text') as $e) {
|
||||
$e = trim($e->innertext);
|
||||
$e = str_replace(",", "", $e);
|
||||
$e = str_replace(" ", "", $e);
|
||||
if (stristr($e, "Cast")) {
|
||||
$e = str_replace(',', '', $e);
|
||||
$e = str_replace(' ', '', $e);
|
||||
if (stristr($e, 'Cast')) {
|
||||
$cast = true;
|
||||
}
|
||||
$e = str_replace("Cast:", "", $e);
|
||||
$e = str_replace('Cast:', '', $e);
|
||||
if ($cast === true) {
|
||||
if (stristr($e, "Director:")) {
|
||||
if (stristr($e, 'Director:')) {
|
||||
$director = true;
|
||||
$e = null;
|
||||
}
|
||||
@@ -252,7 +235,7 @@ class Popporn
|
||||
$e = null;
|
||||
}
|
||||
}
|
||||
if (!stristr($e, "Country:")) {
|
||||
if (!stristr($e, 'Country:')) {
|
||||
if (!empty($e)) {
|
||||
$er[] = $e;
|
||||
}
|
||||
@@ -286,14 +269,18 @@ class Popporn
|
||||
|
||||
/**
|
||||
* Searches for match against searchterm
|
||||
* @return bool, true if search >= 90%
|
||||
*
|
||||
* @param string $movie
|
||||
*
|
||||
* @return bool , true if search >= 90%
|
||||
*/
|
||||
public function search()
|
||||
public function processSite($movie): bool
|
||||
{
|
||||
$result = false;
|
||||
if (isset($this->searchTerm)) {
|
||||
$this->_trailUrl = self::TRAILINGSEARCH . urlencode($this->searchTerm);
|
||||
if ($this->getUrl() !== false) {
|
||||
if (!empty($movie)) {
|
||||
$this->_trailUrl = self::TRAILINGSEARCH . urlencode($movie);
|
||||
$this->_response = getRawHtml(self::POPURL . $this->_trailUrl, $this->cookie);
|
||||
if ($this->_response !== false) {
|
||||
$this->_html->load($this->_response);
|
||||
if ($ret = $this->_html->find('div.product-info, div.title', 1)) {
|
||||
$this->_title = trim($ret->plaintext);
|
||||
$title = preg_replace('/XXX/', '', $ret->plaintext);
|
||||
@@ -301,36 +288,50 @@ class Popporn
|
||||
$title = trim($title);
|
||||
if ($ret = $ret->find('a', 0)) {
|
||||
$this->_trailUrl = trim($ret->href);
|
||||
if ($this->getUrl() !== false) {
|
||||
$this->_html->clear();
|
||||
unset($this->_response);
|
||||
$this->_response = getRawHtml($this->_trailUrl, $this->cookie);
|
||||
if ($this->_response !== false) {
|
||||
$this->_html->load($this->_response);
|
||||
if ($ret = $this->_html->find('#link-to-this', 0)) {
|
||||
$this->_directUrl = trim($ret->href);
|
||||
$this->_html->clear();
|
||||
unset($this->_response);
|
||||
$this->_response = getRawHtml($this->_directUrl, $this->cookie);
|
||||
$this->_html->load($this->_response);
|
||||
}
|
||||
similar_text(strtolower($this->searchTerm), strtolower($title), $p);
|
||||
similar_text(strtolower($movie), strtolower($title), $p);
|
||||
if ($p >= 90) {
|
||||
$result = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->_response = getRawHtml(self::IF18);
|
||||
if ($this->_response !== false) {
|
||||
$this->_html->load($this->_response);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all information
|
||||
* @return array
|
||||
* @return array|bool
|
||||
*/
|
||||
public function getAll()
|
||||
protected function getAll()
|
||||
{
|
||||
$results = [];
|
||||
if (isset($this->_directUrl)) {
|
||||
$results['title'] = $this->_title;
|
||||
$results['directurl'] = $this->_directUrl;
|
||||
}
|
||||
if (is_array($this->sypnosis())) {
|
||||
$results = array_merge($results, $this->sypnosis());
|
||||
if (is_array($this->synopsis())) {
|
||||
$results = array_merge($results, $this->synopsis());
|
||||
}
|
||||
if (is_array($this->productInfo(true))) {
|
||||
$results = array_merge($results, $this->productInfo(true));
|
||||
@@ -347,51 +348,9 @@ class Popporn
|
||||
if (is_array($this->trailers())) {
|
||||
$results = array_merge($results, $this->trailers());
|
||||
}
|
||||
if (empty($results) === true) {
|
||||
return false;
|
||||
} else {
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Raw html of webpage
|
||||
*
|
||||
* @param bool $usepost
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function getUrl($usepost = false)
|
||||
{
|
||||
if (isset($this->_trailUrl)) {
|
||||
$ch = curl_init(self::POPURL . $this->_trailUrl);
|
||||
} else {
|
||||
$ch = curl_init(self::IF18);
|
||||
}
|
||||
|
||||
if ($usepost === true) {
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->_postParams);
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
curl_setopt($ch, CURLOPT_VERBOSE, 0);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, "Firefox/2.0.0.1");
|
||||
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
|
||||
if (isset($this->cookie)) {
|
||||
curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookie);
|
||||
curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookie);
|
||||
}
|
||||
curl_setopt_array($ch, Utility::curlSslContextOptions());
|
||||
$this->_response = curl_exec($ch);
|
||||
if (!$this->_response) {
|
||||
curl_close($ch);
|
||||
if (empty($results)) {
|
||||
return false;
|
||||
}
|
||||
curl_close($ch);
|
||||
$this->_html->load($this->_response);
|
||||
return true;
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
@@ -126,7 +126,7 @@ abstract class TV extends Videos
|
||||
*/
|
||||
abstract protected function formatEpisodeInfo($episode): array;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Retrieve releases for TV processing
|
||||
* Returns a PDO Object of rows or false if none found
|
||||
*
|
||||
|
||||
@@ -413,7 +413,7 @@ class Utility
|
||||
if ($verify && NN_SSL_VERIFY_HOST && (!empty(NN_SSL_CAFILE) || !empty(NN_SSL_CAPATH))) {
|
||||
$options += [
|
||||
CURLOPT_SSL_VERIFYPEER => (bool)NN_SSL_VERIFY_PEER,
|
||||
CURLOPT_SSL_VERIFYHOST => (NN_SSL_VERIFY_HOST ? 2 : 0),
|
||||
CURLOPT_SSL_VERIFYHOST => NN_SSL_VERIFY_HOST ? 2 : 0,
|
||||
];
|
||||
if (!empty(NN_SSL_CAFILE)) {
|
||||
$options += [CURLOPT_CAINFO => NN_SSL_CAFILE];
|
||||
@@ -466,24 +466,24 @@ class Utility
|
||||
switch ($options['language']) {
|
||||
case 'fr':
|
||||
case 'fr-fr':
|
||||
$options['language'] = "fr-fr";
|
||||
$options['language'] = 'fr-fr';
|
||||
break;
|
||||
case 'de':
|
||||
case 'de-de':
|
||||
$options['language'] = "de-de";
|
||||
$options['language'] = 'de-de';
|
||||
break;
|
||||
case 'en-us':
|
||||
$options['language'] = "en-us";
|
||||
$options['language'] = 'en-us';
|
||||
break;
|
||||
case 'en-gb':
|
||||
$options['language'] = "en-gb";
|
||||
$options['language'] = 'en-gb';
|
||||
break;
|
||||
case '':
|
||||
case 'en':
|
||||
default:
|
||||
$options['language'] = 'en';
|
||||
}
|
||||
$header[] = "Accept-Language: " . $options['language'];
|
||||
$header[] = 'Accept-Language: ' . $options['language'];
|
||||
if (is_array($options['requestheaders'])) {
|
||||
$header += $options['requestheaders'];
|
||||
}
|
||||
@@ -526,9 +526,9 @@ class Utility
|
||||
|
||||
if ($err !== 0) {
|
||||
return false;
|
||||
} else {
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
# Increase the varchar for xref in collections to 1024
|
||||
ALTER TABLE collections CHANGE xref xref VARCHAR(1024) NOT NULL DEFAULT '';
|
||||
|
||||
# Increase the varchar for xref in multigroup_collections to 1024
|
||||
ALTER TABLE multigroup_collections CHANGE xref xref VARCHAR(1024) NOT NULL DEFAULT '';
|
||||
|
||||
# Change classussed column in xxxinfo table
|
||||
ALTER TABLE xxxinfo CHANGE classused classused VARCHAR(20) NOT NULL DEFAULT '';
|
||||
@@ -109,7 +109,7 @@ APIs amazonpubkey AKIAIPDNG5EU7LB4AD3Q The amazon public api key. Used for musi
|
||||
APIs giantbombkey The giantbomb api key. Used for game lookups. giantbombkey
|
||||
APIs anidbkey The Anidb api key. Used for Anime lookups. anidbkey
|
||||
APIs fanarttvkey The Fanart.tv api key. Used for Fanart.tv lookups. Fanart.tv would appreciate it if you use this service to help them out by adding high quality images not already available on TMDB. fanarttvkey
|
||||
APIs omdbkey OmdbAPI key obtained from Omdb.Used for Omdb API lookups omdbkey
|
||||
APIs omdbkey OmdbAPIkey obtained from Omdb.Used for Omdb API lookups omdbkey
|
||||
APIs rottentomatokey qxbxyngtujprvw7jxam2m6na The api key used for access to rotten tomatoes. rottentomatokey
|
||||
APIs tmdbkey 9a4e16adddcd1e86da19bcaf5ff3c2a3 The API key used for access to TMDb. tmdbkey
|
||||
APIs trakttvclientkey The Trakt.tv API v2 Client ID (SHA256 hash - 64 characters long string). Used for movie and tv lookups. trakttvclientkey
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 4 and column 214.
|
@@ -224,7 +224,7 @@ CREATE TABLE collections (
|
||||
subject VARCHAR(255) NOT NULL DEFAULT '',
|
||||
fromname VARCHAR(255) NOT NULL DEFAULT '',
|
||||
date DATETIME DEFAULT NULL,
|
||||
xref VARCHAR(255) NOT NULL DEFAULT '',
|
||||
xref VARCHAR(1024) NOT NULL DEFAULT '',
|
||||
totalfiles INT(11) UNSIGNED NOT NULL DEFAULT '0',
|
||||
groups_id INT(11) UNSIGNED NOT NULL DEFAULT '0',
|
||||
collectionhash VARCHAR(255) NOT NULL DEFAULT '0',
|
||||
@@ -539,7 +539,7 @@ CREATE TABLE multigroup_collections (
|
||||
subject VARCHAR(255) NOT NULL DEFAULT '',
|
||||
fromname VARCHAR(255) NOT NULL DEFAULT '',
|
||||
date DATETIME DEFAULT NULL,
|
||||
xref VARCHAR(510) NOT NULL DEFAULT '',
|
||||
xref VARCHAR(1024) NOT NULL DEFAULT '',
|
||||
totalfiles INT(11) UNSIGNED NOT NULL DEFAULT '0',
|
||||
groups_id INT(11) UNSIGNED NOT NULL DEFAULT '0',
|
||||
collectionhash VARCHAR(255) NOT NULL DEFAULT '0',
|
||||
@@ -1364,7 +1364,7 @@ CREATE TABLE xxxinfo (
|
||||
productinfo TEXT DEFAULT NULL,
|
||||
trailers TEXT DEFAULT NULL,
|
||||
directurl VARCHAR(2000) NOT NULL,
|
||||
classused VARCHAR(4) NOT NULL DEFAULT 'ade',
|
||||
classused VARCHAR(20) NOT NULL DEFAULT '',
|
||||
cover TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
|
||||
backdrop TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
|
||||
createddate DATETIME NOT NULL,
|
||||
|
||||
@@ -53,8 +53,8 @@ class InstallTest extends \PHPUnit\Framework\TestCase
|
||||
}
|
||||
|
||||
// Check if user selected right DB type.
|
||||
if (getenv('DB_SYSTEM') !== 'mysql') {
|
||||
ColorCLI::doEcho(ColorCLI::error('Invalid database system. Must be: mysql ; Not: ' . getenv('DB_SYSTEM')));
|
||||
if (env('DB_SYSTEM') !== 'mysql') {
|
||||
ColorCLI::doEcho(ColorCLI::error('Invalid database system. Must be: mysql ; Not: ' . env('DB_SYSTEM')));
|
||||
$error = true;
|
||||
} else {
|
||||
// Connect to the SQL server.
|
||||
@@ -64,13 +64,13 @@ class InstallTest extends \PHPUnit\Framework\TestCase
|
||||
[
|
||||
'checkVersion' => true,
|
||||
'createDb' => true,
|
||||
'dbhost' => getenv('DB_HOST'),
|
||||
'dbname' => getenv('DB_NAME'),
|
||||
'dbpass' => getenv('DB_PASSWORD'),
|
||||
'dbport' => getenv('DB_PORT'),
|
||||
'dbsock' => getenv('DB_SOCKET'),
|
||||
'dbtype' => getenv('DB_SYSTEM'),
|
||||
'dbuser' => getenv('DB_USER'),
|
||||
'dbhost' => env('DB_HOST'),
|
||||
'dbname' => env('DB_NAME'),
|
||||
'dbpass' => env('DB_PASSWORD'),
|
||||
'dbport' => env('DB_PORT'),
|
||||
'dbsock' => env('DB_SOCKET'),
|
||||
'dbtype' => env('DB_SYSTEM'),
|
||||
'dbuser' => env('DB_USER'),
|
||||
]
|
||||
);
|
||||
$dbConnCheck = true;
|
||||
@@ -106,7 +106,7 @@ class InstallTest extends \PHPUnit\Framework\TestCase
|
||||
$error = true;
|
||||
ColorCLI::doEcho(ColorCLI::error(
|
||||
'You are using an unsupported version of ' .
|
||||
getenv('DB_SYSTEM') .
|
||||
env('DB_SYSTEM') .
|
||||
' the minimum allowed version is ' .
|
||||
NN_MINIMUM_MYSQL_VERSION
|
||||
)
|
||||
@@ -179,13 +179,13 @@ class InstallTest extends \PHPUnit\Framework\TestCase
|
||||
}
|
||||
}
|
||||
//Insert admin user into database
|
||||
if (getenv('ADMIN_USER') === '' || getenv('ADMIN_PASS') === '' || getenv('ADMIN_EMAIL') === '') {
|
||||
if (env('ADMIN_USER') === '' || env('ADMIN_PASS') === '' || env('ADMIN_EMAIL') === '') {
|
||||
$error = true;
|
||||
ColorCLI::doEcho(ColorCLI::error('Admin user data cannot be empty! Please edit .env file and fill in admin user details and run this script again!'));
|
||||
exit();
|
||||
}
|
||||
|
||||
switch (getenv('DB_SYSTEM')) {
|
||||
switch (env('DB_SYSTEM')) {
|
||||
case 'mysql':
|
||||
$adapter = 'MySql';
|
||||
break;
|
||||
@@ -197,10 +197,10 @@ class InstallTest extends \PHPUnit\Framework\TestCase
|
||||
}
|
||||
|
||||
if ($adapter !== null) {
|
||||
if (empty(getenv('DB_SOCKET'))) {
|
||||
$host = empty(getenv('DB_PORT')) ? getenv('DB_HOST') : getenv('DB_HOST') . ':' . getenv('DB_PORT');
|
||||
if (empty(env('DB_SOCKET'))) {
|
||||
$host = empty(env('DB_PORT')) ? env('DB_HOST') : env('DB_HOST') . ':' . env('DB_PORT');
|
||||
} else {
|
||||
$host = getenv('DB_SOCKET');
|
||||
$host = env('DB_SOCKET');
|
||||
}
|
||||
|
||||
\lithium\data\Connections::add('default',
|
||||
@@ -208,9 +208,9 @@ class InstallTest extends \PHPUnit\Framework\TestCase
|
||||
'type' => 'database',
|
||||
'adapter' => $adapter,
|
||||
'host' => $host,
|
||||
'login' => getenv('DB_USER'),
|
||||
'password' => getenv('DB_PASSWORD'),
|
||||
'database' => getenv('DB_NAME'),
|
||||
'login' => env('DB_USER'),
|
||||
'password' => env('DB_PASSWORD'),
|
||||
'database' => env('DB_NAME'),
|
||||
'encoding' => 'UTF-8',
|
||||
'persistent' => false,
|
||||
]
|
||||
@@ -218,20 +218,20 @@ class InstallTest extends \PHPUnit\Framework\TestCase
|
||||
}
|
||||
|
||||
$user = new Users();
|
||||
if (!$user->isValidUsername(getenv('ADMIN_USER'))) {
|
||||
if (!$user->isValidUsername(env('ADMIN_USER'))) {
|
||||
$error = true;
|
||||
} else {
|
||||
$usrCheck = $user->getByUsername(getenv('ADMIN_USER'));
|
||||
$usrCheck = $user->getByUsername(env('ADMIN_USER'));
|
||||
if ($usrCheck) {
|
||||
$error = true;
|
||||
}
|
||||
}
|
||||
if (!$user->isValidEmail(getenv('ADMIN_EMAIL'))) {
|
||||
if (!$user->isValidEmail(env('ADMIN_EMAIL'))) {
|
||||
$error = true;
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$adminCheck = $user->add(getenv('ADMIN_USER'), getenv('ADMIN_PASS'), getenv('ADMIN_EMAIL'), 2, '', '');
|
||||
$adminCheck = $user->add(env('ADMIN_USER'), env('ADMIN_PASS'), env('ADMIN_EMAIL'), 2, '', '');
|
||||
if (!is_numeric($adminCheck)) {
|
||||
$error = true;
|
||||
}
|
||||
|
||||
@@ -6,9 +6,7 @@ use nntmux\Regexes;
|
||||
|
||||
$page = new AdminPage();
|
||||
|
||||
$page->title = "Collections Regex Test";
|
||||
|
||||
$page->smarty->assign('tpg', $tpg);
|
||||
$page->title = 'Collections Regex Test';
|
||||
|
||||
$group = trim(isset($_POST['group']) && !empty($_POST['group']) ? $_POST['group'] : '');
|
||||
$regex = trim(isset($_POST['regex']) && !empty($_POST['regex']) ? $_POST['regex'] : '');
|
||||
|
||||
@@ -170,7 +170,7 @@ $page->smarty->assign('book_reqids_selected', $books_selected);
|
||||
|
||||
$page->smarty->assign('themelist', Utility::getThemesList());
|
||||
|
||||
if (strpos(getenv('NNTP_SERVER'), "astra") === false) {
|
||||
if (strpos(env('NNTP_SERVER'), "astra") === false) {
|
||||
$page->smarty->assign('compress_headers_warning', "compress_headers_warning");
|
||||
}
|
||||
|
||||
|
||||
@@ -2,45 +2,42 @@
|
||||
<div class="well well-sm">
|
||||
<p>This page is used for testing regex for grouping usenet collections.<br />Enter the group name to test and a regex. Limit is how many collections to show max on the page, 0 for no limit(slow).</p>
|
||||
|
||||
{if $tpg}
|
||||
<form name="search" action="" method="post" style="margin-bottom:5px;">
|
||||
<label for="group" style="padding-right:1px">Group:</label>
|
||||
<input id="group" type="text" name="group" value="{$group|htmlentities}" size="20" /><br />
|
||||
<label for="regex" style="padding-right:1px">Regex:</label>
|
||||
<input id="regex" type="text" name="regex" value="{$regex|htmlentities}" size="100" /><br/>
|
||||
<label for="limit" style="padding-right:7px">Limit:</label>
|
||||
<input id="limit" type="text" name="limit" value="{$limit}" size="8" /><br/>
|
||||
<input class="btn btn-default" type="submit" value="Test" />
|
||||
</form>
|
||||
{if isset($data)}
|
||||
<form name="search" action="" method="post" style="margin-bottom:5px;">
|
||||
<label for="group" style="padding-right:1px">Group:</label>
|
||||
<input id="group" type="text" name="group" value="{$group|htmlentities}" size="20" /><br />
|
||||
<label for="regex" style="padding-right:1px">Regex:</label>
|
||||
<input id="regex" type="text" name="regex" value="{$regex|htmlentities}" size="100" /><br/>
|
||||
<label for="limit" style="padding-right:7px">Limit:</label>
|
||||
<input id="limit" type="text" name="limit" value="{$limit}" size="8" /><br/>
|
||||
<input class="btn btn-default" type="submit" value="Test" />
|
||||
</form>
|
||||
{if isset($data)}
|
||||
|
||||
{foreach from=$data key=hash item=collection}
|
||||
<table style="margin-top:10px;" class="data table table-striped responsive-utilities jambo-table">
|
||||
<tr>
|
||||
<th>{$hash}<br />Current Files: {count($collection)}</th>
|
||||
{foreach from=$data key=hash item=collection}
|
||||
<table style="margin-top:10px;" class="data table table-striped responsive-utilities jambo-table">
|
||||
<tr>
|
||||
<th>{$hash}<br />Current Files: {count($collection)}</th>
|
||||
</tr>
|
||||
</table>
|
||||
<table style="margin-top:10px;" class="data table table-striped responsive-utilities jambo-table Sortable">
|
||||
<tr>
|
||||
<th>name</th>
|
||||
<th>current parts</th>
|
||||
<th>total parts</th>
|
||||
<th>poster</th>
|
||||
<th>old hash</th>
|
||||
</tr>
|
||||
{foreach from=$collection item=row}
|
||||
<tr id="row-{$row.new_collection_hash}" class="{cycle values=",alt"}">
|
||||
<td>{$row.file_name}</td>
|
||||
<td>{$row.file_current_parts}</td>
|
||||
<td>{$row.file_total_parts}</td>
|
||||
<td>{$row.collection_poster}</td>
|
||||
<td>{$row.old_collection_hash}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table style="margin-top:10px;" class="data table table-striped responsive-utilities jambo-table Sortable">
|
||||
<tr>
|
||||
<th>name</th>
|
||||
<th>current parts</th>
|
||||
<th>total parts</th>
|
||||
<th>poster</th>
|
||||
<th>old hash</th>
|
||||
</tr>
|
||||
{foreach from=$collection item=row}
|
||||
<tr id="row-{$row.new_collection_hash}" class="{cycle values=",alt"}">
|
||||
<td>{$row.file_name}</td>
|
||||
<td>{$row.file_current_parts}</td>
|
||||
<td>{$row.file_total_parts}</td>
|
||||
<td>{$row.collection_poster}</td>
|
||||
<td>{$row.old_collection_hash}</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</table>
|
||||
{/foreach}
|
||||
{/if}
|
||||
{else}
|
||||
<p>The Table Per Group setting is required to be on to use this page, for performance reasons.</p>
|
||||
{/foreach}
|
||||
</table>
|
||||
{/foreach}
|
||||
{/if}
|
||||
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user