@@ -13,21 +13,21 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | class MainModel |
| 15 | 15 | { |
| 16 | - /** |
|
| 16 | + /** |
|
| 17 | 17 | * MyAnimeList main URL |
| 18 | 18 | * |
| 19 | 19 | * @var string |
| 20 | 20 | */ |
| 21 | - protected $_myAnimeListUrl = 'https://myanimelist.net'; |
|
| 21 | + protected $_myAnimeListUrl = 'https://myanimelist.net'; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 23 | + /** |
|
| 24 | 24 | * Trimmed HtmlDomParser. |
| 25 | 25 | * |
| 26 | 26 | * @var \simplehtmldom_1_5\simple_html_dom |
| 27 | 27 | */ |
| 28 | - protected $_parser; |
|
| 28 | + protected $_parser; |
|
| 29 | 29 | |
| 30 | - /** |
|
| 30 | + /** |
|
| 31 | 31 | * Area to be parsed. |
| 32 | 32 | * |
| 33 | 33 | * @var string |
@@ -55,14 +55,14 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @return int |
| 57 | 57 | */ |
| 58 | - static function getHeader($url) |
|
| 59 | - { |
|
| 60 | - $file_headers = @get_headers($url); |
|
| 61 | - if (empty($file_headers) || $file_headers[0] == 'HTTP/1.1 404 Not Found') { |
|
| 62 | - return 404; |
|
| 63 | - } |
|
| 64 | - return 200; |
|
| 65 | - } |
|
| 58 | + static function getHeader($url) |
|
| 59 | + { |
|
| 60 | + $file_headers = @get_headers($url); |
|
| 61 | + if (empty($file_headers) || $file_headers[0] == 'HTTP/1.1 404 Not Found') { |
|
| 62 | + return 404; |
|
| 63 | + } |
|
| 64 | + return 200; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | 67 | /** |
| 68 | 68 | * Get trimmed HtmlDomParser class. |
@@ -72,17 +72,17 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @return \simplehtmldom_1_5\simple_html_dom |
| 74 | 74 | */ |
| 75 | - static function getParser($url,$contentDiv, $additionalSetting = false) |
|
| 76 | - { |
|
| 77 | - $html = HtmlDomParser::file_get_html($url)->find($contentDiv, 0); |
|
| 78 | - $html = !$additionalSetting ? $html : $html->next_sibling(); |
|
| 79 | - $html = $html->outertext; |
|
| 80 | - $html = str_replace('"', '\"', $html); |
|
| 81 | - $html = html_entity_decode($html, ENT_QUOTES, 'UTF-8'); |
|
| 82 | - $html = HtmlDomParser::str_get_html($html); |
|
| 83 | - |
|
| 84 | - return $html; |
|
| 85 | - } |
|
| 75 | + static function getParser($url,$contentDiv, $additionalSetting = false) |
|
| 76 | + { |
|
| 77 | + $html = HtmlDomParser::file_get_html($url)->find($contentDiv, 0); |
|
| 78 | + $html = !$additionalSetting ? $html : $html->next_sibling(); |
|
| 79 | + $html = $html->outertext; |
|
| 80 | + $html = str_replace('"', '\"', $html); |
|
| 81 | + $html = html_entity_decode($html, ENT_QUOTES, 'UTF-8'); |
|
| 82 | + $html = HtmlDomParser::str_get_html($html); |
|
| 83 | + |
|
| 84 | + return $html; |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | 87 | /** |
| 88 | 88 | * Header error check. |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | if (!$model->_error) { |
| 105 | 105 | $header = self::getHeader($model->_url); |
| 106 | 106 | if ($header == 200) { |
| 107 | - $additionalSetting = ($className == 'CharacterPeoplePictureModel'); |
|
| 107 | + $additionalSetting = ($className == 'CharacterPeoplePictureModel'); |
|
| 108 | 108 | $model->_parser = self::getParser(self::getAbsoluteUrl($model), $model->_parserArea, $additionalSetting); |
| 109 | 109 | } else { |
| 110 | 110 | $model->_error = $header; |
@@ -121,31 +121,31 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | static function getAbsoluteUrl($model) |
| 123 | 123 | { |
| 124 | - $className = self::getCleanClassName($model); |
|
| 125 | - $additionalUrl = ''; |
|
| 126 | - |
|
| 127 | - switch ($className) { |
|
| 128 | - case 'CharacterStaffModel': |
|
| 129 | - $area = 'li a[href$=characters]'; |
|
| 130 | - break; |
|
| 131 | - case 'StatModel': |
|
| 132 | - $area = 'li a[href$=stats]'; |
|
| 133 | - $additionalUrl = '?m=all&show=1'; |
|
| 134 | - break; |
|
| 135 | - case 'PictureModel': |
|
| 136 | - $area = 'li a[href$=pics]'; |
|
| 137 | - break; |
|
| 138 | - case 'CharacterPeoplePictureModel': |
|
| 139 | - $area = 'li a[href$=pictures]'; |
|
| 140 | - break; |
|
| 141 | - default: |
|
| 142 | - return $model->_url; |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - $html = HtmlDomParser::file_get_html($model->_url)->find($area, 0)->href; |
|
| 146 | - |
|
| 147 | - if ($model->getType() == 'manga') |
|
| 148 | - return 'https://myanimelist.net'.$html.$additionalUrl; |
|
| 124 | + $className = self::getCleanClassName($model); |
|
| 125 | + $additionalUrl = ''; |
|
| 126 | + |
|
| 127 | + switch ($className) { |
|
| 128 | + case 'CharacterStaffModel': |
|
| 129 | + $area = 'li a[href$=characters]'; |
|
| 130 | + break; |
|
| 131 | + case 'StatModel': |
|
| 132 | + $area = 'li a[href$=stats]'; |
|
| 133 | + $additionalUrl = '?m=all&show=1'; |
|
| 134 | + break; |
|
| 135 | + case 'PictureModel': |
|
| 136 | + $area = 'li a[href$=pics]'; |
|
| 137 | + break; |
|
| 138 | + case 'CharacterPeoplePictureModel': |
|
| 139 | + $area = 'li a[href$=pictures]'; |
|
| 140 | + break; |
|
| 141 | + default: |
|
| 142 | + return $model->_url; |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + $html = HtmlDomParser::file_get_html($model->_url)->find($area, 0)->href; |
|
| 146 | + |
|
| 147 | + if ($model->getType() == 'manga') |
|
| 148 | + return 'https://myanimelist.net'.$html.$additionalUrl; |
|
| 149 | 149 | return $html.$additionalUrl; |
| 150 | 150 | } |
| 151 | 151 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * |
| 16 | 16 | * @var string |
| 17 | 17 | */ |
| 18 | - private $_type; |
|
| 18 | + private $_type; |
|
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * Default constructor. |
@@ -25,15 +25,15 @@ discard block |
||
| 25 | 25 | * |
| 26 | 26 | * @return void |
| 27 | 27 | */ |
| 28 | - public function __construct($type, $parserArea = '.anime-manga-search') |
|
| 28 | + public function __construct($type, $parserArea = '.anime-manga-search') |
|
| 29 | 29 | { |
| 30 | - $this->_type = $type; |
|
| 30 | + $this->_type = $type; |
|
| 31 | 31 | if ($type == 'anime') { |
| 32 | 32 | $this->_url = $this->_myAnimeListUrl.'/anime/producer'; |
| 33 | 33 | } else { |
| 34 | 34 | $this->_url = $this->_myAnimeListUrl.'/manga/magazine'; |
| 35 | 35 | } |
| 36 | - $this->_parserArea = $parserArea; |
|
| 36 | + $this->_parserArea = $parserArea; |
|
| 37 | 37 | |
| 38 | 38 | parent::errorCheck($this); |
| 39 | 39 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * |
| 16 | 16 | * @var string |
| 17 | 17 | */ |
| 18 | - private $_type; |
|
| 18 | + private $_type; |
|
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * Default constructor. |
@@ -25,15 +25,15 @@ discard block |
||
| 25 | 25 | * |
| 26 | 26 | * @return void |
| 27 | 27 | */ |
| 28 | - public function __construct($type, $parserArea = '.anime-manga-search .genre-link') |
|
| 28 | + public function __construct($type, $parserArea = '.anime-manga-search .genre-link') |
|
| 29 | 29 | { |
| 30 | - $this->_type = $type; |
|
| 30 | + $this->_type = $type; |
|
| 31 | 31 | if ($type == 'anime') { |
| 32 | 32 | $this->_url = $this->_myAnimeListUrl.'/anime.php'; |
| 33 | 33 | } else { |
| 34 | 34 | $this->_url = $this->_myAnimeListUrl.'/manga.php'; |
| 35 | 35 | } |
| 36 | - $this->_parserArea = $parserArea; |
|
| 36 | + $this->_parserArea = $parserArea; |
|
| 37 | 37 | |
| 38 | 38 | parent::errorCheck($this); |
| 39 | 39 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | * |
| 23 | 23 | * @var string|int |
| 24 | 24 | */ |
| 25 | - private $_id; |
|
| 25 | + private $_id; |
|
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * Default constructor. |
@@ -32,9 +32,9 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @return void |
| 34 | 34 | */ |
| 35 | - public function __construct($type, $id, $parserArea = '#content table tr td') |
|
| 35 | + public function __construct($type, $id, $parserArea = '#content table tr td') |
|
| 36 | 36 | { |
| 37 | - $this->_type = $type; |
|
| 37 | + $this->_type = $type; |
|
| 38 | 38 | $this->_id = $id; |
| 39 | 39 | if ($this->_type == 'people') { |
| 40 | 40 | $this->_url = $this->_myAnimeListUrl.'/people/'.$id; |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | private function getId() |
| 80 | 80 | { |
| 81 | - return $this->_id; |
|
| 81 | + return $this->_id; |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * |
| 30 | 30 | * @var string|int |
| 31 | 31 | */ |
| 32 | - private $_id; |
|
| 32 | + private $_id; |
|
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * Page number. |
@@ -48,12 +48,12 @@ discard block |
||
| 48 | 48 | * |
| 49 | 49 | * @return void |
| 50 | 50 | */ |
| 51 | - public function __construct($type, $type2, $id, $page = 1, $parserArea = '#content .js-categories-seasonal') |
|
| 51 | + public function __construct($type, $type2, $id, $page = 1, $parserArea = '#content .js-categories-seasonal') |
|
| 52 | 52 | { |
| 53 | 53 | $this->_type = $type; |
| 54 | 54 | $this->_type2 = $type2; |
| 55 | 55 | $this->_id = $id; |
| 56 | - $this->_page = $page; |
|
| 56 | + $this->_page = $page; |
|
| 57 | 57 | |
| 58 | 58 | if ($type2 == 'producer') { |
| 59 | 59 | if ($type == 'anime') { |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * |
| 16 | 16 | * @var string |
| 17 | 17 | */ |
| 18 | - private $_type; |
|
| 18 | + private $_type; |
|
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * Search query. |
@@ -41,10 +41,10 @@ discard block |
||
| 41 | 41 | * |
| 42 | 42 | * @return void |
| 43 | 43 | */ |
| 44 | - public function __construct($type, $query, $page, $parserArea = 'div[class^=js-categories-seasonal]') |
|
| 44 | + public function __construct($type, $query, $page, $parserArea = 'div[class^=js-categories-seasonal]') |
|
| 45 | 45 | { |
| 46 | 46 | $this->_type = $type; |
| 47 | - $this->_query = $query; |
|
| 47 | + $this->_query = $query; |
|
| 48 | 48 | $this->_page = 50 * ($page - 1); |
| 49 | 49 | |
| 50 | 50 | if ($type == 'anime') { |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | } else { |
| 53 | 53 | $this->_url = $this->_myAnimeListUrl.'/manga.php?q='.$query.'&show='.$this->_page; |
| 54 | 54 | } |
| 55 | - $this->_parserArea = $parserArea; |
|
| 55 | + $this->_parserArea = $parserArea; |
|
| 56 | 56 | |
| 57 | 57 | parent::errorCheck($this); |
| 58 | 58 | } |