Move getAll function to AdultMovies class

This commit is contained in:
DariusIII
2017-06-26 15:46:48 +02:00
parent aa1dcf1ad2
commit b5fa3dff97
7 changed files with 58 additions and 189 deletions
+1
View File
@@ -1,4 +1,5 @@
2017-06-26 DariusIII
* Chg: Move getAll function to AdultMovies class
* Chg: Update XXX processing, set protected on most methods, AdultMovies do not extend XXX anymore to fix circular reference
* Chg: Add check to XXX class for false returned result in updateXXXInfo function
* Chg: Remove safe_backfill from processStartWork and processEndWork functions in Forking class
+3 -37
View File
@@ -150,11 +150,10 @@ class ADE extends AdultMovies
/**
* Gets Product Information and/or Features
*
* @param bool $features Include features? true/false
*
* @param bool $extras
* @return array - ProductInfo/Extras = features
*/
protected function productInfo($features = false)
protected function productInfo($extras = false)
{
$dofeature = null;
$this->_tmpResponse = str_ireplace('Section ProductInfo', 'spdinfo', $this->_response);
@@ -171,7 +170,7 @@ class ADE extends AdultMovies
$this->_res['productinfo'][] = trim($strong->innertext);
}
} else {
if ($features === true) {
if ($extras === true) {
$this->_res['extras'][] = trim($strong->innertext);
}
}
@@ -224,37 +223,4 @@ class ADE extends AdultMovies
}
return false;
}
/**
* Gets All Information from the methods
*
* @return array
*/
public function getAll()
{
$results = [];
if (!empty($this->_directUrl)) {
$results['directurl'] = $this->_directUrl;
$results['title'] = $this->_title;
}
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())) {
$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());
}
return $results;
}
}
+3 -36
View File
@@ -110,9 +110,11 @@ class ADM extends AdultMovies
* Get Product Information and Director
*
*
* @param bool $extras
*
* @return array
*/
protected function productInfo()
protected function productInfo($extras = false)
{
foreach ($this->_html->find('ul.list-unstyled li') as $li) {
@@ -219,41 +221,6 @@ class ADM extends AdultMovies
return $result;
}
/**
* Gets all information
* @return array
*/
public function getAll()
{
$results = [];
if (!empty($this->_directUrl)) {
$results['title'] = $this->_title;
$results['directurl'] = $this->_directUrl;
}
if (is_array($this->synopsis())) {
$results = array_merge($results, $this->synopsis());
}
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());
}
$results = empty($results) ? false : $results;
return $results;
}
protected function trailers()
{
+3 -39
View File
@@ -155,9 +155,11 @@ class AEBN extends AdultMovies
/**
* Gets the product information
*
* @param bool $extras
*
* @return array
*/
protected function productInfo()
protected function productInfo($extras = false)
{
if ($ret = $this->_html->find('div#md-detailsLeft', 0)) {
foreach ($ret->find('div') as $div) {
@@ -244,42 +246,4 @@ class AEBN extends AdultMovies
return false;
}
/**
* Gets all the information
*
* @return array|bool
*/
public function getAll()
{
$results = [];
if (!empty($this->_directUrl)) {
$results['title'] = $this->_title;
$results['directurl'] = $this->_directUrl;
}
if (is_array($this->synopsis())) {
$results = array_merge($results, $this->synopsis());
}
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());
}
$covers = $this->covers();
if (is_array($covers)) {
$results = array_merge($results, $covers);
}
if (is_array($this->trailers())) {
$results = array_merge($results, $this->trailers());
}
if (empty($results)) {
return false;
}
return $results;
}
}
+44 -3
View File
@@ -10,6 +10,11 @@ abstract class AdultMovies
*/
protected $_html;
/**
* @var string
*/
protected $_title;
/**
* AdultMovies constructor.
*
@@ -23,9 +28,11 @@ abstract class AdultMovies
}
/**
* @param bool $extras
*
* @return mixed
*/
abstract protected function productInfo();
abstract protected function productInfo($extras = false);
/**
* @return mixed
@@ -55,12 +62,46 @@ abstract class AdultMovies
abstract public function processSite($movie);
/**
* @return mixed
* Gets all information
*
* @return array|bool
*/
abstract public function getAll();
public function getAll()
{
$results = [];
if (isset($this->_directUrl)) {
$results['title'] = $this->_title;
$results['directurl'] = $this->_directUrl;
}
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())) {
$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)) {
return false;
}
return $results;
}
/**
* @return mixed
*/
abstract protected function trailers();
}
+3 -36
View File
@@ -91,41 +91,6 @@ class Hotmovies extends AdultMovies
return false;
}
/**
* Gets all information
* @return bool|array
*/
public function getAll()
{
$results = [];
if (!empty($this->_directUrl)) {
$results['title'] = $this->_title;
$results['directurl'] = $this->_directUrl;
}
if (is_array($this->synopsis())) {
$results = array_merge($results, $this->synopsis());
}
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 (empty($results)) {
return false;
}
return $results;
}
/**
* Gets the synopsis
*
@@ -145,10 +110,12 @@ class Hotmovies extends AdultMovies
}
/**Process ProductInfo
*
* @param bool $extras
*
* @return array
*/
protected function productInfo(): array
protected function productInfo($extras = false): array
{
$studio = false;
$director = false;
+1 -38
View File
@@ -151,7 +151,7 @@ class Popporn extends AdultMovies
*
* @return array|bool
*/
protected function productInfo($extras = true)
protected function productInfo($extras = false)
{
$country = false;
if ($ret = $this->_html->find('div#lside', 0)) {
@@ -324,41 +324,4 @@ class Popporn extends AdultMovies
return false;
}
/**
* Gets all information
*
* @return array|bool
*/
public function getAll()
{
$results = [];
if (isset($this->_directUrl)) {
$results['title'] = $this->_title;
$results['directurl'] = $this->_directUrl;
}
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())) {
$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)) {
return false;
}
return $results;
}
}