-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
69 lines (62 loc) · 2.39 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Stream Selector</title>
<link href="https://unpkg.com/video.js/dist/video-js.css" rel="stylesheet">
<script src="https://unpkg.com/video.js/dist/video.js"></script>
<script src="https://unpkg.com/@videojs/http-streaming/dist/videojs-http-streaming.js"></script>
</head>
<body>
<form id="stream-form">
<label for="stream-select">Select a stream:</label><br>
<select name="streams" id="stream-select">
<!-- options will be added here -->
</select>
<br><br>
<input type="submit" value="Submit">
</form>
<br>
<div id="player-container" style="display: none">
<video id="my_video_1" class="video-js vjs-fluid vjs-default-skin" controls preload="none">
<source id="stream-source" src="" type="application/x-mpegURL">
</video>
</div>
<script>
const corsProxyUrl = 'https://cors.proxy.consumet.org/';
const streamListUrl = 'https://raw.githubusercontent.com/iptv-org/iptv/master/streams/us_pluto.m3u';
const player = videojs('my_video_1');
const formElement = document.getElementById('stream-form');
const selectElement = document.getElementById('stream-select');
const sourceElement = document.getElementById('stream-source');
fetch(streamListUrl)
.then(response => response.text())
.then(streams => {
const lines = streams.split('\n');
const streamOptions = [];
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
if (line.startsWith('#EXTINF')) {
const title = line.split(',')[1];
const link = lines[i + 1].trim();
streamOptions.push({ title, link });
i++;
}
}
streamOptions.forEach(({ title, link }) => {
const optionElement = document.createElement('option');
optionElement.value = link;
optionElement.text = title;
selectElement.appendChild(optionElement);
});
});
formElement.addEventListener('submit', event => {
event.preventDefault();
const selectedLink = selectElement.value;
sourceElement.setAttribute('src', `${corsProxyUrl}${selectedLink}`);
player.src({ src: `${corsProxyUrl}${selectedLink}`, type: 'application/x-mpegURL' });
document.getElementById('player-container').style.display = 'block';
});
</script>
</body>
</html>