-
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathstreaming.php
More file actions
224 lines (198 loc) Β· 6.47 KB
/
streaming.php
File metadata and controls
224 lines (198 loc) Β· 6.47 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<?php
require 'tohost.php';
if (!isset($_GET['animeId']) || empty($_GET['animeId'])) {
die("Anime ID is required.");
}
include 'header.html';
$animeId = htmlspecialchars($_GET['animeId']);
// Endpoint for fetching episodes
$endpoint = '/api/v2/hianime/anime/' . $animeId . '/episodes';
$apiUrl = BASE_API_URL . $endpoint;
// Fetch data from API
$response = file_get_contents($apiUrl);
$data = json_decode($response, true);
if (!$data || !$data['success']) {
die("Failed to fetch episodes.");
}
$episodes = $data['data']['episodes'];
$totalEpisodes = $data['data']['totalEpisodes'];
// Verify the fetched data
if (empty($episodes)) {
die("No episodes found.");
}
// **Group episodes into sections dynamically (e.g., 50 per group)**
$groupSize = 50;
$groupedEpisodes = [];
foreach ($episodes as $episode) {
$groupIndex = floor(($episode['number'] - 1) / $groupSize);
$groupedEpisodes[$groupIndex][] = $episode;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Anime Stream - <?= htmlspecialchars($animeId) ?></title>
<style>
/* π Main Container */
.container {
max-width: 1200px;
margin: auto;
padding: 20px;
}
/* π Episode Navigation */
.episode-nav {
background: #fff;
padding: 15px;
border-radius: 8px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}
/* π Collapsible Sections (Using details/summary) */
.episode-section details {
border-radius: 6px;
margin-bottom: 10px;
overflow: hidden;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
.episode-section summary {
background: #ff6600;
color: white;
padding: 12px;
font-size: 18px;
border-radius: 6px;
cursor: pointer;
transition: 0.3s;
}
.episode-section summary:hover {
background: #e65100;
}
/* π Episode Grid */
.episode-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
gap: 10px;
padding: 10px;
background: #fff;
}
.episode-card {
background: #ffcc80;
padding: 10px;
border-radius: 6px;
text-decoration: none;
color: #333;
transition: 0.3s;
text-align: center;
font-size: 16px;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}
.episode-card:hover {
background: #ffb74d;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
/* π Filler Tag */
.filler-tag {
display: inline-block;
background: red;
color: white;
padding: 2px 6px;
border-radius: 3px;
font-size: 12px;
}
/* π Player */
.player-container {
background: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
text-align: center;
margin-top: 20px;
}
#episode-player {
width: 100%;
height: 100%;
border: none;
border-radius: 6px;
}
/* π Player Options */
.player-options {
display: flex;
justify-content: center;
gap: 20px;
margin-top: 10px;
}
.player-options select {
padding: 8px;
font-size: 16px;
border-radius: 6px;
border: 2px solid #ff6600;
}
</style>
</head>
<body>
<main class="container">
<!-- Episode Navigation -->
<nav class="episode-nav">
<h2>Episodes</h2>
<?php foreach ($groupedEpisodes as $groupIndex => $group): ?>
<section class="episode-section">
<details>
<summary>
Episodes <?= $groupIndex * $groupSize + 1 ?> - <?= min(($groupIndex + 1) * $groupSize, $totalEpisodes) ?>
</summary>
<div class="episode-grid">
<?php foreach ($group as $episode): ?>
<a href="#" class="episode-card"
data-episode-id="<?= $episode['episodeId'] ?>"
onclick="loadEpisode(event, '<?= $episode['episodeId'] ?>')">
<div class="episode-number">Ep <?= $episode['number'] ?></div>
<div class="episode-title"><?= htmlspecialchars($episode['title']) ?></div>
<?php if ($episode['isFiller']): ?>
<span class="filler-tag">Filler</span>
<?php endif; ?>
</a>
<?php endforeach; ?>
</div>
</details>
</section>
<?php endforeach; ?>
</nav>
<!-- Player -->
<section class="player-container">
<iframe id="episode-player" src="<?= !empty($episodes[0]['episodeId']) ? 'player.php?episodeId=' . $episodes[0]['episodeId'] . '&category=sub' : '' ?>"></iframe>
<div class="player-options">
<div>
<label for="language-select">Language:</label>
<select id="language-select" onchange="updatePlayer()">
<option value="sub">Sub</option>
<option value="dub">Dub</option>
</select>
</div>
<div>
<label for="server-select">Server:</label>
<select id="server-select" onchange="updatePlayer()">
<option value="player">Server 1</option>
<option value="player2">Server 2</option>
</select>
</div>
</div>
</section>
<?php include 'detailstream.php'; ?>
</main>
<script>
// Load and update player
let currentEpisodeId = "<?= !empty($episodes[0]['episodeId']) ? $episodes[0]['episodeId'] : '' ?>";
function loadEpisode(event, episodeId) {
event.preventDefault();
currentEpisodeId = episodeId;
updatePlayer();
}
function updatePlayer() {
const language = document.getElementById('language-select').value;
const server = document.getElementById('server-select').value;
const player = document.getElementById('episode-player');
player.src = `${server}.php?episodeId=${currentEpisodeId}&category=${language}`;
}
</script>
</body>
</html>