Spaces:
Paused
Paused
Commit
·
6c29d73
1
Parent(s):
0920ae9
fix
Browse files- app.py +3 -3
- templates/film_player.html +15 -29
- video.py +1 -1
app.py
CHANGED
@@ -19,7 +19,7 @@ CACHE_DIR = os.getenv("CACHE_DIR")
|
|
19 |
if not os.path.exists(CACHE_DIR):
|
20 |
os.makedirs(CACHE_DIR)
|
21 |
|
22 |
-
indexer()
|
23 |
|
24 |
if not os.path.exists(INDEX_FILE):
|
25 |
raise FileNotFoundError(f"{INDEX_FILE} not found. Please make sure the file exists.")
|
@@ -219,8 +219,8 @@ def stream_video():
|
|
219 |
|
220 |
@app.route('/stream/<stream_id>')
|
221 |
def stream_file(stream_id):
|
222 |
-
stream_dir =
|
223 |
-
playlist_path =
|
224 |
|
225 |
if os.path.exists(playlist_path):
|
226 |
return Response(
|
|
|
19 |
if not os.path.exists(CACHE_DIR):
|
20 |
os.makedirs(CACHE_DIR)
|
21 |
|
22 |
+
#indexer()
|
23 |
|
24 |
if not os.path.exists(INDEX_FILE):
|
25 |
raise FileNotFoundError(f"{INDEX_FILE} not found. Please make sure the file exists.")
|
|
|
219 |
|
220 |
@app.route('/stream/<stream_id>')
|
221 |
def stream_file(stream_id):
|
222 |
+
stream_dir = CACHE_DIR+"/stream/"+stream_id
|
223 |
+
playlist_path = stream_dir+'/output.m3u8'
|
224 |
|
225 |
if os.path.exists(playlist_path):
|
226 |
return Response(
|
templates/film_player.html
CHANGED
@@ -49,40 +49,26 @@
|
|
49 |
<script>
|
50 |
document.addEventListener("DOMContentLoaded", function() {
|
51 |
const queryParams = new URLSearchParams(window.location.search);
|
52 |
-
const
|
53 |
|
54 |
-
if (!
|
55 |
-
document.getElementById('error').innerText = 'No
|
56 |
return;
|
57 |
}
|
58 |
|
59 |
-
//
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
-
//
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
if (data.file_path) {
|
67 |
-
return fetch(`/api/stream?path=${encodeURIComponent(data.file_path)}`);
|
68 |
-
} else {
|
69 |
-
throw new Error('File path not found.');
|
70 |
-
}
|
71 |
-
})
|
72 |
-
.then(response => response.json())
|
73 |
-
.then(data => {
|
74 |
-
if (data.stream_id) {
|
75 |
-
// Update video source with the stream URL
|
76 |
-
const videoSource = document.getElementById('videoSource');
|
77 |
-
videoSource.src = `/stream/${data.stream_id}`;
|
78 |
-
document.getElementById('videoPlayer').load();
|
79 |
-
} else {
|
80 |
-
throw new Error('Stream ID not found.');
|
81 |
-
}
|
82 |
-
})
|
83 |
-
.catch(error => {
|
84 |
-
document.getElementById('error').innerText = `Error: ${error.message}`;
|
85 |
-
});
|
86 |
});
|
87 |
</script>
|
88 |
</body>
|
|
|
49 |
<script>
|
50 |
document.addEventListener("DOMContentLoaded", function() {
|
51 |
const queryParams = new URLSearchParams(window.location.search);
|
52 |
+
const streamId = queryParams.get('stream_id');
|
53 |
|
54 |
+
if (!streamId) {
|
55 |
+
document.getElementById('error').innerText = 'No stream ID provided.';
|
56 |
return;
|
57 |
}
|
58 |
|
59 |
+
// Fetch film metadata if needed (optional)
|
60 |
+
// fetch(`/api/film/${encodeURIComponent(streamId)}`)
|
61 |
+
// .then(response => response.json())
|
62 |
+
// .then(data => {
|
63 |
+
// if (data.title) {
|
64 |
+
// document.getElementById('filmTitle').innerText = data.title;
|
65 |
+
// }
|
66 |
+
// });
|
67 |
|
68 |
+
// Set video source
|
69 |
+
const videoSource = document.getElementById('videoSource');
|
70 |
+
videoSource.src = `/stream/${streamId}`;
|
71 |
+
document.getElementById('videoPlayer').load();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
});
|
73 |
</script>
|
74 |
</body>
|
video.py
CHANGED
@@ -19,7 +19,7 @@ def ffmpeg_stream(file_url, token, output_dir="tmp/cache/stream"):
|
|
19 |
|
20 |
ffmpeg_command = [
|
21 |
'ffmpeg',
|
22 |
-
'-headers', f'
|
23 |
'-i', file_url,
|
24 |
'-c:v', 'libx264',
|
25 |
'-crf', '23',
|
|
|
19 |
|
20 |
ffmpeg_command = [
|
21 |
'ffmpeg',
|
22 |
+
'-headers', f'Authorization: Bearer {token}',
|
23 |
'-i', file_url,
|
24 |
'-c:v', 'libx264',
|
25 |
'-crf', '23',
|