-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathleebit.html
More file actions
253 lines (212 loc) · 7.04 KB
/
leebit.html
File metadata and controls
253 lines (212 loc) · 7.04 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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="UTF-8" />
<title>💖 Leebit Streaming Service 💖</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Comic+Neue&family=Pacifico&display=swap');
body {
font-family: 'Comic Neue', cursive;
background: linear-gradient(to bottom, #ffe6f0, #ffd9ec);
padding: 30px;
color: #d63384;
text-align: center;
}
h2 {
font-family: 'Pacifico', cursive;
color: #ff69b4;
font-size: 2.5em;
margin-bottom: 10px;
}
video {
width: 100%;
max-width: 720px;
border: 5px dashed #ffb6c1;
border-radius: 20px;
background-color: #fff;
box-shadow: 0 0 20px #ffb6c1;
margin-top: 20px;
}
select, button {
background: #ffc0cb;
color: #fff;
border: none;
border-radius: 10px;
padding: 10px 15px;
font-size: 1em;
font-weight: bold;
box-shadow: 0 2px 5px #faa;
margin: 10px 5px;
cursor: pointer;
transition: 0.3s;
}
select:hover, button:hover {
background: #ff69b4;
transform: scale(1.05);
}
p#info {
font-size: 1em;
margin-top: 15px;
background: #ffeef8;
border: 2px dotted #ff99cc;
padding: 10px;
border-radius: 10px;
display: inline-block;
max-width: 720px;
text-align: left;
white-space: pre-line;
}
#bitrateButtons button {
margin: 5px;
padding: 8px 12px;
}
#requests {
max-width: 720px;
margin: 15px auto;
background: #fff0f6;
border-radius: 10px;
padding: 10px;
font-size: 0.9em;
text-align: left;
height: 150px;
overflow-y: auto;
border: 1px solid #ff99cc;
}
</style>
</head>
<body>
<h2>💖 Leebit 💖</h2>
<select id="playlistSelect">
<option value="https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8">🌸 Sample Stream 1 🌸</option>
<option value="https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8">🔥 Sample Stream 2 🔥</option>
<option value="https://moose1-hls.live.cdn.bitgravity.com/live/moose1/playlist.m3u8">✨ Sample Stream 3 ✨</option>
</select>
<button onclick="loadSelected()">✨ Load video ✨</button>
<br />
<video id="video" controls></video>
<div id="bitrateButtons"></div>
<p id="info">Loading... 💫</p>
<h3>Requests being fetched (on-the-fly):</h3>
<div id="requests">No requests yet...</div>
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
<script>
const video = document.getElementById('video');
const info = document.getElementById('info');
const playlistSelect = document.getElementById('playlistSelect');
const bitrateButtonsDiv = document.getElementById('bitrateButtons');
const requestsDiv = document.getElementById('requests');
let hls;
let geoAccessGranted = false;
// Simulated GEO whitelist check: allow IPs starting with 192
async function checkGeoAccess() {
try {
const response = await fetch('http://www.geoplugin.net/json.gp');
const data = await response.json();
console.log('GEO data:', data);
if (data.geoplugin_request && data.geoplugin_request.startsWith('192.')) {
geoAccessGranted = true;
} else {
geoAccessGranted = false;
}
if (!geoAccessGranted) {
alert('Access denied: your location is not permitted to view Premium content.');
}
} catch (e) {
console.warn('Could not verify GEO location:', e);
geoAccessGranted = true; // fallback: allow
}
}
async function loadSelected() {
const selected = playlistSelect.value;
// Check GEO access before loading
await checkGeoAccess();
if (!geoAccessGranted) {
info.textContent = 'Access denied for your location.';
video.pause();
video.src = '';
bitrateButtonsDiv.innerHTML = '';
return;
}
if (hls) {
hls.destroy();
bitrateButtonsDiv.innerHTML = '';
requestsDiv.textContent = 'No requests yet...';
}
hls = new Hls({
debug: false,
});
// Track all requests being made (on-the-fly)
hls.on(Hls.Events.FRAG_LOADING, function (event, data) {
const url = data.url || data.frag?.url;
if (url) {
addRequestLog(url);
}
});
// Handle level (quality) switching manually
hls.on(Hls.Events.MANIFEST_PARSED, function (_, data) {
info.textContent = 'Manifest loaded, ' + data.levels.length + ' quality levels found.';
// Create bitrate buttons
bitrateButtonsDiv.innerHTML = '';
data.levels.forEach((level, index) => {
const btn = document.createElement('button');
btn.textContent = `${Math.round(level.bitrate / 1000)} kbps (${level.width}x${level.height})`;
btn.onclick = () => {
hls.currentLevel = index;
updateVideoInfo();
};
bitrateButtonsDiv.appendChild(btn);
});
// Start with automatic level (default)
hls.currentLevel = -1;
updateVideoInfo();
});
hls.attachMedia(video);
hls.loadSource(selected);
// Update info about video and audio codecs on level switch
hls.on(Hls.Events.LEVEL_SWITCHED, () => {
updateVideoInfo();
});
// When video metadata is loaded, update info
video.addEventListener('loadedmetadata', () => {
updateVideoInfo();
});
}
function updateVideoInfo() {
if (!hls || !hls.levels || hls.levels.length === 0) {
info.textContent = 'No levels loaded';
return;
}
const levelIndex = hls.currentLevel;
let level;
if (levelIndex === -1) {
// Auto mode: find current level from hls stats
level = hls.levels[hls.nextLevel] || hls.levels[0];
} else {
level = hls.levels[levelIndex];
}
if (!level) {
info.textContent = 'No level information available.';
return;
}
const videoCodec = level.videoCodec || 'unknown';
const audioCodec = level.audioCodec || 'unknown';
const text = `
Bitrate: ${Math.round(level.bitrate / 1000)} kbps
Resolution: ${level.width}x${level.height}
Video Codec: ${videoCodec}
Audio Codec: ${audioCodec}
Current Level Index: ${levelIndex === -1 ? 'Auto' : levelIndex}
`.trim();
info.textContent = text;
}
function addRequestLog(url) {
// Append request url with scroll-down
if (requestsDiv.textContent === 'No requests yet...') requestsDiv.textContent = '';
requestsDiv.textContent += url + '\n';
requestsDiv.scrollTop = requestsDiv.scrollHeight;
}
// Load initial playlist on page load
loadSelected();
</script>
</body>
</html>