[], 'boxcover' => [], 'cast' => [], 'director' => [], 'genres' => [], 'productinfo' => [], 'synopsis' => [], 'trailers' => ['url' => []], ]; /** * Sets title in getAll method. */ protected string $_title = ''; public $cookie; /** * Gets Trailer URL . will be processed in XXX insertswf. */ protected function trailers(): mixed { $ret = $this->_html->find('a[itemprop=trailer]', 0); if (! empty($ret) && preg_match('/movieId=(?\d+)&/', trim($ret->href), $hits)) { $movieid = $hits['movieid']; $this->_res['trailers']['url'] = self::AEBNSURL.self::TRAILERURL.$movieid; } return $this->_res; } /** * Gets the front and back cover of the box. */ protected function covers(): array { $ret = $this->_html->find('div#md-boxCover, img[itemprop=thumbnailUrl]', 1); if ($ret !== false) { $ret = trim($ret->src); if (str_starts_with($ret, '//')) { $ret = 'https:'.$ret; } $this->_res['boxcover'] = str_ireplace('160w.jpg', 'xlf.jpg', $ret); $this->_res['backcover'] = str_ireplace('160w.jpg', 'xlb.jpg', $ret); } return $this->_res; } /** * Gets the Genres "Categories". */ protected function genres(): array { if ($ret = $this->_html->findOne('div.md-detailsCategories')) { foreach ($ret->find('a[itemprop=genre]') as $genre) { $this->_res['genres'][] = trim($genre->plaintext); } } if (! empty($this->_res['genres'])) { $this->_res['genres'] = array_unique($this->_res['genres']); } return $this->_res; } /** * Gets the Cast Members "Stars" and Director if any. */ protected function cast(): array { // Do not reset the whole results array; only populate the cast key. $cast = []; $ret = $this->_html->findOne('div.starsFull'); if (! $ret instanceof SimpleHtmlDomNodeBlank) { foreach ($ret->find('span[itemprop=name]') as $star) { $cast[] = trim($star->plaintext); } } else { $ret = $this->_html->findOne('div.detailsLink'); if (! $ret instanceof SimpleHtmlDomNodeBlank) { foreach ($ret->find('span') as $star) { if (str_contains($star->plaintext, '/More/') && str_contains($star->plaintext, '/Stars/')) { $cast[] = trim($star->plaintext); } } } } if (! empty($cast)) { $this->_res['cast'] = $cast; } return $this->_res; } /** * Gets the product information. */ protected function productInfo(bool $extras = false): mixed { if ($ret = $this->_html->find('div#md-detailsLeft', 0)) { foreach ($ret->find('div') as $div) { foreach ($div->find('span') as $span) { $text = rawurldecode($span->plaintext); $text = preg_replace('/ /', '', $text); $this->_res['productinfo'][] = trim($text); } } if (false !== $key = array_search('Running Time:', $this->_res['productinfo'], false)) { unset($this->_res['productinfo'][$key + 2]); } if (false !== $key = array_search('Director:', $this->_res['productinfo'], false)) { $this->_res['director'] = $this->_res['productinfo'][$key + 1]; unset($this->_res['productinfo'][$key], $this->_res['productinfo'][$key + 1]); } $this->_res['productinfo'] = array_chunk($this->_res['productinfo'], 2, false); } return $this->_res; } /** * Gets the synopsis "plot". */ protected function synopsis(): array { // Prefer the modern schema attribute $ret = $this->_html->findOne('span[itemprop=about]'); if ($ret && $ret->plaintext !== null) { $this->_res['synopsis'] = trim($ret->plaintext); return $this->_res; } // Fallback to legacy description container $ret = $this->_html->findOne('div.movieDetailDescription'); if ($ret && $ret->plaintext !== null) { $text = trim($ret->plaintext); $this->_res['synopsis'] = preg_replace('/^Description:\s*/', '', $text); } return $this->_res; } /** * Searches for a XXX name. */ public function processSite(string $movie): bool { if (empty($movie)) { return false; } $this->_trailerUrl = self::TRAILINGSEARCH.urlencode($movie); $this->_response = getRawHtml(self::AEBNSURL.$this->_trailerUrl, $this->cookie); if ($this->_response !== false) { $i = 1; foreach ($this->_html->loadHtml($this->_response)->find('div.movie') as $mov) { $string = 'a#FTSMovieSearch_link_title_detail_'.$i; if ($ret = $mov->findOne($string)) { $title = str_replace('/XXX/', '', $ret->title); $title = trim(preg_replace('/\(.*?\)|[._-]/', ' ', $title)); similar_text(strtolower($movie), strtolower($title), $p); if ($p >= 90) { $this->_title = trim($ret->title); $this->_trailerUrl = html_entity_decode($ret->href); $this->_directUrl = self::AEBNSURL.$this->_trailerUrl; unset($this->_response); $this->_response = getRawHtml(self::AEBNSURL.$this->_trailerUrl, $this->cookie); $this->_html->loadHtml($this->_response); return true; } continue; } $i++; } } return false; } }