diff --git a/newznab/controllers/ADE.php b/newznab/controllers/ADE.php index 9f38d80a4..a91942085 100644 --- a/newznab/controllers/ADE.php +++ b/newznab/controllers/ADE.php @@ -1,33 +1,37 @@ _tmpResponse); } - /** - * Gets the direct link information and returns it - * @return array|bool - */ - public function getDirect() - { - if (isset($this->directlink)) { - if ($this->getUrl() === false) { - return false; - } else { - $this->_html->load($this->_response); - - return $this->getAll(); - } - } - - return false; - } - - public function getAll() - { - $results = array(); - if (isset($this->_directUrl)) { - $results['directurl'] = $this->_directUrl; - $results['title'] = $this->_title; - } - if (is_array($this->sypnosis(true))) { - $results = array_merge($results, $this->sypnosis(true)); - } - if (is_array($this->productInfo(true))) { - $results = array_merge($results, $this->productInfo(true)); - } - if (is_array($this->cast(true))) { - $results = array_merge($results, $this->cast(true)); - } - if (is_array($this->genres())) { - $results = array_merge($results, $this->genres()); - } - if (is_array($this->covers())) { - $results = array_merge($results, $this->covers()); - } - if (is_array($this->trailers())) { - $results = array_merge($results, $this->trailers()); - } - return $results; - } - - /** - * Gets the sypnosis and tagline - * - * @param bool $tagline - Include tagline? true/false - * - * @return array - plot,tagline - */ - public function sypnosis($tagline = false) - { - if ($tagline === true) { - if ($ret = $this->_html->find("p.Tagline", 0)){ - if (!empty($ret->plaintext)) { - $this->_res['tagline'] = trim($ret->plaintext); - } - } - } - if ($ret = @$this->_html->find("p.Tagline", 0)->next_sibling()->next_sibling()) { - $this->_res['sypnosis'] = trim($ret->innertext); - } - - return $this->_res; - } - - /** - * Gets Product Information and/or Features - * - * @param bool $features Include features? true/false - * - * @return array - ProductInfo/Extras = features - */ - public function productInfo($features = false) - { - $dofeature = null; - $this->_tmpResponse = str_ireplace("Section ProductInfo", "spdinfo", $this->_response); - $this->_edithtml->load($this->_tmpResponse); - if ($ret = $this->_edithtml->find("div[class=spdinfo]", 0)) { - $this->_tmpResponse = trim($ret->outertext); - $ret = $this->_edithtml->load($this->_tmpResponse); - foreach ($ret->find("text") as $strong) { - if (trim($strong->innertext) == "Features") { - $dofeature = true; - } - if ($dofeature != true) { - if (trim($strong->innertext) != " ") { - $this->_res['productinfo'][] = trim($strong->innertext); - } - } else { - if ($features == true) { - $this->_res['extras'][] = trim($strong->innertext); - } - } - } - - array_shift($this->_res['productinfo']); - array_shift($this->_res['productinfo']); - $this->_res['productinfo'] = array_chunk($this->_res['productinfo'], 2, false); - } - $this->_edithtml->clear(); - unset($this->_tmpResponse); - unset($ret); - - return $this->_res; - } - - /** - * Gets the cast members and/or awards - * - * @param bool $awards - Include Awards? true/false - * - * @return array - cast,awards - */ - public function cast($awards = false) - { - $this->_tmpResponse = str_ireplace("Section Cast", "scast", $this->_response); - $this->_edithtml->load($this->_tmpResponse); - - - if ($ret = $this->_edithtml->find("div[class=scast]", 0)) { - $this->_tmpResponse = trim($ret->outertext); - $ret = $this->_edithtml->load($this->_tmpResponse); - foreach ($ret->find("a.PerformerName") as $a) { - if ($a->plaintext != "(bio)") { - if ($a->plaintext != "(interview)") { - $this->_res['cast'][] = trim($a->plaintext); - } - } - } - if ($awards == true) { - if ($ret->find("ul", 1)) { - foreach ($ret->find("ul", 1)->find("li, strong") as $li) { - $this->_res['awards'][] = trim($li->plaintext); - } - } - } - $this->_edithtml->clear(); - unset($ret); - unset($this->_tmpResponse); - } - - return $this->_res; - } - - /** - * Gets categories, if exists return array else return false - * @return mixed array|bool - Categories, false - */ - public function genres() - { - $categories = null; - $this->_tmpResponse = str_ireplace("Section Categories", "scat", $this->_response); - $this->_edithtml->load($this->_tmpResponse); - if ($ret = $this->_edithtml->find("div[class=scat]", 0)) { - $this->_tmpResponse = trim($ret->outertext); - $ret = $this->_edithtml->load($this->_tmpResponse); - - foreach ($ret->find("p, a") as $categories) { - $categories = trim($categories->plaintext); - if (stristr($categories, ",")) { - $categories = explode(",", $categories); - break; - } - } - $categories = array_map('trim', $categories); - $this->_res['genres'] = $categories; - } - $this->_edithtml->clear(); - unset($this->_tmpResponse); - unset($ret); - - return $this->_res; - } - - /** - * Gets cover images for the xxx release - * @return array - Boxcover and backcover - */ - public function covers() - { - $this->getUrl($this->_boxCover . $this->_urlFound); - $this->_html->load($this->_response); - foreach ($this->_html->find("div[id=FrontBoxCover], img[itemprop=image]") as $img) { - if (stristr($img->src, "h.jpg")) { - $this->_res['boxcover'] = $img->src; - break; - } - } - $this->getUrl($this->_backCover . $this->_urlFound); - $this->_html->load($this->_response); - foreach ($this->_html->find("div[id=BackBoxCover], img[itemprop=image]") as $img) { - if (stristr($img->src, "bh.jpg")) { - $this->_res['backcover'] = $img->src; - break; - } - } - - if (empty($this->_res['boxcover'])) { - if ($ret = $this->_html->find("a[rel=boxcover]", 0)) { - if (stristr($ret->href, "h.jpg")) { - $this->_res['boxcover'] = $ret->href; - $this->_res['backcoer'] = str_ireplace("h.jpg", "bh.jpg", $ret->href); - } - if (stristr($ret->href, "m.jpg")) { - $this->_res['boxcover'] = str_ireplace("m.jpg", "h.jpg", $ret->href); - $this->_res['backcoer'] = str_ireplace("m.jpg", "bh.jpg", $ret->href); - } - } - } - - return $this->_res; - } - /** * Gets Trailer Movies * @return array - url, streamid, basestreamingurl @@ -331,10 +117,210 @@ class ADE return $this->_res; } + /** + * Gets cover images for the xxx release + * @return array - Boxcover and backcover + */ + public function covers() + { + if ($ret = $this->_html->find("div#Boxcover, img[itemprop=image]", 1)) { + $this->_res['boxcover'] = preg_replace('/m\.jpg/', 'h.jpg', $ret->src); + $this->_res['backcover'] = preg_replace('/m\.jpg/', 'bh.jpg', $ret->src); + } + + return $this->_res; + } + + /** + * Gets the sypnosis and tagline + * + * @param bool $tagline - Include tagline? true/false + * + * @return array - plot,tagline + */ + public function sypnosis($tagline = false) + { + if ($tagline === true) { + if ($ret = $this->_html->find("p.Tagline", 0)) { + if (!empty($ret->plaintext)) { + $this->_res['tagline'] = trim($ret->plaintext); + } + } + } + if ($ret = @$this->_html->find("p.Tagline", 0)->next_sibling()->next_sibling()) { + $this->_res['sypnosis'] = trim($ret->innertext); + } + + return $this->_res; + } + + /** + * Gets the cast members and/or awards + * + * @param bool $awards - Include Awards? true/false + * + * @return array - cast, awards + */ + public function cast($awards = false) + { + $this->_tmpResponse = str_ireplace("Section Cast", "scast", $this->_response); + $this->_edithtml->load($this->_tmpResponse); + + + if ($ret = $this->_edithtml->find("div[class=scast]", 0)) { + $this->_tmpResponse = trim($ret->outertext); + $ret = $this->_edithtml->load($this->_tmpResponse); + foreach ($ret->find("a.PerformerName") as $a) { + if ($a->plaintext != "(bio)") { + if ($a->plaintext != "(interview)") { + $this->_res['cast'][] = trim($a->plaintext); + } + } + } + if ($awards == true) { + if ($ret->find("ul", 1)) { + foreach ($ret->find("ul", 1)->find("li, strong") as $li) { + $this->_res['awards'][] = trim($li->plaintext); + } + } + } + $this->_edithtml->clear(); + unset($ret); + unset($this->_tmpResponse); + } + return $this->_res; + } + + /** + * Gets Genres, if exists return array else return false + * @return mixed array - Genres + */ + public function genres() + { + $genres = []; + $this->_tmpResponse = str_ireplace("Section Categories", "scat", $this->_response); + $this->_edithtml->load($this->_tmpResponse); + if ($ret = $this->_edithtml->find("div[class=scat]", 0)) { + $ret = $ret->find("p", 0); + $this->_tmpResponse = trim($ret->outertext); + $ret = $this->_edithtml->load($this->_tmpResponse); + + foreach ($ret->find("a") as $categories) { + $categories = trim($categories->plaintext); + if (stristr($categories, ",")) { + $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); + unset($ret); + return $this->_res; + } + + /** + * Gets Product Information and/or Features + * + * @param bool $features Include features? true/false + * + * @return array - ProductInfo/Extras = features + */ + public function productInfo($features = false) + { + $dofeature = null; + $this->_tmpResponse = str_ireplace("Section ProductInfo", "spdinfo", $this->_response); + $this->_edithtml->load($this->_tmpResponse); + if ($ret = $this->_edithtml->find("div[class=spdinfo]", 0)) { + $this->_tmpResponse = trim($ret->outertext); + $ret = $this->_edithtml->load($this->_tmpResponse); + foreach ($ret->find("text") as $strong) { + if (trim($strong->innertext) == "Features") { + $dofeature = true; + } + if ($dofeature != true) { + if (trim($strong->innertext) != " ") { + $this->_res['productinfo'][] = trim($strong->innertext); + } + } else { + if ($features == true) { + $this->_res['extras'][] = trim($strong->innertext); + } + } + } + + array_shift($this->_res['productinfo']); + array_shift($this->_res['productinfo']); + $this->_res['productinfo'] = array_chunk($this->_res['productinfo'], 2, false); + } + $this->_edithtml->clear(); + unset($this->_tmpResponse); + unset($ret); + + return $this->_res; + } + + /** + * Gets the direct link information and returns it + * @return array|bool + */ + public function getDirect() + { + if (!empty($this->directLink) && $this->getUrl() !== false) { + $this->_html->load($this->_response); + return $this->getAll(); + } + return false; + } + /** + * Searches xxx name. + * @return bool - True if releases has 90% match, else false + */ + public function search() + { + if (!isset($this->searchTerm)) { + return false; + } + if ($this->getUrl($this->_dvdQuery . rawurlencode($this->searchTerm)) === false) { + return false; + } else { + $this->_html->load($this->_response); + if ($ret = $this->_html->find("a.boxcover", 0)) { + $title = $ret->title; + $title = preg_replace('/XXX/', '', $title); + $title = preg_replace('/\(.*?\)|[-._]/i', ' ', $title); + $ret = (string)trim($ret->href); + similar_text(strtolower($this->searchTerm), strtolower($title), $p); + if ($p >= 90) { + $this->found = true; + $this->_urlFound = $ret; + $this->_directUrl = self::ADE . $ret; + $this->_title = trim($title); + unset($ret); + $this->_html->clear(); + $this->getUrl($this->_urlFound); + $this->_html->load($this->_response); + } else { + $this->found = false; + + return false; + } + } else { + return false; + } + } + return false; + } + /** * Gets raw html content using adeurl and any trailing url. * - * @param null $trailing - required + * @param string $trailing - required * * @return bool - true if page has content */ @@ -352,6 +338,7 @@ class ADE curl_setopt($this->_ch, CURLOPT_VERBOSE, 0); curl_setopt($this->_ch, CURLOPT_USERAGENT, "Firefox/2.0.0.1"); curl_setopt($this->_ch, CURLOPT_FAILONERROR, 1); + curl_setopt_array($this->_ch, Utility::curlSslContextOptions()); $this->_response = curl_exec($this->_ch); if (!$this->_response) { curl_close($this->_ch); @@ -362,52 +349,36 @@ class ADE return true; } - - - /* - * Gets all Information. + /** + * Gets All Information from the methods * * @return array */ - - /** - * Searches xxx name. - * @return bool - True if releases has 90% match, else false - */ - public function search() + public function getAll() { - if (!isset($this->searchTerm)) { - return false; + $results = []; + if (isset($this->_directUrl)) { + $results['directurl'] = $this->_directUrl; + $results['title'] = $this->_title; } - if ($this->getUrl($this->_dvdQuery . rawurlencode($this->searchTerm)) === false) { - return false; - } else { - $this->_html->load($this->_response); - if ($ret = $this->_html->find("a.boxcover", 0)){ - $title = $ret->title; - $title = preg_replace('/XXX/', '', $title); - $title = preg_replace('/\(.*?\)|[-._]/i', ' ', $title); - $ret = (string)trim($ret->href); - similar_text($this->searchTerm, $title, $p); - if ($p >= 90) { - $this->found = true; - $this->_urlFound = $ret; - $this->_directUrl = self::ADE . $ret; - $this->_title = trim($title); - unset($ret); - $this->_html->clear(); - $this->getUrl($this->_urlFound); - $this->_html->load($this->_response); - } else { - $this->found = false; - - return false; - } - } else { - return false; - } + if (is_array($this->sypnosis(true))) { + $results = array_merge($results, $this->sypnosis(true)); } - - return false; + if (is_array($this->productInfo(true))) { + $results = array_merge($results, $this->productInfo(true)); + } + if (is_array($this->cast(true))) { + $results = array_merge($results, $this->cast(true)); + } + if (is_array($this->genres())) { + $results = array_merge($results, $this->genres()); + } + if (is_array($this->covers())) { + $results = array_merge($results, $this->covers()); + } + if (is_array($this->trailers())) { + $results = array_merge($results, $this->trailers()); + } + return $results; } } \ No newline at end of file diff --git a/newznab/controllers/ADM.php b/newznab/controllers/ADM.php index e99ffeafd..ba2feaa51 100644 --- a/newznab/controllers/ADM.php +++ b/newznab/controllers/ADM.php @@ -11,9 +11,9 @@ class ADM * Define Adult DVD Marketplace url * Needed Search Queries Constant */ - const ADMURL = "http://www.adultdvdmarketplace.com"; - const IF18 = "http://www.adultdvdmarketplace.com/xcart/adult_dvd/disclaimer.php?action=enter&site=intl&return_url="; - const TRAILINGSEARCH = "/xcart/adult_dvd/advanced_search.php?sort_by=relev&title="; + const ADMURL = "http://www.adultdvdmarketplace.com"; + const IF18 = "http://www.adultdvdmarketplace.com/xcart/adult_dvd/disclaimer.php?action=enter&site=intl&return_url="; + const TRAILINGSEARCH = "/xcart/adult_dvd/advanced_search.php?sort_by=relev&title="; /** * Define a cookie file location for curl @@ -42,7 +42,7 @@ class ADM /** * Simple Html Dom Object * - * @var simple_html_dom + * @var \simple_html_dom */ protected $_html; @@ -56,7 +56,7 @@ class ADM * * @var array */ - protected $_res = array(); + protected $_res = []; /** * Curl Raw Html @@ -78,7 +78,7 @@ class ADM public function __construct() { - $this->_html = new simple_html_dom(); + $this->_html = new \simple_html_dom(); if (isset($this->cookie)) { $this->getUrl(); } @@ -120,11 +120,11 @@ class ADM public function sypnosis() { if ($ret = $this->_html->find('span[itemprop=description]', 0)) { - if(preg_match('/(?\(.*)\<\/b\>)/i', $ret->innertext, $matches)){ + if (preg_match('/(?\(.*)\<\/b\>)/i', $ret->innertext, $matches)) { $this->_res['tagline'] = trim(strip_tags($matches['tagline'])); $ret->plaintext = str_replace($matches['tagline'], '', $ret->innertext); } - $this->_res['sypnosis'] = trim(strip_tags($ret->plaintext,"
")); + $this->_res['sypnosis'] = trim(strip_tags($ret->plaintext, "
")); } else { $this->_res['sypnosis'] = "N/A"; } @@ -163,7 +163,7 @@ class ADM */ public function cast() { - $cast = array(); + $cast = []; foreach ($this->_html->find('td.section_heading') as $category) { if (trim($category->plaintext) == "CAST") { foreach ($this->_html->find('td.GrayDialogBody') as $td) { @@ -186,7 +186,7 @@ class ADM */ public function genres() { - $genres = array(); + $genres = []; foreach ($this->_html->find('td.DarkGrayTable') as $category) { if (trim($category->plaintext) == "CATEGORY") { foreach ($category->next_sibling()->find('a') as $e) { @@ -201,7 +201,7 @@ class ADM /** * Searches for match against searchterm - * @return bool, true if search = 100% + * @return bool - true if search = 100% */ public function search() { @@ -219,11 +219,11 @@ class ADM $comparesearch = preg_replace('/[^\w]/', '', $this->searchTerm); similar_text($comparetitle, $comparesearch, $p); if ($p == 100) { - if(preg_match('/\/(?\d+)\.jpg/i', $ret->src, $matches)){ - $this->_title = trim($title); - $this->_trailUrl = "/dvd_view_" . (string)$matches['sku'] . ".html"; + if (preg_match('/\/(?\d+)\.jpg/i', $ret->src, $matches)) { + $this->_title = trim($title); + $this->_trailUrl = "/dvd_view_" . (string)$matches['sku'] . ".html"; $this->_directUrl = self::ADMURL . $this->_trailUrl; - if($this->getUrl() !== false){ + if ($this->getUrl() !== false) { $result = true; } } @@ -243,7 +243,7 @@ class ADM */ public function getAll() { - $results = array(); + $results = []; if (isset($this->_directUrl)) { $results['title'] = $this->_title; $results['directurl'] = $this->_directUrl; @@ -288,7 +288,7 @@ class ADM $ch = curl_init(self::IF18); } - if($usepost === true){ + if ($usepost === true) { curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $this->_postParams); diff --git a/newznab/controllers/AEBN.php b/newznab/controllers/AEBN.php index 28d1ae4f5..dbe04edb4 100644 --- a/newznab/controllers/AEBN.php +++ b/newznab/controllers/AEBN.php @@ -2,8 +2,24 @@ require_once NN_LIBS . 'simple_html_dom.php'; +use newznab\utility\Utility; + class AEBN { + /** + * Cookie File location used in curl + * + * @var string + */ + public $cookie = ""; + + /** + * Keyword to search + * + * @var string + */ + public $searchTerm = ""; + /** * Url Constants used within this class */ @@ -12,36 +28,22 @@ class AEBN 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="; - /** - * Cookie File location used in curl - * - * @var string - */ - public $cookie = ""; - /** - * Keyword to search - * - * @var string - */ - public $searchTerm = ""; + /** * Sets the current site to search - * * @var string */ protected $_currentSite = "straight"; /** * Direct Url in getAll method - * * @var string */ protected $_directUrl = ""; /** * Simple Html Dom Object - * - * @var simple_html_dom + * @var \simple_html_dom */ protected $_html; @@ -50,7 +52,7 @@ class AEBN * * @var array */ - protected $_postParams = array(); + protected $_postParams = []; /** * Raw Html response from curl @@ -63,35 +65,32 @@ class AEBN * * @var array */ - protected $_res = array(); + protected $_res = []; /** * If searchTerm is found - * * @var bool */ protected $_searchFound = false; /** * Sets title in getAll method - * * @var string */ protected $_title = ""; /** * Trailing Url - * * @var string */ protected $_trailUrl = ""; /** * Used in __construct - * * @var array - straight, gay */ - protected $_whichSite = array(); + protected $_whichSite = []; + /** @@ -100,56 +99,13 @@ class AEBN */ public function __construct() { - $this->_whichSite = array("straight" => self::AEBNSURL, "gay" => self::AEBNGURL); + $this->_whichSite = ["straight" => self::AEBNSURL, "gay" => self::AEBNGURL]; $this->_html = new \simple_html_dom(); if (isset($this->cookie)) { $this->getUrl(); } } - /** - * Get Raw html of webpage - * - * @param bool $usepost - * @param string $site - * - * @return bool - */ - private function getUrl($usepost = false, $site = "straight") - { - if (isset($this->_trailUrl)) { - $ch = curl_init($this->_whichSite[$site] . $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); - } - $this->_response = curl_exec($ch); - if (!$this->_response) { - curl_close($ch); - - return false; - } - curl_close($ch); - $this->_html->load($this->_response); - - return true; - } - /** * If they arent' removed from memory. Force them. */ @@ -161,109 +117,71 @@ class AEBN } /** - * Searches for a XXX name - * - * @return bool - */ - public function search() - { - if (!isset($this->searchTerm)) { - return false; - } - $this->_trailUrl = self::TRAILINGSEARCH . urlencode($this->searchTerm); - if ($this->getUrl(false, $this->_currentSite) === false) { - return false; - } else { - if ($count = count($this->_html->find("div.movie"))) { - $i = 1; - foreach ($this->_html->find("div.movie") as $movie) { - $string = "a#FTSMovieSearch_link_title_detail_" . $i; - if ($ret = $movie->find($string, 0)) { - $title = trim($ret->title); - $title = preg_replace('/XXX/', '', $title); - $title = preg_replace('/\(.*?\)|[-._]/i', ' ', $title); - similar_text($this->searchTerm, $title, $p); - if ($p >= 90) { - $this->_title = trim($ret->title); - $this->_trailUrl = $ret->href; - $this->_directUrl = $this->_whichSite[$this->_currentSite] . $this->_trailUrl; - $this->getUrl(false, $this->_currentSite); - - return true; - } else { - continue; - } - } - $i = $i + 1; - } - if ($i === $count || $count === 0) { - if ($this->_currentSite === "gay") { - return false; - } - $this->_currentSite = "gay"; - $this->search(); - } - } else { - return false; - } - } - - return false; - } - - /** - * Gets all the information + * Gets Trailer URL .. will be processed in XXX insertswf * * @return array|bool */ - public function getAll() + public function trailers() { - $results = array(); - if (isset($this->_directUrl)) { - $results['title'] = $this->_title; - $results['directurl'] = $this->_directUrl; - } - if (is_array($this->sypnosis())) { - $results = array_merge($results, $this->sypnosis()); - } - if (is_array($this->productinfo())) { - $results = array_merge($results, $this->productInfo()); - } - if (is_array($this->cast())) { - $results = array_merge($results, $this->cast()); - } - if (is_array($this->genres())) { - $results = array_merge($results, $this->genres()); - } - if (is_array($this->covers())) { - $results = array_merge($results, $this->covers()); - } - if (is_array($this->trailers())) { - $results = array_merge($results, $this->trailers()); - } - if (empty($results) === true) { - return false; - } else { - return $results; + if ($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; + } } + + return $this->_res; } /** - * Gets the sypnosis "plot" + * Gets the front and back cover of the box * * @return array - * */ - public function sypnosis() + public function covers() { - if ($ret = $this->_html->find("span[itemprop=about]", 0)) { - if (is_null($ret)) { - if ($ret = $this->_html->find("div.movieDetailDescription", 0)) { - $this->_res['sypnosis'] = trim($ret->plaintext); - $this->_res['sypnosis'] = preg_replace('/Description:\s/', "", $this->_res['plot']); + if ($ret = $this->_html->find("div#md-boxCover, img[itemprop=thumbnailUrl]", 1)) { + $ret = trim($ret->src); + $this->_res['boxcover'] = str_ireplace("160w.jpg", "xlf.jpg", $ret); + $this->_res['backcover'] = str_ireplace("160w.jpg", "xlb.jpg", $ret); + } + return $this->_res; + } + + /** + * Gets the Genres "Categories". + * + * @return array + */ + public function genres() + { + if ($ret = $this->_html->find("div.md-detailsCategories", 0)) { + foreach ($ret->find("a[itemprop=genre]") as $genre) { + $this->_res['genres'][] = trim($genre->plaintext); + } + } + $this->_res['genres'] = array_unique($this->_res['genres']); + return $this->_res; + } + + /** + * Gets the Cast Members "Stars" and Director if any + * + * @return array + */ + public function cast() + { + if ($ret = $this->_html->find("div.starsFull", 0)) { + foreach ($ret->find("span[itemprop=name]") as $star) { + $this->_res['cast'][] = trim($star->plaintext); + } + } else { + if ($ret = $this->_html->find("div.detailsLink", 0)) { + foreach ($ret->find("span") as $star) { + if (!preg_match("/More/", $star->plaintext) && !preg_match("/Stars/", $star->plaintext)) { + $this->_res['cast'][] = trim($star->plaintext); + } } - } else { - $this->_res['sypnosis'] = trim($ret->plaintext); } } @@ -300,23 +218,21 @@ class AEBN } /** - * Gets the Cast Members "Stars" and Director if any + * Gets the sypnosis "plot" * * @return array + * */ - public function cast() + public function sypnosis() { - if ($ret = $this->_html->find("div.starsFull", 0)) { - foreach ($ret->find("span[itemprop=name]") as $star) { - $this->_res['cast'][] = trim($star->plaintext); - } - } else { - if ($ret = $this->_html->find("div.detailsLink", 0)) { - foreach ($ret->find("span") as $star) { - if (!preg_match("/More/", $star->plaintext) && !preg_match("/Stars/", $star->plaintext)) { - $this->_res['cast'][] = trim($star->plaintext); - } + if ($ret = $this->_html->find("span[itemprop=about]", 0)) { + if (is_null($ret)) { + if ($ret = $this->_html->find("div.movieDetailDescription", 0)) { + $this->_res['sypnosis'] = trim($ret->plaintext); + $this->_res['sypnosis'] = preg_replace('/Description:\s/', "", $this->_res['plot']); } + } else { + $this->_res['sypnosis'] = trim($ret->plaintext); } } @@ -324,51 +240,133 @@ class AEBN } /** - * Gets the Genres "Categories". + * Searches for a XXX name * - * @return array + * @return bool */ - public function genres() + public function search() { - if ($ret = $this->_html->find("div.md-detailsCategories", 0)) { - foreach ($ret->find("a[itemprop=genre]") as $genre) { - $this->_res['genres'][] = trim($genre->plaintext); + if (!isset($this->searchTerm)) { + return false; + } + $this->_trailUrl = self::TRAILINGSEARCH . urlencode($this->searchTerm); + if ($this->getUrl(false, $this->_currentSite) === false) { + return false; + } else { + if ($count = count($this->_html->find("div.movie"))) { + $i = 1; + foreach ($this->_html->find("div.movie") as $movie) { + $string = "a#FTSMovieSearch_link_title_detail_" . $i; + if ($ret = $movie->find($string, 0)) { + $title = preg_replace('/XXX/', '', $ret->title); + $title = preg_replace('/\(.*?\)|[-._]/i', ' ', $title); + $title = trim($title); + similar_text(strtolower($this->searchTerm), strtolower($title), $p); + if ($p >= 90) { + $this->_title = trim($ret->title); + $this->_trailUrl = $ret->href; + $this->_directUrl = $this->_whichSite[$this->_currentSite] . $this->_trailUrl; + $this->getUrl(false, $this->_currentSite); + return true; + } else { + continue; + } + } + $i++; + } + if ($i === $count || $count === 0) { + if ($this->_currentSite === "gay") { + return false; + } + $this->_currentSite = "gay"; + $this->search(); + } + } else { + return false; } } - return $this->_res; + return false; } /** - * Gets the front and back cover of the box - * - * @return array - */ - public function covers() - { - if ($ret = $this->_html->find("img#boxImage, img[itemprop=thumbnailUrl]", 1)) { - $ret = trim($ret->src); - $this->_res['boxcover'] = str_ireplace("160w.jpg", "xlf.jpg", $ret); - $this->_res['backcover'] = str_ireplace("160w.jpg", "xlb.jpg", $ret); - } - - return $this->_res; - } - - /** - * Gets Trailer URL .. will be processed in XXX insertswf + * Gets all the information * * @return array|bool */ - public function trailers() + public function getAll() { - if ($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;; - } + $results = []; + if (isset($this->_directUrl)) { + $results['title'] = $this->_title; + $results['directurl'] = $this->_directUrl; + } + if (is_array($this->sypnosis())) { + $results = array_merge($results, $this->sypnosis()); + } + if (is_array($this->productinfo())) { + $results = array_merge($results, $this->productInfo()); + } + if (is_array($this->cast())) { + $results = array_merge($results, $this->cast()); + } + if (is_array($this->genres())) { + $results = array_merge($results, $this->genres()); + } + if (is_array($this->covers())) { + $results = array_merge($results, $this->covers()); + } + if (is_array($this->trailers())) { + $results = array_merge($results, $this->trailers()); + } + if (empty($results) === true) { + return false; + } else { + return $results; + } + } + + /** + * Get Raw html of webpage + * + * @param bool $usepost + * @param string $site + * + * @return bool + */ + private function getUrl($usepost = false, $site = "straight") + { + if (isset($this->_trailUrl)) { + $ch = curl_init($this->_whichSite[$site] . $this->_trailUrl); + } else { + $ch = curl_init(self::IF18); } - return $this->_res; + 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; } } \ No newline at end of file diff --git a/newznab/controllers/IAFD.php b/newznab/controllers/IAFD.php index 82a5d7c5e..09064a4d2 100644 --- a/newznab/controllers/IAFD.php +++ b/newznab/controllers/IAFD.php @@ -2,24 +2,26 @@ require_once NN_LIBS . 'simple_html_dom.php'; +use newznab\utility\Utility; + class IAFD { - - - const ADE = "Adult DVD Empire"; - const IAFDSEARCHURL = "http://iafd.com.prx.proxyunblocker.org/results.asp?searchtype=title&searchstring="; - const IAFDURL = "http://iafd.com.prx.proxyunblocker.org"; - const HM = "Hot Movies"; public $classUsed = ""; public $cookie = ""; public $directUrl; public $searchTerm = ""; public $title = ""; + + const ADE = "Adult DVD Empire"; + const ADM = "AdultDVDMarketplace"; + const IAFDSEARCHURL = "http://www.iafd.com/results.asp?searchtype=title&searchstring="; + const IAFDURL = "http://www.iafd.com"; + protected $_dvdFound = false; protected $_doSearch = false; protected $_getRedirect; protected $_html; - protected $_res = array(); + protected $_res = []; protected $_response; @@ -31,48 +33,6 @@ class IAFD } } - 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, "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); - } - $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; - } - public function __destruct() { $this->_html->clear(); @@ -102,12 +62,14 @@ class IAFD $this->_dvdFound = false; break; } - if ($compare === self::HM && !empty($compare)) { - $this->classUsed = "hm"; + 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->directUrl = false; + $this->directUrl = preg_replace('/\?(.*)/', + '', + $this->directUrl); + $this->_dvdFound = false; break; } } @@ -131,7 +93,9 @@ class IAFD if (!isset($this->searchTerm)) { return false; } + $this->_doSearch = true; + if ($this->getUrl() === false) { return false; } else { @@ -155,14 +119,18 @@ class IAFD $secondtitle = preg_replace('/\(([0-9]+)\)/', "", $secondtitle); $secondtitle = preg_replace('/XXX/', '', $secondtitle); $secondtitle = preg_replace('/\(.*?\)|[-._]/i', ' ', $secondtitle); - similar_text($this->searchTerm, trim($firsttitle), $p); + similar_text(strtolower($this->searchTerm), strtolower(trim($firsttitle)), $p); if ($p >= 90) { $this->title = trim($firsttitle); + return true; } else { - similar_text($this->searchTerm, trim($secondtitle), $p); + similar_text(strtolower($this->searchTerm), + strtolower(trim($secondtitle)), + $p); if ($p >= 90) { $this->title = trim($secondtitle); + return true; } else { return false; @@ -178,5 +146,54 @@ class IAFD } + 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, "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 (!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; + } + + } \ No newline at end of file