Spaces:
Running
Running
Create static/index.html
Browse files- static/index.html +75 -0
static/index.html
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!-- index.html -->
|
2 |
+
<!DOCTYPE html>
|
3 |
+
<html>
|
4 |
+
<head>
|
5 |
+
<title>TorrentGalaxy Streamer</title>
|
6 |
+
<style>
|
7 |
+
body { font-family: Arial, sans-serif; max-width: 1200px; margin: 0 auto; padding: 20px; }
|
8 |
+
.search-section, .player-section { margin-bottom: 30px; }
|
9 |
+
#results { margin-top: 20px; }
|
10 |
+
.torrent-item { padding: 10px; border-bottom: 1px solid #ddd; cursor: pointer; }
|
11 |
+
.torrent-item:hover { background: #f5f5f5; }
|
12 |
+
#player { width: 100%; height: 500px; }
|
13 |
+
</style>
|
14 |
+
</head>
|
15 |
+
<body>
|
16 |
+
<div class="search-section">
|
17 |
+
<h1>TorrentGalaxy Streamer</h1>
|
18 |
+
<input type="text" id="searchInput" placeholder="Search TorrentGalaxy...">
|
19 |
+
<button onclick="searchTorrents()">Search</button>
|
20 |
+
<div id="results"></div>
|
21 |
+
</div>
|
22 |
+
|
23 |
+
<div class="player-section">
|
24 |
+
<video id="player" controls></video>
|
25 |
+
</div>
|
26 |
+
|
27 |
+
<script>
|
28 |
+
async function searchTorrents() {
|
29 |
+
const query = document.getElementById('searchInput').value;
|
30 |
+
const results = document.getElementById('results');
|
31 |
+
results.innerHTML = 'Loading...';
|
32 |
+
|
33 |
+
try {
|
34 |
+
const response = await fetch(`/search?q=${encodeURIComponent(query)}`);
|
35 |
+
const torrents = await response.json();
|
36 |
+
|
37 |
+
results.innerHTML = torrents.map(t => `
|
38 |
+
<div class="torrent-item" onclick="startStream('${t.magnet}')">
|
39 |
+
<strong>${t.title}</strong><br>
|
40 |
+
<small>Size: ${t.size} | Seeds: ${t.seeds}</small>
|
41 |
+
</div>
|
42 |
+
`).join('');
|
43 |
+
} catch (error) {
|
44 |
+
results.innerHTML = 'Error loading results';
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
async function startStream(magnet) {
|
49 |
+
try {
|
50 |
+
// Start the stream
|
51 |
+
const startResp = await fetch('/start_stream', {
|
52 |
+
method: 'POST',
|
53 |
+
headers: {'Content-Type': 'application/json'},
|
54 |
+
body: JSON.stringify({ magnet_link: magnet })
|
55 |
+
});
|
56 |
+
|
57 |
+
const { stream_url } = await startResp.json();
|
58 |
+
|
59 |
+
// Get MIME type and set up player
|
60 |
+
const mimeResp = await fetch(`${stream_url}/mime`);
|
61 |
+
const { mime_type } = await mimeResp.json();
|
62 |
+
|
63 |
+
// Set up video player
|
64 |
+
const player = document.getElementById('player');
|
65 |
+
player.src = stream_url;
|
66 |
+
player.type = mime_type;
|
67 |
+
player.load();
|
68 |
+
player.play();
|
69 |
+
} catch (error) {
|
70 |
+
alert('Error starting stream: ' + error.message);
|
71 |
+
}
|
72 |
+
}
|
73 |
+
</script>
|
74 |
+
</body>
|
75 |
+
</html>
|