UPDATE: Changed "stream_data" volume to "user_data" volume
This commit is contained in:
@@ -11,7 +11,7 @@ services:
|
|||||||
networks:
|
networks:
|
||||||
- app_network
|
- app_network
|
||||||
volumes:
|
volumes:
|
||||||
- stream_data:/stream_data
|
- user_data:/user_data
|
||||||
|
|
||||||
web_server:
|
web_server:
|
||||||
build:
|
build:
|
||||||
@@ -26,7 +26,7 @@ services:
|
|||||||
- FLASK_APP=blueprints.__init__
|
- FLASK_APP=blueprints.__init__
|
||||||
- FLASK_ENV=production
|
- FLASK_ENV=production
|
||||||
volumes:
|
volumes:
|
||||||
- stream_data:/web_server/stream_data
|
- user_data:/web_server/user_data
|
||||||
- database_data:/web_server/database
|
- database_data:/web_server/database
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
@@ -58,7 +58,7 @@ services:
|
|||||||
- redis
|
- redis
|
||||||
volumes:
|
volumes:
|
||||||
- .:/app
|
- .:/app
|
||||||
- stream_data:/web_server/stream_data
|
- user_data:/web_server/user_data
|
||||||
- database_data:/web_server/database
|
- database_data:/web_server/database
|
||||||
networks:
|
networks:
|
||||||
- app_network
|
- app_network
|
||||||
@@ -71,7 +71,7 @@ services:
|
|||||||
- redis
|
- redis
|
||||||
volumes:
|
volumes:
|
||||||
- .:/app
|
- .:/app
|
||||||
- stream_data:/web_server/stream_data
|
- user_data:/web_server/user_data
|
||||||
- database_data:/web_server/database
|
- database_data:/web_server/database
|
||||||
networks:
|
networks:
|
||||||
- app_network
|
- app_network
|
||||||
@@ -81,7 +81,7 @@ networks:
|
|||||||
driver: bridge
|
driver: bridge
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
stream_data:
|
user_data:
|
||||||
driver: local
|
driver: local
|
||||||
database_data:
|
database_data:
|
||||||
driver: local
|
driver: local
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ rtmp {
|
|||||||
live on;
|
live on;
|
||||||
|
|
||||||
hls on;
|
hls on;
|
||||||
hls_path /stream_data/;
|
hls_path /user_data/;
|
||||||
|
|
||||||
allow publish 127.0.0.1;
|
allow publish 127.0.0.1;
|
||||||
deny publish all;
|
deny publish all;
|
||||||
@@ -80,7 +80,7 @@ http {
|
|||||||
## The HLS stream location with thumbnails
|
## The HLS stream location with thumbnails
|
||||||
## Contains TS files, M3U8 files and PNG thumbnails
|
## Contains TS files, M3U8 files and PNG thumbnails
|
||||||
location ~ ^/stream/(.+)/(.+\.(ts|m3u8|png))$ {
|
location ~ ^/stream/(.+)/(.+\.(ts|m3u8|png))$ {
|
||||||
alias /stream_data/stream/$1/$2;
|
alias /user_data/$1/stream/$2;
|
||||||
|
|
||||||
# Let the MPEG-TS video chunks be cacheable
|
# Let the MPEG-TS video chunks be cacheable
|
||||||
expires max;
|
expires max;
|
||||||
@@ -89,7 +89,7 @@ http {
|
|||||||
## VoDs Location and thumbnails
|
## VoDs Location and thumbnails
|
||||||
## Contains MP4 files and PNG thumbnails
|
## Contains MP4 files and PNG thumbnails
|
||||||
location ~ ^/vods/(.+)/(.+\.(mp4|png))$ {
|
location ~ ^/vods/(.+)/(.+\.(mp4|png))$ {
|
||||||
alias /stream_data/vods/$1/$2;
|
alias /user_data/vods/$1/$2;
|
||||||
|
|
||||||
# The thumbnails should not be cacheable
|
# The thumbnails should not be cacheable
|
||||||
expires -1d;
|
expires -1d;
|
||||||
@@ -97,7 +97,7 @@ http {
|
|||||||
|
|
||||||
## Profile pictures location
|
## Profile pictures location
|
||||||
location ~ ^/user/(.+)/index.png$ {
|
location ~ ^/user/(.+)/index.png$ {
|
||||||
alias /stream_data/profile_pictures/$1.png;
|
alias /user_data/profile_pictures/$1.png;
|
||||||
|
|
||||||
# The profile pictures should not be cacheable
|
# The profile pictures should not be cacheable
|
||||||
expires -1d;
|
expires -1d;
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ import os
|
|||||||
|
|
||||||
class PathManager():
|
class PathManager():
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.root_path = "stream_data"
|
self.root_path = "user_data"
|
||||||
self.vods_path = os.path.join(self.root_path, "vods")
|
self.vod_directory_name = "vods"
|
||||||
self.stream_path = os.path.join(self.root_path, "stream")
|
self.stream_directory_name = "streams"
|
||||||
self.profile_pictures_path = os.path.join(self.root_path, "profile_pictures")
|
self.profile_picture_name = "index.png"
|
||||||
|
self.stream_index_name = "index.m3u8"
|
||||||
self._create_root_directories()
|
self.stream_thumbnail_name = "index.png"
|
||||||
|
|
||||||
def _create_directory(self, path):
|
def _create_directory(self, path):
|
||||||
"""
|
"""
|
||||||
@@ -19,20 +19,33 @@ class PathManager():
|
|||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
os.chmod(path, 0o777)
|
os.chmod(path, 0o777)
|
||||||
|
|
||||||
def _create_root_directories(self):
|
def create_user(self, username):
|
||||||
"""
|
"""
|
||||||
Create directories for stream data if they do not exist
|
Create directories for user stream data if they do not exist
|
||||||
"""
|
"""
|
||||||
self._create_directory(self.root_path)
|
self._create_directory(os.path.join(self.root_path, username))
|
||||||
self._create_directory(self.vods_path)
|
vods_path = self.get_vods_path(username)
|
||||||
self._create_directory(self.stream_path)
|
stream_path = self.get_stream_path(username)
|
||||||
self._create_directory(self.profile_pictures_path)
|
|
||||||
|
self._create_directory(vods_path)
|
||||||
|
self._create_directory(stream_path)
|
||||||
|
|
||||||
|
def delete_user(self, username):
|
||||||
|
"""
|
||||||
|
Delete directories for user stream data
|
||||||
|
"""
|
||||||
|
user_path = self.get_user_path(username)
|
||||||
|
if os.path.exists(user_path):
|
||||||
|
os.rmdir(user_path)
|
||||||
|
|
||||||
|
def get_user_path(self, username):
|
||||||
|
return os.path.join(self.root_path, username)
|
||||||
|
|
||||||
def get_vods_path(self, username):
|
def get_vods_path(self, username):
|
||||||
return os.path.join(self.vods_path, username)
|
return os.path.join(self.root_path, username, self.vod_directory_name)
|
||||||
|
|
||||||
def get_stream_path(self, username):
|
def get_stream_path(self, username):
|
||||||
return os.path.join(self.stream_path, username)
|
return os.path.join(self.root_path, username, self.stream_directory_name)
|
||||||
|
|
||||||
def get_stream_file_path(self, username):
|
def get_stream_file_path(self, username):
|
||||||
return os.path.join(self.get_stream_path(username), "index.m3u8")
|
return os.path.join(self.get_stream_path(username), "index.m3u8")
|
||||||
@@ -47,7 +60,4 @@ class PathManager():
|
|||||||
return os.path.join(self.get_vods_path(username), f"{vod_id}.png")
|
return os.path.join(self.get_vods_path(username), f"{vod_id}.png")
|
||||||
|
|
||||||
def get_profile_picture_file_path(self, username):
|
def get_profile_picture_file_path(self, username):
|
||||||
return os.path.join(self.profile_pictures_path, f"{username}.png")
|
return os.path.join(self.root_path, username, self.profile_picture_name)
|
||||||
|
|
||||||
def get_profile_picture_path(self):
|
|
||||||
return self.profile_pictures_path
|
|
||||||
Reference in New Issue
Block a user