|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
// Return json file |
|
4
|
|
|
header('Content-type:application/json;charset=utf-8'); |
|
5
|
|
|
|
|
6
|
|
|
// ini_set('max_execution_time', 0); |
|
7
|
|
|
|
|
8
|
|
|
// Use the Mal-Scraper library |
|
9
|
|
|
require 'vendor/autoload.php'; |
|
10
|
|
|
use MalScraper\MalScraper; |
|
11
|
|
|
|
|
12
|
|
|
date_default_timezone_set('UTC'); |
|
13
|
|
|
|
|
14
|
|
|
$myMalScraper = new MalScraper([ |
|
15
|
|
|
'enable_cache' => true, |
|
16
|
|
|
'cache_time' => 3600, |
|
17
|
|
|
'to_api' => true, |
|
18
|
|
|
]); |
|
19
|
|
|
|
|
20
|
|
|
// Get the parameter |
|
21
|
|
|
$method = isset($_GET['m']) ? $_GET['m'] : ''; |
|
22
|
|
|
|
|
23
|
|
|
$type = isset($_GET['t']) ? $_GET['t'] : ''; |
|
24
|
|
|
$id = isset($_GET['id']) ? $_GET['id'] : ''; |
|
25
|
|
|
|
|
26
|
|
|
$id1 = isset($_GET['id1']) ? $_GET['id1'] : ''; |
|
27
|
|
|
$id2 = isset($_GET['id2']) ? $_GET['id2'] : ''; |
|
28
|
|
|
|
|
29
|
|
|
$page = isset($_GET['p']) ? $_GET['p'] : 1; |
|
30
|
|
|
|
|
31
|
|
|
$query = isset($_GET['q']) ? $_GET['q'] : ''; |
|
32
|
|
|
|
|
33
|
|
|
$year = isset($_GET['y']) ? $_GET['y'] : date('Y'); |
|
34
|
|
|
$season = isset($_GET['s']) ? $_GET['s'] : getCurrentSeason(); |
|
35
|
|
|
|
|
36
|
|
|
$user = isset($_GET['u']) ? $_GET['u'] : ''; |
|
37
|
|
|
$status = isset($_GET['st']) ? $_GET['st'] : 7; |
|
38
|
|
|
|
|
39
|
|
|
// Call the requested method |
|
40
|
|
|
switch ($method) { |
|
41
|
|
|
|
|
42
|
|
|
// General Method ---------- |
|
43
|
|
|
case 'info': |
|
44
|
|
|
if ($type && $id) { |
|
45
|
|
|
$result = $myMalScraper->getInfo($type, $id); |
|
46
|
|
|
print_r($result); |
|
47
|
|
|
} else { |
|
48
|
|
|
print_r(paramError()); |
|
49
|
|
|
} |
|
50
|
|
|
break; |
|
51
|
|
|
case 'character': |
|
52
|
|
|
if ($id) { |
|
53
|
|
|
$result = $myMalScraper->getCharacter($id); |
|
54
|
|
|
print_r($result); |
|
55
|
|
|
} else { |
|
56
|
|
|
print_r(paramError()); |
|
57
|
|
|
} |
|
58
|
|
|
break; |
|
59
|
|
|
case 'people': |
|
60
|
|
|
if ($id) { |
|
61
|
|
|
$result = $myMalScraper->getPeople($id); |
|
62
|
|
|
print_r($result); |
|
63
|
|
|
} else { |
|
64
|
|
|
print_r(paramError()); |
|
65
|
|
|
} |
|
66
|
|
|
break; |
|
67
|
|
|
case 'studio-producer': |
|
68
|
|
|
case 'studioproducer': |
|
69
|
|
|
if ($id) { |
|
70
|
|
|
$result = $myMalScraper->getStudioProducer($id, $page); |
|
71
|
|
|
print_r($result); |
|
72
|
|
|
} else { |
|
73
|
|
|
print_r(paramError()); |
|
74
|
|
|
} |
|
75
|
|
|
break; |
|
76
|
|
|
case 'magazine': |
|
77
|
|
|
if ($id) { |
|
78
|
|
|
$result = $myMalScraper->getMagazine($id, $page); |
|
79
|
|
|
print_r($result); |
|
80
|
|
|
} else { |
|
81
|
|
|
print_r(paramError()); |
|
82
|
|
|
} |
|
83
|
|
|
break; |
|
84
|
|
|
case 'genre': |
|
85
|
|
|
if ($type && $id) { |
|
86
|
|
|
$result = $myMalScraper->getGenre($type, $id, $page); |
|
87
|
|
|
print_r($result); |
|
88
|
|
|
} else { |
|
89
|
|
|
print_r(paramError()); |
|
90
|
|
|
} |
|
91
|
|
|
break; |
|
92
|
|
|
case 'review': |
|
93
|
|
|
if ($id) { |
|
94
|
|
|
$result = $myMalScraper->getReview($id); |
|
95
|
|
|
print_r($result); |
|
96
|
|
|
} else { |
|
97
|
|
|
print_r(paramError()); |
|
98
|
|
|
} |
|
99
|
|
|
break; |
|
100
|
|
|
case 'recommendation': |
|
101
|
|
|
if ($type && $id1 && $id2) { |
|
102
|
|
|
$result = $myMalScraper->getRecommendation($type, $id1, $id2); |
|
103
|
|
|
print_r($result); |
|
104
|
|
|
} else { |
|
105
|
|
|
print_r(paramError()); |
|
106
|
|
|
} |
|
107
|
|
|
break; |
|
108
|
|
|
|
|
109
|
|
|
// Additional Method ---------- |
|
110
|
|
|
case 'character-staff': |
|
111
|
|
|
case 'characterstaff': |
|
112
|
|
|
if ($type && $id) { |
|
113
|
|
|
$result = $myMalScraper->getCharacterStaff($type, $id); |
|
114
|
|
|
print_r($result); |
|
115
|
|
|
} else { |
|
116
|
|
|
print_r(paramError()); |
|
117
|
|
|
} |
|
118
|
|
|
break; |
|
119
|
|
|
case 'stat': |
|
120
|
|
|
if ($type && $id) { |
|
121
|
|
|
$result = $myMalScraper->getStat($type, $id); |
|
122
|
|
|
print_r($result); |
|
123
|
|
|
} else { |
|
124
|
|
|
print_r(paramError()); |
|
125
|
|
|
} |
|
126
|
|
|
break; |
|
127
|
|
|
case 'picture': |
|
128
|
|
|
if ($type && $id) { |
|
129
|
|
|
$result = $myMalScraper->getPicture($type, $id); |
|
130
|
|
|
print_r($result); |
|
131
|
|
|
} else { |
|
132
|
|
|
print_r(paramError()); |
|
133
|
|
|
} |
|
134
|
|
|
break; |
|
135
|
|
|
case 'character-picture': |
|
136
|
|
|
case 'characterpicture': |
|
137
|
|
|
if ($id) { |
|
138
|
|
|
$result = $myMalScraper->getCharacterPicture($id); |
|
139
|
|
|
print_r($result); |
|
140
|
|
|
} else { |
|
141
|
|
|
print_r(paramError()); |
|
142
|
|
|
} |
|
143
|
|
|
break; |
|
144
|
|
|
case 'people-picture': |
|
145
|
|
|
case 'peoplepicture': |
|
146
|
|
|
if ($id) { |
|
147
|
|
|
$result = $myMalScraper->getPeoplePicture($id); |
|
148
|
|
|
print_r($result); |
|
149
|
|
|
} else { |
|
150
|
|
|
print_r(paramError()); |
|
151
|
|
|
} |
|
152
|
|
|
break; |
|
153
|
|
|
case 'video': |
|
154
|
|
|
if ($id) { |
|
155
|
|
|
$result = $myMalScraper->getVideo($id, $page); |
|
156
|
|
|
print_r($result); |
|
157
|
|
|
} else { |
|
158
|
|
|
print_r(paramError()); |
|
159
|
|
|
} |
|
160
|
|
|
break; |
|
161
|
|
|
case 'episode': |
|
162
|
|
|
if ($id) { |
|
163
|
|
|
$result = $myMalScraper->getEpisode($id, $page); |
|
164
|
|
|
print_r($result); |
|
165
|
|
|
} else { |
|
166
|
|
|
print_r(paramError()); |
|
167
|
|
|
} |
|
168
|
|
|
break; |
|
169
|
|
|
case 'anime-review': |
|
170
|
|
|
case 'animereview': |
|
171
|
|
|
if ($id) { |
|
172
|
|
|
$result = $myMalScraper->getAnimeReview($id, $page); |
|
173
|
|
|
print_r($result); |
|
174
|
|
|
} else { |
|
175
|
|
|
print_r(paramError()); |
|
176
|
|
|
} |
|
177
|
|
|
break; |
|
178
|
|
|
case 'manga-review': |
|
179
|
|
|
case 'mangareview': |
|
180
|
|
|
if ($id) { |
|
181
|
|
|
$result = $myMalScraper->getMangaReview($id, $page); |
|
182
|
|
|
print_r($result); |
|
183
|
|
|
} else { |
|
184
|
|
|
print_r(paramError()); |
|
185
|
|
|
} |
|
186
|
|
|
break; |
|
187
|
|
|
case 'anime-recommendation': |
|
188
|
|
|
case 'animerecommendation': |
|
189
|
|
|
if ($id) { |
|
190
|
|
|
$result = $myMalScraper->getAnimeRecommendation($id); |
|
191
|
|
|
print_r($result); |
|
192
|
|
|
} else { |
|
193
|
|
|
print_r(paramError()); |
|
194
|
|
|
} |
|
195
|
|
|
break; |
|
196
|
|
|
case 'manga-recommendation': |
|
197
|
|
|
case 'mangarecommendation': |
|
198
|
|
|
if ($id) { |
|
199
|
|
|
$result = $myMalScraper->getMangaRecommendation($id); |
|
200
|
|
|
print_r($result); |
|
201
|
|
|
} else { |
|
202
|
|
|
print_r(paramError()); |
|
203
|
|
|
} |
|
204
|
|
|
break; |
|
205
|
|
|
|
|
206
|
|
|
// List ---------- |
|
207
|
|
|
case 'all-anime-genre': |
|
208
|
|
|
case 'allanimegenre': |
|
209
|
|
|
$result = $myMalScraper->getAllAnimeGenre(); |
|
210
|
|
|
print_r($result); |
|
211
|
|
|
break; |
|
212
|
|
|
case 'all-manga-genre': |
|
213
|
|
|
case 'allmangagenre': |
|
214
|
|
|
$result = $myMalScraper->getAllMangaGenre(); |
|
215
|
|
|
print_r($result); |
|
216
|
|
|
break; |
|
217
|
|
|
case 'all-studio-producer': |
|
218
|
|
|
case 'allstudioproducer': |
|
219
|
|
|
$result = $myMalScraper->getAllStudioProducer(); |
|
220
|
|
|
print_r($result); |
|
221
|
|
|
break; |
|
222
|
|
|
case 'all-magazine': |
|
223
|
|
|
case 'allmagazine': |
|
224
|
|
|
$result = $myMalScraper->getAllMagazine(); |
|
225
|
|
|
print_r($result); |
|
226
|
|
|
break; |
|
227
|
|
|
case 'all-review': |
|
228
|
|
|
case 'allreview': |
|
229
|
|
|
$result = $myMalScraper->getAllReview($type, $page); |
|
230
|
|
|
print_r($result); |
|
231
|
|
|
break; |
|
232
|
|
|
case 'all-recommendation': |
|
233
|
|
|
case 'allrecommendation': |
|
234
|
|
|
$result = $myMalScraper->getAllRecommendation($type, $page); |
|
235
|
|
|
print_r($result); |
|
236
|
|
|
break; |
|
237
|
|
|
|
|
238
|
|
|
// Search ---------- |
|
239
|
|
|
case 'search-anime': |
|
240
|
|
|
case 'searchanime': |
|
241
|
|
|
if ($query) { |
|
242
|
|
|
$result = $myMalScraper->searchAnime($query, $page); |
|
243
|
|
|
print_r($result); |
|
244
|
|
|
} else { |
|
245
|
|
|
print_r(paramError()); |
|
246
|
|
|
} |
|
247
|
|
|
break; |
|
248
|
|
|
case 'search-manga': |
|
249
|
|
|
case 'searchmanga': |
|
250
|
|
|
if ($query) { |
|
251
|
|
|
$result = $myMalScraper->searchManga($query, $page); |
|
252
|
|
|
print_r($result); |
|
253
|
|
|
} else { |
|
254
|
|
|
print_r(paramError()); |
|
255
|
|
|
} |
|
256
|
|
|
break; |
|
257
|
|
|
case 'search-character': |
|
258
|
|
|
case 'searchcharacter': |
|
259
|
|
|
if ($query) { |
|
260
|
|
|
$result = $myMalScraper->searchCharacter($query, $page); |
|
261
|
|
|
print_r($result); |
|
262
|
|
|
} else { |
|
263
|
|
|
print_r(paramError()); |
|
264
|
|
|
} |
|
265
|
|
|
break; |
|
266
|
|
|
case 'search-people': |
|
267
|
|
|
case 'searchpeople': |
|
268
|
|
|
if ($query) { |
|
269
|
|
|
$result = $myMalScraper->searchPeople($query, $page); |
|
270
|
|
|
print_r($result); |
|
271
|
|
|
} else { |
|
272
|
|
|
print_r(paramError()); |
|
273
|
|
|
} |
|
274
|
|
|
break; |
|
275
|
|
|
case 'search-user': |
|
276
|
|
|
case 'searchuser': |
|
277
|
|
|
if ($query) { |
|
278
|
|
|
$result = $myMalScraper->searchUser($query, $page); |
|
279
|
|
|
print_r($result); |
|
280
|
|
|
} else { |
|
281
|
|
|
print_r(paramError()); |
|
282
|
|
|
} |
|
283
|
|
|
break; |
|
284
|
|
|
|
|
285
|
|
|
// Seasonal ---------- |
|
286
|
|
|
case 'season': |
|
287
|
|
|
$result = $myMalScraper->getSeason($year, $season); |
|
288
|
|
|
print_r($result); |
|
289
|
|
|
break; |
|
290
|
|
|
|
|
291
|
|
|
// Top List ---------- |
|
292
|
|
|
case 'top-anime': |
|
293
|
|
|
case 'topanime': |
|
294
|
|
|
$type = $type ? $type : 0; |
|
295
|
|
|
$result = $myMalScraper->getTopAnime($type, $page); |
|
296
|
|
|
print_r($result); |
|
297
|
|
|
break; |
|
298
|
|
|
case 'top-manga': |
|
299
|
|
|
case 'topmanga': |
|
300
|
|
|
$type = $type ? $type : 0; |
|
301
|
|
|
$result = $myMalScraper->getTopManga($type, $page); |
|
302
|
|
|
print_r($result); |
|
303
|
|
|
break; |
|
304
|
|
|
case 'top-character': |
|
305
|
|
|
case 'topcharacter': |
|
306
|
|
|
$result = $myMalScraper->getTopCharacter($page); |
|
307
|
|
|
print_r($result); |
|
308
|
|
|
break; |
|
309
|
|
|
case 'top-people': |
|
310
|
|
|
case 'toppeople': |
|
311
|
|
|
$result = $myMalScraper->getTopPeople($page); |
|
312
|
|
|
print_r($result); |
|
313
|
|
|
break; |
|
314
|
|
|
|
|
315
|
|
|
// User ---------- |
|
316
|
|
|
case 'user': |
|
317
|
|
|
if ($user) { |
|
318
|
|
|
$result = $myMalScraper->getUser($user); |
|
319
|
|
|
print_r($result); |
|
320
|
|
|
} else { |
|
321
|
|
|
print_r(paramError()); |
|
322
|
|
|
} |
|
323
|
|
|
break; |
|
324
|
|
|
case 'user-friend': |
|
325
|
|
|
case 'userfriend': |
|
326
|
|
|
if ($user) { |
|
327
|
|
|
$result = $myMalScraper->getUserFriend($user); |
|
328
|
|
|
print_r($result); |
|
329
|
|
|
} else { |
|
330
|
|
|
print_r(paramError()); |
|
331
|
|
|
} |
|
332
|
|
|
break; |
|
333
|
|
|
case 'user-history': |
|
334
|
|
|
case 'userhistory': |
|
335
|
|
|
if ($user) { |
|
336
|
|
|
$result = $myMalScraper->getUserHistory($user, $type); |
|
337
|
|
|
print_r($result); |
|
338
|
|
|
} else { |
|
339
|
|
|
print_r(paramError()); |
|
340
|
|
|
} |
|
341
|
|
|
break; |
|
342
|
|
|
case 'user-list': |
|
343
|
|
|
case 'userlist': |
|
344
|
|
|
if ($user) { |
|
345
|
|
|
$type = $type ? $type : 'anime'; |
|
346
|
|
|
$result = $myMalScraper->getUserList($user, $type, $status); |
|
347
|
|
|
print_r($result); |
|
348
|
|
|
} else { |
|
349
|
|
|
print_r(paramError()); |
|
350
|
|
|
} |
|
351
|
|
|
break; |
|
352
|
|
|
case 'user-cover': |
|
353
|
|
|
case 'usercover': |
|
354
|
|
|
if ($user) { |
|
355
|
|
|
header('Content-Type: text/css'); |
|
356
|
|
|
|
|
357
|
|
|
$type = $type ? $type : 'anime'; |
|
358
|
|
|
$query = $query ? $query : false; |
|
359
|
|
|
|
|
360
|
|
|
$result = $myMalScraper->getUserCover($user, $type, $query); |
|
361
|
|
|
$result = json_decode($result, true); |
|
362
|
|
|
$result = $result['data']; |
|
363
|
|
|
|
|
364
|
|
|
print_r($result); |
|
365
|
|
|
} else { |
|
366
|
|
|
print_r(paramError()); |
|
367
|
|
|
} |
|
368
|
|
|
break; |
|
369
|
|
|
|
|
370
|
|
|
// Secret ---------- |
|
371
|
|
|
case 'auto-cover': |
|
372
|
|
|
header('Content-Type: text/css'); |
|
373
|
|
|
|
|
374
|
|
|
$user_url = $_SERVER['HTTP_REFERER']; |
|
375
|
|
|
$user_url = str_replace('https://myanimelist.net', '', $user_url); |
|
376
|
|
|
|
|
377
|
|
|
preg_match("/\/.+(list)\//", $user_url, $user_type); |
|
378
|
|
|
$type = str_replace(['/', 'list'], '', $user_type[0]); |
|
379
|
|
|
|
|
380
|
|
|
$user_url = str_replace(['/animelist/', '/mangalist/'], '', $user_url); |
|
381
|
|
|
$user_url = preg_replace('/\?+.+/', '', $user_url); |
|
382
|
|
|
|
|
383
|
|
|
$user = $user_url; |
|
384
|
|
|
$type = $type ? $type : 'anime'; |
|
385
|
|
|
$query = $query ? $query : false; |
|
386
|
|
|
|
|
387
|
|
|
$result = $myMalScraper->getUserCover($user, $type, $query); |
|
388
|
|
|
$result = json_decode($result, true); |
|
389
|
|
|
$result = $result['data']; |
|
390
|
|
|
|
|
391
|
|
|
print_r($result); |
|
392
|
|
|
break; |
|
393
|
|
|
default: |
|
394
|
|
|
print_r(paramError(true)); |
|
395
|
|
|
break; |
|
396
|
|
|
} |
|
397
|
|
|
|
|
398
|
|
|
// Return error parameter |
|
399
|
|
|
function paramError($a = false) |
|
400
|
|
|
{ |
|
401
|
|
|
$result = []; |
|
402
|
|
|
if ($a) { |
|
403
|
|
|
header('HTTP/1.1 404'); |
|
404
|
|
|
$result['status'] = 404; |
|
405
|
|
|
$result['status_message'] = 'Method not found'; |
|
406
|
|
|
$result['data'] = []; |
|
407
|
|
|
} else { |
|
408
|
|
|
header('HTTP/1.1 400'); |
|
409
|
|
|
$result['status'] = 400; |
|
410
|
|
|
$result['status_message'] = 'Bad Request'; |
|
411
|
|
|
$result['data'] = []; |
|
412
|
|
|
} |
|
413
|
|
|
|
|
414
|
|
|
return json_encode($result, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); |
|
415
|
|
|
} |
|
416
|
|
|
|
|
417
|
|
|
// Get current season (spring,summer,fall,winter) |
|
418
|
|
|
function getCurrentSeason() |
|
419
|
|
|
{ |
|
420
|
|
|
$currentMonth = date('m'); |
|
421
|
|
|
|
|
422
|
|
|
if ($currentMonth >= '01' && $currentMonth < '04') { |
|
423
|
|
|
return 'winter'; |
|
424
|
|
|
} |
|
425
|
|
|
if ($currentMonth >= '04' && $currentMonth < '07') { |
|
426
|
|
|
return 'spring'; |
|
427
|
|
|
} |
|
428
|
|
|
if ($currentMonth >= '07' && $currentMonth < '10') { |
|
429
|
|
|
return 'summer'; |
|
430
|
|
|
} |
|
431
|
|
|
|
|
432
|
|
|
return 'autumn'; |
|
433
|
|
|
} |
|
434
|
|
|
|