From 1bbc64138b5de3a43ffba0617b8d3d47d551392e Mon Sep 17 00:00:00 2001 From: DariusIII Date: Fri, 2 Jun 2017 17:18:52 +0200 Subject: [PATCH 01/49] Update php-tmdb and php-giantbomb libraries --- Changelog | 2 ++ composer.lock | 32 ++++++++++++++++---------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/Changelog b/Changelog index 146428728..fa0e4fc89 100755 --- a/Changelog +++ b/Changelog @@ -1,3 +1,5 @@ +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 diff --git a/composer.lock b/composer.lock index f702e1117..3db8517fe 100644 --- a/composer.lock +++ b/composer.lock @@ -1528,12 +1528,12 @@ "source": { "type": "git", "url": "https://github.com/dborsatto/php-giantbomb.git", - "reference": "e95553774caf9b6dace6d044710c7e03dee3af43" + "reference": "909b2b75200270daf62b1cd3dab91ffdca49ab23" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/dborsatto/php-giantbomb/zipball/e95553774caf9b6dace6d044710c7e03dee3af43", - "reference": "e95553774caf9b6dace6d044710c7e03dee3af43", + "url": "https://api.github.com/repos/dborsatto/php-giantbomb/zipball/909b2b75200270daf62b1cd3dab91ffdca49ab23", + "reference": "909b2b75200270daf62b1cd3dab91ffdca49ab23", "shasum": "" }, "require": { @@ -1562,7 +1562,7 @@ } ], "description": "A PHP library that acts as a wrapper for the GiantBomb API.", - "time": "2017-05-18 16:20:43" + "time": "2017-05-29 12:05:57" }, { "name": "doctrine/annotations", @@ -2752,16 +2752,16 @@ }, { "name": "php-tmdb/api", - "version": "2.1.8", + "version": "v2.1.9", "source": { "type": "git", "url": "https://github.com/php-tmdb/api.git", - "reference": "5aae08086a17301b78aa26fd59bd6c10910cd5f6" + "reference": "1c2e87653f6df62ea9075b7118c2a80dcb355f66" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-tmdb/api/zipball/5aae08086a17301b78aa26fd59bd6c10910cd5f6", - "reference": "5aae08086a17301b78aa26fd59bd6c10910cd5f6", + "url": "https://api.github.com/repos/php-tmdb/api/zipball/1c2e87653f6df62ea9075b7118c2a80dcb355f66", + "reference": "1c2e87653f6df62ea9075b7118c2a80dcb355f66", "shasum": "" }, "require": { @@ -2785,7 +2785,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "2.1-dev" } }, "autoload": { @@ -2816,7 +2816,7 @@ "tvdb", "wrapper" ], - "time": "2017-02-28T23:30:08+00:00" + "time": "2017-06-02T03:27:09+00:00" }, { "name": "phpmailer/phpmailer", @@ -4526,16 +4526,16 @@ }, { "name": "phpunit/phpunit", - "version": "6.1.4", + "version": "6.2.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "42b7f394a8e009516582331b1e03a1aba40175d1" + "reference": "16999a1e9a8a25d68f0ab8cc8ab818b043ad5374" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/42b7f394a8e009516582331b1e03a1aba40175d1", - "reference": "42b7f394a8e009516582331b1e03a1aba40175d1", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/16999a1e9a8a25d68f0ab8cc8ab818b043ad5374", + "reference": "16999a1e9a8a25d68f0ab8cc8ab818b043ad5374", "shasum": "" }, "require": { @@ -4580,7 +4580,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "6.1.x-dev" + "dev-master": "6.2.x-dev" } }, "autoload": { @@ -4606,7 +4606,7 @@ "testing", "xunit" ], - "time": "2017-05-22T07:45:30+00:00" + "time": "2017-06-02T12:24:37+00:00" }, { "name": "phpunit/phpunit-mock-objects", From 38fbd7050ad509133434a231e900ce7b5e65a5dd Mon Sep 17 00:00:00 2001 From: DariusIII Date: Mon, 5 Jun 2017 16:29:52 +0200 Subject: [PATCH 02/49] Add laravel/framework to composer.json for future usage --- Changelog | 2 + composer.json | 4 +- composer.lock | 685 +++++++++++++++++++++++++++++++++++++++----------- 3 files changed, 539 insertions(+), 152 deletions(-) diff --git a/Changelog b/Changelog index fa0e4fc89..caef625f8 100755 --- a/Changelog +++ b/Changelog @@ -1,3 +1,5 @@ +2017-06-05 DariusIII + * 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 diff --git a/composer.json b/composer.json index a9cf091b9..7d5cad7f7 100755 --- a/composer.json +++ b/composer.json @@ -137,10 +137,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": { diff --git a/composer.lock b/composer.lock index 3db8517fe..d89839a44 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "a9563463542fa483d403d0c08b7b4c59", + "content-hash": "f2aa144131a6fb8b3d72a01fc6bed139", "packages": [ { "name": "adrenth/thetvdb2", @@ -1963,6 +1963,48 @@ ], "time": "2014-09-09T13:34:57+00:00" }, + { + "name": "erusev/parsedown", + "version": "1.6.2", + "source": { + "type": "git", + "url": "https://github.com/erusev/parsedown.git", + "reference": "1bf24f7334fe16c88bf9d467863309ceaf285b01" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/erusev/parsedown/zipball/1bf24f7334fe16c88bf9d467863309ceaf285b01", + "reference": "1bf24f7334fe16c88bf9d467863309ceaf285b01", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "autoload": { + "psr-0": { + "Parsedown": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Emanuil Rusev", + "email": "hello@erusev.com", + "homepage": "http://erusev.com" + } + ], + "description": "Parser for Markdown.", + "homepage": "http://parsedown.org", + "keywords": [ + "markdown", + "parser" + ], + "time": "2017-03-29T16:04:15+00:00" + }, { "name": "exeu/apai-io", "version": "2.1.0", @@ -2302,155 +2344,6 @@ ], "time": "2017-03-20T17:10:46+00:00" }, - { - "name": "illuminate/contracts", - "version": "v5.4.19", - "source": { - "type": "git", - "url": "https://github.com/illuminate/contracts.git", - "reference": "ab2825726bee46a67c8cc66789852189dbef74a9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/illuminate/contracts/zipball/ab2825726bee46a67c8cc66789852189dbef74a9", - "reference": "ab2825726bee46a67c8cc66789852189dbef74a9", - "shasum": "" - }, - "require": { - "php": ">=5.6.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.4-dev" - } - }, - "autoload": { - "psr-4": { - "Illuminate\\Contracts\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Taylor Otwell", - "email": "taylor@laravel.com" - } - ], - "description": "The Illuminate Contracts package.", - "homepage": "https://laravel.com", - "time": "2017-03-29T13:17:47+00:00" - }, - { - "name": "illuminate/filesystem", - "version": "v5.4.19", - "source": { - "type": "git", - "url": "https://github.com/illuminate/filesystem.git", - "reference": "7f656e3421b94d759627e891567380b50586f045" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/illuminate/filesystem/zipball/7f656e3421b94d759627e891567380b50586f045", - "reference": "7f656e3421b94d759627e891567380b50586f045", - "shasum": "" - }, - "require": { - "illuminate/contracts": "5.4.*", - "illuminate/support": "5.4.*", - "php": ">=5.6.4", - "symfony/finder": "~3.2" - }, - "suggest": { - "league/flysystem": "Required to use the Flysystem local and FTP drivers (~1.0).", - "league/flysystem-aws-s3-v3": "Required to use the Flysystem S3 driver (~1.0).", - "league/flysystem-rackspace": "Required to use the Flysystem Rackspace driver (~1.0)." - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.4-dev" - } - }, - "autoload": { - "psr-4": { - "Illuminate\\Filesystem\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Taylor Otwell", - "email": "taylor@laravel.com" - } - ], - "description": "The Illuminate Filesystem package.", - "homepage": "https://laravel.com", - "time": "2017-04-07T19:38:05+00:00" - }, - { - "name": "illuminate/support", - "version": "v5.4.19", - "source": { - "type": "git", - "url": "https://github.com/illuminate/support.git", - "reference": "b8cb37e15331c59da51c8ee5838038baa22d7955" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/illuminate/support/zipball/b8cb37e15331c59da51c8ee5838038baa22d7955", - "reference": "b8cb37e15331c59da51c8ee5838038baa22d7955", - "shasum": "" - }, - "require": { - "doctrine/inflector": "~1.0", - "ext-mbstring": "*", - "illuminate/contracts": "5.4.*", - "paragonie/random_compat": "~1.4|~2.0", - "php": ">=5.6.4" - }, - "replace": { - "tightenco/collect": "self.version" - }, - "suggest": { - "illuminate/filesystem": "Required to use the composer class (5.2.*).", - "symfony/process": "Required to use the composer class (~3.2).", - "symfony/var-dumper": "Required to use the dd function (~3.2)." - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.4-dev" - } - }, - "autoload": { - "psr-4": { - "Illuminate\\Support\\": "" - }, - "files": [ - "helpers.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Taylor Otwell", - "email": "taylor@laravel.com" - } - ], - "description": "The Illuminate Support package.", - "homepage": "https://laravel.com", - "time": "2017-04-09T14:34:57+00:00" - }, { "name": "james-heinrich/getid3", "version": "v1.9.14", @@ -2624,6 +2517,218 @@ ], "time": "2017-01-16T07:02:13+00:00" }, + { + "name": "laravel/framework", + "version": "v5.4.24", + "source": { + "type": "git", + "url": "https://github.com/laravel/framework.git", + "reference": "ec8548db26c1b147570f661128649e98f3ac0f29" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/framework/zipball/ec8548db26c1b147570f661128649e98f3ac0f29", + "reference": "ec8548db26c1b147570f661128649e98f3ac0f29", + "shasum": "" + }, + "require": { + "doctrine/inflector": "~1.0", + "erusev/parsedown": "~1.6", + "ext-mbstring": "*", + "ext-openssl": "*", + "league/flysystem": "~1.0", + "monolog/monolog": "~1.11", + "mtdowling/cron-expression": "~1.0", + "nesbot/carbon": "~1.20", + "paragonie/random_compat": "~1.4|~2.0", + "php": ">=5.6.4", + "ramsey/uuid": "~3.0", + "swiftmailer/swiftmailer": "~5.4", + "symfony/console": "~3.2", + "symfony/debug": "~3.2", + "symfony/finder": "~3.2", + "symfony/http-foundation": "~3.2", + "symfony/http-kernel": "~3.2", + "symfony/process": "~3.2", + "symfony/routing": "~3.2", + "symfony/var-dumper": "~3.2", + "tijsverkoyen/css-to-inline-styles": "~2.2", + "vlucas/phpdotenv": "~2.2" + }, + "replace": { + "illuminate/auth": "self.version", + "illuminate/broadcasting": "self.version", + "illuminate/bus": "self.version", + "illuminate/cache": "self.version", + "illuminate/config": "self.version", + "illuminate/console": "self.version", + "illuminate/container": "self.version", + "illuminate/contracts": "self.version", + "illuminate/cookie": "self.version", + "illuminate/database": "self.version", + "illuminate/encryption": "self.version", + "illuminate/events": "self.version", + "illuminate/exception": "self.version", + "illuminate/filesystem": "self.version", + "illuminate/hashing": "self.version", + "illuminate/http": "self.version", + "illuminate/log": "self.version", + "illuminate/mail": "self.version", + "illuminate/notifications": "self.version", + "illuminate/pagination": "self.version", + "illuminate/pipeline": "self.version", + "illuminate/queue": "self.version", + "illuminate/redis": "self.version", + "illuminate/routing": "self.version", + "illuminate/session": "self.version", + "illuminate/support": "self.version", + "illuminate/translation": "self.version", + "illuminate/validation": "self.version", + "illuminate/view": "self.version", + "tightenco/collect": "self.version" + }, + "require-dev": { + "aws/aws-sdk-php": "~3.0", + "doctrine/dbal": "~2.5", + "mockery/mockery": "~0.9.4", + "pda/pheanstalk": "~3.0", + "phpunit/phpunit": "~5.7", + "predis/predis": "~1.0", + "symfony/css-selector": "~3.2", + "symfony/dom-crawler": "~3.2" + }, + "suggest": { + "aws/aws-sdk-php": "Required to use the SQS queue driver and SES mail driver (~3.0).", + "doctrine/dbal": "Required to rename columns and drop SQLite columns (~2.5).", + "fzaninotto/faker": "Required to use the eloquent factory builder (~1.4).", + "guzzlehttp/guzzle": "Required to use the Mailgun and Mandrill mail drivers and the ping methods on schedules (~6.0).", + "laravel/tinker": "Required to use the tinker console command (~1.0).", + "league/flysystem-aws-s3-v3": "Required to use the Flysystem S3 driver (~1.0).", + "league/flysystem-rackspace": "Required to use the Flysystem Rackspace driver (~1.0).", + "nexmo/client": "Required to use the Nexmo transport (~1.0).", + "pda/pheanstalk": "Required to use the beanstalk queue driver (~3.0).", + "predis/predis": "Required to use the redis cache and queue drivers (~1.0).", + "pusher/pusher-php-server": "Required to use the Pusher broadcast driver (~2.0).", + "symfony/css-selector": "Required to use some of the crawler integration testing tools (~3.2).", + "symfony/dom-crawler": "Required to use most of the crawler integration testing tools (~3.2).", + "symfony/psr-http-message-bridge": "Required to psr7 bridging features (0.2.*)." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.4-dev" + } + }, + "autoload": { + "files": [ + "src/Illuminate/Foundation/helpers.php", + "src/Illuminate/Support/helpers.php" + ], + "psr-4": { + "Illuminate\\": "src/Illuminate/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Laravel Framework.", + "homepage": "https://laravel.com", + "keywords": [ + "framework", + "laravel" + ], + "time": "2017-05-30T12:44:32+00:00" + }, + { + "name": "league/flysystem", + "version": "1.0.40", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/flysystem.git", + "reference": "3828f0b24e2c1918bb362d57a53205d6dc8fde61" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/3828f0b24e2c1918bb362d57a53205d6dc8fde61", + "reference": "3828f0b24e2c1918bb362d57a53205d6dc8fde61", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "conflict": { + "league/flysystem-sftp": "<1.0.6" + }, + "require-dev": { + "ext-fileinfo": "*", + "mockery/mockery": "~0.9", + "phpspec/phpspec": "^2.2", + "phpunit/phpunit": "~4.8" + }, + "suggest": { + "ext-fileinfo": "Required for MimeType", + "league/flysystem-aws-s3-v2": "Allows you to use S3 storage with AWS SDK v2", + "league/flysystem-aws-s3-v3": "Allows you to use S3 storage with AWS SDK v3", + "league/flysystem-azure": "Allows you to use Windows Azure Blob storage", + "league/flysystem-cached-adapter": "Flysystem adapter decorator for metadata caching", + "league/flysystem-copy": "Allows you to use Copy.com storage", + "league/flysystem-eventable-filesystem": "Allows you to use EventableFilesystem", + "league/flysystem-rackspace": "Allows you to use Rackspace Cloud Files", + "league/flysystem-sftp": "Allows you to use SFTP server storage via phpseclib", + "league/flysystem-webdav": "Allows you to use WebDAV storage", + "league/flysystem-ziparchive": "Allows you to use ZipArchive adapter", + "spatie/flysystem-dropbox": "Allows you to use Dropbox storage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "League\\Flysystem\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Frank de Jonge", + "email": "info@frenky.net" + } + ], + "description": "Filesystem abstraction: Many filesystems, one API.", + "keywords": [ + "Cloud Files", + "WebDAV", + "abstraction", + "aws", + "cloud", + "copy.com", + "dropbox", + "file systems", + "files", + "filesystem", + "filesystems", + "ftp", + "rackspace", + "remote", + "s3", + "sftp", + "storage" + ], + "time": "2017-04-28T10:15:08+00:00" + }, { "name": "monolog/monolog", "version": "1.22.1", @@ -2702,6 +2807,103 @@ ], "time": "2017-03-13T07:08:03+00:00" }, + { + "name": "mtdowling/cron-expression", + "version": "v1.2.0", + "source": { + "type": "git", + "url": "https://github.com/mtdowling/cron-expression.git", + "reference": "9504fa9ea681b586028adaaa0877db4aecf32bad" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mtdowling/cron-expression/zipball/9504fa9ea681b586028adaaa0877db4aecf32bad", + "reference": "9504fa9ea681b586028adaaa0877db4aecf32bad", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.0|~5.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Cron\\": "src/Cron/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "CRON for PHP: Calculate the next or previous run date and determine if a CRON expression is due", + "keywords": [ + "cron", + "schedule" + ], + "time": "2017-01-23T04:29:33+00:00" + }, + { + "name": "nesbot/carbon", + "version": "1.22.1", + "source": { + "type": "git", + "url": "https://github.com/briannesbitt/Carbon.git", + "reference": "7cdf42c0b1cc763ab7e4c33c47a24e27c66bfccc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/7cdf42c0b1cc763ab7e4c33c47a24e27c66bfccc", + "reference": "7cdf42c0b1cc763ab7e4c33c47a24e27c66bfccc", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "symfony/translation": "~2.6 || ~3.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "~2", + "phpunit/phpunit": "~4.0 || ~5.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.23-dev" + } + }, + "autoload": { + "psr-4": { + "Carbon\\": "src/Carbon/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Brian Nesbitt", + "email": "brian@nesbot.com", + "homepage": "http://nesbot.com" + } + ], + "description": "A simple API extension for DateTime.", + "homepage": "http://carbon.nesbot.com", + "keywords": [ + "date", + "datetime", + "time" + ], + "time": "2017-01-16T07:55:07+00:00" + }, { "name": "paragonie/random_compat", "version": "v2.0.10", @@ -3037,6 +3239,88 @@ ], "time": "2016-10-10T12:19:37+00:00" }, + { + "name": "ramsey/uuid", + "version": "3.6.1", + "source": { + "type": "git", + "url": "https://github.com/ramsey/uuid.git", + "reference": "4ae32dd9ab8860a4bbd750ad269cba7f06f7934e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ramsey/uuid/zipball/4ae32dd9ab8860a4bbd750ad269cba7f06f7934e", + "reference": "4ae32dd9ab8860a4bbd750ad269cba7f06f7934e", + "shasum": "" + }, + "require": { + "paragonie/random_compat": "^1.0|^2.0", + "php": "^5.4 || ^7.0" + }, + "replace": { + "rhumsaa/uuid": "self.version" + }, + "require-dev": { + "apigen/apigen": "^4.1", + "codeception/aspect-mock": "^1.0 | ^2.0", + "doctrine/annotations": "~1.2.0", + "goaop/framework": "1.0.0-alpha.2 | ^1.0 | ^2.1", + "ircmaxell/random-lib": "^1.1", + "jakub-onderka/php-parallel-lint": "^0.9.0", + "mockery/mockery": "^0.9.4", + "moontoast/math": "^1.1", + "php-mock/php-mock-phpunit": "^0.3|^1.1", + "phpunit/phpunit": "^4.7|>=5.0 <5.4", + "satooshi/php-coveralls": "^0.6.1", + "squizlabs/php_codesniffer": "^2.3" + }, + "suggest": { + "ext-libsodium": "Provides the PECL libsodium extension for use with the SodiumRandomGenerator", + "ext-uuid": "Provides the PECL UUID extension for use with the PeclUuidTimeGenerator and PeclUuidRandomGenerator", + "ircmaxell/random-lib": "Provides RandomLib for use with the RandomLibAdapter", + "moontoast/math": "Provides support for converting UUID to 128-bit integer (in string form).", + "ramsey/uuid-console": "A console application for generating UUIDs with ramsey/uuid", + "ramsey/uuid-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Ramsey\\Uuid\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marijn Huizendveld", + "email": "marijn.huizendveld@gmail.com" + }, + { + "name": "Thibaud Fabre", + "email": "thibaud@aztech.io" + }, + { + "name": "Ben Ramsey", + "email": "ben@benramsey.com", + "homepage": "https://benramsey.com" + } + ], + "description": "Formerly rhumsaa/uuid. A PHP 5.4+ library for generating RFC 4122 version 1, 3, 4, and 5 universally unique identifiers (UUID).", + "homepage": "https://github.com/ramsey/uuid", + "keywords": [ + "guid", + "identifier", + "uuid" + ], + "time": "2017-03-26T20:37:53+00:00" + }, { "name": "roave/security-advisories", "version": "dev-master", @@ -3278,6 +3562,60 @@ ], "time": "2016-12-14T21:57:25+00:00" }, + { + "name": "swiftmailer/swiftmailer", + "version": "v5.4.8", + "source": { + "type": "git", + "url": "https://github.com/swiftmailer/swiftmailer.git", + "reference": "9a06dc570a0367850280eefd3f1dc2da45aef517" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/9a06dc570a0367850280eefd3f1dc2da45aef517", + "reference": "9a06dc570a0367850280eefd3f1dc2da45aef517", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "mockery/mockery": "~0.9.1", + "symfony/phpunit-bridge": "~3.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.4-dev" + } + }, + "autoload": { + "files": [ + "lib/swift_required.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Chris Corbyn" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Swiftmailer, free feature-rich PHP mailer", + "homepage": "http://swiftmailer.org", + "keywords": [ + "email", + "mail", + "mailer" + ], + "time": "2017-05-01T15:54:03+00:00" + }, { "name": "symfony/polyfill-intl-icu", "version": "v1.3.0", @@ -3706,6 +4044,53 @@ ], "time": "2017-03-10T18:35:48+00:00" }, + { + "name": "tijsverkoyen/css-to-inline-styles", + "version": "2.2.0", + "source": { + "type": "git", + "url": "https://github.com/tijsverkoyen/CssToInlineStyles.git", + "reference": "ab03919dfd85a74ae0372f8baf9f3c7d5c03b04b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/tijsverkoyen/CssToInlineStyles/zipball/ab03919dfd85a74ae0372f8baf9f3c7d5c03b04b", + "reference": "ab03919dfd85a74ae0372f8baf9f3c7d5c03b04b", + "shasum": "" + }, + "require": { + "php": "^5.5 || ^7", + "symfony/css-selector": "^2.7|~3.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.8|5.1.*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "TijsVerkoyen\\CssToInlineStyles\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Tijs Verkoyen", + "email": "css_to_inline_styles@verkoyen.eu", + "role": "Developer" + } + ], + "description": "CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very useful when you're sending emails.", + "homepage": "https://github.com/tijsverkoyen/CssToInlineStyles", + "time": "2016-09-20T12:50:39+00:00" + }, { "name": "twig/twig", "version": "v2.3.2", From 562975f436314710925cb9a9f7de5aa3bcf4b877 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Mon, 5 Jun 2017 16:30:55 +0200 Subject: [PATCH 03/49] Update minimum MariaDB version to 10.1 --- Changelog | 1 + nntmux/constants.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index caef625f8..c88cb9b13 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 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 diff --git a/nntmux/constants.php b/nntmux/constants.php index 5ff435d7e..c1eb7a3f7 100755 --- a/nntmux/constants.php +++ b/nntmux/constants.php @@ -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); From 9486af69b50608d7aa918fc8eca77d1173646b73 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Mon, 5 Jun 2017 23:18:42 +0200 Subject: [PATCH 04/49] Update composer.lock --- composer.lock | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/composer.lock b/composer.lock index d89839a44..aaa171f30 100644 --- a/composer.lock +++ b/composer.lock @@ -4093,16 +4093,16 @@ }, { "name": "twig/twig", - "version": "v2.3.2", + "version": "v2.4.1", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "85e8372c451510165c04bf781295f9d922fa524b" + "reference": "97c5e1f7e2f208df4433fc47197dbcf6cbc797a6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/85e8372c451510165c04bf781295f9d922fa524b", - "reference": "85e8372c451510165c04bf781295f9d922fa524b", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/97c5e1f7e2f208df4433fc47197dbcf6cbc797a6", + "reference": "97c5e1f7e2f208df4433fc47197dbcf6cbc797a6", "shasum": "" }, "require": { @@ -4117,12 +4117,15 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.3-dev" + "dev-master": "2.4-dev" } }, "autoload": { "psr-0": { "Twig_": "lib/" + }, + "psr-4": { + "Twig\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -4152,7 +4155,7 @@ "keywords": [ "templating" ], - "time": "2017-04-21T00:13:02+00:00" + "time": "2017-06-05T18:29:51+00:00" }, { "name": "unionofrad/lithium", From ab1594f5ad3f0b0e5e3d86b74d6476dd465f0b3d Mon Sep 17 00:00:00 2001 From: DariusIII Date: Wed, 7 Jun 2017 19:35:05 +0200 Subject: [PATCH 05/49] Update composer.lock --- Changelog | 2 ++ composer.lock | 29 +++++++++++++++-------------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Changelog b/Changelog index c88cb9b13..ff6135e93 100755 --- a/Changelog +++ b/Changelog @@ -1,3 +1,5 @@ +2017-06-06 DariusIII + * 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 diff --git a/composer.lock b/composer.lock index aaa171f30..9bac1f543 100644 --- a/composer.lock +++ b/composer.lock @@ -2519,16 +2519,16 @@ }, { "name": "laravel/framework", - "version": "v5.4.24", + "version": "v5.4.25", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "ec8548db26c1b147570f661128649e98f3ac0f29" + "reference": "6bcc9b1f542b3deed16d51f6aa1fe318ab407c2a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/ec8548db26c1b147570f661128649e98f3ac0f29", - "reference": "ec8548db26c1b147570f661128649e98f3ac0f29", + "url": "https://api.github.com/repos/laravel/framework/zipball/6bcc9b1f542b3deed16d51f6aa1fe318ab407c2a", + "reference": "6bcc9b1f542b3deed16d51f6aa1fe318ab407c2a", "shasum": "" }, "require": { @@ -2644,7 +2644,7 @@ "framework", "laravel" ], - "time": "2017-05-30T12:44:32+00:00" + "time": "2017-06-07T13:35:12+00:00" }, { "name": "league/flysystem", @@ -3327,12 +3327,12 @@ "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "ccffea64be8575eaa7ad09cd16dfeedfa4711607" + "reference": "7cd88c8d4e4e6b483633bb13c35bcec95fd6cd4c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/ccffea64be8575eaa7ad09cd16dfeedfa4711607", - "reference": "ccffea64be8575eaa7ad09cd16dfeedfa4711607", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/7cd88c8d4e4e6b483633bb13c35bcec95fd6cd4c", + "reference": "7cd88c8d4e4e6b483633bb13c35bcec95fd6cd4c", "shasum": "" }, "conflict": { @@ -3374,6 +3374,7 @@ "magento/magento2ce": ">=2,<2.2", "monolog/monolog": ">=1.8,<1.12", "namshi/jose": "<2.2", + "onelogin/php-saml": "<2.10.4", "oro/crm": ">=1.7,<1.7.4", "oro/platform": ">=1.7,<1.7.4", "phpmailer/phpmailer": ">=5,<5.2.22", @@ -3454,7 +3455,7 @@ } ], "description": "Prevents installation of composer packages with known security vulnerabilities: no API, simply require it", - "time": "2017-05-13T14:02:28+00:00" + "time": "2017-06-07T12:12:03+00:00" }, { "name": "rtheunissen/guzzle-log-middleware", @@ -4093,16 +4094,16 @@ }, { "name": "twig/twig", - "version": "v2.4.1", + "version": "v2.4.2", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "97c5e1f7e2f208df4433fc47197dbcf6cbc797a6" + "reference": "fe3e3f3359b23b36f65cb600cd516142c07a2e7d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/97c5e1f7e2f208df4433fc47197dbcf6cbc797a6", - "reference": "97c5e1f7e2f208df4433fc47197dbcf6cbc797a6", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/fe3e3f3359b23b36f65cb600cd516142c07a2e7d", + "reference": "fe3e3f3359b23b36f65cb600cd516142c07a2e7d", "shasum": "" }, "require": { @@ -4155,7 +4156,7 @@ "keywords": [ "templating" ], - "time": "2017-06-05T18:29:51+00:00" + "time": "2017-06-06T03:58:14+00:00" }, { "name": "unionofrad/lithium", From 9af3abdc4653402528a2ddd8d8843773f9434040 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Wed, 7 Jun 2017 22:57:00 +0200 Subject: [PATCH 06/49] Use laravel helpers file and replace getenv with env function --- Changelog | 1 + app/config/bootstrap/connections.php | 14 ++++---- cli/verify_permissions.php | 2 +- composer.json | 3 ++ misc/testing/DB/check_unique_indexes.php | 8 ++--- misc/testing/DB/mysqldump_tables.php | 30 ++++++++-------- misc/testing/DB/rename_to_lower.php | 2 +- misc/testing/DB/show_table_sizes.php | 2 +- misc/update/nix/tmux/monitor.php | 4 +-- nntmux/NNTP.php | 32 ++++++++--------- nntmux/Tmux.php | 8 ++--- nntmux/db/DB.php | 14 ++++---- tests/Install/InstallTest.php | 44 ++++++++++++------------ www/admin/site-edit.php | 2 +- 14 files changed, 85 insertions(+), 81 deletions(-) diff --git a/Changelog b/Changelog index ff6135e93..793dbeae2 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 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 diff --git a/app/config/bootstrap/connections.php b/app/config/bootstrap/connections.php index 1a8f27c14..fd1ae97c5 100644 --- a/app/config/bootstrap/connections.php +++ b/app/config/bootstrap/connections.php @@ -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, ] diff --git a/cli/verify_permissions.php b/cli/verify_permissions.php index 76aa36960..ddee77779 100644 --- a/cli/verify_permissions.php +++ b/cli/verify_permissions.php @@ -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]; diff --git a/composer.json b/composer.json index 7d5cad7f7..906e97acf 100755 --- a/composer.json +++ b/composer.json @@ -5,6 +5,9 @@ } ], "autoload": { + "files": [ + "app/libraries/laravel/framework/src/Illuminate/Support/helpers.php" + ], "psr-4": { "nntmux\\": "nntmux/" }, diff --git a/misc/testing/DB/check_unique_indexes.php b/misc/testing/DB/check_unique_indexes.php index 4f0753f90..130e70c2f 100755 --- a/misc/testing/DB/check_unique_indexes.php +++ b/misc/testing/DB/check_unique_indexes.php @@ -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'])) { diff --git a/misc/testing/DB/mysqldump_tables.php b/misc/testing/DB/mysqldump_tables.php index 807f5666c..281635a6f 100644 --- a/misc/testing/DB/mysqldump_tables.php +++ b/misc/testing/DB/mysqldump_tables.php @@ -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."); diff --git a/misc/testing/DB/rename_to_lower.php b/misc/testing/DB/rename_to_lower.php index c186f6935..072d1612e 100644 --- a/misc/testing/DB/rename_to_lower.php +++ b/misc/testing/DB/rename_to_lower.php @@ -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 . "'"); diff --git a/misc/testing/DB/show_table_sizes.php b/misc/testing/DB/show_table_sizes.php index 7e7a4cf05..e93c09705 100644 --- a/misc/testing/DB/show_table_sizes.php +++ b/misc/testing/DB/show_table_sizes.php @@ -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); diff --git a/misc/update/nix/tmux/monitor.php b/misc/update/nix/tmux/monitor.php index 41c1f2efd..9558e4f69 100644 --- a/misc/update/nix/tmux/monitor.php +++ b/misc/update/nix/tmux/monitor.php @@ -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; diff --git a/nntmux/NNTP.php b/nntmux/NNTP.php index c870b4b8d..7a3c4a4d0 100755 --- a/nntmux/NNTP.php +++ b/nntmux/NNTP.php @@ -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); } diff --git a/nntmux/Tmux.php b/nntmux/Tmux.php index bea73d127..9fc5c6f75 100755 --- a/nntmux/Tmux.php +++ b/nntmux/Tmux.php @@ -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']; diff --git a/nntmux/db/DB.php b/nntmux/db/DB.php index a7b5325eb..9a0107915 100755 --- a/nntmux/db/DB.php +++ b/nntmux/db/DB.php @@ -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, ]; diff --git a/tests/Install/InstallTest.php b/tests/Install/InstallTest.php index 4dd4ddda8..5bb7ad001 100644 --- a/tests/Install/InstallTest.php +++ b/tests/Install/InstallTest.php @@ -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; } diff --git a/www/admin/site-edit.php b/www/admin/site-edit.php index ccc76fa94..c2037b35a 100644 --- a/www/admin/site-edit.php +++ b/www/admin/site-edit.php @@ -171,7 +171,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"); } From e3c2ac3592207a0d9448bfd00085fab02492af4c Mon Sep 17 00:00:00 2001 From: DariusIII Date: Thu, 8 Jun 2017 00:51:27 +0200 Subject: [PATCH 07/49] Move XXX related clasess into nntmux\processing\adult namespace --- nntmux/XXX.php | 2 +- nntmux/{ => processing/adult}/ADE.php | 0 nntmux/{ => processing/adult}/ADM.php | 0 nntmux/{ => processing/adult}/AEBN.php | 0 nntmux/processing/adult/AdultMovies.php | 322 ++++++++++++++++++++ nntmux/{ => processing/adult}/Hotmovies.php | 0 nntmux/{ => processing/adult}/IAFD.php | 0 nntmux/{ => processing/adult}/Popporn.php | 0 8 files changed, 323 insertions(+), 1 deletion(-) rename nntmux/{ => processing/adult}/ADE.php (100%) rename nntmux/{ => processing/adult}/ADM.php (100%) rename nntmux/{ => processing/adult}/AEBN.php (100%) create mode 100644 nntmux/processing/adult/AdultMovies.php rename nntmux/{ => processing/adult}/Hotmovies.php (100%) rename nntmux/{ => processing/adult}/IAFD.php (100%) rename nntmux/{ => processing/adult}/Popporn.php (100%) diff --git a/nntmux/XXX.php b/nntmux/XXX.php index d5f5ae095..98a7ec050 100755 --- a/nntmux/XXX.php +++ b/nntmux/XXX.php @@ -749,7 +749,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; diff --git a/nntmux/ADE.php b/nntmux/processing/adult/ADE.php similarity index 100% rename from nntmux/ADE.php rename to nntmux/processing/adult/ADE.php diff --git a/nntmux/ADM.php b/nntmux/processing/adult/ADM.php similarity index 100% rename from nntmux/ADM.php rename to nntmux/processing/adult/ADM.php diff --git a/nntmux/AEBN.php b/nntmux/processing/adult/AEBN.php similarity index 100% rename from nntmux/AEBN.php rename to nntmux/processing/adult/AEBN.php diff --git a/nntmux/processing/adult/AdultMovies.php b/nntmux/processing/adult/AdultMovies.php new file mode 100644 index 000000000..c68bb578c --- /dev/null +++ b/nntmux/processing/adult/AdultMovies.php @@ -0,0 +1,322 @@ +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[\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; + } + +} \ No newline at end of file diff --git a/nntmux/Hotmovies.php b/nntmux/processing/adult/Hotmovies.php similarity index 100% rename from nntmux/Hotmovies.php rename to nntmux/processing/adult/Hotmovies.php diff --git a/nntmux/IAFD.php b/nntmux/processing/adult/IAFD.php similarity index 100% rename from nntmux/IAFD.php rename to nntmux/processing/adult/IAFD.php diff --git a/nntmux/Popporn.php b/nntmux/processing/adult/Popporn.php similarity index 100% rename from nntmux/Popporn.php rename to nntmux/processing/adult/Popporn.php From 4348434ecf5d8b49df951caaec28478e18ea72b6 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Fri, 9 Jun 2017 00:01:50 +0200 Subject: [PATCH 08/49] Add custom helpers.php --- app/extensions/helper/helpers.php | 38 +++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 app/extensions/helper/helpers.php diff --git a/app/extensions/helper/helpers.php b/app/extensions/helper/helpers.php new file mode 100644 index 000000000..245c963d4 --- /dev/null +++ b/app/extensions/helper/helpers.php @@ -0,0 +1,38 @@ +setCookie(SetCookie::fromString($this->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; + } +} \ No newline at end of file From 40cba044a6ad235d73eb7298aba6a433bc8cfbc8 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Fri, 9 Jun 2017 00:02:25 +0200 Subject: [PATCH 09/49] Update adult classes --- composer.json | 3 +- nntmux/processing/adult/ADE.php | 80 ++-------------------- nntmux/processing/adult/ADM.php | 88 +++---------------------- nntmux/processing/adult/AEBN.php | 6 +- nntmux/processing/adult/AdultMovies.php | 2 +- nntmux/processing/adult/Hotmovies.php | 14 ++-- nntmux/processing/adult/IAFD.php | 6 +- nntmux/processing/adult/Popporn.php | 6 +- nntmux/utility/Utility.php | 16 ++--- 9 files changed, 49 insertions(+), 172 deletions(-) diff --git a/composer.json b/composer.json index 906e97acf..4d93f8681 100755 --- a/composer.json +++ b/composer.json @@ -6,7 +6,8 @@ ], "autoload": { "files": [ - "app/libraries/laravel/framework/src/Illuminate/Support/helpers.php" + "app/libraries/laravel/framework/src/Illuminate/Support/helpers.php", + "app/extensions/helper/helpers.php" ], "psr-4": { "nntmux\\": "nntmux/" diff --git a/nntmux/processing/adult/ADE.php b/nntmux/processing/adult/ADE.php index 1ed1daca7..6795776d6 100755 --- a/nntmux/processing/adult/ADE.php +++ b/nntmux/processing/adult/ADE.php @@ -1,16 +1,14 @@ _html = new \simple_html_dom(); $this->_edithtml = new \simple_html_dom(); - $this->client = new Client(); - $this->pdo = new DB(); } /** @@ -295,9 +282,8 @@ class ADE if (empty($this->searchTerm)) { return false; } - if ($this->getUrl($this->_dvdQuery . rawurlencode($this->searchTerm)) === false) { - return false; - } else { + $this->_response = getUrl($this->_dvdQuery . rawurlencode($this->searchTerm)); + if ($this->_response !== false) { $this->_html->load($this->_response); if ($ret = $this->_html->find('a.boxcover', 0)) { $title = $ret->title; @@ -312,7 +298,7 @@ class ADE $this->_title = trim($title); unset($ret); $this->_html->clear(); - $this->getUrl($this->_urlFound); + getUrl($this->_urlFound); $this->_html->load($this->_response); } else { $this->found = false; @@ -326,58 +312,6 @@ class ADE 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 * diff --git a/nntmux/processing/adult/ADM.php b/nntmux/processing/adult/ADM.php index 42e2a44b7..2723b3c65 100755 --- a/nntmux/processing/adult/ADM.php +++ b/nntmux/processing/adult/ADM.php @@ -1,14 +1,10 @@ _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]); - } } /** @@ -133,6 +109,7 @@ class ADM /** * Gets the synopsis + * * @return array */ public function synopsis() @@ -148,7 +125,7 @@ class ADM } /** - * Get Product Informtion and Director + * Get Product Information and Director * * * @return array @@ -224,7 +201,9 @@ class ADM $result = false; if (!empty($this->searchTerm)) { $this->_trailUrl = self::TRAILINGSEARCH . urlencode($this->searchTerm); - if ($this->getUrl() !== false) { + $this->_response = getUrl(self::ADMURL . $this->_trailUrl); + 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) { @@ -287,53 +266,4 @@ class ADM $results = empty($results) ? false : $results; return $results; } - - /** - * Get Raw html of webpage - * - * @return bool - */ - private function getUrl() - { - 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())); - } - } - - if (!$this->_response) { - return false; - } - - $this->_html->load($this->_response); - return true; - } } diff --git a/nntmux/processing/adult/AEBN.php b/nntmux/processing/adult/AEBN.php index 85e3c8d81..be1884e4a 100755 --- a/nntmux/processing/adult/AEBN.php +++ b/nntmux/processing/adult/AEBN.php @@ -6,8 +6,9 @@ use GuzzleHttp\Cookie\SetCookie; use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Client; use nntmux\db\DB; +use nntmux\processing\adult\AdultMovies; -class AEBN +class AEBN extends AdultMovies { /** * Cookie File location used in curl @@ -119,8 +120,9 @@ class AEBN * Sets the variables that used throughout the class * */ - public function __construct() + public function __construct(array $options = []) { + parent::__construct($options); $this->_whichSite = ['straight' => self::AEBNSURL, 'gay' => self::AEBNGURL]; $this->_html = new \simple_html_dom(); $this->client = new Client(); diff --git a/nntmux/processing/adult/AdultMovies.php b/nntmux/processing/adult/AdultMovies.php index c68bb578c..02cf8573a 100644 --- a/nntmux/processing/adult/AdultMovies.php +++ b/nntmux/processing/adult/AdultMovies.php @@ -6,7 +6,7 @@ namespace nntmux\processing\adult; use nntmux\ColorCLI; use nntmux\XXX; -class AdultMovies extends XXX +abstract class AdultMovies extends XXX { // Television Sources const SOURCE_NONE = 0; diff --git a/nntmux/processing/adult/Hotmovies.php b/nntmux/processing/adult/Hotmovies.php index 643cf8965..96144c040 100755 --- a/nntmux/processing/adult/Hotmovies.php +++ b/nntmux/processing/adult/Hotmovies.php @@ -1,7 +1,9 @@ _html = new \simple_html_dom(); // Set a cookie to override +18 warning. diff --git a/nntmux/processing/adult/IAFD.php b/nntmux/processing/adult/IAFD.php index 465531943..a24e812ce 100755 --- a/nntmux/processing/adult/IAFD.php +++ b/nntmux/processing/adult/IAFD.php @@ -1,9 +1,10 @@ _html = new \simple_html_dom(); if (!empty($this->cookie)) { @$this->getUrl(); diff --git a/nntmux/processing/adult/Popporn.php b/nntmux/processing/adult/Popporn.php index 803662fd0..1529e23d0 100755 --- a/nntmux/processing/adult/Popporn.php +++ b/nntmux/processing/adult/Popporn.php @@ -1,9 +1,10 @@ _html = new \simple_html_dom(); if (isset($this->cookie)) { $this->getUrl(); diff --git a/nntmux/utility/Utility.php b/nntmux/utility/Utility.php index e8a059cce..803f215ce 100755 --- a/nntmux/utility/Utility.php +++ b/nntmux/utility/Utility.php @@ -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; } From 6125aa18e7a78e00811d885fef69e81a49ced035 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Fri, 9 Jun 2017 15:21:51 +0200 Subject: [PATCH 10/49] Update XXX processing, declare abstract functions, fix some bad logic --- nntmux/processing/adult/ADM.php | 14 +- nntmux/processing/adult/AEBN.php | 201 ++++++------------------ nntmux/processing/adult/AdultMovies.php | 40 +++++ nntmux/processing/adult/IAFD.php | 194 ----------------------- 4 files changed, 95 insertions(+), 354 deletions(-) delete mode 100755 nntmux/processing/adult/IAFD.php diff --git a/nntmux/processing/adult/ADM.php b/nntmux/processing/adult/ADM.php index 2723b3c65..cdafe3fc8 100755 --- a/nntmux/processing/adult/ADM.php +++ b/nntmux/processing/adult/ADM.php @@ -91,7 +91,7 @@ class ADM extends AdultMovies * 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)) { @@ -112,7 +112,7 @@ class ADM extends AdultMovies * * @return array */ - public function synopsis() + protected function synopsis() { $this->_res['synopsis'] = 'N/A'; foreach ($this->_html->find('h3') as $heading) { @@ -130,7 +130,7 @@ class ADM extends AdultMovies * * @return array */ - public function productInfo() + protected function productInfo() { foreach ($this->_html->find('ul.list-unstyled li') as $li) { @@ -154,7 +154,7 @@ class ADM extends AdultMovies * Gets the cast members * @return array */ - public function cast() + protected function cast() { $cast = []; foreach ($this->_html->find('h3') as $heading) { @@ -175,7 +175,7 @@ class ADM extends AdultMovies * Gets categories * @return array */ - public function genres() + protected function genres() { $genres = []; foreach ($this->_html->find('ul.list-unstyled li') as $li) { @@ -196,7 +196,7 @@ class ADM extends AdultMovies * Searches for match against searchterm * @return bool - true if search = 100% */ - public function search() + protected function search() { $result = false; if (!empty($this->searchTerm)) { @@ -235,7 +235,7 @@ class ADM extends AdultMovies * Gets all information * @return array */ - public function getAll() + protected function getAll() { $results = []; if (!empty($this->_directUrl)) { diff --git a/nntmux/processing/adult/AEBN.php b/nntmux/processing/adult/AEBN.php index be1884e4a..01733210a 100755 --- a/nntmux/processing/adult/AEBN.php +++ b/nntmux/processing/adult/AEBN.php @@ -27,18 +27,11 @@ class AEBN extends AdultMovies /** * 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 @@ -51,23 +44,6 @@ class AEBN extends AdultMovies */ 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 * @@ -79,7 +55,7 @@ class AEBN extends AdultMovies * * @var array */ - protected $_res = [ + protected static $res = [ 'backcover' => [], 'boxcover' => [], 'cast' => [], @@ -106,41 +82,18 @@ class AEBN extends AdultMovies * Trailing Url * @var string */ - protected $_trailUrl = ''; - - /** - * Used in __construct - * @var array - straight, gay - */ - protected $_whichSite = []; - + protected $_trailerUrl = ''; /** * Sets the variables that used throughout the class * + * @param array $options */ public function __construct(array $options = []) { parent::__construct($options); - $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); } /** @@ -148,15 +101,15 @@ class AEBN extends AdultMovies * * @return array|bool */ - public function trailers() + protected function trailers() { $ret = $this->_html->find('a[itemprop=trailer]', 0); if (preg_match('/movieId=(?\d+)&/', trim($ret->href), $matches)) { $movieid = $matches['movieid']; - $this->_res['trailers']['url'] = $this->_whichSite[$this->_currentSite] . self::TRAILERURL . $movieid; + AEBN::$res['trailers']['url'] = AEBN::AEBNSURL . self::TRAILERURL . $movieid; } - return $this->_res; + return AEBN::$res; } /** @@ -164,17 +117,17 @@ class AEBN extends AdultMovies * * @return array */ - public function covers() + protected 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); + AEBN::$res['boxcover'] = str_ireplace('160w.jpg', 'xlf.jpg', $ret); + AEBN::$res['backcover'] = str_ireplace('160w.jpg', 'xlb.jpg', $ret); } - return $this->_res; + return AEBN::$res; } /** @@ -182,15 +135,15 @@ class AEBN extends AdultMovies * * @return array */ - public function genres() + 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); + AEBN::$res['genres'][] = trim($genre->plaintext); } } - $this->_res['genres'] = array_unique($this->_res['genres']); - return $this->_res; + AEBN::$res['genres'] = array_unique(AEBN::$res['genres']); + return AEBN::$res; } /** @@ -198,23 +151,23 @@ class AEBN extends AdultMovies * * @return array */ - public function cast() + protected function cast() { if ($ret = $this->_html->find('div.starsFull', 0)) { foreach ($ret->find('span[itemprop=name]') as $star) { - $this->_res['cast'][] = trim($star->plaintext); + AEBN::$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); + AEBN::$res['cast'][] = trim($star->plaintext); } } } } - return $this->_res; + return AEBN::$res; } /** @@ -222,27 +175,27 @@ class AEBN extends AdultMovies * * @return array */ - public function productInfo() + 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); + AEBN::$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('Running Time:', AEBN::$res['productinfo'])) { + unset(AEBN::$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]); + if (false !== $key = array_search("Director:", AEBN::$res['productinfo'])) { + AEBN::$res['director'] = AEBN::$res['productinfo'][$key + 1]; + unset(AEBN::$res['productinfo'][$key], AEBN::$res['productinfo'][$key + 1]); } - $this->_res['productinfo'] = array_chunk($this->_res['productinfo'], 2, false); + AEBN::$res['productinfo'] = array_chunk(AEBN::$res['productinfo'], 2, false); } - return $this->_res; + return AEBN::$res; } /** @@ -251,20 +204,19 @@ class AEBN extends AdultMovies * @return array * */ - public function synopsis() + 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'] = trim($ret->plaintext); - $this->_res['synopsis'] = preg_replace('/Description:\s/', "", $this->_res['plot']); + AEBN::$res['synopsis'] = preg_replace('/Description:\s/', '', AEBN::$res['plot']); } } else { - $this->_res['synopsis'] = trim($ret->plaintext); + AEBN::$res['synopsis'] = trim($ret->plaintext); } } - return $this->_res; + return AEBN::$res; } /** @@ -272,17 +224,19 @@ class AEBN extends AdultMovies * * @return bool */ - public function search() + protected 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; + $this->_response = false; + $this->_trailerUrl = self::TRAILINGSEARCH . urlencode($this->searchTerm); + $this->_response = getUrl(self::IF18); + if ($this->_response !== false) { + $this->_html->load($this->_response); + $count = count($this->_html->find('div.movie')); + $i = 1; + while ($count >= $i) { foreach ($this->_html->find('div.movie') as $movie) { $string = 'a#FTSMovieSearch_link_title_detail_' . $i; if ($ret = $movie->find($string, 0)) { @@ -292,26 +246,18 @@ class AEBN extends AdultMovies 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); + $this->_trailerUrl = html_entity_decode($ret->href); + $this->_directUrl = self::AEBNSURL . $this->_trailerUrl; + getUrl(self::AEBNSURL); return true; - } else { - continue; } + continue; } $i++; } - if ($i === $count || $count === 0) { - if ($this->_currentSite === 'gay') { - return false; - } - $this->_currentSite = 'gay'; - $this->search(); - } - } else { - return false; } + + return false; } return false; @@ -348,61 +294,10 @@ class AEBN extends AdultMovies 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) { + if (empty($results)) { return false; } - $this->_html->load($this->_response); - return true; + return $results; } } diff --git a/nntmux/processing/adult/AdultMovies.php b/nntmux/processing/adult/AdultMovies.php index 02cf8573a..f09477bb4 100644 --- a/nntmux/processing/adult/AdultMovies.php +++ b/nntmux/processing/adult/AdultMovies.php @@ -37,6 +37,46 @@ abstract class AdultMovies extends XXX 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(); + + /** + * @return mixed + */ + abstract protected function search(); + + /** + * @return mixed + */ + abstract protected function getAll(); + + /** + * @return mixed + */ + abstract protected function trailers(); + /** * Fetch xxx info for the movie. * diff --git a/nntmux/processing/adult/IAFD.php b/nntmux/processing/adult/IAFD.php deleted file mode 100755 index a24e812ce..000000000 --- a/nntmux/processing/adult/IAFD.php +++ /dev/null @@ -1,194 +0,0 @@ -_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; - } -} From 06328e6b1ea77eccd7849073817a0ec057fde972 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Fri, 9 Jun 2017 19:17:50 +0200 Subject: [PATCH 11/49] Update composer.lock --- Changelog | 2 + composer.lock | 104 ++++++++++++++++++++++++++++++-------------------- 2 files changed, 65 insertions(+), 41 deletions(-) diff --git a/Changelog b/Changelog index 793dbeae2..5ace104c1 100755 --- a/Changelog +++ b/Changelog @@ -1,3 +1,5 @@ +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 diff --git a/composer.lock b/composer.lock index 9bac1f543..2a26d4ff4 100644 --- a/composer.lock +++ b/composer.lock @@ -604,19 +604,41 @@ }, { "name": "bower-asset/fancybox", - "version": "v3.0.47", + "version": "v3.1.20", "source": { "type": "git", "url": "https://github.com/fancyapps/fancybox.git", - "reference": "04bd1bd751ac10048c06e7db79197770cff4a1d7" + "reference": "3607c5562130ff4eb4ced258e30de6613dc7c2c1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fancyapps/fancybox/zipball/04bd1bd751ac10048c06e7db79197770cff4a1d7", - "reference": "04bd1bd751ac10048c06e7db79197770cff4a1d7", + "url": "https://api.github.com/repos/fancyapps/fancybox/zipball/3607c5562130ff4eb4ced258e30de6613dc7c2c1", + "reference": "3607c5562130ff4eb4ced258e30de6613dc7c2c1", "shasum": "" }, - "type": "bower-asset-library" + "require": { + "bower-asset/jquery": ">=1.9.0" + }, + "type": "bower-asset-library", + "extra": { + "bower-asset-main": [ + "dist/jquery.fancybox.min.css", + "dist/jquery.fancybox.min.js" + ] + }, + "license": [ + "GPL-3.0" + ], + "description": "Touch enabled, responsive and fully customizable jQuery lightbox script", + "keywords": [ + "fancybox", + "gallery", + "jQuery", + "lightbox", + "plugin", + "responsive", + "touch" + ] }, { "name": "bower-asset/fastclick", @@ -3619,21 +3641,21 @@ }, { "name": "symfony/polyfill-intl-icu", - "version": "v1.3.0", + "version": "v1.4.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-icu.git", - "reference": "2d6e2b20d457603eefb6e614286c22efca30fdb4" + "reference": "3191cbe0ce64987bd382daf6724af31c53daae01" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-icu/zipball/2d6e2b20d457603eefb6e614286c22efca30fdb4", - "reference": "2d6e2b20d457603eefb6e614286c22efca30fdb4", + "url": "https://api.github.com/repos/symfony/polyfill-intl-icu/zipball/3191cbe0ce64987bd382daf6724af31c53daae01", + "reference": "3191cbe0ce64987bd382daf6724af31c53daae01", "shasum": "" }, "require": { "php": ">=5.3.3", - "symfony/intl": "~2.3|~3.0" + "symfony/intl": "~2.3|~3.0|~4.0" }, "suggest": { "ext-intl": "For best performance" @@ -3641,7 +3663,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3-dev" + "dev-master": "1.4-dev" } }, "autoload": { @@ -3673,20 +3695,20 @@ "portable", "shim" ], - "time": "2016-11-14T01:06:16+00:00" + "time": "2017-06-09T08:25:21+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.3.0", + "version": "v1.4.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4" + "reference": "f29dca382a6485c3cbe6379f0c61230167681937" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/e79d363049d1c2128f133a2667e4f4190904f7f4", - "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/f29dca382a6485c3cbe6379f0c61230167681937", + "reference": "f29dca382a6485c3cbe6379f0c61230167681937", "shasum": "" }, "require": { @@ -3698,7 +3720,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3-dev" + "dev-master": "1.4-dev" } }, "autoload": { @@ -3732,20 +3754,20 @@ "portable", "shim" ], - "time": "2016-11-14T01:06:16+00:00" + "time": "2017-06-09T14:24:12+00:00" }, { "name": "symfony/polyfill-php56", - "version": "v1.3.0", + "version": "v1.4.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php56.git", - "reference": "1dd42b9b89556f18092f3d1ada22cb05ac85383c" + "reference": "bc0b7d6cb36b10cfabb170a3e359944a95174929" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/1dd42b9b89556f18092f3d1ada22cb05ac85383c", - "reference": "1dd42b9b89556f18092f3d1ada22cb05ac85383c", + "url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/bc0b7d6cb36b10cfabb170a3e359944a95174929", + "reference": "bc0b7d6cb36b10cfabb170a3e359944a95174929", "shasum": "" }, "require": { @@ -3755,7 +3777,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3-dev" + "dev-master": "1.4-dev" } }, "autoload": { @@ -3788,20 +3810,20 @@ "portable", "shim" ], - "time": "2016-11-14T01:06:16+00:00" + "time": "2017-06-09T08:25:21+00:00" }, { "name": "symfony/polyfill-php70", - "version": "v1.3.0", + "version": "v1.4.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php70.git", - "reference": "13ce343935f0f91ca89605a2f6ca6f5c2f3faac2" + "reference": "032fd647d5c11a9ceab8ee8747e13b5448e93874" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/13ce343935f0f91ca89605a2f6ca6f5c2f3faac2", - "reference": "13ce343935f0f91ca89605a2f6ca6f5c2f3faac2", + "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/032fd647d5c11a9ceab8ee8747e13b5448e93874", + "reference": "032fd647d5c11a9ceab8ee8747e13b5448e93874", "shasum": "" }, "require": { @@ -3811,7 +3833,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3-dev" + "dev-master": "1.4-dev" } }, "autoload": { @@ -3847,20 +3869,20 @@ "portable", "shim" ], - "time": "2016-11-14T01:06:16+00:00" + "time": "2017-06-09T14:24:12+00:00" }, { "name": "symfony/polyfill-util", - "version": "v1.3.0", + "version": "v1.4.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-util.git", - "reference": "746bce0fca664ac0a575e465f65c6643faddf7fb" + "reference": "ebccbde4aad410f6438d86d7d261c6b4d2b9a51d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-util/zipball/746bce0fca664ac0a575e465f65c6643faddf7fb", - "reference": "746bce0fca664ac0a575e465f65c6643faddf7fb", + "url": "https://api.github.com/repos/symfony/polyfill-util/zipball/ebccbde4aad410f6438d86d7d261c6b4d2b9a51d", + "reference": "ebccbde4aad410f6438d86d7d261c6b4d2b9a51d", "shasum": "" }, "require": { @@ -3869,7 +3891,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3-dev" + "dev-master": "1.4-dev" } }, "autoload": { @@ -3899,7 +3921,7 @@ "polyfill", "shim" ], - "time": "2016-11-14T01:06:16+00:00" + "time": "2017-06-09T08:25:21+00:00" }, { "name": "symfony/symfony", @@ -4094,16 +4116,16 @@ }, { "name": "twig/twig", - "version": "v2.4.2", + "version": "v2.4.3", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "fe3e3f3359b23b36f65cb600cd516142c07a2e7d" + "reference": "eab7c3288ae6603d7d6f92b531626af2b162d1f2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/fe3e3f3359b23b36f65cb600cd516142c07a2e7d", - "reference": "fe3e3f3359b23b36f65cb600cd516142c07a2e7d", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/eab7c3288ae6603d7d6f92b531626af2b162d1f2", + "reference": "eab7c3288ae6603d7d6f92b531626af2b162d1f2", "shasum": "" }, "require": { @@ -4156,7 +4178,7 @@ "keywords": [ "templating" ], - "time": "2017-06-06T03:58:14+00:00" + "time": "2017-06-07T18:47:58+00:00" }, { "name": "unionofrad/lithium", From 3814aac915e942fb4899b89bc588a02aa90f606b Mon Sep 17 00:00:00 2001 From: DariusIII Date: Fri, 9 Jun 2017 21:00:34 +0200 Subject: [PATCH 12/49] Update AEBN and PopPorn classes --- nntmux/processing/adult/AEBN.php | 66 +++++++++++------------------ nntmux/processing/adult/Popporn.php | 37 ++++++---------- 2 files changed, 37 insertions(+), 66 deletions(-) diff --git a/nntmux/processing/adult/AEBN.php b/nntmux/processing/adult/AEBN.php index 01733210a..9d435fbc8 100755 --- a/nntmux/processing/adult/AEBN.php +++ b/nntmux/processing/adult/AEBN.php @@ -1,28 +1,16 @@ _html->find('a[itemprop=trailer]', 0); if (preg_match('/movieId=(?\d+)&/', trim($ret->href), $matches)) { $movieid = $matches['movieid']; - AEBN::$res['trailers']['url'] = AEBN::AEBNSURL . self::TRAILERURL . $movieid; + self::$res['trailers']['url'] = self::AEBNSURL . self::TRAILERURL . $movieid; } - return AEBN::$res; + return self::$res; } /** @@ -124,10 +106,10 @@ class AEBN extends AdultMovies if (strpos($ret, '//') === 0) { $ret = 'http:' . $ret; } - AEBN::$res['boxcover'] = str_ireplace('160w.jpg', 'xlf.jpg', $ret); - AEBN::$res['backcover'] = str_ireplace('160w.jpg', 'xlb.jpg', $ret); + self::$res['boxcover'] = str_ireplace('160w.jpg', 'xlf.jpg', $ret); + self::$res['backcover'] = str_ireplace('160w.jpg', 'xlb.jpg', $ret); } - return AEBN::$res; + return self::$res; } /** @@ -139,11 +121,11 @@ class AEBN extends AdultMovies { if ($ret = $this->_html->find('div.md-detailsCategories', 0)) { foreach ($ret->find('a[itemprop=genre]') as $genre) { - AEBN::$res['genres'][] = trim($genre->plaintext); + self::$res['genres'][] = trim($genre->plaintext); } } - AEBN::$res['genres'] = array_unique(AEBN::$res['genres']); - return AEBN::$res; + self::$res['genres'] = array_unique(self::$res['genres']); + return self::$res; } /** @@ -155,19 +137,19 @@ class AEBN extends AdultMovies { if ($ret = $this->_html->find('div.starsFull', 0)) { foreach ($ret->find('span[itemprop=name]') as $star) { - AEBN::$res['cast'][] = trim($star->plaintext); + self::$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) { - AEBN::$res['cast'][] = trim($star->plaintext); + self::$res['cast'][] = trim($star->plaintext); } } } } - return AEBN::$res; + return self::$res; } /** @@ -182,20 +164,20 @@ class AEBN extends AdultMovies foreach ($div->find('span') as $span) { $span->plaintext = rawurldecode($span->plaintext); $span->plaintext = preg_replace('/ /', '', $span->plaintext); - AEBN::$res['productinfo'][] = trim($span->plaintext); + self::$res['productinfo'][] = trim($span->plaintext); } } - if (false !== $key = array_search('Running Time:', AEBN::$res['productinfo'])) { - unset(AEBN::$res['productinfo'][$key + 2]); + if (false !== $key = array_search('Running Time:', self::$res['productinfo'])) { + unset(self::$res['productinfo'][$key + 2]); } - if (false !== $key = array_search("Director:", AEBN::$res['productinfo'])) { - AEBN::$res['director'] = AEBN::$res['productinfo'][$key + 1]; - unset(AEBN::$res['productinfo'][$key], AEBN::$res['productinfo'][$key + 1]); + if (false !== $key = array_search("Director:", self::$res['productinfo'])) { + self::$res['director'] = self::$res['productinfo'][$key + 1]; + unset(self::$res['productinfo'][$key], self::$res['productinfo'][$key + 1]); } - AEBN::$res['productinfo'] = array_chunk(AEBN::$res['productinfo'], 2, false); + self::$res['productinfo'] = array_chunk(self::$res['productinfo'], 2, false); } - return AEBN::$res; + return self::$res; } /** @@ -209,14 +191,14 @@ class AEBN extends AdultMovies if ($ret = $this->_html->find('span[itemprop=about]', 0)) { if ($ret === null) { if ($ret = $this->_html->find('div.movieDetailDescription', 0)) { - AEBN::$res['synopsis'] = preg_replace('/Description:\s/', '', AEBN::$res['plot']); + self::$res['synopsis'] = preg_replace('/Description:\s/', '', self::$res['plot']); } } else { - AEBN::$res['synopsis'] = trim($ret->plaintext); + self::$res['synopsis'] = trim($ret->plaintext); } } - return AEBN::$res; + return self::$res; } /** @@ -231,7 +213,7 @@ class AEBN extends AdultMovies } $this->_response = false; $this->_trailerUrl = self::TRAILINGSEARCH . urlencode($this->searchTerm); - $this->_response = getUrl(self::IF18); + $this->_response = getUrl(self::IF18, false); if ($this->_response !== false) { $this->_html->load($this->_response); $count = count($this->_html->find('div.movie')); diff --git a/nntmux/processing/adult/Popporn.php b/nntmux/processing/adult/Popporn.php index 1529e23d0..d093edef0 100755 --- a/nntmux/processing/adult/Popporn.php +++ b/nntmux/processing/adult/Popporn.php @@ -80,16 +80,6 @@ class Popporn extends AdultMovies } } - /** - * Remove from memory. - */ - public function __destruct() - { - $this->_html->clear(); - unset($this->_response); - unset($this->_res); - } - /** * Get Box Cover Images * @return array - boxcover,backcover @@ -98,10 +88,10 @@ class Popporn extends AdultMovies { 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)) { @@ -116,20 +106,20 @@ class Popporn extends AdultMovies } /** - * 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"; } } } @@ -322,7 +312,7 @@ class Popporn extends AdultMovies /** * Gets all information - * @return array + * @return array|bool */ public function getAll() { @@ -331,8 +321,8 @@ class Popporn extends AdultMovies $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)); @@ -349,11 +339,10 @@ class Popporn extends AdultMovies if (is_array($this->trailers())) { $results = array_merge($results, $this->trailers()); } - if (empty($results) === true) { + if (empty($results)) { return false; - } else { - return $results; } + return $results; } /** From 8c85f7e42220e381a96dac2c13fe8055281dd04a Mon Sep 17 00:00:00 2001 From: DariusIII Date: Sat, 10 Jun 2017 00:13:09 +0200 Subject: [PATCH 13/49] More adjustments to classes --- nntmux/XXX.php | 320 ++++++++++++------------ nntmux/processing/PostProcess.php | 13 +- nntmux/processing/adult/ADE.php | 28 +-- nntmux/processing/adult/ADM.php | 11 +- nntmux/processing/adult/AEBN.php | 23 +- nntmux/processing/adult/AdultMovies.php | 312 ++++------------------- nntmux/processing/adult/Hotmovies.php | 43 ++-- nntmux/processing/adult/Popporn.php | 10 +- nntmux/processing/tv/TV.php | 2 +- 9 files changed, 275 insertions(+), 487 deletions(-) diff --git a/nntmux/XXX.php b/nntmux/XXX.php index 98a7ec050..411b23d2f 100755 --- a/nntmux/XXX.php +++ b/nntmux/XXX.php @@ -73,6 +73,8 @@ class XXX /** * @param array $options Echo to cli / Class instances. + * + * @throws \Exception */ public function __construct(array $options = []) { @@ -410,57 +412,178 @@ class XXX } /** - * Fetch xxx info for the movie. + * Get all genres for search-filter.tpl * - * @param $xxxmovie + * @param bool $activeOnly + * + * @return array|null + */ + public function getAllGenres($activeOnly = false) + { + $ret = null; + + if ($activeOnly) { + $res = $this->pdo->query('SELECT title FROM genres WHERE disabled = 0 AND type = ' . + Category::XXX_ROOT . ' ORDER BY title' + ); + } else { + $res = $this->pdo->query('SELECT title FROM genres WHERE disabled = 1 AND type = ' . + Category::XXX_ROOT . ' ORDER BY title' + ); + } + + foreach ($res as $arr => $value) { + $ret[] = $value['title']; + } + + return $ret; + } + + /** + * Get Genres for activeonly and/or an ID + * + * @param bool $activeOnly + * @param null|string $gid + * + * @return array|bool + */ + public function getGenres($activeOnly = false, $gid = null) + { + if ($gid !== null) { + $gid = ' AND id = ' . $this->pdo->escapeString($gid) . ' ORDER BY title'; + } else { + $gid = ' ORDER BY title'; + } + + if ($activeOnly) { + return $this->pdo->queryOneRow('SELECT title FROM genres WHERE disabled = 0 AND type = ' . Category::XXX_ROOT . $gid); + } + + return $this->pdo->queryOneRow('SELECT title FROM genres WHERE disabled = 1 AND type = ' . Category::XXX_ROOT . $gid); + } + + /** + * Get Genre id's Of the title + * + * @param $arr - Array or String + * + * @return string - If array .. 1,2,3,4 if string .. 1 + */ + protected function getGenreID($arr): string + { + $ret = null; + + if (!is_array($arr)) { + $res = $this->pdo->queryOneRow('SELECT id FROM genres WHERE title = ' . $this->pdo->escapeString($arr)); + if ($res !== false) { + return $res['id']; + } + } + + foreach ($arr as $key => $value) { + $res = $this->pdo->queryOneRow('SELECT id FROM genres WHERE title = ' . $this->pdo->escapeString($value)); + if ($res !== false) { + $ret .= ',' . $res['id']; + } else { + $ret .= ',' . $this->insertGenre($value); + } + } + + $ret = ltrim($ret, ','); + + return $ret; + } + + /** + * Inserts Genre and returns last affected row (Genre ID) + * + * @param $genre * * @return bool */ - public function updateXXXInfo($xxxmovie): bool + private function insertGenre($genre): bool + { + $res = ''; + if ($genre !== null) { + $res = $this->pdo->queryInsert(sprintf('INSERT INTO genres (title, type, disabled) VALUES (%s ,%d ,%d)', $this->pdo->escapeString($genre), Category::XXX_ROOT, 0)); + } + + return $res; + } + + /** + * Inserts Trailer Code by Class + * + * @param $whichclass + * @param $res + * + * @return string + */ + public function insertSwf($whichclass, $res): string + { + $ret = ''; + if ($whichclass === 'ade') { + if (!empty($res)) { + $trailers = unserialize($res, 'ade'); + $ret .= ""; + $ret .= ""; + $ret .= ""; + + return $ret; + } + } + if ($whichclass === 'pop') { + if (!empty($res)) { + $trailers = unserialize($res, 'pop'); + $ret .= ""; + + return $ret; + } + } + + return $ret; + } + + /** + * Fetch xxx info for the movie. + * + * @param $movie + * + * @return bool + */ + public function updateXXXInfo($movie): 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(); + $res = $mov->search($movie); if ($res === false) { $this->whichclass = 'ade'; $mov = new ADE(); - $mov->searchTerm = $xxxmovie; - $res = $mov->search(); + $res = $mov->search($movie); } if ($res === false) { $this->whichclass = 'pop'; $mov = new Popporn(); $mov->cookie = $this->cookie; - $mov->searchTerm = $xxxmovie; - $res = $mov->search(); + $res = $mov->search($movie); + } + + if ($res === false) { + $this->whichclass = 'hotmovies'; + $mov = new Hotmovies(); + $mov->cookie = $this->cookie; + $res = $mov->search($movie); } // Last in list as it doesn't have trailers @@ -468,8 +591,7 @@ class XXX $this->whichclass = 'adm'; $mov = new ADM(); $mov->cookie = $this->cookie; - $mov->searchTerm = $xxxmovie; - $res = $mov->search(); + $res = $mov->search($movie); } @@ -490,6 +612,9 @@ class XXX case 'adm': $fromstr = 'Adult DVD Marketplace'; break; + case 'hotmovies': + $fromstr = 'HotMovies'; + break; default: $fromstr = null; } @@ -512,7 +637,7 @@ class XXX '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') : '', + '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') : '', @@ -690,139 +815,4 @@ class XXX return false; } - - /** - * Get all genres for search-filter.tpl - * - * @param bool $activeOnly - * - * @return array|null - */ - public function getAllGenres($activeOnly = false) - { - $ret = null; - - if ($activeOnly) { - $res = $this->pdo->query('SELECT title FROM genres WHERE disabled = 0 AND type = ' . - Category::XXX_ROOT . ' ORDER BY title' - ); - } else { - $res = $this->pdo->query('SELECT title FROM genres WHERE disabled = 1 AND type = ' . - Category::XXX_ROOT . ' ORDER BY title' - ); - } - - foreach ($res as $arr => $value) { - $ret[] = $value['title']; - } - - return $ret; - } - - /** - * Get Genres for activeonly and/or an ID - * - * @param bool $activeOnly - * @param null|string $gid - * - * @return array|bool - */ - public function getGenres($activeOnly = false, $gid = null) - { - if ($gid !== null) { - $gid = ' AND id = ' . $this->pdo->escapeString($gid) . ' ORDER BY title'; - } else { - $gid = ' ORDER BY title'; - } - - if ($activeOnly) { - return $this->pdo->queryOneRow('SELECT title FROM genres WHERE disabled = 0 AND type = ' . Category::XXX_ROOT . $gid); - } - - return $this->pdo->queryOneRow('SELECT title FROM genres WHERE disabled = 1 AND type = ' . Category::XXX_ROOT . $gid); - } - - /** - * Get Genre id's Of the title - * - * @param $arr - Array or String - * - * @return string - If array .. 1,2,3,4 if string .. 1 - */ - protected function getGenreID($arr): string - { - $ret = null; - - if (!is_array($arr)) { - $res = $this->pdo->queryOneRow('SELECT id FROM genres WHERE title = ' . $this->pdo->escapeString($arr)); - if ($res !== false) { - return $res['id']; - } - } - - foreach ($arr as $key => $value) { - $res = $this->pdo->queryOneRow('SELECT id FROM genres WHERE title = ' . $this->pdo->escapeString($value)); - if ($res !== false) { - $ret .= ',' . $res['id']; - } else { - $ret .= ',' . $this->insertGenre($value); - } - } - - $ret = ltrim($ret, ','); - - return $ret; - } - - /** - * Inserts Genre and returns last affected row (Genre ID) - * - * @param $genre - * - * @return bool - */ - private function insertGenre($genre): bool - { - $res = ''; - if ($genre !== null) { - $res = $this->pdo->queryInsert(sprintf('INSERT INTO genres (title, type, disabled) VALUES (%s ,%d ,%d)', $this->pdo->escapeString($genre), Category::XXX_ROOT, 0)); - } - - return $res; - } - - /** - * Inserts Trailer Code by Class - * - * @param $whichclass - * @param $res - * - * @return string - */ - public function insertSwf($whichclass, $res): string - { - $ret = ''; - if ($whichclass === 'ade') { - if (!empty($res)) { - $trailers = unserialize($res, 'ade'); - $ret .= ""; - $ret .= ""; - $ret .= ""; - - return $ret; - } - } - if ($whichclass === 'pop') { - if (!empty($res)) { - $trailers = unserialize($res, 'pop'); - $ret .= ""; - - return $ret; - } - } - - return $ret; - } } diff --git a/nntmux/processing/PostProcess.php b/nntmux/processing/PostProcess.php index 49e6a83f4..a682036c0 100755 --- a/nntmux/processing/PostProcess.php +++ b/nntmux/processing/PostProcess.php @@ -3,23 +3,28 @@ 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; @@ -299,7 +304,11 @@ class PostProcess public function processXXX() { if (Settings::value('..lookupxxx') == 1) { - (new XXX(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processXXXReleases(); + (new ADE(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processXXXReleases(); + (new ADM(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processXXXReleases(); + (new AEBN(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processXXXReleases(); + (new Popporn(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processXXXReleases(); + (new Hotmovies(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processXXXReleases(); } } diff --git a/nntmux/processing/adult/ADE.php b/nntmux/processing/adult/ADE.php index 6795776d6..721688b67 100755 --- a/nntmux/processing/adult/ADE.php +++ b/nntmux/processing/adult/ADE.php @@ -133,13 +133,13 @@ class ADE extends AdultMovies } /** - * Gets the sypnosis and tagline + * Gets the synopsis and tagline * * @param bool $tagline - Include tagline? true/false * * @return array - plot,tagline */ - public function sypnosis($tagline = false) + public function synopsis($tagline = false) { if ($tagline === true) { $ret = $this->_html->find('p.Tagline', 0); @@ -148,7 +148,7 @@ class ADE extends AdultMovies } } if ($ret = @$this->_html->find('p.Tagline', 0)->next_sibling()->next_sibling()) { - $this->_res['sypnosis'] = trim($ret->innertext); + $this->_res['synopsis'] = trim($ret->innertext); } return $this->_res; @@ -277,12 +277,12 @@ class ADE extends AdultMovies * Searches xxx name. * @return bool - True if releases has 90% match, else false */ - public function search() + public function search($movie) { - if (empty($this->searchTerm)) { + if (empty($movie)) { return false; } - $this->_response = getUrl($this->_dvdQuery . rawurlencode($this->searchTerm)); + $this->_response = getUrl($this->_dvdQuery . rawurlencode($movie)); if ($this->_response !== false) { $this->_html->load($this->_response); if ($ret = $this->_html->find('a.boxcover', 0)) { @@ -290,7 +290,7 @@ class ADE extends AdultMovies $title = str_replace('/XXX/', '', $title); $title = preg_replace('/\(.*?\)|[-._]/', ' ', $title); $ret = (string)trim($ret->href); - similar_text(strtolower($this->searchTerm), strtolower($title), $p); + similar_text(strtolower($movie), strtolower($title), $p); if ($p >= 90) { $this->found = true; $this->_urlFound = $ret; @@ -300,14 +300,12 @@ class ADE extends AdultMovies $this->_html->clear(); getUrl($this->_urlFound); $this->_html->load($this->_response); - } else { - $this->found = false; - - return false; + return true; } - } else { + $this->found = false; return false; } + return false; } return false; } @@ -317,15 +315,15 @@ class ADE extends AdultMovies * * @return array */ - public function getAll() + protected 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->synopsis(true))) { + $results = array_merge($results, $this->synopsis(true)); } if (is_array($this->productInfo(true))) { $results = array_merge($results, $this->productInfo(true)); diff --git a/nntmux/processing/adult/ADM.php b/nntmux/processing/adult/ADM.php index cdafe3fc8..199082be7 100755 --- a/nntmux/processing/adult/ADM.php +++ b/nntmux/processing/adult/ADM.php @@ -194,13 +194,16 @@ class ADM extends AdultMovies /** * Searches for match against searchterm + * + * @param $movie + * * @return bool - true if search = 100% */ - protected function search() + public function search function getAll($movie) { $result = false; - if (!empty($this->searchTerm)) { - $this->_trailUrl = self::TRAILINGSEARCH . urlencode($this->searchTerm); + if (!empty($movie)) { + $this->_trailUrl = self::TRAILINGSEARCH . urlencode($movie); $this->_response = getUrl(self::ADMURL . $this->_trailUrl); if ($this->_response !== false) { $this->_html->load($this->_response); @@ -211,7 +214,7 @@ class ADM extends AdultMovies $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 (preg_match('/\/(?\d+)\.jpg/i', $ret->src, $matches)) { diff --git a/nntmux/processing/adult/AEBN.php b/nntmux/processing/adult/AEBN.php index 9d435fbc8..aabaa26c3 100755 --- a/nntmux/processing/adult/AEBN.php +++ b/nntmux/processing/adult/AEBN.php @@ -38,6 +38,11 @@ class AEBN extends AdultMovies */ protected $_response; + /** + * @var string + */ + protected $_trailerUrl = ''; + /** * Returned results in all methods except search/geturl * @@ -206,30 +211,30 @@ class AEBN extends AdultMovies * * @return bool */ - protected function search() + public function search($movie) { - if (empty($this->searchTerm)) { + if (empty($movie)) { return false; } $this->_response = false; - $this->_trailerUrl = self::TRAILINGSEARCH . urlencode($this->searchTerm); - $this->_response = getUrl(self::IF18, false); + $this->_trailerUrl = self::TRAILINGSEARCH . urlencode($movie); + $this->_response = getUrl(self::IF18); if ($this->_response !== false) { $this->_html->load($this->_response); $count = count($this->_html->find('div.movie')); $i = 1; while ($count >= $i) { - foreach ($this->_html->find('div.movie') as $movie) { + foreach ($this->_html->find('div.movie') as $mov) { $string = 'a#FTSMovieSearch_link_title_detail_' . $i; - if ($ret = $movie->find($string, 0)) { + if ($ret = $mov->find($string, 0)) { $title = str_replace('/XXX/', '', $ret->title); $title = preg_replace('/\(.*?\)|[-._]/', ' ', $title); $title = trim($title); - similar_text(strtolower($this->searchTerm), strtolower($title), $p); + similar_text(strtolower($mov), 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->_directUrl = self::AEBNSURL . self::TRAILINGSEARCH . urlencode($movie); getUrl(self::AEBNSURL); return true; } @@ -250,7 +255,7 @@ class AEBN extends AdultMovies * * @return array|bool */ - public function getAll() + protected function getAll() { $results = []; if (!empty($this->_directUrl)) { diff --git a/nntmux/processing/adult/AdultMovies.php b/nntmux/processing/adult/AdultMovies.php index f09477bb4..1ceedc94c 100644 --- a/nntmux/processing/adult/AdultMovies.php +++ b/nntmux/processing/adult/AdultMovies.php @@ -3,12 +3,11 @@ namespace nntmux\processing\adult; -use nntmux\ColorCLI; use nntmux\XXX; abstract class AdultMovies extends XXX { - // Television Sources + // XXX Sources const SOURCE_NONE = 0; const SOURCE_ADE = 1; const SOURCE_ADM = 2; @@ -31,6 +30,8 @@ abstract class AdultMovies extends XXX * AdultMovies constructor. * * @param array $options + * + * @throws \Exception */ public function __construct(array $options = []) { @@ -65,7 +66,7 @@ abstract class AdultMovies extends XXX /** * @return mixed */ - abstract protected function search(); + abstract protected function search($movie); /** * @return mixed @@ -78,285 +79,64 @@ abstract class AdultMovies extends XXX abstract protected function trailers(); /** - * Fetch xxx info for the movie. + * Updates the release tv_episodes_id status when scraper match is not found * - * @param $xxxmovie - * - * @return bool + * @param $status + * @param $Id */ - public function updateXXXInfo($xxxmovie): bool + public function setXXXNotFound($status, $Id): void { - - $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; + $this->pdo->queryExec( + sprintf(' + UPDATE releases + SET xxxinfo_id = %d + WHERE %s + AND id = %d', + $status, + $this->catWhere, + $Id + ) + ); } /** - * Process XXX releases where xxxinfo is 0 + * Retrieve releases for XXX processing + * Returns a PDO Object of rows or false if none found * + * @param string $groupID -- ID of the usenet group to process + * @param string $guidChar -- threading method by first guid character + * @param int $lookupSetting -- whether or not to use the API + * @param int $status -- release processing status of tv_episodes_id + * + * @return false|int|\PDOStatement */ - public function processXXXReleases(): void + public function getXXXReleases($groupID = '', $guidChar = '', $lookupSetting = 1, $status = 0) { - $res = $this->pdo->query(sprintf(' - SELECT r.searchname, r.id + $ret = 0; + if ($lookupSetting === 0) { + return $ret; + } + + $res = $this->pdo->queryDirect( + sprintf(' + SELECT SQL_NO_CACHE r.searchname, r.id FROM releases r WHERE r.nzbstatus = 1 - AND r.xxxinfo_id = 0 - %s + AND r.xxxinfo_id = %d + AND r.size > 1048576 + AND %s + %s %s %s + ORDER BY r.postdate+0 DESC LIMIT %d', + $status, $this->catWhere, + ($groupID === '' ? '' : 'AND r.groups_id = ' . $groupID), + ($guidChar === '' ? '' : 'AND r.leftguid = ' . $this->pdo->escapeString($guidChar)), + ($lookupSetting === 2 ? 'AND r.isrenamed = 1' : ''), $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[\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; + return $res; } } \ No newline at end of file diff --git a/nntmux/processing/adult/Hotmovies.php b/nntmux/processing/adult/Hotmovies.php index 96144c040..e08471b66 100755 --- a/nntmux/processing/adult/Hotmovies.php +++ b/nntmux/processing/adult/Hotmovies.php @@ -19,7 +19,7 @@ class Hotmovies extends AdultMovies * * @var string */ - public $searchTerm = ''; + protected $searchTerm = ''; /** * Define a cookie location * @@ -96,10 +96,6 @@ class Hotmovies extends AdultMovies } } - /* - * Remove from memory if it still exists - */ - /** * Get Raw html of webpage * @@ -150,12 +146,19 @@ class Hotmovies extends AdultMovies unset($this->_response, $this->_res); } + protected function trailers() + { + // TODO: Implement trailers() method. + + return false; + } + /** * Directly gets the link if directlink is set, and parses it. * * @return bool|array */ - public function getDirect() + protected function getDirect() { if (!empty($this->directLink)) { if ($this->getUrl() === false) { @@ -171,15 +174,15 @@ class Hotmovies extends AdultMovies * 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()); @@ -202,16 +205,16 @@ class Hotmovies extends AdultMovies } /** - * Gets the sypnosis + * Gets the synopsis * * @return array */ - public function sypnosis() + protected function synopsis() { if ($this->_html->find('.desc_link', 0)) { preg_match('/var descfullcontent = (?.*)/', $this->_response,$matches); if (is_array($matches)) { - $this->_res['sypnosis'] = rawurldecode($matches['content']); + $this->_res['synopsis'] = rawurldecode($matches['content']); } } @@ -222,7 +225,7 @@ class Hotmovies extends AdultMovies * * @return array */ - public function productInfo() + protected function productInfo() { $studio = false; $director = false; @@ -275,7 +278,7 @@ class Hotmovies extends AdultMovies * *@return array */ - public function cast() + protected function cast() { $cast = null; if ($this->_html->find('a[itemprop=actor]')) { @@ -296,7 +299,7 @@ class Hotmovies extends AdultMovies * *@return array */ - public function genres() + protected function genres() { $genres = []; if ($ret = $this->_html->find('div.categories',0)) { @@ -317,7 +320,7 @@ class Hotmovies extends AdultMovies * 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); @@ -333,12 +336,12 @@ class Hotmovies extends AdultMovies * Searches for match against searchterm * @return bool, true if search >= 90% */ - public function search() + public function search ($movie) { - if (empty($this->searchTerm)) { + if (empty($movie)) { return false; } - $this->_getLink = self::HMURL . self::TRAILINGSEARCH . urlencode($this->searchTerm) . self::EXTRASEARCH; + $this->_getLink = self::HMURL . self::TRAILINGSEARCH . urlencode($movie) . self::EXTRASEARCH; if ($this->getUrl() === false) { return false; } else { @@ -355,7 +358,7 @@ class Hotmovies extends AdultMovies return false; } if (!empty($title)) { - similar_text($this->searchTerm, $title, $p); + similar_text($movie, $title, $p); if ($p >= 90) { $this->_title = $title; // 90$ match found, load the url to start parsing diff --git a/nntmux/processing/adult/Popporn.php b/nntmux/processing/adult/Popporn.php index d093edef0..eeabde823 100755 --- a/nntmux/processing/adult/Popporn.php +++ b/nntmux/processing/adult/Popporn.php @@ -280,11 +280,11 @@ class Popporn extends AdultMovies * Searches for match against searchterm * @return bool, true if search >= 90% */ - public function search() + public function search($movie) { $result = false; - if (isset($this->searchTerm)) { - $this->_trailUrl = self::TRAILINGSEARCH . urlencode($this->searchTerm); + if (isset($movie)) { + $this->_trailUrl = self::TRAILINGSEARCH . urlencode($movie); if ($this->getUrl() !== false) { if ($ret = $this->_html->find('div.product-info, div.title', 1)) { $this->_title = trim($ret->plaintext); @@ -297,7 +297,7 @@ class Popporn extends AdultMovies if ($ret = $this->_html->find('#link-to-this', 0)) { $this->_directUrl = trim($ret->href); } - similar_text(strtolower($this->searchTerm), strtolower($title), $p); + similar_text(strtolower($movie), strtolower($title), $p); if ($p >= 90) { $result = true; } @@ -314,7 +314,7 @@ class Popporn extends AdultMovies * Gets all information * @return array|bool */ - public function getAll() + protected function getAll() { $results = []; if (isset($this->_directUrl)) { diff --git a/nntmux/processing/tv/TV.php b/nntmux/processing/tv/TV.php index f07593c4a..9f648adc9 100755 --- a/nntmux/processing/tv/TV.php +++ b/nntmux/processing/tv/TV.php @@ -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 * From c1243fa80374e1fe9c5ed5cbf31873ec6e737b3d Mon Sep 17 00:00:00 2001 From: DariusIII Date: Sat, 10 Jun 2017 22:54:26 +0200 Subject: [PATCH 14/49] Use getUrl in all the classes --- nntmux/processing/PostProcess.php | 9 +++++---- nntmux/processing/adult/ADE.php | 2 +- nntmux/processing/adult/ADM.php | 4 ++-- nntmux/processing/adult/AEBN.php | 2 +- nntmux/processing/adult/AdultMovies.php | 4 +++- nntmux/processing/adult/Hotmovies.php | 18 ++++++++---------- nntmux/processing/adult/Popporn.php | 10 ++++------ 7 files changed, 24 insertions(+), 25 deletions(-) diff --git a/nntmux/processing/PostProcess.php b/nntmux/processing/PostProcess.php index a682036c0..e0b4cf485 100755 --- a/nntmux/processing/PostProcess.php +++ b/nntmux/processing/PostProcess.php @@ -259,12 +259,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 = '') { @@ -304,7 +305,7 @@ class PostProcess public function processXXX() { if (Settings::value('..lookupxxx') == 1) { - (new ADE(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processXXXReleases(); + (new ADE(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processSite(); (new ADM(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processXXXReleases(); (new AEBN(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processXXXReleases(); (new Popporn(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processXXXReleases(); diff --git a/nntmux/processing/adult/ADE.php b/nntmux/processing/adult/ADE.php index 721688b67..51857ade7 100755 --- a/nntmux/processing/adult/ADE.php +++ b/nntmux/processing/adult/ADE.php @@ -277,7 +277,7 @@ class ADE extends AdultMovies * Searches xxx name. * @return bool - True if releases has 90% match, else false */ - public function search($movie) + public function processSite($movie) { if (empty($movie)) { return false; diff --git a/nntmux/processing/adult/ADM.php b/nntmux/processing/adult/ADM.php index 199082be7..b72fa4fc7 100755 --- a/nntmux/processing/adult/ADM.php +++ b/nntmux/processing/adult/ADM.php @@ -199,7 +199,7 @@ class ADM extends AdultMovies * * @return bool - true if search = 100% */ - public function search function getAll($movie) + public function processSite($movie) { $result = false; if (!empty($movie)) { @@ -216,7 +216,7 @@ class ADM extends AdultMovies $comparetitle = preg_replace('/[\W]/', '', $title); $comparesearch = preg_replace('/[\W]/', '', $movie); similar_text($comparetitle, $comparesearch, $p); - if ($p === 100) { + if ($p >= 90) { if (preg_match('/\/(?\d+)\.jpg/i', $ret->src, $matches)) { $this->_title = trim($title); $this->_trailUrl = '/dvd_view_' . (string)$matches['sku'] . '.html'; diff --git a/nntmux/processing/adult/AEBN.php b/nntmux/processing/adult/AEBN.php index aabaa26c3..6145e7efb 100755 --- a/nntmux/processing/adult/AEBN.php +++ b/nntmux/processing/adult/AEBN.php @@ -211,7 +211,7 @@ class AEBN extends AdultMovies * * @return bool */ - public function search($movie) + public function processSite($movie) { if (empty($movie)) { return false; diff --git a/nntmux/processing/adult/AdultMovies.php b/nntmux/processing/adult/AdultMovies.php index 1ceedc94c..07210ae37 100644 --- a/nntmux/processing/adult/AdultMovies.php +++ b/nntmux/processing/adult/AdultMovies.php @@ -64,9 +64,11 @@ abstract class AdultMovies extends XXX abstract protected function genres(); /** + * @param string $movie + * * @return mixed */ - abstract protected function search($movie); + abstract protected function processSite($movie); /** * @return mixed diff --git a/nntmux/processing/adult/Hotmovies.php b/nntmux/processing/adult/Hotmovies.php index e08471b66..19efb5c5c 100755 --- a/nntmux/processing/adult/Hotmovies.php +++ b/nntmux/processing/adult/Hotmovies.php @@ -336,16 +336,18 @@ class Hotmovies extends AdultMovies * Searches for match against searchterm * @return bool, true if search >= 90% */ - public function search ($movie) + public function processSite($movie) { if (empty($movie)) { return false; } $this->_getLink = self::HMURL . self::TRAILINGSEARCH . urlencode($movie) . self::EXTRASEARCH; - if ($this->getUrl() === false) { + $this->_response = getUrl($this->_getLink); + if ($this->_response === false) { return false; - } else { - if ($ret = $this->_html->find('h3[class=title]', 0)) { + } + $this->_html->load($this->_response); + if ($ret = $this->_html->find('h3[class=title]', 0)) { if ($ret->find('a[title]',0)){ $ret = $ret->find('a[title]', 0); $title = trim($ret->title); @@ -361,17 +363,13 @@ class Hotmovies extends AdultMovies similar_text($movie, $title, $p); if ($p >= 90) { $this->_title = $title; - // 90$ match found, load the url to start parsing - $this->getUrl(); unset($ret); return true; - } else { - return false; } - } else { return false; + } + return false; } - } } diff --git a/nntmux/processing/adult/Popporn.php b/nntmux/processing/adult/Popporn.php index eeabde823..1b863f693 100755 --- a/nntmux/processing/adult/Popporn.php +++ b/nntmux/processing/adult/Popporn.php @@ -75,9 +75,6 @@ class Popporn extends AdultMovies { parent::__construct($options); $this->_html = new \simple_html_dom(); - if (isset($this->cookie)) { - $this->getUrl(); - } } /** @@ -280,12 +277,14 @@ class Popporn extends AdultMovies * Searches for match against searchterm * @return bool, true if search >= 90% */ - public function search($movie) + public function processSite($movie) { $result = false; if (isset($movie)) { $this->_trailUrl = self::TRAILINGSEARCH . urlencode($movie); - if ($this->getUrl() !== false) { + $this->_response = getUrl(self::POPURL . $this->_trailUrl); + 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); @@ -306,7 +305,6 @@ class Popporn extends AdultMovies } } } - return $result; } From 46d9ec3c98fcfc16e2a56aafbc4073505ce30d47 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Mon, 12 Jun 2017 00:25:26 +0200 Subject: [PATCH 15/49] Improve classes --- app/extensions/helper/helpers.php | 4 +- nntmux/XXX.php | 123 ++++++++++++------------ nntmux/processing/PostProcess.php | 9 +- nntmux/processing/adult/ADE.php | 14 +-- nntmux/processing/adult/ADM.php | 15 ++- nntmux/processing/adult/AEBN.php | 7 +- nntmux/processing/adult/AdultMovies.php | 63 +----------- nntmux/processing/adult/Hotmovies.php | 97 +++++-------------- nntmux/processing/adult/Popporn.php | 34 +++---- 9 files changed, 125 insertions(+), 241 deletions(-) diff --git a/app/extensions/helper/helpers.php b/app/extensions/helper/helpers.php index 245c963d4..def14928d 100644 --- a/app/extensions/helper/helpers.php +++ b/app/extensions/helper/helpers.php @@ -6,9 +6,9 @@ use GuzzleHttp\Cookie\SetCookie; use GuzzleHttp\Cookie\CookieJar; use nntmux\ColorCLI; -if (!function_exists('getUrl')) { +if (!function_exists('getRawHtml')) { - function getUrl($url, $cookie = false) + function getRawHtml($url, $cookie = false) { $response = false; $cookiejar = new CookieJar(); diff --git a/nntmux/XXX.php b/nntmux/XXX.php index 411b23d2f..a6ffceb77 100755 --- a/nntmux/XXX.php +++ b/nntmux/XXX.php @@ -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; /** @@ -552,79 +557,77 @@ class XXX * @param $movie * * @return bool + * @throws \Exception */ public function updateXXXInfo($movie): bool { - - $res = false; - $this->whichclass = ''; + $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); + } - $this->whichclass = 'aebn'; - $mov = new AEBN(); + if ($res === false) { + $this->whichclass = 'pop'; + $mov = new Popporn(); $mov->cookie = $this->cookie; - $res = $mov->search($movie); + ColorCLI::doEcho(ColorCLI::info('Checking PopPorn for movie info')); + $res = $mov->processSite($movie); + } - if ($res === false) { - $this->whichclass = 'ade'; - $mov = new ADE(); - $res = $mov->search($movie); - } + if ($res === false) { + $this->whichclass = 'hotmovies'; + $mov = new Hotmovies(); + $mov->cookie = $this->cookie; + ColorCLI::doEcho(ColorCLI::info('Checking HotMovies for movie info')); + $res = $mov->processSite($movie); + } - if ($res === false) { - $this->whichclass = 'pop'; - $mov = new Popporn(); - $mov->cookie = $this->cookie; - $res = $mov->search($movie); - } - - if ($res === false) { - $this->whichclass = 'hotmovies'; - $mov = new Hotmovies(); - $mov->cookie = $this->cookie; - $res = $mov->search($movie); - } - - // Last in list as it doesn't have trailers - if ($res === false) { - $this->whichclass = 'adm'; - $mov = new ADM(); - $mov->cookie = $this->cookie; - $res = $mov->search($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 !== false) { - if ($this->echooutput) { + // 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 'hotmovies': - $fromstr = 'HotMovies'; - break; - default: - $fromstr = null; - } - ColorCLI::doEcho(ColorCLI::primary('Fetching XXX info from: ' . $fromstr)); + 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 'hotmovies': + $fromstr = 'HotMovies'; + break; + default: + $fromstr = null; } - $res = $mov->getAll(); - } else { - // Nothing was found, go ahead and set to -2 - return -2; + 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']) : ''; @@ -652,7 +655,7 @@ class XXX $xxxID = $check['id']; } - // Update Current XXX Information - getXXXCovers.php + // Update Current XXX Information 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']; diff --git a/nntmux/processing/PostProcess.php b/nntmux/processing/PostProcess.php index e0b4cf485..f1199bb20 100755 --- a/nntmux/processing/PostProcess.php +++ b/nntmux/processing/PostProcess.php @@ -30,6 +30,7 @@ use nntmux\db\DB; use nntmux\processing\post\AniDB; use nntmux\processing\post\ProcessAdditional; use nntmux\SpotNab; +use nntmux\XXX; class PostProcess { @@ -301,15 +302,13 @@ class PostProcess /** * Lookup xxx if enabled. + * + * @throws \Exception */ public function processXXX() { if (Settings::value('..lookupxxx') == 1) { - (new ADE(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processSite(); - (new ADM(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processXXXReleases(); - (new AEBN(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processXXXReleases(); - (new Popporn(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processXXXReleases(); - (new Hotmovies(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processXXXReleases(); + (new XXX(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processXXXReleases(); } } diff --git a/nntmux/processing/adult/ADE.php b/nntmux/processing/adult/ADE.php index 51857ade7..767605183 100755 --- a/nntmux/processing/adult/ADE.php +++ b/nntmux/processing/adult/ADE.php @@ -1,9 +1,5 @@ getUrl($this->_trailers . $this->_urlFound); + $this->_response = getRawHtml($this->_trailers . $this->_urlFound); $this->_html->load($this->_response); if (preg_match("/(\"|')(?P[^\"']+.swf)(\"|')/i", $this->_response, $matches)) { $this->_res['trailers']['url'] = self::ADE . trim(trim($matches['swf']), '"'); @@ -267,7 +263,7 @@ class ADE extends AdultMovies */ public function getDirect() { - if (!empty($this->directLink) && $this->getUrl() !== false) { + if (!empty($this->directLink) && $this->getRawHtml() !== false) { $this->_html->load($this->_response); return $this->getAll(); } @@ -282,7 +278,7 @@ class ADE extends AdultMovies if (empty($movie)) { return false; } - $this->_response = getUrl($this->_dvdQuery . rawurlencode($movie)); + $this->_response = getRawHtml($this->_dvdQuery . rawurlencode($movie)); if ($this->_response !== false) { $this->_html->load($this->_response); if ($ret = $this->_html->find('a.boxcover', 0)) { @@ -298,7 +294,7 @@ class ADE extends AdultMovies $this->_title = trim($title); unset($ret); $this->_html->clear(); - getUrl($this->_urlFound); + $this->_response = getRawHtml($this->_urlFound); $this->_html->load($this->_response); return true; } diff --git a/nntmux/processing/adult/ADM.php b/nntmux/processing/adult/ADM.php index b72fa4fc7..c4a9f8ee0 100755 --- a/nntmux/processing/adult/ADM.php +++ b/nntmux/processing/adult/ADM.php @@ -1,8 +1,7 @@ _trailUrl = self::TRAILINGSEARCH . urlencode($movie); - $this->_response = getUrl(self::ADMURL . $this->_trailUrl); + $this->_response = getRawHtml(self::ADMURL . $this->_trailUrl); if ($this->_response !== false) { $this->_html->load($this->_response); if ($ret = $this->_html->find('img[rel=license]')) { @@ -221,16 +220,15 @@ class ADM extends AdultMovies $this->_title = trim($title); $this->_trailUrl = '/dvd_view_' . (string)$matches['sku'] . '.html'; $this->_directUrl = self::ADMURL . $this->_trailUrl; + $result = true; } } } } } } - $result = true; } } - return $result; } @@ -269,4 +267,11 @@ class ADM extends AdultMovies $results = empty($results) ? false : $results; return $results; } + + protected function trailers() + { + // TODO: Implement trailers() method. + + return false; + } } diff --git a/nntmux/processing/adult/AEBN.php b/nntmux/processing/adult/AEBN.php index 6145e7efb..1bef030cc 100755 --- a/nntmux/processing/adult/AEBN.php +++ b/nntmux/processing/adult/AEBN.php @@ -1,7 +1,5 @@ _response = false; $this->_trailerUrl = self::TRAILINGSEARCH . urlencode($movie); - $this->_response = getUrl(self::IF18); + $this->_response = getRawHtml(self::AEBNSURL); if ($this->_response !== false) { $this->_html->load($this->_response); $count = count($this->_html->find('div.movie')); @@ -235,7 +233,6 @@ class AEBN extends AdultMovies $this->_title = trim($ret->title); $this->_trailerUrl = html_entity_decode($ret->href); $this->_directUrl = self::AEBNSURL . self::TRAILINGSEARCH . urlencode($movie); - getUrl(self::AEBNSURL); return true; } continue; diff --git a/nntmux/processing/adult/AdultMovies.php b/nntmux/processing/adult/AdultMovies.php index 07210ae37..c0e5d63c5 100644 --- a/nntmux/processing/adult/AdultMovies.php +++ b/nntmux/processing/adult/AdultMovies.php @@ -2,30 +2,10 @@ namespace nntmux\processing\adult; - use nntmux\XXX; abstract class AdultMovies extends XXX { - // XXX Sources - const SOURCE_NONE = 0; - const SOURCE_ADE = 1; - const SOURCE_ADM = 2; - const SOURCE_AEBN = 3; - const SOURCE_HOTMOVIES = 4; - const SOURCE_IAFD = 5; - const SOURCE_POPPORN = 6; - - // Processing signifiers - const PROCESS_ADE = 0; - const PROCESS_ADM = -1; - const PROCESS_AEBN = -2; - const PROCESS_HOTMOVIES = -3; - const PROCESS_IAFD = -4; - const PROCESS_POPPORN = -5; - const NO_MATCH_FOUND = -6; - const FAILED_PARSE = -100; - /** * AdultMovies constructor. * @@ -81,7 +61,7 @@ abstract class AdultMovies extends XXX abstract protected function trailers(); /** - * Updates the release tv_episodes_id status when scraper match is not found + * Updates the release xxxinfo_id status when scraper match is not found * * @param $status * @param $Id @@ -100,45 +80,4 @@ abstract class AdultMovies extends XXX ) ); } - - /** - * Retrieve releases for XXX processing - * Returns a PDO Object of rows or false if none found - * - * @param string $groupID -- ID of the usenet group to process - * @param string $guidChar -- threading method by first guid character - * @param int $lookupSetting -- whether or not to use the API - * @param int $status -- release processing status of tv_episodes_id - * - * @return false|int|\PDOStatement - */ - public function getXXXReleases($groupID = '', $guidChar = '', $lookupSetting = 1, $status = 0) - { - $ret = 0; - if ($lookupSetting === 0) { - return $ret; - } - - $res = $this->pdo->queryDirect( - sprintf(' - SELECT SQL_NO_CACHE r.searchname, r.id - FROM releases r - WHERE r.nzbstatus = 1 - AND r.xxxinfo_id = %d - AND r.size > 1048576 - AND %s - %s %s %s - ORDER BY r.postdate+0 DESC - LIMIT %d', - $status, - $this->catWhere, - ($groupID === '' ? '' : 'AND r.groups_id = ' . $groupID), - ($guidChar === '' ? '' : 'AND r.leftguid = ' . $this->pdo->escapeString($guidChar)), - ($lookupSetting === 2 ? 'AND r.isrenamed = 1' : ''), - $this->movieqty - ) - ); - return $res; - } - } \ No newline at end of file diff --git a/nntmux/processing/adult/Hotmovies.php b/nntmux/processing/adult/Hotmovies.php index 19efb5c5c..1143c9e0c 100755 --- a/nntmux/processing/adult/Hotmovies.php +++ b/nntmux/processing/adult/Hotmovies.php @@ -1,7 +1,5 @@ _html = new \simple_html_dom(); - - // Set a cookie to override +18 warning. - if (!empty($this->cookie)) { - @$this->getUrl(); - } - } - - /** - * Get Raw html of webpage - * - * @param bool $usepost - * - * @return bool - */ - private function getUrl($usepost = false) - { - 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); - - return false; - } - $this->_html->load($this->_response); - curl_close($ch); - return true; - } - - public function __destruct() - { - $this->_html->clear(); - unset($this->_response, $this->_res); } protected function trailers() @@ -161,11 +106,10 @@ class Hotmovies extends AdultMovies protected function getDirect() { if (!empty($this->directLink)) { - if ($this->getUrl() === false) { + if (getRawHtml($this->_directUrl) === false) { return false; - } else { - return $this->getAll(); } + return $this->getAll(); } return false; } @@ -180,6 +124,8 @@ class Hotmovies extends AdultMovies if (!empty($this->_directUrl)) { $results['title'] = $this->_title; $results['directurl'] = $this->_directUrl; + $this->_response = getRawHtml($this->_directUrl); + $this->_html->load($this->_response); } if (is_array($this->synopsis())) { $results = array_merge($results, $this->synopsis()); @@ -197,11 +143,11 @@ class Hotmovies extends AdultMovies $results = array_merge($results, $this->covers()); } - if (empty($results) === true){ + if (empty($results)){ return false; - }else{ - return $results; } + return $results; + } /** @@ -212,9 +158,10 @@ class Hotmovies extends AdultMovies protected function synopsis() { if ($this->_html->find('.desc_link', 0)) { - preg_match('/var descfullcontent = (?.*)/', $this->_response,$matches); - if (is_array($matches)) { - $this->_res['synopsis'] = rawurldecode($matches['content']); + foreach ($this->_html->find('[itemprop=description]') as $heading) { + if (trim($heading->plaintext) === 'description') { + $this->_res['synopsis'] = trim($heading->next_sibling()->plaintext); + } } } @@ -269,7 +216,6 @@ class Hotmovies extends AdultMovies if (is_array($this->_res['productinfo'])) { $this->_res['productinfo'] = array_chunk($this->_res['productinfo'], 2, false); } - return $this->_res; } @@ -342,7 +288,7 @@ class Hotmovies extends AdultMovies return false; } $this->_getLink = self::HMURL . self::TRAILINGSEARCH . urlencode($movie) . self::EXTRASEARCH; - $this->_response = getUrl($this->_getLink); + $this->_response = getRawHtml($this->_getLink); if ($this->_response === false) { return false; } @@ -363,12 +309,17 @@ class Hotmovies extends AdultMovies similar_text($movie, $title, $p); if ($p >= 90) { $this->_title = $title; - unset($ret); - + if (!empty($this->_getLink)) { + $this->_response = getRawHtml($this->_getLink); + } else { + $this->_response = getRawHtml(self::HMURL); + } + if (!empty($this->directLink)) { + $this->_response = getRawHtml($this->directLink); + $this->directLink = ''; + } return true; } - return false; - } return false; } diff --git a/nntmux/processing/adult/Popporn.php b/nntmux/processing/adult/Popporn.php index 1b863f693..eca053193 100755 --- a/nntmux/processing/adult/Popporn.php +++ b/nntmux/processing/adult/Popporn.php @@ -1,7 +1,6 @@ value = str_replace("..", "", $ret->value); $tmprsp = $this->_response; $this->_trailUrl = $ret->value; - $this->getUrl(); + $this->getRawHtml(); if (preg_match_all('/productID="\+(?[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->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"; @@ -282,7 +276,7 @@ class Popporn extends AdultMovies $result = false; if (isset($movie)) { $this->_trailUrl = self::TRAILINGSEARCH . urlencode($movie); - $this->_response = getUrl(self::POPURL . $this->_trailUrl); + $this->_response = getRawHtml(self::POPURL . $this->_trailUrl); if ($this->_response !== false) { $this->_html->load($this->_response); if ($ret = $this->_html->find('div.product-info, div.title', 1)) { @@ -292,7 +286,7 @@ class Popporn extends AdultMovies $title = trim($title); if ($ret = $ret->find('a', 0)) { $this->_trailUrl = trim($ret->href); - if ($this->getUrl() !== false) { + if ($this->getRawHtml() !== false) { if ($ret = $this->_html->find('#link-to-this', 0)) { $this->_directUrl = trim($ret->href); } @@ -350,7 +344,7 @@ class Popporn extends AdultMovies * * @return bool */ - private function getUrl($usepost = false) + private function getRawHtml($usepost = false) { if (isset($this->_trailUrl)) { $ch = curl_init(self::POPURL . $this->_trailUrl); From efc1c0193d3bcc5a70484320fc25fb7dc6a11f3b Mon Sep 17 00:00:00 2001 From: DariusIII Date: Mon, 12 Jun 2017 15:55:01 +0200 Subject: [PATCH 16/49] Further adjust xxx parsing --- misc/update/postprocess.php | 18 ++--- nntmux/XXX.php | 18 ++--- nntmux/processing/adult/AEBN.php | 6 -- nntmux/processing/adult/AdultMovies.php | 29 +++----- nntmux/processing/adult/Hotmovies.php | 93 +++++++++++++------------ 5 files changed, 76 insertions(+), 88 deletions(-) diff --git a/misc/update/postprocess.php b/misc/update/postprocess.php index 3ff461ecb..bd15c9b58 100644 --- a/misc/update/postprocess.php +++ b/misc/update/postprocess.php @@ -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(); diff --git a/nntmux/XXX.php b/nntmux/XXX.php index a6ffceb77..9c79e4b39 100755 --- a/nntmux/XXX.php +++ b/nntmux/XXX.php @@ -4,6 +4,7 @@ namespace nntmux; use app\models\Settings; use nntmux\db\DB; +use nntmux\processing\adult\AdultMovies; use nntmux\processing\adult\AEBN; use nntmux\processing\adult\ADM; use nntmux\processing\adult\ADE; @@ -626,8 +627,8 @@ class XXX } $res = $mov->getAll(); } else { - // Nothing was found, go ahead and set to -2 - return -2; + // Nothing was found, go ahead and set to -6 + return AdultMovies::NO_MATCH_FOUND; } $res['cast'] = !empty($res['cast']) ? implode(',', $res['cast']) : ''; @@ -636,7 +637,7 @@ class XXX $mov = [ 'trailers' => !empty($res['trailers']) ? serialize($res['trailers']) : '', 'extras' => !empty($res['extras']) ? serialize($res['extras']) : '', - 'productinfo' => !empty($res['productinfo']) ? serialize($res['productinfo']) : '', + 'productinfo' => !empty($res['productinfo']) ? serialize($res['productinfo'][0]) : '', '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') : '', @@ -648,6 +649,7 @@ class XXX 'directurl' => !empty($res['directurl']) ? html_entity_decode($res['directurl'], ENT_QUOTES, 'UTF-8') : '', 'classused' => $this->whichclass ]; + print_r($mov); $check = $this->pdo->queryOneRow(sprintf('SELECT id FROM xxxinfo WHERE title = %s', $this->pdo->escapeString($mov['title']))); $xxxID = 0; @@ -673,14 +675,14 @@ class XXX $this->pdo->queryExec(sprintf('UPDATE xxxinfo SET cover = %d, backdrop = %d WHERE id = %d', $mov['cover'], $mov['backdrop'], $xxxID)); } else { - $xxxID = -2; + $xxxID = AdultMovies::NO_MATCH_FOUND; } // Insert New XXX Information if ($check === false) { $xxxID = $this->pdo->queryInsert( sprintf(' - INSERT INTO xxxinfo + INSERT IGNORE 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())', @@ -711,6 +713,7 @@ class XXX /** * Process XXX releases where xxxinfo is 0 * + * @throws \Exception */ public function processXXXReleases(): void { @@ -736,7 +739,7 @@ class XXX // Loop over releases. foreach ($res as $arr) { - $idcheck = -2; + $idcheck = AdultMovies::NO_MATCH_FOUND; // Try to get a name. if ($this->parseXXXSearchName($arr['searchname']) !== false) { @@ -756,7 +759,7 @@ class XXX $idcheck = (int)$check['id']; } } else { - ColorCLI::doEcho('.', true); + ColorCLI::doEcho('.'); } $this->pdo->queryExec(sprintf('UPDATE releases SET xxxinfo_id = %d WHERE id = %d %s', $idcheck, $arr['id'], $this->catWhere)); } @@ -813,7 +816,6 @@ class XXX return true; } - ColorCLI::doEcho('.', false); } return false; diff --git a/nntmux/processing/adult/AEBN.php b/nntmux/processing/adult/AEBN.php index 1bef030cc..4d4a86b12 100755 --- a/nntmux/processing/adult/AEBN.php +++ b/nntmux/processing/adult/AEBN.php @@ -57,12 +57,6 @@ class AEBN extends AdultMovies 'trailers' => ['url' =>[]], ]; - /** - * If searchTerm is found - * @var bool - */ - protected $_searchFound = false; - /** * Sets title in getAll method * @var string diff --git a/nntmux/processing/adult/AdultMovies.php b/nntmux/processing/adult/AdultMovies.php index c0e5d63c5..3644db42f 100644 --- a/nntmux/processing/adult/AdultMovies.php +++ b/nntmux/processing/adult/AdultMovies.php @@ -6,6 +6,14 @@ 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. * @@ -59,25 +67,4 @@ abstract class AdultMovies extends XXX * @return mixed */ abstract protected function trailers(); - - /** - * Updates the release xxxinfo_id status when scraper match is not found - * - * @param $status - * @param $Id - */ - public function setXXXNotFound($status, $Id): void - { - $this->pdo->queryExec( - sprintf(' - UPDATE releases - SET xxxinfo_id = %d - WHERE %s - AND id = %d', - $status, - $this->catWhere, - $Id - ) - ); - } } \ No newline at end of file diff --git a/nntmux/processing/adult/Hotmovies.php b/nntmux/processing/adult/Hotmovies.php index 1143c9e0c..5df9a7bc8 100755 --- a/nntmux/processing/adult/Hotmovies.php +++ b/nntmux/processing/adult/Hotmovies.php @@ -1,4 +1,5 @@ _directUrl) === false) { return false; } + return $this->getAll(); } + return false; } @@ -143,9 +146,10 @@ class Hotmovies extends AdultMovies $results = array_merge($results, $this->covers()); } - if (empty($results)){ + if (empty($results)) { return false; } + return $results; } @@ -155,10 +159,10 @@ class Hotmovies extends AdultMovies * * @return array */ - protected function synopsis() + protected function synopsis(): array { if ($this->_html->find('.desc_link', 0)) { - foreach ($this->_html->find('[itemprop=description]') as $heading) { + foreach ($this->_html->find('div[itemprop=description]') as $heading) { if (trim($heading->plaintext) === 'description') { $this->_res['synopsis'] = trim($heading->next_sibling()->plaintext); } @@ -172,18 +176,14 @@ class Hotmovies extends AdultMovies * * @return array */ - protected 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; @@ -216,21 +216,22 @@ class Hotmovies extends AdultMovies if (is_array($this->_res['productinfo'])) { $this->_res['productinfo'] = array_chunk($this->_res['productinfo'], 2, false); } + return $this->_res; } /** * Gets the cast members and director * - *@return array + * @return array */ protected function cast() { $cast = null; - if ($this->_html->find('a[itemprop=actor]')) { - foreach ($this->_html->find('a[itemprop=actor]') as $e) { + if ($this->_html->find('a[itemprop=actors]')) { + foreach ($this->_html->find('a[itemprop=actors]') as $e) { $e = trim($e->title); - $e = preg_replace('/\((.*)\)/','',$e); + $e = preg_replace('/\((.*)\)/', '', $e); $cast[] = trim($e); } $this->_res['cast'] = $cast; @@ -243,15 +244,15 @@ class Hotmovies extends AdultMovies /** * Gets categories * - *@return array + * @return array */ protected function genres() { $genres = []; - if ($ret = $this->_html->find('div.categories',0)) { + if ($ret = $this->_html->find('div.categories', 0)) { foreach ($ret->find('a') as $e) { if (strpos($e->title, '->') !== false) { - $e = explode('->',$e->plaintext); + $e = explode('->', $e->plaintext); $genres[] = trim($e[1]); } } @@ -271,7 +272,7 @@ class Hotmovies extends AdultMovies 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; } @@ -279,22 +280,24 @@ class Hotmovies extends AdultMovies } /** - * 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 processSite($movie) + public function processSite($movie): bool { if (empty($movie)) { return false; } + $this->_response = false; $this->_getLink = self::HMURL . self::TRAILINGSEARCH . urlencode($movie) . self::EXTRASEARCH; $this->_response = getRawHtml($this->_getLink); - if ($this->_response === false) { - return false; - } - $this->_html->load($this->_response); - if ($ret = $this->_html->find('h3[class=title]', 0)) { - if ($ret->find('a[title]',0)){ + if ($this->_response !== false) { + $this->_html->load($this->_response); + if ($ret = $this->_html->find('h3[class=title]', 0)) { + if ($ret->find('a[title]', 0)) { $ret = $ret->find('a[title]', 0); $title = trim($ret->title); $title = str_replace('/XXX/', '', $title); @@ -302,25 +305,27 @@ class Hotmovies extends AdultMovies $this->_getLink = trim($ret->href); $this->_directUrl = trim($ret->href); } - } else { - return false; - } - if (!empty($title)) { - similar_text($movie, $title, $p); - if ($p >= 90) { - $this->_title = $title; - if (!empty($this->_getLink)) { - $this->_response = getRawHtml($this->_getLink); - } else { - $this->_response = getRawHtml(self::HMURL); - } - if (!empty($this->directLink)) { - $this->_response = getRawHtml($this->directLink); - $this->directLink = ''; - } - return true; - } } + } else { return false; } + if (!empty($title)) { + similar_text($movie, $title, $p); + if ($p >= 90) { + $this->_title = $title; + if (!empty($this->_getLink)) { + $this->_response = getRawHtml($this->_getLink); + } else { + $this->_response = getRawHtml(self::HMURL); + } + if (!empty($this->directLink)) { + $this->_response = getRawHtml($this->directLink); + $this->directLink = ''; + } + return true; + } + } + + return false; + } } From ee17a91fc7903a2e5c2b41870fee69b9f0c17f8c Mon Sep 17 00:00:00 2001 From: DariusIII Date: Tue, 13 Jun 2017 00:28:12 +0200 Subject: [PATCH 17/49] Fix ADM lookups --- composer.json | 3 +- composer.lock | 51 ++++++++++++++++++++++++++- nntmux/XXX.php | 2 +- nntmux/processing/adult/ADE.php | 28 +++++---------- nntmux/processing/adult/ADM.php | 2 ++ nntmux/processing/adult/AEBN.php | 9 ++--- nntmux/processing/adult/Hotmovies.php | 32 +++++++---------- nntmux/processing/adult/Popporn.php | 15 ++++---- 8 files changed, 89 insertions(+), 53 deletions(-) diff --git a/composer.json b/composer.json index 4d93f8681..f628c3816 100755 --- a/composer.json +++ b/composer.json @@ -144,7 +144,8 @@ "monolog/monolog": "^1.22", "aharen/omdbapi": "^2.0", "vlucas/phpdotenv": "^2.4", - "laravel/framework": "^5.4" + "laravel/framework": "^5.4", + "fabpot/goutte": "^3.2" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 2a26d4ff4..e1979ccfa 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "f2aa144131a6fb8b3d72a01fc6bed139", + "content-hash": "c400d847c0aca8f687814725c5590f42", "packages": [ { "name": "adrenth/thetvdb2", @@ -2081,6 +2081,55 @@ ], "time": "2017-02-24T10:12:27+00:00" }, + { + "name": "fabpot/goutte", + "version": "v3.2.1", + "source": { + "type": "git", + "url": "https://github.com/FriendsOfPHP/Goutte.git", + "reference": "db5c28f4a010b4161d507d5304e28a7ebf211638" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/FriendsOfPHP/Goutte/zipball/db5c28f4a010b4161d507d5304e28a7ebf211638", + "reference": "db5c28f4a010b4161d507d5304e28a7ebf211638", + "shasum": "" + }, + "require": { + "guzzlehttp/guzzle": "^6.0", + "php": ">=5.5.0", + "symfony/browser-kit": "~2.1|~3.0", + "symfony/css-selector": "~2.1|~3.0", + "symfony/dom-crawler": "~2.1|~3.0" + }, + "type": "application", + "extra": { + "branch-alias": { + "dev-master": "3.2-dev" + } + }, + "autoload": { + "psr-4": { + "Goutte\\": "Goutte" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "A simple PHP Web Scraper", + "homepage": "https://github.com/FriendsOfPHP/Goutte", + "keywords": [ + "scraper" + ], + "time": "2017-01-03T13:21:43+00:00" + }, { "name": "fxp/composer-asset-plugin", "version": "v1.3.1", diff --git a/nntmux/XXX.php b/nntmux/XXX.php index 9c79e4b39..914bd546f 100755 --- a/nntmux/XXX.php +++ b/nntmux/XXX.php @@ -637,7 +637,7 @@ class XXX $mov = [ 'trailers' => !empty($res['trailers']) ? serialize($res['trailers']) : '', 'extras' => !empty($res['extras']) ? serialize($res['extras']) : '', - 'productinfo' => !empty($res['productinfo']) ? serialize($res['productinfo'][0]) : '', + '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') : '', diff --git a/nntmux/processing/adult/ADE.php b/nntmux/processing/adult/ADE.php index 767605183..853aef50b 100755 --- a/nntmux/processing/adult/ADE.php +++ b/nntmux/processing/adult/ADE.php @@ -91,7 +91,7 @@ class ADE extends AdultMovies */ public function trailers() { - $this->_response = getRawHtml($this->_trailers . $this->_urlFound); + $this->_response = getRawHtml($this->_trailers . $this->_directUrl); $this->_html->load($this->_response); if (preg_match("/(\"|')(?P[^\"']+.swf)(\"|')/i", $this->_response, $matches)) { $this->_res['trailers']['url'] = self::ADE . trim(trim($matches['swf']), '"'); @@ -129,21 +129,13 @@ class ADE extends AdultMovies } /** - * Gets the synopsis and tagline + * Gets the synopsis * - * @param bool $tagline - Include tagline? true/false - * - * @return array - plot,tagline + * @return array - plot */ - public function synopsis($tagline = false) + public function synopsis() { - 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()) { + if ($ret = $this->_html->find('meta[name="og:description"]', 0)->content()) { $this->_res['synopsis'] = trim($ret->innertext); } @@ -273,7 +265,7 @@ class ADE extends AdultMovies * Searches xxx name. * @return bool - True if releases has 90% match, else false */ - public function processSite($movie) + public function processSite($movie): bool { if (empty($movie)) { return false; @@ -281,24 +273,20 @@ class ADE extends AdultMovies $this->_response = getRawHtml($this->_dvdQuery . rawurlencode($movie)); if ($this->_response !== false) { $this->_html->load($this->_response); - if ($ret = $this->_html->find('a.boxcover', 0)) { + if ($ret = $this->_html->find('div[id=boxcover]', 0)) { $title = $ret->title; $title = str_replace('/XXX/', '', $title); $title = preg_replace('/\(.*?\)|[-._]/', ' ', $title); $ret = (string)trim($ret->href); similar_text(strtolower($movie), 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->_response = getRawHtml($this->_urlFound); + $this->_response = getRawHtml($this->_directUrl); $this->_html->load($this->_response); return true; } - $this->found = false; return false; } return false; diff --git a/nntmux/processing/adult/ADM.php b/nntmux/processing/adult/ADM.php index c4a9f8ee0..8d262af53 100755 --- a/nntmux/processing/adult/ADM.php +++ b/nntmux/processing/adult/ADM.php @@ -220,6 +220,8 @@ class ADM extends AdultMovies $this->_title = trim($title); $this->_trailUrl = '/dvd_view_' . (string)$matches['sku'] . '.html'; $this->_directUrl = self::ADMURL . $this->_trailUrl; + $this->_response = getRawHtml($this->_directUrl); + $this->_html->load($this->_response); $result = true; } } diff --git a/nntmux/processing/adult/AEBN.php b/nntmux/processing/adult/AEBN.php index 4d4a86b12..1d3617ad1 100755 --- a/nntmux/processing/adult/AEBN.php +++ b/nntmux/processing/adult/AEBN.php @@ -130,7 +130,7 @@ class AEBN extends AdultMovies * * @return array */ - protected function cast() + protected function cast(): array { if ($ret = $this->_html->find('div.starsFull', 0)) { foreach ($ret->find('span[itemprop=name]') as $star) { @@ -203,14 +203,13 @@ class AEBN extends AdultMovies * * @return bool */ - public function processSite($movie) + public function processSite($movie): bool { if (empty($movie)) { return false; } - $this->_response = false; $this->_trailerUrl = self::TRAILINGSEARCH . urlencode($movie); - $this->_response = getRawHtml(self::AEBNSURL); + $this->_response = getRawHtml(self::AEBNSURL . $this->_trailerUrl); if ($this->_response !== false) { $this->_html->load($this->_response); $count = count($this->_html->find('div.movie')); @@ -227,6 +226,8 @@ class AEBN extends AdultMovies $this->_title = trim($ret->title); $this->_trailerUrl = html_entity_decode($ret->href); $this->_directUrl = self::AEBNSURL . self::TRAILINGSEARCH . urlencode($movie); + $this->_response = getRawHtml($this->_directUrl); + $this->_html->load($this->_response); return true; } continue; diff --git a/nntmux/processing/adult/Hotmovies.php b/nntmux/processing/adult/Hotmovies.php index 5df9a7bc8..62bbb373e 100755 --- a/nntmux/processing/adult/Hotmovies.php +++ b/nntmux/processing/adult/Hotmovies.php @@ -127,8 +127,6 @@ class Hotmovies extends AdultMovies if (!empty($this->_directUrl)) { $results['title'] = $this->_title; $results['directurl'] = $this->_directUrl; - $this->_response = getRawHtml($this->_directUrl); - $this->_html->load($this->_response); } if (is_array($this->synopsis())) { $results = array_merge($results, $this->synopsis()); @@ -302,29 +300,23 @@ class Hotmovies extends AdultMovies $title = trim($ret->title); $title = str_replace('/XXX/', '', $title); $title = preg_replace('/\(.*?\)|[-._]/', ' ', $title); - $this->_getLink = trim($ret->href); - $this->_directUrl = trim($ret->href); + 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->_response = getRawHtml($this->_directUrl); + $this->_html->load($this->_response); + return true; + } + } } } } else { return false; } - if (!empty($title)) { - similar_text($movie, $title, $p); - if ($p >= 90) { - $this->_title = $title; - if (!empty($this->_getLink)) { - $this->_response = getRawHtml($this->_getLink); - } else { - $this->_response = getRawHtml(self::HMURL); - } - if (!empty($this->directLink)) { - $this->_response = getRawHtml($this->directLink); - $this->directLink = ''; - } - return true; - } - } + return false; } diff --git a/nntmux/processing/adult/Popporn.php b/nntmux/processing/adult/Popporn.php index eca053193..592841ca6 100755 --- a/nntmux/processing/adult/Popporn.php +++ b/nntmux/processing/adult/Popporn.php @@ -271,10 +271,9 @@ class Popporn extends AdultMovies * Searches for match against searchterm * @return bool, true if search >= 90% */ - public function processSite($movie) + public function processSite($movie): bool { - $result = false; - if (isset($movie)) { + if (!empty($movie)) { $this->_trailUrl = self::TRAILINGSEARCH . urlencode($movie); $this->_response = getRawHtml(self::POPURL . $this->_trailUrl); if ($this->_response !== false) { @@ -286,20 +285,24 @@ class Popporn extends AdultMovies $title = trim($title); if ($ret = $ret->find('a', 0)) { $this->_trailUrl = trim($ret->href); - if ($this->getRawHtml() !== false) { + $this->_response = getRawHtml($this->_trailUrl); + if ($this->_response !== false) { + $this->_html->load($this->_response); if ($ret = $this->_html->find('#link-to-this', 0)) { $this->_directUrl = trim($ret->href); + $this->_response = getRawHtml($this->_directUrl); + $this->_html->load($this->_response); } similar_text(strtolower($movie), strtolower($title), $p); if ($p >= 90) { - $result = true; + return true; } } } } } } - return $result; + return false; } /** From cd42d8ba53a2f46bb6140b1e1e04ff6936377926 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Tue, 13 Jun 2017 16:04:06 +0200 Subject: [PATCH 18/49] Fix ADM and Hotmovies movies parsing --- app/extensions/helper/helpers.php | 2 +- nntmux/XXX.php | 3 +- nntmux/processing/adult/ADM.php | 8 +- nntmux/processing/adult/AEBN.php | 8 +- nntmux/processing/adult/Hotmovies.php | 64 +++++++--------- nntmux/processing/adult/Popporn.php | 105 ++++++++++---------------- 6 files changed, 79 insertions(+), 111 deletions(-) diff --git a/app/extensions/helper/helpers.php b/app/extensions/helper/helpers.php index def14928d..8a6141aab 100644 --- a/app/extensions/helper/helpers.php +++ b/app/extensions/helper/helpers.php @@ -14,7 +14,7 @@ if (!function_exists('getRawHtml')) { $cookiejar = new CookieJar(); $client = new Client(); if ($cookie !== false) { - $cookieJar = $cookiejar->setCookie(SetCookie::fromString($this->cookie)); + $cookieJar = $cookiejar->setCookie(SetCookie::fromString($cookie)); $client = new Client(['cookies' => $cookieJar]); } try { diff --git a/nntmux/XXX.php b/nntmux/XXX.php index 914bd546f..88da0bd68 100755 --- a/nntmux/XXX.php +++ b/nntmux/XXX.php @@ -564,7 +564,8 @@ class XXX { $this->whichclass = 'aebn'; $mov = new AEBN(); - $mov->cookie = $this->cookie; ColorCLI::doEcho(ColorCLI::info('Checking AEBN for movie info')); + $mov->cookie = $this->cookie; + ColorCLI::doEcho(ColorCLI::info('Checking AEBN for movie info')); $res = $mov->processSite($movie); if ($res === false) { diff --git a/nntmux/processing/adult/ADM.php b/nntmux/processing/adult/ADM.php index 8d262af53..3aafc0d71 100755 --- a/nntmux/processing/adult/ADM.php +++ b/nntmux/processing/adult/ADM.php @@ -177,7 +177,7 @@ class ADM extends AdultMovies 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]); @@ -203,7 +203,7 @@ class ADM extends AdultMovies $result = false; if (!empty($movie)) { $this->_trailUrl = self::TRAILINGSEARCH . urlencode($movie); - $this->_response = getRawHtml(self::ADMURL . $this->_trailUrl); + $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]')) { @@ -220,7 +220,9 @@ class ADM extends AdultMovies $this->_title = trim($title); $this->_trailUrl = '/dvd_view_' . (string)$matches['sku'] . '.html'; $this->_directUrl = self::ADMURL . $this->_trailUrl; - $this->_response = getRawHtml($this->_directUrl); + $this->_html->clear(); + unset($this->_response); + $this->_response = getRawHtml($this->_directUrl, $this->cookie); $this->_html->load($this->_response); $result = true; } diff --git a/nntmux/processing/adult/AEBN.php b/nntmux/processing/adult/AEBN.php index 1d3617ad1..86ee026e9 100755 --- a/nntmux/processing/adult/AEBN.php +++ b/nntmux/processing/adult/AEBN.php @@ -201,6 +201,8 @@ class AEBN extends AdultMovies /** * Searches for a XXX name * + * @param string $movie + * * @return bool */ public function processSite($movie): bool @@ -209,7 +211,7 @@ class AEBN extends AdultMovies return false; } $this->_trailerUrl = self::TRAILINGSEARCH . urlencode($movie); - $this->_response = getRawHtml(self::AEBNSURL . $this->_trailerUrl); + $this->_response = getRawHtml(self::AEBNSURL . $this->_trailerUrl, $this->cookie); if ($this->_response !== false) { $this->_html->load($this->_response); $count = count($this->_html->find('div.movie')); @@ -226,7 +228,9 @@ class AEBN extends AdultMovies $this->_title = trim($ret->title); $this->_trailerUrl = html_entity_decode($ret->href); $this->_directUrl = self::AEBNSURL . self::TRAILINGSEARCH . urlencode($movie); - $this->_response = getRawHtml($this->_directUrl); + $this->_html->clear(); + unset($this->_response); + $this->_response = getRawHtml($this->_directUrl, $this->cookie); $this->_html->load($this->_response); return true; } diff --git a/nntmux/processing/adult/Hotmovies.php b/nntmux/processing/adult/Hotmovies.php index 62bbb373e..fd91ff45c 100755 --- a/nntmux/processing/adult/Hotmovies.php +++ b/nntmux/processing/adult/Hotmovies.php @@ -99,24 +99,6 @@ class Hotmovies extends AdultMovies return false; } - /** - * Directly gets the link if directlink is set, and parses it. - * - * @return bool|array - */ - protected function getDirect() - { - if (!empty($this->directLink)) { - if (getRawHtml($this->_directUrl) === false) { - return false; - } - - return $this->getAll(); - } - - return false; - } - /** * Gets all information * @return bool|array @@ -159,11 +141,11 @@ class Hotmovies extends AdultMovies */ protected function synopsis(): array { + $this->_res['synopsis'] = 'N/A'; if ($this->_html->find('.desc_link', 0)) { - foreach ($this->_html->find('div[itemprop=description]') as $heading) { - if (trim($heading->plaintext) === 'description') { - $this->_res['synopsis'] = trim($heading->next_sibling()->plaintext); - } + $ret = $this->_html->find('.video_description', 0); + if ($ret !== false) { + $this->_res['synopsis'] = trim($ret->innertext); } } @@ -225,9 +207,10 @@ class Hotmovies extends AdultMovies */ protected function cast() { - $cast = null; - if ($this->_html->find('a[itemprop=actors]')) { - foreach ($this->_html->find('a[itemprop=actors]') 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); $cast[] = trim($e); @@ -246,17 +229,15 @@ class Hotmovies extends AdultMovies */ 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); - $genres[] = trim($e[1]); - } - } - $this->_res['genres'] = $genres; + $genres = []; + foreach ($this->_html->find('span[itemprop=genre]') as $e) { + if (strpos($e->innertext, ' -> ') !== false) { + $e = explode(' -> ', $e->plaintext); + $genres[] = $e; + } } + $this->_res['genres'] = $genres; return $this->_res; } @@ -291,7 +272,7 @@ class Hotmovies extends AdultMovies } $this->_response = false; $this->_getLink = self::HMURL . self::TRAILINGSEARCH . urlencode($movie) . self::EXTRASEARCH; - $this->_response = getRawHtml($this->_getLink); + $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)) { @@ -306,8 +287,16 @@ class Hotmovies extends AdultMovies $this->_title = $title; $this->_getLink = trim($ret->href); $this->_directUrl = trim($ret->href); - $this->_response = getRawHtml($this->_directUrl); - $this->_html->load($this->_response); + $this->_html->clear(); + unset($this->_response); + if (!empty($this->_getLink)) { + $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; } } @@ -317,7 +306,6 @@ class Hotmovies extends AdultMovies return false; } - return false; } } diff --git a/nntmux/processing/adult/Popporn.php b/nntmux/processing/adult/Popporn.php index 592841ca6..2dfc34a98 100755 --- a/nntmux/processing/adult/Popporn.php +++ b/nntmux/processing/adult/Popporn.php @@ -75,7 +75,7 @@ class Popporn extends AdultMovies * 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); @@ -110,7 +110,7 @@ class Popporn extends AdultMovies if ($ret->next_sibling()->next_sibling()) { $this->_res['synopsis'] = trim($ret->next_sibling()->next_sibling()->next_sibling()->plaintext); } else { - $this->_res['synopsis'] = "N/A"; + $this->_res['synopsis'] = 'N/A'; } } } @@ -127,19 +127,19 @@ class Popporn extends AdultMovies { 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->getRawHtml(); if (preg_match_all('/productID="\+(?[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->_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; } @@ -161,14 +161,14 @@ class Popporn extends AdultMovies 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; } @@ -187,11 +187,11 @@ class Popporn extends AdultMovies 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; } @@ -214,16 +214,16 @@ class Popporn extends AdultMovies $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; } @@ -235,7 +235,7 @@ class Popporn extends AdultMovies $e = null; } } - if (!stristr($e, "Country:")) { + if (!stristr($e, 'Country:')) { if (!empty($e)) { $er[] = $e; } @@ -269,13 +269,16 @@ class Popporn extends AdultMovies /** * Searches for match against searchterm - * @return bool, true if search >= 90% + * + * @param string $movie + * + * @return bool , true if search >= 90% */ public function processSite($movie): bool { if (!empty($movie)) { $this->_trailUrl = self::TRAILINGSEARCH . urlencode($movie); - $this->_response = getRawHtml(self::POPURL . $this->_trailUrl); + $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)) { @@ -285,12 +288,16 @@ class Popporn extends AdultMovies $title = trim($title); if ($ret = $ret->find('a', 0)) { $this->_trailUrl = trim($ret->href); - $this->_response = getRawHtml($this->_trailUrl); + $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->_response = getRawHtml($this->_directUrl); + $this->_html->clear(); + unset($this->_response); + $this->_response = getRawHtml($this->_directUrl, $this->cookie); $this->_html->load($this->_response); } similar_text(strtolower($movie), strtolower($title), $p); @@ -300,6 +307,13 @@ class Popporn extends AdultMovies } } } + } else { + $this->_response = getRawHtml(self::IF18); + if ($this->_response !== false) { + $this->_html->load($this->_response); + return true; + } + return false; } } return false; @@ -339,45 +353,4 @@ class Popporn extends AdultMovies } return $results; } - - /** - * Get Raw html of webpage - * - * @param bool $usepost - * - * @return bool - */ - private function getRawHtml($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); - return false; - } - curl_close($ch); - $this->_html->load($this->_response); - return true; - } } From 075e39dfb99e410e7a38a932e1422041786659fa Mon Sep 17 00:00:00 2001 From: DariusIII Date: Wed, 14 Jun 2017 02:19:59 +0200 Subject: [PATCH 19/49] Update xxx parsing --- nntmux/XXX.php | 11 +++-- nntmux/processing/adult/ADE.php | 4 ++ nntmux/processing/adult/AEBN.php | 68 ++++++++++++++------------- nntmux/processing/adult/Hotmovies.php | 14 +++--- 4 files changed, 52 insertions(+), 45 deletions(-) diff --git a/nntmux/XXX.php b/nntmux/XXX.php index 88da0bd68..9bd0af80f 100755 --- a/nntmux/XXX.php +++ b/nntmux/XXX.php @@ -747,20 +747,21 @@ class XXX $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); + ColorCLI::doEcho(ColorCLI::primaryOver('Looking up: ') . ColorCLI::headerOver($this ->currentTitle), true); } - $idcheck = $this->updateXXXInfo($movieName); + 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('.'); + ColorCLI::doEcho('.', true); } $this->pdo->queryExec(sprintf('UPDATE releases SET xxxinfo_id = %d WHERE id = %d %s', $idcheck, $arr['id'], $this->catWhere)); } @@ -778,7 +779,7 @@ class XXX */ protected function checkXXXInfoExists($releaseName) { - return $this->pdo->queryOneRow(sprintf('SELECT id, title FROM xxxinfo WHERE title %s', $this->pdo->likeString($releaseName, false, true))); + return $this->pdo->queryOneRow(sprintf('SELECT id, title FROM xxxinfo WHERE title %s', $this->pdo->likeString($releaseName, true, true))); } /** diff --git a/nntmux/processing/adult/ADE.php b/nntmux/processing/adult/ADE.php index 853aef50b..c29b669c8 100755 --- a/nntmux/processing/adult/ADE.php +++ b/nntmux/processing/adult/ADE.php @@ -261,8 +261,12 @@ class ADE extends AdultMovies } return false; } + /** * Searches xxx name. + * + * @param string $movie + * * @return bool - True if releases has 90% match, else false */ public function processSite($movie): bool diff --git a/nntmux/processing/adult/AEBN.php b/nntmux/processing/adult/AEBN.php index 86ee026e9..ef02153ec 100755 --- a/nntmux/processing/adult/AEBN.php +++ b/nntmux/processing/adult/AEBN.php @@ -1,4 +1,5 @@ [], - 'boxcover' => [], - 'cast' => [], - 'director' => [], - 'genres' => [], - 'productinfo' => [], - 'synopsis' => [], - 'trailers' => ['url' =>[]], + 'backcover' => [], + 'boxcover' => [], + 'cast' => [], + 'director' => [], + 'genres' => [], + 'productinfo' => [], + 'synopsis' => [], + 'trailers' => ['url' => []], ]; /** * Sets title in getAll method + * * @var string */ protected $_title = ''; @@ -106,6 +110,7 @@ class AEBN extends AdultMovies self::$res['boxcover'] = str_ireplace('160w.jpg', 'xlf.jpg', $ret); self::$res['backcover'] = str_ireplace('160w.jpg', 'xlb.jpg', $ret); } + return self::$res; } @@ -122,6 +127,7 @@ class AEBN extends AdultMovies } } self::$res['genres'] = array_unique(self::$res['genres']); + return self::$res; } @@ -214,33 +220,29 @@ class AEBN extends AdultMovies $this->_response = getRawHtml(self::AEBNSURL . $this->_trailerUrl, $this->cookie); if ($this->_response !== false) { $this->_html->load($this->_response); - $count = count($this->_html->find('div.movie')); $i = 1; - while ($count >= $i) { - 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($mov), strtolower($title), $p); - if ($p >= 90) { - $this->_title = trim($ret->title); - $this->_trailerUrl = html_entity_decode($ret->href); - $this->_directUrl = self::AEBNSURL . self::TRAILINGSEARCH . urlencode($movie); - $this->_html->clear(); - unset($this->_response); - $this->_response = getRawHtml($this->_directUrl, $this->cookie); - $this->_html->load($this->_response); - return true; - } - continue; - } - $i++; - } - } + 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($mov), strtolower($title), $p); + if ($p >= 90) { + $this->_title = trim($ret->title); + $this->_trailerUrl = html_entity_decode($ret->href); + $this->_directUrl = self::AEBNSURL . self::TRAILINGSEARCH . urlencode($movie); + $this->_html->clear(); + unset($this->_response); + $this->_response = getRawHtml($this->_directUrl, $this->cookie); + $this->_html->load($this->_response); - return false; + return true; + } + continue; + } + $i++; + } } return false; diff --git a/nntmux/processing/adult/Hotmovies.php b/nntmux/processing/adult/Hotmovies.php index fd91ff45c..b290dc6e1 100755 --- a/nntmux/processing/adult/Hotmovies.php +++ b/nntmux/processing/adult/Hotmovies.php @@ -229,16 +229,16 @@ class Hotmovies extends AdultMovies */ protected function genres() { - $genres = []; - foreach ($this->_html->find('span[itemprop=genre]') as $e) { - if (strpos($e->innertext, ' -> ') !== false) { - $e = explode(' -> ', $e->plaintext); - $genres[] = $e; + if ($ret = $this->_html->find('div.categories',0)) { + foreach ($ret->find('a') as $e) { + if (strpos($e->title, '->') !== false) { + $e = explode('->', $e->plaintext); + $genres[] = trim($e[1]); + } } + $this->_res['genres'] = $genres; } - $this->_res['genres'] = $genres; - return $this->_res; } From 9af75d6976620581c3ea78101c6f8a9d134c804e Mon Sep 17 00:00:00 2001 From: DariusIII Date: Wed, 14 Jun 2017 12:50:15 +0200 Subject: [PATCH 20/49] AEBN lookups 100% fixed --- nntmux/processing/adult/AEBN.php | 60 +++++++++++++++++--------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/nntmux/processing/adult/AEBN.php b/nntmux/processing/adult/AEBN.php index ef02153ec..7d4f00866 100755 --- a/nntmux/processing/adult/AEBN.php +++ b/nntmux/processing/adult/AEBN.php @@ -49,7 +49,7 @@ class AEBN extends AdultMovies * * @var array */ - protected static $res = [ + protected $_res = [ 'backcover' => [], 'boxcover' => [], 'cast' => [], @@ -87,12 +87,12 @@ class AEBN extends AdultMovies protected function trailers() { $ret = $this->_html->find('a[itemprop=trailer]', 0); - if (preg_match('/movieId=(?\d+)&/', trim($ret->href), $matches)) { + if (!empty($ret) && preg_match('/movieId=(?\d+)&/', trim($ret->href), $matches)) { $movieid = $matches['movieid']; - self::$res['trailers']['url'] = self::AEBNSURL . self::TRAILERURL . $movieid; + $this->_res['trailers']['url'] = self::AEBNSURL . self::TRAILERURL . $movieid; } - return self::$res; + return $this->_res; } /** @@ -107,11 +107,11 @@ class AEBN extends AdultMovies if (strpos($ret, '//') === 0) { $ret = 'http:' . $ret; } - self::$res['boxcover'] = str_ireplace('160w.jpg', 'xlf.jpg', $ret); - self::$res['backcover'] = str_ireplace('160w.jpg', 'xlb.jpg', $ret); + $this->_res['boxcover'] = str_ireplace('160w.jpg', 'xlf.jpg', $ret); + $this->_res['backcover'] = str_ireplace('160w.jpg', 'xlb.jpg', $ret); } - return self::$res; + return $this->_res; } /** @@ -123,12 +123,13 @@ class AEBN extends AdultMovies { if ($ret = $this->_html->find('div.md-detailsCategories', 0)) { foreach ($ret->find('a[itemprop=genre]') as $genre) { - self::$res['genres'][] = trim($genre->plaintext); + $this->_res['genres'][] = trim($genre->plaintext); } } - self::$res['genres'] = array_unique(self::$res['genres']); - - return self::$res; + if (!empty($this->_res['genres'])) { + $this->_res['genres'] = array_unique($this->_res['genres']); + } + return $this->_res; } /** @@ -136,23 +137,24 @@ class AEBN extends AdultMovies * * @return array */ - protected function cast(): array + protected function cast() { + $this->_res = false; if ($ret = $this->_html->find('div.starsFull', 0)) { foreach ($ret->find('span[itemprop=name]') as $star) { - self::$res['cast'][] = trim($star->plaintext); + $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) { - self::$res['cast'][] = trim($star->plaintext); + $this->_res['cast'][] = trim($star->plaintext); } } } } - return self::$res; + return $this->_res; } /** @@ -167,20 +169,20 @@ class AEBN extends AdultMovies foreach ($div->find('span') as $span) { $span->plaintext = rawurldecode($span->plaintext); $span->plaintext = preg_replace('/ /', '', $span->plaintext); - self::$res['productinfo'][] = trim($span->plaintext); + $this->_res['productinfo'][] = trim($span->plaintext); } } - if (false !== $key = array_search('Running Time:', self::$res['productinfo'])) { - unset(self::$res['productinfo'][$key + 2]); + if (false !== $key = array_search('Running Time:', $this->_res['productinfo'], false)) { + unset($this->_res['productinfo'][$key + 2]); } - if (false !== $key = array_search("Director:", self::$res['productinfo'])) { - self::$res['director'] = self::$res['productinfo'][$key + 1]; - unset(self::$res['productinfo'][$key], self::$res['productinfo'][$key + 1]); + 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]); } - self::$res['productinfo'] = array_chunk(self::$res['productinfo'], 2, false); + $this->_res['productinfo'] = array_chunk($this->_res['productinfo'], 2, false); } - return self::$res; + return $this->_res; } /** @@ -194,14 +196,14 @@ class AEBN extends AdultMovies if ($ret = $this->_html->find('span[itemprop=about]', 0)) { if ($ret === null) { if ($ret = $this->_html->find('div.movieDetailDescription', 0)) { - self::$res['synopsis'] = preg_replace('/Description:\s/', '', self::$res['plot']); + $this->_res['synopsis'] = preg_replace('/Description:\s/', '', $this->_res['plot']); } } else { - self::$res['synopsis'] = trim($ret->plaintext); + $this->_res['synopsis'] = trim($ret->plaintext); } } - return self::$res; + return $this->_res; } /** @@ -227,14 +229,14 @@ class AEBN extends AdultMovies $title = str_replace('/XXX/', '', $ret->title); $title = preg_replace('/\(.*?\)|[-._]/', ' ', $title); $title = trim($title); - similar_text(strtolower($mov), strtolower($title), $p); + 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 . self::TRAILINGSEARCH . urlencode($movie); + $this->_directUrl = self::AEBNSURL . $this->_trailerUrl; $this->_html->clear(); unset($this->_response); - $this->_response = getRawHtml($this->_directUrl, $this->cookie); + $this->_response = getRawHtml(self::AEBNSURL . $this->_trailerUrl, $this->cookie); $this->_html->load($this->_response); return true; From ea461fb8094680a77530d35ba82d9d63c8ccbbe4 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Wed, 14 Jun 2017 15:50:29 +0200 Subject: [PATCH 21/49] Fix ADE search --- nntmux/processing/adult/ADE.php | 139 +++++++++----------------- nntmux/processing/adult/Hotmovies.php | 6 +- 2 files changed, 48 insertions(+), 97 deletions(-) diff --git a/nntmux/processing/adult/ADE.php b/nntmux/processing/adult/ADE.php index c29b669c8..698142c5f 100755 --- a/nntmux/processing/adult/ADE.php +++ b/nntmux/processing/adult/ADE.php @@ -34,7 +34,7 @@ class ADE extends AdultMovies * * @var string */ - protected $_directUrl = ""; + protected $_directUrl = ''; /** * If a url is found that matches the keyword @@ -47,7 +47,7 @@ class ADE extends AdultMovies * * @var string */ - protected $_title = ""; + protected $_title = ''; /** Trailing urls */ protected $_dvdQuery = '/dvd/search?q='; @@ -70,19 +70,6 @@ class ADE extends AdultMovies { parent::__construct($options); $this->_html = new \simple_html_dom(); - $this->_edithtml = new \simple_html_dom(); - } - - /** - * - * Remove from memory if they were not removed - * - */ - public function __destruct() - { - $this->_html->clear(); - $this->_edithtml->clear(); - unset($this->_response, $this->_tmpResponse); } /** @@ -91,7 +78,7 @@ class ADE extends AdultMovies */ public function trailers() { - $this->_response = getRawHtml($this->_trailers . $this->_directUrl); + $this->_response = getRawHtml(self::ADE . $this->_trailers . $this->_directUrl); $this->_html->load($this->_response); if (preg_match("/(\"|')(?P[^\"']+.swf)(\"|')/i", $this->_response, $matches)) { $this->_res['trailers']['url'] = self::ADE . trim(trim($matches['swf']), '"'); @@ -108,8 +95,6 @@ class ADE extends AdultMovies $this->_res['trailers']['baseurl'] = $matches['baseurl']; } } - unset($matches); - $this->_html->clear(); return $this->_res; } @@ -135,8 +120,9 @@ class ADE extends AdultMovies */ public function synopsis() { - if ($ret = $this->_html->find('meta[name="og:description"]', 0)->content()) { - $this->_res['synopsis'] = trim($ret->innertext); + $ret = $this->_html->find('meta[name=og:description]', 0)->content; + if ($ret !== false) { + $this->_res['synopsis'] = trim($ret); } return $this->_res; @@ -145,34 +131,16 @@ class ADE extends AdultMovies /** * Gets the cast members and/or awards * - * @param bool $awards - Include Awards? true/false * * @return array - cast, awards */ - public function cast($awards = false) + public function cast() { - $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) { + foreach ($this->_html->find('a.PerformerName') as $a) { if ($a->plaintext !== '(bio)' && $a->plaintext !== '(interview)') { - $this->_res['cast'][] = trim($a->plaintext); + $this->_res['cast'][] = trim($a->innertext); } } - } - 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; } @@ -184,28 +152,22 @@ class ADE extends AdultMovies 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; + $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); } - } - $this->_edithtml->clear(); - unset($this->_tmpResponse, $ret); return $this->_res; } @@ -220,10 +182,10 @@ class ADE extends AdultMovies { $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->_html->load($this->_tmpResponse); + if ($ret = $this->_html->find('div[class=spdinfo]', 0)) { $this->_tmpResponse = trim($ret->outertext); - $ret = $this->_edithtml->load($this->_tmpResponse); + $ret = $this->_html->load($this->_tmpResponse); foreach ($ret->find("text") as $strong) { if (trim($strong->innertext) === 'Features') { $dofeature = true; @@ -243,25 +205,10 @@ class ADE extends AdultMovies 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->getRawHtml() !== false) { - $this->_html->load($this->_response); - return $this->getAll(); - } - return false; - } - /** * Searches xxx name. * @@ -274,22 +221,26 @@ class ADE extends AdultMovies if (empty($movie)) { return false; } - $this->_response = getRawHtml($this->_dvdQuery . rawurlencode($movie)); + $this->_response = getRawHtml(self::ADE . $this->_dvdQuery . rawurlencode($movie)); if ($this->_response !== false) { $this->_html->load($this->_response); - if ($ret = $this->_html->find('div[id=boxcover]', 0)) { - $title = $ret->title; - $title = str_replace('/XXX/', '', $title); - $title = preg_replace('/\(.*?\)|[-._]/', ' ', $title); - $ret = (string)trim($ret->href); - similar_text(strtolower($movie), strtolower($title), $p); - if ($p >= 90) { - $this->_urlFound = $ret; - $this->_directUrl = self::ADE . $ret; - $this->_title = trim($title); - $this->_response = getRawHtml($this->_directUrl); - $this->_html->load($this->_response); - return true; + 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; } @@ -310,14 +261,14 @@ class ADE extends AdultMovies $results['directurl'] = $this->_directUrl; $results['title'] = $this->_title; } - if (is_array($this->synopsis(true))) { - $results = array_merge($results, $this->synopsis(true)); + 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(true))) { - $results = array_merge($results, $this->cast(true)); + if (is_array($this->cast())) { + $results = array_merge($results, $this->cast()); } if (is_array($this->genres())) { $results = array_merge($results, $this->genres()); diff --git a/nntmux/processing/adult/Hotmovies.php b/nntmux/processing/adult/Hotmovies.php index b290dc6e1..eabedd314 100755 --- a/nntmux/processing/adult/Hotmovies.php +++ b/nntmux/processing/adult/Hotmovies.php @@ -232,8 +232,8 @@ class Hotmovies extends AdultMovies $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]); } } @@ -289,7 +289,7 @@ class Hotmovies extends AdultMovies $this->_directUrl = trim($ret->href); $this->_html->clear(); unset($this->_response); - if (!empty($this->_getLink)) { + if ($this->_getLink !== false) { $this->_response = getRawHtml($this->_getLink, $this->cookie); $this->_html->load($this->_response); } else { From f9207f37bfb12de6e6d04df991abbda52bdc0396 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Wed, 14 Jun 2017 15:51:07 +0200 Subject: [PATCH 22/49] Remove debugging info from XXX class --- nntmux/XXX.php | 1 - 1 file changed, 1 deletion(-) diff --git a/nntmux/XXX.php b/nntmux/XXX.php index 9bd0af80f..f8579239d 100755 --- a/nntmux/XXX.php +++ b/nntmux/XXX.php @@ -650,7 +650,6 @@ class XXX 'directurl' => !empty($res['directurl']) ? html_entity_decode($res['directurl'], ENT_QUOTES, 'UTF-8') : '', 'classused' => $this->whichclass ]; - print_r($mov); $check = $this->pdo->queryOneRow(sprintf('SELECT id FROM xxxinfo WHERE title = %s', $this->pdo->escapeString($mov['title']))); $xxxID = 0; From b46948a55dd1d2eb6aa0ba9b00519e6952337b5b Mon Sep 17 00:00:00 2001 From: DariusIII Date: Wed, 14 Jun 2017 15:58:44 +0200 Subject: [PATCH 23/49] Update composer libraries --- Changelog | 2 ++ composer.json | 3 +- composer.lock | 79 ++++++++++----------------------------------------- 3 files changed, 18 insertions(+), 66 deletions(-) diff --git a/Changelog b/Changelog index 5ace104c1..319d9a3be 100755 --- a/Changelog +++ b/Changelog @@ -1,3 +1,5 @@ +2017-06-14 DariusIII + * Chg: Update composer libraries 2017-06-09 DariusIII * Chg: Update composer.lock 2017-06-06 DariusIII diff --git a/composer.json b/composer.json index f628c3816..4d93f8681 100755 --- a/composer.json +++ b/composer.json @@ -144,8 +144,7 @@ "monolog/monolog": "^1.22", "aharen/omdbapi": "^2.0", "vlucas/phpdotenv": "^2.4", - "laravel/framework": "^5.4", - "fabpot/goutte": "^3.2" + "laravel/framework": "^5.4" }, "require-dev": { diff --git a/composer.lock b/composer.lock index e1979ccfa..03425a3ea 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "c400d847c0aca8f687814725c5590f42", + "content-hash": "f2aa144131a6fb8b3d72a01fc6bed139", "packages": [ { "name": "adrenth/thetvdb2", @@ -2081,55 +2081,6 @@ ], "time": "2017-02-24T10:12:27+00:00" }, - { - "name": "fabpot/goutte", - "version": "v3.2.1", - "source": { - "type": "git", - "url": "https://github.com/FriendsOfPHP/Goutte.git", - "reference": "db5c28f4a010b4161d507d5304e28a7ebf211638" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/Goutte/zipball/db5c28f4a010b4161d507d5304e28a7ebf211638", - "reference": "db5c28f4a010b4161d507d5304e28a7ebf211638", - "shasum": "" - }, - "require": { - "guzzlehttp/guzzle": "^6.0", - "php": ">=5.5.0", - "symfony/browser-kit": "~2.1|~3.0", - "symfony/css-selector": "~2.1|~3.0", - "symfony/dom-crawler": "~2.1|~3.0" - }, - "type": "application", - "extra": { - "branch-alias": { - "dev-master": "3.2-dev" - } - }, - "autoload": { - "psr-4": { - "Goutte\\": "Goutte" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "A simple PHP Web Scraper", - "homepage": "https://github.com/FriendsOfPHP/Goutte", - "keywords": [ - "scraper" - ], - "time": "2017-01-03T13:21:43+00:00" - }, { "name": "fxp/composer-asset-plugin", "version": "v1.3.1", @@ -2240,12 +2191,12 @@ "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "1739e8b94e058421d4da8b66887c52ee523f7d45" + "reference": "065287bc14f3e606fe6aec6ecfeac9616afbd3cb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/1739e8b94e058421d4da8b66887c52ee523f7d45", - "reference": "1739e8b94e058421d4da8b66887c52ee523f7d45", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/065287bc14f3e606fe6aec6ecfeac9616afbd3cb", + "reference": "065287bc14f3e606fe6aec6ecfeac9616afbd3cb", "shasum": "" }, "require": { @@ -2297,7 +2248,7 @@ "rest", "web service" ], - "time": "2017-05-15 08:45:24" + "time": "2017-06-10 14:17:14" }, { "name": "guzzlehttp/promises", @@ -2590,16 +2541,16 @@ }, { "name": "laravel/framework", - "version": "v5.4.25", + "version": "v5.4.26", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "6bcc9b1f542b3deed16d51f6aa1fe318ab407c2a" + "reference": "a7ebbfab64111e24f8e584db64e2be9279ded357" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/6bcc9b1f542b3deed16d51f6aa1fe318ab407c2a", - "reference": "6bcc9b1f542b3deed16d51f6aa1fe318ab407c2a", + "url": "https://api.github.com/repos/laravel/framework/zipball/a7ebbfab64111e24f8e584db64e2be9279ded357", + "reference": "a7ebbfab64111e24f8e584db64e2be9279ded357", "shasum": "" }, "require": { @@ -2715,7 +2666,7 @@ "framework", "laravel" ], - "time": "2017-06-07T13:35:12+00:00" + "time": "2017-06-13T18:58:49+00:00" }, { "name": "league/flysystem", @@ -4986,16 +4937,16 @@ }, { "name": "phpunit/phpunit", - "version": "6.2.1", + "version": "6.2.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "16999a1e9a8a25d68f0ab8cc8ab818b043ad5374" + "reference": "f2786490399836d2a544a34785c4a8d3ab32cf0e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/16999a1e9a8a25d68f0ab8cc8ab818b043ad5374", - "reference": "16999a1e9a8a25d68f0ab8cc8ab818b043ad5374", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f2786490399836d2a544a34785c4a8d3ab32cf0e", + "reference": "f2786490399836d2a544a34785c4a8d3ab32cf0e", "shasum": "" }, "require": { @@ -5066,7 +5017,7 @@ "testing", "xunit" ], - "time": "2017-06-02T12:24:37+00:00" + "time": "2017-06-13T14:07:07+00:00" }, { "name": "phpunit/phpunit-mock-objects", From eceb6b94aa4c76cba7f04f4d6c81df56a47fb074 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Thu, 15 Jun 2017 00:03:14 +0200 Subject: [PATCH 24/49] Use monolog/monolog to handle logging --- Changelog | 1 + nntmux/Logger.php | 208 +++------------------------------------------- 2 files changed, 14 insertions(+), 195 deletions(-) diff --git a/Changelog b/Changelog index 319d9a3be..85e6c3e7e 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2017-06-14 DariusIII + * Chg: Use monolog/monolog to handle logging * Chg: Update composer libraries 2017-06-09 DariusIII * Chg: Update composer.lock diff --git a/nntmux/Logger.php b/nntmux/Logger.php index 6e39c8264..4d571cf8e 100755 --- a/nntmux/Logger.php +++ b/nntmux/Logger.php @@ -1,5 +1,8 @@ colorCLI = ($options['ColorCLI'] instanceof ColorCLI ? $options['ColorCLI'] : new ColorCLI()); - $this->getSettings(); $this->currentLogFolder = ( @@ -198,21 +201,12 @@ class Logger : $this->currentLogName ) . '.log'; - $this->setLogFile(); - $this->outputCLI = (strtolower(PHP_SAPI) === 'cli'); $this->isWindows = (strtolower(substr(PHP_OS, 0, 3)) === 'win'); $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 +277,14 @@ class Logger round( $actualUsage / - pow( - 1024, - ($i = + (1024 ** ($i = floor( log( $actualUsage, 1024 ) ) - ) - ), 2 + )), 2 ) ), 4, '~~~', STR_PAD_LEFT ) . @@ -353,13 +344,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 +374,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 +394,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 +407,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 +428,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 +441,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 '
' . $this->logMessage . '

'; } From 392f78d36f5cd9d04346d1b3f6c28fff884dc011 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Thu, 15 Jun 2017 00:14:38 +0200 Subject: [PATCH 25/49] Add PHPDoc to helpers.php --- app/extensions/helper/helpers.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/extensions/helper/helpers.php b/app/extensions/helper/helpers.php index 8a6141aab..8c9cefd1f 100644 --- a/app/extensions/helper/helpers.php +++ b/app/extensions/helper/helpers.php @@ -8,6 +8,12 @@ use nntmux\ColorCLI; if (!function_exists('getRawHtml')) { + /** + * @param $url + * @param bool|string $cookie + * + * @return bool|string + */ function getRawHtml($url, $cookie = false) { $response = false; From f549d8a9544e778aee86c246e9a8626c577fa5ff Mon Sep 17 00:00:00 2001 From: DariusIII Date: Thu, 15 Jun 2017 00:18:42 +0200 Subject: [PATCH 26/49] Remove return type declaration fot getAlternate function in DNZBFailures --- nntmux/DnzbFailures.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nntmux/DnzbFailures.php b/nntmux/DnzbFailures.php index 91e236799..b23c25f3e 100755 --- a/nntmux/DnzbFailures.php +++ b/nntmux/DnzbFailures.php @@ -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(' From 2c841f1785af129122e7678d5540735c532620d2 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Thu, 15 Jun 2017 00:20:52 +0200 Subject: [PATCH 27/49] Declare logger property. --- nntmux/Logger.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/nntmux/Logger.php b/nntmux/Logger.php index 4d571cf8e..d1e96fb1b 100755 --- a/nntmux/Logger.php +++ b/nntmux/Logger.php @@ -51,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? From 88e3447c3bbd2bec1d0d6f6399a937543a318131 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Thu, 15 Jun 2017 14:52:44 +0200 Subject: [PATCH 28/49] Update Logging class --- nntmux/Logging.php | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/nntmux/Logging.php b/nntmux/Logging.php index 03b4ffa4f..367cdf98a 100755 --- a/nntmux/Logging.php +++ b/nntmux/Logging.php @@ -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'); } From 56e4505a39bd5b267befffb8cf553f806b18b71e Mon Sep 17 00:00:00 2001 From: DariusIII Date: Thu, 15 Jun 2017 15:43:50 +0200 Subject: [PATCH 29/49] Change windows check in Logger class --- nntmux/Logger.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nntmux/Logger.php b/nntmux/Logger.php index d1e96fb1b..0a1a894c4 100755 --- a/nntmux/Logger.php +++ b/nntmux/Logger.php @@ -200,7 +200,7 @@ class Logger ) . '.log'; $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(); $this->logger = new MonoLogger('nntmux'); From 10bf1821f8e7b4c91c5ba620e4f3d0a60db6f42f Mon Sep 17 00:00:00 2001 From: DariusIII Date: Thu, 15 Jun 2017 23:16:00 +0200 Subject: [PATCH 30/49] Fix collection regexes testing page --- Changelog | 2 + www/admin/collection_regexes-test.php | 4 +- .../admin/collection_regexes-test.tpl | 73 +++++++++---------- 3 files changed, 38 insertions(+), 41 deletions(-) diff --git a/Changelog b/Changelog index 85e6c3e7e..89ec67bee 100755 --- a/Changelog +++ b/Changelog @@ -1,3 +1,5 @@ +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 diff --git a/www/admin/collection_regexes-test.php b/www/admin/collection_regexes-test.php index a60043af1..cb890129e 100644 --- a/www/admin/collection_regexes-test.php +++ b/www/admin/collection_regexes-test.php @@ -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'] : ''); diff --git a/www/themes/shared/templates/admin/collection_regexes-test.tpl b/www/themes/shared/templates/admin/collection_regexes-test.tpl index 127041bce..dba35eb16 100644 --- a/www/themes/shared/templates/admin/collection_regexes-test.tpl +++ b/www/themes/shared/templates/admin/collection_regexes-test.tpl @@ -2,45 +2,42 @@

