UPDATE: Changed stream access URL to use streamer_name instead of streamer_key, to hide streamer key.
This commit is contained in:
@@ -25,7 +25,7 @@ rtmp {
|
||||
live on;
|
||||
|
||||
hls on;
|
||||
hls_path /stream_data/stream/;
|
||||
hls_path /stream_data/;
|
||||
|
||||
allow publish 127.0.0.1;
|
||||
deny publish all;
|
||||
|
||||
@@ -185,11 +185,11 @@ def init_stream():
|
||||
print("Unauthorized - Invalid stream key", flush=True)
|
||||
return "Unauthorized - Invalid stream key", 403
|
||||
|
||||
# Create necessary directories
|
||||
username = user_info["username"]
|
||||
create_local_directories(username)
|
||||
# Create necessary directories
|
||||
username = user_info["username"]
|
||||
create_local_directories(username)
|
||||
|
||||
return "OK", 200
|
||||
return redirect(f"/stream/{username}")
|
||||
|
||||
|
||||
@stream_bp.route("/publish_stream", methods=["POST"])
|
||||
@@ -243,7 +243,7 @@ def publish_stream():
|
||||
# Update thumbnail periodically
|
||||
update_thumbnail.delay(user_id,
|
||||
path_manager.get_stream_file_path(username),
|
||||
path_manager.get_thumbnail_file_path(username),
|
||||
path_manager.get_current_stream_thumbnail_file_path(username),
|
||||
THUMBNAIL_GENERATION_INTERVAL)
|
||||
|
||||
return "OK", 200
|
||||
|
||||
@@ -22,6 +22,7 @@ def user_data(username: str):
|
||||
data = get_user(user_id)
|
||||
return jsonify(data)
|
||||
|
||||
@login_required
|
||||
@user_bp.route('/user/<string:username>/stream_key')
|
||||
def user_stream_key(username: str):
|
||||
"""
|
||||
|
||||
@@ -2,16 +2,19 @@
|
||||
|
||||
class PathManager():
|
||||
def get_vods_path(self, username):
|
||||
return f"stream_data/{username}/vods"
|
||||
return f"stream_data/vods/{username}"
|
||||
|
||||
def get_stream_path(self, username):
|
||||
return f"stream_data/{username}/stream"
|
||||
|
||||
def get_thumbnail_path(self, username):
|
||||
return f"stream_data/{username}/thumbnails"
|
||||
return f"stream_data/stream/{username}"
|
||||
|
||||
def get_stream_file_path(self, username):
|
||||
return f"{self.get_stream_path(username)}/index.m3u8"
|
||||
|
||||
def get_thumbnail_file_path(self, username):
|
||||
return f"{self.get_thumbnail_path(username)}/stream.jpg"
|
||||
def get_current_stream_thumbnail_file_path(self, username):
|
||||
return f"{self.get_stream_path(username)}/index.jpg"
|
||||
|
||||
def get_vod_file_path(self, username, vod_id):
|
||||
return f"{self.get_vods_path(username)}/{vod_id}.mp4"
|
||||
|
||||
def get_vod_thumbnail_file_path(self, username, vod_id):
|
||||
return f"{self.get_vods_path(username)}/{vod_id}.jpg"
|
||||
@@ -3,6 +3,7 @@ from typing import Optional
|
||||
import os, subprocess
|
||||
from typing import Optional, List
|
||||
from time import sleep
|
||||
from utils.path_manager import PathManager
|
||||
|
||||
def get_streamer_live_status(user_id: int):
|
||||
"""
|
||||
@@ -147,9 +148,10 @@ def create_local_directories(username: str):
|
||||
Create directories for user stream data if they do not exist
|
||||
"""
|
||||
|
||||
vods_path = f"stream_data/vods/{username}"
|
||||
stream_path = f"stream_data/stream"
|
||||
thumbnail_path = f"stream_data/thumbnails/{username}"
|
||||
path_m = PathManager()
|
||||
|
||||
vods_path = path_m.get_vods_path(username)
|
||||
stream_path = path_m.get_stream_path(username)
|
||||
|
||||
if not os.path.exists(vods_path):
|
||||
os.makedirs(vods_path)
|
||||
@@ -157,16 +159,11 @@ def create_local_directories(username: str):
|
||||
if not os.path.exists(stream_path):
|
||||
os.makedirs(stream_path)
|
||||
|
||||
if not os.path.exists(thumbnail_path):
|
||||
os.makedirs(thumbnail_path)
|
||||
|
||||
# Fix permissions
|
||||
os.chmod(vods_path, 0o777)
|
||||
os.chmod(stream_path, 0o777)
|
||||
os.chmod(thumbnail_path, 0o777)
|
||||
|
||||
return {
|
||||
"vod_path": vods_path,
|
||||
"stream_path": stream_path,
|
||||
"thumbnail_path": thumbnail_path
|
||||
"stream_path": stream_path
|
||||
}
|
||||
Reference in New Issue
Block a user