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