This page is used for testing regex for grouping usenet collections.
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).

-{if $tpg} -
- -
- -
- -
- -
- {if isset($data)} +
+ +
+ +
+ +
+ +
+{if isset($data)} - {foreach from=$data key=hash item=collection} - - - + {foreach from=$data key=hash item=collection} +
{$hash}
Current Files: {count($collection)}
+ + + +
{$hash}
Current Files: {count($collection)}
+ + + + + + + + + {foreach from=$collection item=row} + + + + + + -
namecurrent partstotal partsposterold hash
{$row.file_name}{$row.file_current_parts}{$row.file_total_parts}{$row.collection_poster}{$row.old_collection_hash}
- - - - - - - - - {foreach from=$collection item=row} - - - - - - - - {/foreach} -
namecurrent partstotal partsposterold hash
{$row.file_name}{$row.file_current_parts}{$row.file_total_parts}{$row.collection_poster}{$row.old_collection_hash}
- {/foreach} - {/if} -{else} -

The Table Per Group setting is required to be on to use this page, for performance reasons.

+ {/foreach} + + {/foreach} {/if} +
From 02cc687e64a74fa43a9e754abc3337b953c1cee6 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Fri, 16 Jun 2017 11:42:58 +0200 Subject: [PATCH 31/49] Add more debugging output to DbUpdate class and install_nntmux script --- Changelog | 2 ++ _install/install_nntmux.php | 44 ++++++++++++++++++------------------- nntmux/db/DbUpdate.php | 17 ++++++++++---- 3 files changed, 37 insertions(+), 26 deletions(-) diff --git a/Changelog b/Changelog index 89ec67bee..721d359d0 100755 --- a/Changelog +++ b/Changelog @@ -1,3 +1,5 @@ +2017-06-16 DariusIII + * 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 diff --git a/_install/install_nntmux.php b/_install/install_nntmux.php index 5a60e276b..3244bfb68 100644 --- a/_install/install_nntmux.php +++ b/_install/install_nntmux.php @@ -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; } diff --git a/nntmux/db/DbUpdate.php b/nntmux/db/DbUpdate.php index d0ffadc98..983a23f12 100755 --- a/nntmux/db/DbUpdate.php +++ b/nntmux/db/DbUpdate.php @@ -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,18 @@ 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)); + $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"); } From 9c440301b5571f5ca0d260fb67712ea918821930 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Fri, 16 Jun 2017 12:39:25 +0200 Subject: [PATCH 32/49] Fix tabs in 10-settings.tsv --- resources/db/schema/data/10-settings.tsv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/db/schema/data/10-settings.tsv b/resources/db/schema/data/10-settings.tsv index 4f63270fc..2a496709a 100755 --- a/resources/db/schema/data/10-settings.tsv +++ b/resources/db/schema/data/10-settings.tsv @@ -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 OmdbAPI key 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 From 96914d6c536b145eb25c020f45f101eb3dd1a28d Mon Sep 17 00:00:00 2001 From: DariusIII Date: Fri, 16 Jun 2017 12:49:58 +0200 Subject: [PATCH 33/49] Properly fix 10-settings.tsv --- nntmux/db/DbUpdate.php | 12 +++++++----- resources/db/schema/data/10-settings.tsv | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/nntmux/db/DbUpdate.php b/nntmux/db/DbUpdate.php index 983a23f12..4d71acfd0 100755 --- a/nntmux/db/DbUpdate.php +++ b/nntmux/db/DbUpdate.php @@ -127,11 +127,13 @@ class DbUpdate $file = str_replace("\\", '\/', $file); } $this->pdo->queryExec(sprintf($sql, $file, $table, $fields)); - $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')); + 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"); diff --git a/resources/db/schema/data/10-settings.tsv b/resources/db/schema/data/10-settings.tsv index 2a496709a..29230cd43 100755 --- a/resources/db/schema/data/10-settings.tsv +++ b/resources/db/schema/data/10-settings.tsv @@ -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 From 1a8eb9a483cf5a322b8498bf1c785fe282431cfe Mon Sep 17 00:00:00 2001 From: DariusIII Date: Fri, 16 Jun 2017 13:08:04 +0200 Subject: [PATCH 34/49] Remove getXXXSamples script from tmux loop as it serves no purpose anymore --- Changelog | 1 + nntmux/TmuxRun.php | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 721d359d0..fc5326475 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2017-06-16 DariusIII + * 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 diff --git a/nntmux/TmuxRun.php b/nntmux/TmuxRun.php index a1e0f9874..0de37e79f 100755 --- a/nntmux/TmuxRun.php +++ b/nntmux/TmuxRun.php @@ -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 From 99243199bbd46512c1a45652108d03aa36eddd8e Mon Sep 17 00:00:00 2001 From: DariusIII Date: Fri, 16 Jun 2017 13:21:28 +0200 Subject: [PATCH 35/49] Shorten classused for hotmovies to hotm --- nntmux/XXX.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nntmux/XXX.php b/nntmux/XXX.php index f8579239d..c47b0a813 100755 --- a/nntmux/XXX.php +++ b/nntmux/XXX.php @@ -584,7 +584,7 @@ class XXX } if ($res === false) { - $this->whichclass = 'hotmovies'; + $this->whichclass = 'hotm'; $mov = new Hotmovies(); $mov->cookie = $this->cookie; ColorCLI::doEcho(ColorCLI::info('Checking HotMovies for movie info')); @@ -618,7 +618,7 @@ class XXX case 'adm': $fromstr = 'Adult DVD Marketplace'; break; - case 'hotmovies': + case 'hotm': $fromstr = 'HotMovies'; break; default: From c8bab26d1a80cb9c1628df2b6c098c4718356c29 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Fri, 16 Jun 2017 13:43:52 +0200 Subject: [PATCH 36/49] Increase xref column in collections and multigroup_collections to 1024 and change classused in xxxinfo table to varchar(20) and empty default value --- Changelog | 2 ++ build/nntmux.xml | 4 ++-- nntmux/XXX.php | 2 +- resources/db/patches/mysql/0311~general.sql | 8 ++++++++ resources/db/schema/mysql-ddl.sql | 6 +++--- 5 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 resources/db/patches/mysql/0311~general.sql diff --git a/Changelog b/Changelog index fc5326475..9dc761efc 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,6 @@ 2017-06-16 DariusIII + * 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 diff --git a/build/nntmux.xml b/build/nntmux.xml index 4e3f046fa..1b8945259 100755 --- a/build/nntmux.xml +++ b/build/nntmux.xml @@ -16,8 +16,8 @@ - 310 - 310 + 311 + 311 diff --git a/nntmux/XXX.php b/nntmux/XXX.php index c47b0a813..4d9259515 100755 --- a/nntmux/XXX.php +++ b/nntmux/XXX.php @@ -622,7 +622,7 @@ class XXX $fromstr = 'HotMovies'; break; default: - $fromstr = null; + $fromstr = ''; } ColorCLI::doEcho(ColorCLI::primary('Fetching XXX info from: ' . $fromstr)); } diff --git a/resources/db/patches/mysql/0311~general.sql b/resources/db/patches/mysql/0311~general.sql new file mode 100644 index 000000000..b466e8816 --- /dev/null +++ b/resources/db/patches/mysql/0311~general.sql @@ -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 ''; \ No newline at end of file diff --git a/resources/db/schema/mysql-ddl.sql b/resources/db/schema/mysql-ddl.sql index c877d1642..2233534d2 100755 --- a/resources/db/schema/mysql-ddl.sql +++ b/resources/db/schema/mysql-ddl.sql @@ -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, From 3912a80b6275433e7313b0063dee68391da105b2 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Fri, 16 Jun 2017 14:38:32 +0200 Subject: [PATCH 37/49] Catch exception when checking for existing and missing collection tables (irritating message about Base table or view not found) --- Changelog | 1 + nntmux/libraries/Forking.php | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 9dc761efc..49a3839d7 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 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 diff --git a/nntmux/libraries/Forking.php b/nntmux/libraries/Forking.php index 21830318a..71d720340 100755 --- a/nntmux/libraries/Forking.php +++ b/nntmux/libraries/Forking.php @@ -597,8 +597,11 @@ 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 (\Exception $e) { } } } From 338a2488f648b40da961d9ca38fc9c2cfee32c6c Mon Sep 17 00:00:00 2001 From: DariusIII Date: Fri, 16 Jun 2017 14:43:04 +0200 Subject: [PATCH 38/49] Do the same in switch.php --- misc/update/nix/multiprocessing/.do_not_run/switch.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/misc/update/nix/multiprocessing/.do_not_run/switch.php b/misc/update/nix/multiprocessing/.do_not_run/switch.php index 16bfe0c71..62bb30d97 100644 --- a/misc/update/nix/multiprocessing/.do_not_run/switch.php +++ b/misc/update/nix/multiprocessing/.do_not_run/switch.php @@ -323,8 +323,11 @@ 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 (\Exception $e) { } } From dd9a20dc3a56cd2b60cd450a4308b14aab551497 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Fri, 16 Jun 2017 14:46:17 +0200 Subject: [PATCH 39/49] Fix exception type catched from Exception to proper PDOException --- misc/update/nix/multiprocessing/.do_not_run/switch.php | 2 +- nntmux/libraries/Forking.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/misc/update/nix/multiprocessing/.do_not_run/switch.php b/misc/update/nix/multiprocessing/.do_not_run/switch.php index 62bb30d97..9dd4f6a17 100644 --- a/misc/update/nix/multiprocessing/.do_not_run/switch.php +++ b/misc/update/nix/multiprocessing/.do_not_run/switch.php @@ -327,7 +327,7 @@ function collectionCheck(&$pdo, $groupID) if ($pdo->queryOneRow(sprintf('SELECT id FROM collections_%d LIMIT 1', $groupID)) === false) { exit(); } - } catch (\Exception $e) { + } catch (\PDOException $e) { } } diff --git a/nntmux/libraries/Forking.php b/nntmux/libraries/Forking.php index 71d720340..2ae5f117c 100755 --- a/nntmux/libraries/Forking.php +++ b/nntmux/libraries/Forking.php @@ -601,7 +601,7 @@ class Forking extends \fork_daemon if ($this->pdo->queryOneRow(sprintf('SELECT id FROM collections_%d LIMIT 1', $group['id'])) !== false) { $this->work[] = ['id' => $group['id']]; } - } catch (\Exception $e) { + } catch (\PDOException $e) { } } } From 88eab42e749efe364ced3e5397005e064ffbdef9 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Fri, 16 Jun 2017 14:52:59 +0200 Subject: [PATCH 40/49] One more try --- misc/update/nix/multiprocessing/.do_not_run/switch.php | 3 ++- nntmux/libraries/Forking.php | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/misc/update/nix/multiprocessing/.do_not_run/switch.php b/misc/update/nix/multiprocessing/.do_not_run/switch.php index 9dd4f6a17..31d585ad4 100644 --- a/misc/update/nix/multiprocessing/.do_not_run/switch.php +++ b/misc/update/nix/multiprocessing/.do_not_run/switch.php @@ -327,7 +327,8 @@ function collectionCheck(&$pdo, $groupID) if ($pdo->queryOneRow(sprintf('SELECT id FROM collections_%d LIMIT 1', $groupID)) === false) { exit(); } - } catch (\PDOException $e) { + } catch (PDOException $e) { + $e->getMessage(); } } diff --git a/nntmux/libraries/Forking.php b/nntmux/libraries/Forking.php index 2ae5f117c..ae5c29325 100755 --- a/nntmux/libraries/Forking.php +++ b/nntmux/libraries/Forking.php @@ -602,6 +602,7 @@ class Forking extends \fork_daemon $this->work[] = ['id' => $group['id']]; } } catch (\PDOException $e) { + $e->getMessage(); } } } From cedaffa268ee7f404c7da642c64b299dcb5246f9 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Fri, 16 Jun 2017 15:01:50 +0200 Subject: [PATCH 41/49] Change matching for checkXXXInfoExists function --- nntmux/XXX.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nntmux/XXX.php b/nntmux/XXX.php index 4d9259515..608638e9f 100755 --- a/nntmux/XXX.php +++ b/nntmux/XXX.php @@ -778,7 +778,7 @@ class XXX */ protected function checkXXXInfoExists($releaseName) { - return $this->pdo->queryOneRow(sprintf('SELECT id, title FROM xxxinfo WHERE title %s', $this->pdo->likeString($releaseName, true, true))); + return $this->pdo->queryOneRow(sprintf('SELECT id, title FROM xxxinfo WHERE title %s', $this->pdo->likeString($releaseName, false, true))); } /** From a1a3b2bde3a6dba572884d0b0c9da11f84b1a125 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Fri, 16 Jun 2017 15:35:57 +0200 Subject: [PATCH 42/49] Fix AEBN covers --- nntmux/processing/adult/AEBN.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nntmux/processing/adult/AEBN.php b/nntmux/processing/adult/AEBN.php index 7d4f00866..dfd18697b 100755 --- a/nntmux/processing/adult/AEBN.php +++ b/nntmux/processing/adult/AEBN.php @@ -102,7 +102,8 @@ class AEBN extends AdultMovies */ protected function covers() { - if ($ret = $this->_html->find('div#md-boxCover, img[itemprop=thumbnailUrl]', 1)) { + $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; From 2ae8a0af4aaa6fee650b7a18c94091b600bf5ea7 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Fri, 16 Jun 2017 15:41:41 +0200 Subject: [PATCH 43/49] Revert XXX class idcheck to -2. --- nntmux/XXX.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nntmux/XXX.php b/nntmux/XXX.php index 608638e9f..29141ce13 100755 --- a/nntmux/XXX.php +++ b/nntmux/XXX.php @@ -628,8 +628,8 @@ class XXX } $res = $mov->getAll(); } else { - // Nothing was found, go ahead and set to -6 - return AdultMovies::NO_MATCH_FOUND; + // Nothing was found, go ahead and set to -2 + return -2; } $res['cast'] = !empty($res['cast']) ? implode(',', $res['cast']) : ''; @@ -675,7 +675,7 @@ class XXX $this->pdo->queryExec(sprintf('UPDATE xxxinfo SET cover = %d, backdrop = %d WHERE id = %d', $mov['cover'], $mov['backdrop'], $xxxID)); } else { - $xxxID = AdultMovies::NO_MATCH_FOUND; + $xxxID = -2; } // Insert New XXX Information @@ -739,7 +739,7 @@ class XXX // Loop over releases. foreach ($res as $arr) { - $idcheck = AdultMovies::NO_MATCH_FOUND; + $idcheck = -2; // Try to get a name. if ($this->parseXXXSearchName($arr['searchname']) !== false) { From 11fcb36a76682ba9f989757614792f7ff6378d6b Mon Sep 17 00:00:00 2001 From: DariusIII Date: Fri, 16 Jun 2017 17:25:11 +0200 Subject: [PATCH 44/49] Try to prevent bad data --- nntmux/XXX.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nntmux/XXX.php b/nntmux/XXX.php index 29141ce13..5bc1ee951 100755 --- a/nntmux/XXX.php +++ b/nntmux/XXX.php @@ -4,7 +4,6 @@ namespace nntmux; use app\models\Settings; use nntmux\db\DB; -use nntmux\processing\adult\AdultMovies; use nntmux\processing\adult\AEBN; use nntmux\processing\adult\ADM; use nntmux\processing\adult\ADE; @@ -682,7 +681,7 @@ class XXX if ($check === false) { $xxxID = $this->pdo->queryInsert( sprintf(' - INSERT IGNORE INTO xxxinfo + 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())', From 89053b8d96b672efd0765a1227dc24486b650076 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Fri, 16 Jun 2017 19:18:30 +0200 Subject: [PATCH 45/49] Fix bad PHPdocblocks --- nntmux/XXX.php | 10 ++++------ nntmux/processing/adult/AEBN.php | 2 ++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/nntmux/XXX.php b/nntmux/XXX.php index 5bc1ee951..c9e5af820 100755 --- a/nntmux/XXX.php +++ b/nntmux/XXX.php @@ -552,14 +552,12 @@ class XXX } /** - * Fetch xxx info for the movie. - * * @param $movie * - * @return bool + * @return false|int|string * @throws \Exception */ - public function updateXXXInfo($movie): bool + public function updateXXXInfo($movie) { $this->whichclass = 'aebn'; $mov = new AEBN(); @@ -651,7 +649,7 @@ class XXX ]; $check = $this->pdo->queryOneRow(sprintf('SELECT id FROM xxxinfo WHERE title = %s', $this->pdo->escapeString($mov['title']))); - $xxxID = 0; + $xxxID = -2; if (isset($check['id'])) { $xxxID = $check['id']; } @@ -702,7 +700,7 @@ class XXX 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']))) + ColorCLI::headerOver(($xxxID !== false ? 'Added XXX movie: ' . ColorCLI::primary($mov['title']) : 'Nothing to update for XXX movie: ' . ColorCLI::primary($mov['title']))) ); } diff --git a/nntmux/processing/adult/AEBN.php b/nntmux/processing/adult/AEBN.php index dfd18697b..90f86ac4f 100755 --- a/nntmux/processing/adult/AEBN.php +++ b/nntmux/processing/adult/AEBN.php @@ -72,6 +72,8 @@ class AEBN extends AdultMovies * Sets the variables that used throughout the class * * @param array $options + * + * @throws \Exception */ public function __construct(array $options = []) { From 9fd698cd8cc8da89517548d5c948eb2ca3305fdb Mon Sep 17 00:00:00 2001 From: DariusIII Date: Sat, 17 Jun 2017 00:25:06 +0200 Subject: [PATCH 46/49] Fix inserting of xxx releases --- nntmux/XXX.php | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/nntmux/XXX.php b/nntmux/XXX.php index c9e5af820..60a1bd7f5 100755 --- a/nntmux/XXX.php +++ b/nntmux/XXX.php @@ -654,22 +654,24 @@ class XXX $xxxID = $check['id']; } + // BoxCover. + $cover = 0; + if (isset($mov['cover'])) { + $cover = $this->releaseImage->saveImage($xxxID . '-cover', $mov['cover'], $this->imgSavePath); + } + + // BackCover. + $backdrop = 0; + if (isset($mov['backdrop'])) { + $backdrop = $this->releaseImage->saveImage($xxxID . '-backdrop', $mov['backdrop'], $this->imgSavePath, 1920, 1024); + } + // Update Current XXX Information 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)); + $this->pdo->queryExec(sprintf('UPDATE xxxinfo SET cover = %d, backdrop = %d WHERE id = %d', $cover, $backdrop, $xxxID)); } else { $xxxID = -2; @@ -682,7 +684,7 @@ class XXX 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())', + (%s, %s, COMPRESS(%s), %s, %s, %s, %s, %s, %s, %s, %s, %d, %d, NOW(), NOW())', $this->pdo->escapeString($mov['title']), $this->pdo->escapeString($mov['tagline']), $this->pdo->escapeString($mov['plot']), @@ -693,14 +695,16 @@ class XXX $this->pdo->escapeString($mov['productinfo']), $this->pdo->escapeString($mov['trailers']), $this->pdo->escapeString($mov['directurl']), - $this->pdo->escapeString($mov['classused']) + $this->pdo->escapeString($mov['classused']), + $cover, + $backdrop ) ); } if ($this->echooutput) { ColorCLI::doEcho( - ColorCLI::headerOver(($xxxID !== false ? 'Added XXX movie: ' . ColorCLI::primary($mov['title']) : 'Nothing to update for XXX movie: ' . ColorCLI::primary($mov['title']))) + ColorCLI::headerOver(($xxxID !== false ? 'Added/updated XXX movie: ' . ColorCLI::primary($mov['title']) : 'Nothing to update for XXX movie: ' . ColorCLI::primary($mov['title']))) ); } From aaea7bd59388e3f6bec0455b414bb2a45716a2ec Mon Sep 17 00:00:00 2001 From: DariusIII Date: Sun, 18 Jun 2017 22:38:56 +0200 Subject: [PATCH 47/49] Merge PR #145 by Nightah - Admin Menu cleanup --- Changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changelog b/Changelog index 49a3839d7..1f8a9ef30 100755 --- a/Changelog +++ b/Changelog @@ -1,3 +1,5 @@ +2017-06-18 DariusIII + * 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 From e4987e471c9094a72e04df0501563701a2bc3797 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Sun, 18 Jun 2017 23:36:30 +0200 Subject: [PATCH 48/49] Update laravel/framework --- composer.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.lock b/composer.lock index 03425a3ea..9571015c9 100644 --- a/composer.lock +++ b/composer.lock @@ -2541,16 +2541,16 @@ }, { "name": "laravel/framework", - "version": "v5.4.26", + "version": "v5.4.27", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "a7ebbfab64111e24f8e584db64e2be9279ded357" + "reference": "66f5e1b37cbd66e730ea18850ded6dc0ad570404" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/a7ebbfab64111e24f8e584db64e2be9279ded357", - "reference": "a7ebbfab64111e24f8e584db64e2be9279ded357", + "url": "https://api.github.com/repos/laravel/framework/zipball/66f5e1b37cbd66e730ea18850ded6dc0ad570404", + "reference": "66f5e1b37cbd66e730ea18850ded6dc0ad570404", "shasum": "" }, "require": { @@ -2666,7 +2666,7 @@ "framework", "laravel" ], - "time": "2017-06-13T18:58:49+00:00" + "time": "2017-06-15T19:08:25+00:00" }, { "name": "league/flysystem", From 103130ba7c2df66c30e8102b3d1a130b1a9325dc Mon Sep 17 00:00:00 2001 From: DariusIII Date: Mon, 19 Jun 2017 00:05:33 +0200 Subject: [PATCH 49/49] Improve XXX releases logic --- Changelog | 1 + nntmux/XXX.php | 54 ++++++++++++++++++++++++++------------------------ 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/Changelog b/Changelog index 1f8a9ef30..3ab78669c 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 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) diff --git a/nntmux/XXX.php b/nntmux/XXX.php index 60a1bd7f5..0571f7c6b 100755 --- a/nntmux/XXX.php +++ b/nntmux/XXX.php @@ -559,6 +559,8 @@ class XXX */ public function updateXXXInfo($movie) { + $cover = $backdrop = 0; + $xxxID = -2; $this->whichclass = 'aebn'; $mov = new AEBN(); $mov->cookie = $this->cookie; @@ -649,32 +651,23 @@ class XXX ]; $check = $this->pdo->queryOneRow(sprintf('SELECT id FROM xxxinfo WHERE title = %s', $this->pdo->escapeString($mov['title']))); - $xxxID = -2; - if (isset($check['id'])) { - $xxxID = $check['id']; - } - // BoxCover. - $cover = 0; - if (isset($mov['cover'])) { - $cover = $this->releaseImage->saveImage($xxxID . '-cover', $mov['cover'], $this->imgSavePath); - } + if ($check['id'] > 0) { - // BackCover. - $backdrop = 0; - if (isset($mov['backdrop'])) { - $backdrop = $this->releaseImage->saveImage($xxxID . '-backdrop', $mov['backdrop'], $this->imgSavePath, 1920, 1024); - } - - // Update Current XXX Information - 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']; - $this->pdo->queryExec(sprintf('UPDATE xxxinfo SET cover = %d, backdrop = %d WHERE id = %d', $cover, $backdrop, $xxxID)); + // Update BoxCover. + if (!empty($mov['cover'])) { + $cover = $this->releaseImage->saveImage($xxxID . '-cover', $mov['cover'], $this->imgSavePath); + } - } else { - $xxxID = -2; + // 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 @@ -682,9 +675,9 @@ class XXX $xxxID = $this->pdo->queryInsert( sprintf(' INSERT INTO xxxinfo - (title, tagline, plot, genre, director, actors, extras, productinfo, trailers, directurl, classused, cover, backdrop, createddate, updateddate) + (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, %d, %d, NOW(), NOW())', + (%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']), @@ -695,11 +688,20 @@ class XXX $this->pdo->escapeString($mov['productinfo']), $this->pdo->escapeString($mov['trailers']), $this->pdo->escapeString($mov['directurl']), - $this->pdo->escapeString($mov['classused']), - $cover, - $backdrop + $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) {