@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | class Helper |
| 9 | 9 | { |
| 10 | - /** |
|
| 10 | + /** |
|
| 11 | 11 | * Convert return result into easy-to-read result. |
| 12 | 12 | * |
| 13 | 13 | * @param string|array $response |
@@ -85,138 +85,138 @@ discard block |
||
| 85 | 85 | * |
| 86 | 86 | * @return string |
| 87 | 87 | */ |
| 88 | - public static function getTopAnimeType($type) |
|
| 89 | - { |
|
| 90 | - $converted_type = ''; |
|
| 91 | - switch ($type) { |
|
| 92 | - case '0': |
|
| 93 | - $converted_type = ''; |
|
| 94 | - break; |
|
| 95 | - case '1': |
|
| 96 | - $converted_type = 'airing'; |
|
| 97 | - break; |
|
| 98 | - case '2': |
|
| 99 | - $converted_type = 'upcoming'; |
|
| 100 | - break; |
|
| 101 | - case '3': |
|
| 102 | - $converted_type = 'tv'; |
|
| 103 | - break; |
|
| 104 | - case '4': |
|
| 105 | - $converted_type = 'movie'; |
|
| 106 | - break; |
|
| 107 | - case '5': |
|
| 108 | - $converted_type = 'ova'; |
|
| 109 | - break; |
|
| 110 | - case '6': |
|
| 111 | - $converted_type = 'special'; |
|
| 112 | - break; |
|
| 113 | - case '7': |
|
| 114 | - $converted_type = 'bypopularity'; |
|
| 115 | - break; |
|
| 116 | - case '8': |
|
| 117 | - $converted_type = 'favorite'; |
|
| 118 | - break; |
|
| 119 | - default: |
|
| 120 | - $converted_type = ''; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - return $converted_type; |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * Get top manga code. |
|
| 128 | - * |
|
| 129 | - * @param string|int $type |
|
| 130 | - * |
|
| 131 | - * @return string |
|
| 132 | - */ |
|
| 133 | - public static function getTopMangaType($type) |
|
| 134 | - { |
|
| 135 | - $converted_type = ''; |
|
| 136 | - switch ($type) { |
|
| 137 | - case '0': |
|
| 138 | - $converted_type = ''; |
|
| 139 | - break; |
|
| 140 | - case '1': |
|
| 141 | - $converted_type = 'manga'; |
|
| 142 | - break; |
|
| 143 | - case '2': |
|
| 144 | - $converted_type = 'novels'; |
|
| 145 | - break; |
|
| 146 | - case '3': |
|
| 147 | - $converted_type = 'oneshots'; |
|
| 148 | - break; |
|
| 149 | - case '4': |
|
| 150 | - $converted_type = 'doujin'; |
|
| 151 | - break; |
|
| 152 | - case '5': |
|
| 153 | - $converted_type = 'manhwa'; |
|
| 154 | - break; |
|
| 155 | - case '6': |
|
| 156 | - $converted_type = 'manhua'; |
|
| 157 | - break; |
|
| 158 | - case '7': |
|
| 159 | - $converted_type = 'bypopularity'; |
|
| 160 | - break; |
|
| 161 | - case '8': |
|
| 162 | - $converted_type = 'favorite'; |
|
| 163 | - break; |
|
| 164 | - default: |
|
| 165 | - $converted_type = ''; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - return $converted_type; |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - /** |
|
| 172 | - * Get current season. |
|
| 173 | - * |
|
| 174 | - * @return string |
|
| 175 | - */ |
|
| 176 | - public static function getCurrentSeason() |
|
| 177 | - { |
|
| 178 | - $day = new DateTime(); |
|
| 179 | - |
|
| 180 | - // Days of spring |
|
| 181 | - $spring_starts = new DateTime('April 1'); |
|
| 182 | - $spring_ends = new DateTime('June 30'); |
|
| 183 | - |
|
| 184 | - // Days of summer |
|
| 185 | - $summer_starts = new DateTime('July 1'); |
|
| 186 | - $summer_ends = new DateTime('September 30'); |
|
| 187 | - |
|
| 188 | - // Days of autumn |
|
| 189 | - $autumn_starts = new DateTime('October 1'); |
|
| 190 | - $autumn_ends = new DateTime('December 31'); |
|
| 191 | - |
|
| 192 | - // If $day is between the days of spring, summer, autumn, and winter |
|
| 193 | - if ($day >= $spring_starts && $day <= $spring_ends) : |
|
| 194 | - $season = 'spring'; elseif ($day >= $summer_starts && $day <= $summer_ends) : |
|
| 195 | - $season = 'summer'; elseif ($day >= $autumn_starts && $day <= $autumn_ends) : |
|
| 196 | - $season = 'fall'; else : |
|
| 197 | - $season = 'winter'; |
|
| 198 | - endif; |
|
| 199 | - |
|
| 200 | - return $season; |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - /** |
|
| 204 | - * Clean image URL. |
|
| 205 | - * |
|
| 206 | - * @param string $str |
|
| 207 | - * |
|
| 208 | - * @return string |
|
| 209 | - */ |
|
| 210 | - public static function imageUrlCleaner($str) |
|
| 211 | - { |
|
| 212 | - preg_match('/(questionmark)|(qm_50)/', $str, $temp_image); |
|
| 213 | - $str = $temp_image ? '' : $str; |
|
| 214 | - $str = str_replace('v.jpg', '.jpg', $str); |
|
| 215 | - $str = str_replace('_thumb.jpg', '.jpg', $str); |
|
| 216 | - $str = str_replace('userimages/thumbs', 'userimages', $str); |
|
| 217 | - $str = preg_replace('/r\/\d{1,3}x\d{1,3}\//', '', $str); |
|
| 218 | - $str = preg_replace('/\?.+/', '', $str); |
|
| 219 | - |
|
| 220 | - return $str; |
|
| 221 | - } |
|
| 88 | + public static function getTopAnimeType($type) |
|
| 89 | + { |
|
| 90 | + $converted_type = ''; |
|
| 91 | + switch ($type) { |
|
| 92 | + case '0': |
|
| 93 | + $converted_type = ''; |
|
| 94 | + break; |
|
| 95 | + case '1': |
|
| 96 | + $converted_type = 'airing'; |
|
| 97 | + break; |
|
| 98 | + case '2': |
|
| 99 | + $converted_type = 'upcoming'; |
|
| 100 | + break; |
|
| 101 | + case '3': |
|
| 102 | + $converted_type = 'tv'; |
|
| 103 | + break; |
|
| 104 | + case '4': |
|
| 105 | + $converted_type = 'movie'; |
|
| 106 | + break; |
|
| 107 | + case '5': |
|
| 108 | + $converted_type = 'ova'; |
|
| 109 | + break; |
|
| 110 | + case '6': |
|
| 111 | + $converted_type = 'special'; |
|
| 112 | + break; |
|
| 113 | + case '7': |
|
| 114 | + $converted_type = 'bypopularity'; |
|
| 115 | + break; |
|
| 116 | + case '8': |
|
| 117 | + $converted_type = 'favorite'; |
|
| 118 | + break; |
|
| 119 | + default: |
|
| 120 | + $converted_type = ''; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + return $converted_type; |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * Get top manga code. |
|
| 128 | + * |
|
| 129 | + * @param string|int $type |
|
| 130 | + * |
|
| 131 | + * @return string |
|
| 132 | + */ |
|
| 133 | + public static function getTopMangaType($type) |
|
| 134 | + { |
|
| 135 | + $converted_type = ''; |
|
| 136 | + switch ($type) { |
|
| 137 | + case '0': |
|
| 138 | + $converted_type = ''; |
|
| 139 | + break; |
|
| 140 | + case '1': |
|
| 141 | + $converted_type = 'manga'; |
|
| 142 | + break; |
|
| 143 | + case '2': |
|
| 144 | + $converted_type = 'novels'; |
|
| 145 | + break; |
|
| 146 | + case '3': |
|
| 147 | + $converted_type = 'oneshots'; |
|
| 148 | + break; |
|
| 149 | + case '4': |
|
| 150 | + $converted_type = 'doujin'; |
|
| 151 | + break; |
|
| 152 | + case '5': |
|
| 153 | + $converted_type = 'manhwa'; |
|
| 154 | + break; |
|
| 155 | + case '6': |
|
| 156 | + $converted_type = 'manhua'; |
|
| 157 | + break; |
|
| 158 | + case '7': |
|
| 159 | + $converted_type = 'bypopularity'; |
|
| 160 | + break; |
|
| 161 | + case '8': |
|
| 162 | + $converted_type = 'favorite'; |
|
| 163 | + break; |
|
| 164 | + default: |
|
| 165 | + $converted_type = ''; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + return $converted_type; |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + /** |
|
| 172 | + * Get current season. |
|
| 173 | + * |
|
| 174 | + * @return string |
|
| 175 | + */ |
|
| 176 | + public static function getCurrentSeason() |
|
| 177 | + { |
|
| 178 | + $day = new DateTime(); |
|
| 179 | + |
|
| 180 | + // Days of spring |
|
| 181 | + $spring_starts = new DateTime('April 1'); |
|
| 182 | + $spring_ends = new DateTime('June 30'); |
|
| 183 | + |
|
| 184 | + // Days of summer |
|
| 185 | + $summer_starts = new DateTime('July 1'); |
|
| 186 | + $summer_ends = new DateTime('September 30'); |
|
| 187 | + |
|
| 188 | + // Days of autumn |
|
| 189 | + $autumn_starts = new DateTime('October 1'); |
|
| 190 | + $autumn_ends = new DateTime('December 31'); |
|
| 191 | + |
|
| 192 | + // If $day is between the days of spring, summer, autumn, and winter |
|
| 193 | + if ($day >= $spring_starts && $day <= $spring_ends) : |
|
| 194 | + $season = 'spring'; elseif ($day >= $summer_starts && $day <= $summer_ends) : |
|
| 195 | + $season = 'summer'; elseif ($day >= $autumn_starts && $day <= $autumn_ends) : |
|
| 196 | + $season = 'fall'; else : |
|
| 197 | + $season = 'winter'; |
|
| 198 | + endif; |
|
| 199 | + |
|
| 200 | + return $season; |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + /** |
|
| 204 | + * Clean image URL. |
|
| 205 | + * |
|
| 206 | + * @param string $str |
|
| 207 | + * |
|
| 208 | + * @return string |
|
| 209 | + */ |
|
| 210 | + public static function imageUrlCleaner($str) |
|
| 211 | + { |
|
| 212 | + preg_match('/(questionmark)|(qm_50)/', $str, $temp_image); |
|
| 213 | + $str = $temp_image ? '' : $str; |
|
| 214 | + $str = str_replace('v.jpg', '.jpg', $str); |
|
| 215 | + $str = str_replace('_thumb.jpg', '.jpg', $str); |
|
| 216 | + $str = str_replace('userimages/thumbs', 'userimages', $str); |
|
| 217 | + $str = preg_replace('/r\/\d{1,3}x\d{1,3}\//', '', $str); |
|
| 218 | + $str = preg_replace('/\?.+/', '', $str); |
|
| 219 | + |
|
| 220 | + return $str; |
|
| 221 | + } |
|
| 222 | 222 | } |
| 223 | 223 | \ No newline at end of file |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | class MalScraper2 |
| 35 | 35 | { |
| 36 | - /** |
|
| 36 | + /** |
|
| 37 | 37 | * Cache class. |
| 38 | 38 | * |
| 39 | 39 | * @var Cache |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | // if cache function enabled |
| 106 | 106 | if ($this->_enable_cache === true) { |
| 107 | - $this->_cache->setCache(str_replace('get', '', $method)); |
|
| 108 | - $this->_cache->eraseExpired($this->_cache_time); |
|
| 107 | + $this->_cache->setCache(str_replace('get', '', $method)); |
|
| 108 | + $this->_cache->eraseExpired($this->_cache_time); |
|
| 109 | 109 | |
| 110 | 110 | $cacheName = $method.'('.implode(',', $arguments).')'; |
| 111 | 111 | $isCached = $this->_cache->isCached($cacheName); |
@@ -136,10 +136,10 @@ discard block |
||
| 136 | 136 | * |
| 137 | 137 | * @return array |
| 138 | 138 | */ |
| 139 | - private function getInfo($type, $id) |
|
| 140 | - { |
|
| 141 | - return (new Info($type, $id))->getAllInfo(); |
|
| 142 | - } |
|
| 139 | + private function getInfo($type, $id) |
|
| 140 | + { |
|
| 141 | + return (new Info($type, $id))->getAllInfo(); |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | 144 | /** |
| 145 | 145 | * Get character information. |
@@ -14,14 +14,14 @@ discard block |
||
| 14 | 14 | * |
| 15 | 15 | * @var string |
| 16 | 16 | */ |
| 17 | - private $_type; |
|
| 17 | + private $_type; |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * Id of the anime or manga. |
| 21 | 21 | * |
| 22 | 22 | * @var string|int |
| 23 | 23 | */ |
| 24 | - private $_id; |
|
| 24 | + private $_id; |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * Default constructor. |
@@ -32,12 +32,12 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @return void |
| 34 | 34 | */ |
| 35 | - public function __construct($type, $id, $parserArea = '#content') |
|
| 35 | + public function __construct($type, $id, $parserArea = '#content') |
|
| 36 | 36 | { |
| 37 | - $this->_type = $type; |
|
| 38 | - $this->_id = $id; |
|
| 37 | + $this->_type = $type; |
|
| 38 | + $this->_id = $id; |
|
| 39 | 39 | $this->_url = $this->_myAnimeListUrl.'/'.$type.'/'.$id; |
| 40 | - $this->_parserArea = $parserArea; |
|
| 40 | + $this->_parserArea = $parserArea; |
|
| 41 | 41 | |
| 42 | 42 | parent::errorCheck($this); |
| 43 | 43 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | private function getId() |
| 66 | 66 | { |
| 67 | - return $this->_id; |
|
| 67 | + return $this->_id; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -463,6 +463,6 @@ discard block |
||
| 463 | 463 | |
| 464 | 464 | $data = array_merge($data, $data2); |
| 465 | 465 | |
| 466 | - return $data; |
|
| 466 | + return $data; |
|
| 467 | 467 | } |
| 468 | 468 | } |
| 469 | 469 | \ No newline at end of file |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | * |
| 15 | 15 | * @var string|int |
| 16 | 16 | */ |
| 17 | - private $_id; |
|
| 17 | + private $_id; |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * Default constructor. |
@@ -24,11 +24,11 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @return void |
| 26 | 26 | */ |
| 27 | - public function __construct($id, $parserArea = '#contentWrapper') |
|
| 27 | + public function __construct($id, $parserArea = '#contentWrapper') |
|
| 28 | 28 | { |
| 29 | - $this->_id = $id; |
|
| 29 | + $this->_id = $id; |
|
| 30 | 30 | $this->_url = $this->_myAnimeListUrl.'/character/'.$id; |
| 31 | - $this->_parserArea = $parserArea; |
|
| 31 | + $this->_parserArea = $parserArea; |
|
| 32 | 32 | |
| 33 | 33 | parent::errorCheck($this); |
| 34 | 34 | } |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | * |
| 15 | 15 | * @var string|int |
| 16 | 16 | */ |
| 17 | - private $_id; |
|
| 17 | + private $_id; |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * Biodata area. |
@@ -31,11 +31,11 @@ discard block |
||
| 31 | 31 | * |
| 32 | 32 | * @return void |
| 33 | 33 | */ |
| 34 | - public function __construct($id, $parserArea = '#contentWrapper') |
|
| 34 | + public function __construct($id, $parserArea = '#contentWrapper') |
|
| 35 | 35 | { |
| 36 | - $this->_id = $id; |
|
| 36 | + $this->_id = $id; |
|
| 37 | 37 | $this->_url = $this->_myAnimeListUrl.'/people/'.$id; |
| 38 | - $this->_parserArea = $parserArea; |
|
| 38 | + $this->_parserArea = $parserArea; |
|
| 39 | 39 | |
| 40 | 40 | parent::errorCheck($this); |
| 41 | 41 | |
@@ -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 | * Page number. |
@@ -39,11 +39,11 @@ discard block |
||
| 39 | 39 | * |
| 40 | 40 | * @return void |
| 41 | 41 | */ |
| 42 | - public function __construct($type, $id, $page = 1, $parserArea = '#content .js-categories-seasonal') |
|
| 42 | + public function __construct($type, $id, $page = 1, $parserArea = '#content .js-categories-seasonal') |
|
| 43 | 43 | { |
| 44 | 44 | $this->_type = $type; |
| 45 | 45 | $this->_id = $id; |
| 46 | - $this->_page = $page; |
|
| 46 | + $this->_page = $page; |
|
| 47 | 47 | if ($type == 'anime') { |
| 48 | 48 | $this->_url = $this->_myAnimeListUrl.'/anime/producer/'.$id.'/?page='.$page; |
| 49 | 49 | } else { |
@@ -14,21 +14,21 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | class MainModel |
| 16 | 16 | { |
| 17 | - /** |
|
| 17 | + /** |
|
| 18 | 18 | * MyAnimeList main URL |
| 19 | 19 | * |
| 20 | 20 | * @var string |
| 21 | 21 | */ |
| 22 | - protected $_myAnimeListUrl = 'https://myanimelist.net'; |
|
| 22 | + protected $_myAnimeListUrl = 'https://myanimelist.net'; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 24 | + /** |
|
| 25 | 25 | * Trimmed HtmlDomParser. |
| 26 | 26 | * |
| 27 | 27 | * @var \simplehtmldom_1_5\simple_html_dom |
| 28 | 28 | */ |
| 29 | - protected $_parser; |
|
| 29 | + protected $_parser; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 31 | + /** |
|
| 32 | 32 | * Area to be parsed. |
| 33 | 33 | * |
| 34 | 34 | * @var string |
@@ -56,14 +56,14 @@ discard block |
||
| 56 | 56 | * |
| 57 | 57 | * @return int |
| 58 | 58 | */ |
| 59 | - static function getHeader($url) |
|
| 60 | - { |
|
| 61 | - $file_headers = @get_headers($url); |
|
| 62 | - if (empty($file_headers) || $file_headers[0] == 'HTTP/1.1 404 Not Found') { |
|
| 63 | - return 404; |
|
| 64 | - } |
|
| 65 | - return 200; |
|
| 66 | - } |
|
| 59 | + static function getHeader($url) |
|
| 60 | + { |
|
| 61 | + $file_headers = @get_headers($url); |
|
| 62 | + if (empty($file_headers) || $file_headers[0] == 'HTTP/1.1 404 Not Found') { |
|
| 63 | + return 404; |
|
| 64 | + } |
|
| 65 | + return 200; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | 68 | /** |
| 69 | 69 | * Get trimmed HtmlDomParser class. |
@@ -73,17 +73,17 @@ discard block |
||
| 73 | 73 | * |
| 74 | 74 | * @return \simplehtmldom_1_5\simple_html_dom |
| 75 | 75 | */ |
| 76 | - static function getParser($url,$contentDiv, $additionalSetting = false) |
|
| 77 | - { |
|
| 78 | - $html = HtmlDomParser::file_get_html($url)->find($contentDiv, 0); |
|
| 79 | - $html = !$additionalSetting ? $html : $html->next_sibling(); |
|
| 80 | - $html = $html->outertext; |
|
| 81 | - $html = str_replace('"', '\"', $html); |
|
| 82 | - $html = html_entity_decode($html, ENT_QUOTES, 'UTF-8'); |
|
| 83 | - $html = HtmlDomParser::str_get_html($html); |
|
| 84 | - |
|
| 85 | - return $html; |
|
| 86 | - } |
|
| 76 | + static function getParser($url,$contentDiv, $additionalSetting = false) |
|
| 77 | + { |
|
| 78 | + $html = HtmlDomParser::file_get_html($url)->find($contentDiv, 0); |
|
| 79 | + $html = !$additionalSetting ? $html : $html->next_sibling(); |
|
| 80 | + $html = $html->outertext; |
|
| 81 | + $html = str_replace('"', '\"', $html); |
|
| 82 | + $html = html_entity_decode($html, ENT_QUOTES, 'UTF-8'); |
|
| 83 | + $html = HtmlDomParser::str_get_html($html); |
|
| 84 | + |
|
| 85 | + return $html; |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | 89 | * Header error check. |
@@ -96,8 +96,8 @@ discard block |
||
| 96 | 96 | { |
| 97 | 97 | $header = self::getHeader($model->_url); |
| 98 | 98 | if ($header == 200) { |
| 99 | - $className = self::getCleanClassName($model); |
|
| 100 | - $additionalSetting = ($className == 'CharacterPictureModel') || ($className == 'PeoplePictureModel'); |
|
| 99 | + $className = self::getCleanClassName($model); |
|
| 100 | + $additionalSetting = ($className == 'CharacterPictureModel') || ($className == 'PeoplePictureModel'); |
|
| 101 | 101 | $model->_parser = self::getParser(self::getAbsoluteUrl($model), $model->_parserArea, $additionalSetting); |
| 102 | 102 | } else { |
| 103 | 103 | $model->_error = $header; |
@@ -113,32 +113,32 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | static function getAbsoluteUrl($model) |
| 115 | 115 | { |
| 116 | - $className = self::getCleanClassName($model); |
|
| 117 | - $additionalUrl = ''; |
|
| 118 | - |
|
| 119 | - switch ($className) { |
|
| 120 | - case 'CharacterStaffModel': |
|
| 121 | - $area = 'li a[href$=characters]'; |
|
| 122 | - break; |
|
| 123 | - case 'StatModel': |
|
| 124 | - $area = 'li a[href$=stats]'; |
|
| 125 | - $additionalUrl = '?m=all&show=1'; |
|
| 126 | - break; |
|
| 127 | - case 'PictureModel': |
|
| 128 | - $area = 'li a[href$=pics]'; |
|
| 129 | - break; |
|
| 130 | - case 'CharacterPictureModel': |
|
| 131 | - case 'PeoplePictureModel': |
|
| 132 | - $area = 'li a[href$=pictures]'; |
|
| 133 | - break; |
|
| 134 | - default: |
|
| 135 | - return $model->_url; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - $html = HtmlDomParser::file_get_html($model->_url)->find($area, 0)->href; |
|
| 139 | - |
|
| 140 | - if ($model->getType() == 'manga') |
|
| 141 | - return 'https://myanimelist.net'.$html.$additionalUrl; |
|
| 116 | + $className = self::getCleanClassName($model); |
|
| 117 | + $additionalUrl = ''; |
|
| 118 | + |
|
| 119 | + switch ($className) { |
|
| 120 | + case 'CharacterStaffModel': |
|
| 121 | + $area = 'li a[href$=characters]'; |
|
| 122 | + break; |
|
| 123 | + case 'StatModel': |
|
| 124 | + $area = 'li a[href$=stats]'; |
|
| 125 | + $additionalUrl = '?m=all&show=1'; |
|
| 126 | + break; |
|
| 127 | + case 'PictureModel': |
|
| 128 | + $area = 'li a[href$=pics]'; |
|
| 129 | + break; |
|
| 130 | + case 'CharacterPictureModel': |
|
| 131 | + case 'PeoplePictureModel': |
|
| 132 | + $area = 'li a[href$=pictures]'; |
|
| 133 | + break; |
|
| 134 | + default: |
|
| 135 | + return $model->_url; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + $html = HtmlDomParser::file_get_html($model->_url)->find($area, 0)->href; |
|
| 139 | + |
|
| 140 | + if ($model->getType() == 'manga') |
|
| 141 | + return 'https://myanimelist.net'.$html.$additionalUrl; |
|
| 142 | 142 | return $html.$additionalUrl; |
| 143 | 143 | } |
| 144 | 144 | |
@@ -14,14 +14,14 @@ discard block |
||
| 14 | 14 | * |
| 15 | 15 | * @var string |
| 16 | 16 | */ |
| 17 | - private $_type; |
|
| 17 | + private $_type; |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * Id of the anime or manga. |
| 21 | 21 | * |
| 22 | 22 | * @var string|int |
| 23 | 23 | */ |
| 24 | - private $_id; |
|
| 24 | + private $_id; |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * Default constructor. |
@@ -32,12 +32,12 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @return void |
| 34 | 34 | */ |
| 35 | - public function __construct($type, $id, $parserArea = '.js-scrollfix-bottom-rel') |
|
| 35 | + public function __construct($type, $id, $parserArea = '.js-scrollfix-bottom-rel') |
|
| 36 | 36 | { |
| 37 | - $this->_type = $type; |
|
| 38 | - $this->_id = $id; |
|
| 37 | + $this->_type = $type; |
|
| 38 | + $this->_id = $id; |
|
| 39 | 39 | $this->_url = $this->_myAnimeListUrl.'/'.$type.'/'.$id; |
| 40 | - $this->_parserArea = $parserArea; |
|
| 40 | + $this->_parserArea = $parserArea; |
|
| 41 | 41 | |
| 42 | 42 | parent::errorCheck($this); |
| 43 | 43 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | private function getId() |
| 76 | 76 | { |
| 77 | - return $this->_id; |
|
| 77 | + return $this->_id; |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | * |
| 15 | 15 | * @var string|int |
| 16 | 16 | */ |
| 17 | - private $_id; |
|
| 17 | + private $_id; |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * Default constructor. |
@@ -24,11 +24,11 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @return void |
| 26 | 26 | */ |
| 27 | - public function __construct($id, $parserArea = '#content table tr td') |
|
| 27 | + public function __construct($id, $parserArea = '#content table tr td') |
|
| 28 | 28 | { |
| 29 | - $this->_id = $id; |
|
| 29 | + $this->_id = $id; |
|
| 30 | 30 | $this->_url = $this->_myAnimeListUrl.'/character/'.$id; |
| 31 | - $this->_parserArea = $parserArea; |
|
| 31 | + $this->_parserArea = $parserArea; |
|
| 32 | 32 | |
| 33 | 33 | parent::errorCheck($this); |
| 34 | 34 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | private function getId() |
| 67 | 67 | { |
| 68 | - return $this->_id; |
|
| 68 | + return $this->_id; |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |