-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrecent.php
71 lines (49 loc) · 1.64 KB
/
recent.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
use voku\helper\HtmlDomParser;
require_once 'composer/vendor/autoload.php';
require_once 'config.php';
require_once 'functions.php';
if (!isset($_REQUEST['page']) || !isset($_REQUEST['type'])) {
sendErrorResponse("No page number or type.");
}
$page = $_REQUEST['page'];
$type = $_REQUEST['type'];
if(!ctype_digit($page) || !ctype_digit($type)) {
sendErrorResponse("Invalid page number or type.");
}
$gogo_request_url = $gogo_ajax_url . "/page-recent-release.html?type=" . $type . "&page=" . $page;
$html = getHtmlFromUrl($gogo_request_url);
$dom = HtmlDomParser::str_get_html($html);
$items = $dom->findOne('.items')->findMulti("li");
$anime = array();
foreach ($items as $item) {
$episode_id = "";
$anime_id = "";
$anime_name = "";
$thumbnail = "";
$episode_number = "";
$sub_or_dub = "sub";
$episode_id = $item->findOne("a")->getAttribute("href");
if ($episode_id[0] === '/') {
$episode_id = substr($episode_id, 1);
}
$anime_name = $item->findOne("a")->getAttribute("title");
$thumbnail = $item->findOne("img")->getAttribute("src");
$episode_id_parts = explode("-episode-", $episode_id);
$anime_id = $episode_id_parts[0];
$episode_number = $episode_id_parts[1];
if($type == "2") {
$sub_or_dub = "dub";
}
$anime_info_array = array(
"episodeId" => $episode_id,
"animeId" => $anime_id,
"animeTitle" => $anime_name,
"animeImg" => $thumbnail,
"episodeNum" => $episode_number,
"subOrDub" => $sub_or_dub
);
$anime[] = $anime_info_array;
}
header('Content-Type: application/json');
echo json_encode($anime);