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; }