PATCH: Fixed old .ts files still being present after stream end
This commit is contained in:
@@ -50,12 +50,6 @@ def combine_ts_stream(stream_path, vods_path, vod_file_name):
|
|||||||
|
|
||||||
subprocess.run(vod_command)
|
subprocess.run(vod_command)
|
||||||
|
|
||||||
# Remove ts files
|
|
||||||
for ts_file in ts_files:
|
|
||||||
remove(f"{stream_path}/{ts_file}")
|
|
||||||
# Remove m3u8 file
|
|
||||||
remove(f"{stream_path}/index.m3u8")
|
|
||||||
|
|
||||||
@shared_task
|
@shared_task
|
||||||
def convert_image_to_png(image_path, png_path):
|
def convert_image_to_png(image_path, png_path):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -80,6 +80,9 @@ def end_user_stream(stream_key, user_id, username):
|
|||||||
stream_info = db.fetchone("""SELECT *
|
stream_info = db.fetchone("""SELECT *
|
||||||
FROM streams
|
FROM streams
|
||||||
WHERE user_id = ?""", (user_id,))
|
WHERE user_id = ?""", (user_id,))
|
||||||
|
|
||||||
|
# Remove HLS files, even if user is not streaming
|
||||||
|
remove_hls_files(path_manager.get_stream_path(username))
|
||||||
|
|
||||||
# If user is not streaming, just return
|
# If user is not streaming, just return
|
||||||
if not stream_info:
|
if not stream_info:
|
||||||
@@ -194,6 +197,14 @@ def generate_thumbnail(stream_file: str, thumbnail_file: str) -> None:
|
|||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
print(f"No information available for {stream_file}, aborting thumbnail generation")
|
print(f"No information available for {stream_file}, aborting thumbnail generation")
|
||||||
|
|
||||||
|
def remove_hls_files(stream_path: str) -> None:
|
||||||
|
"""
|
||||||
|
Removes all hls files in a stream directory
|
||||||
|
"""
|
||||||
|
for file in os.listdir(stream_path):
|
||||||
|
if file.endswith(".ts") or file.endswith(".m3u8"):
|
||||||
|
os.remove(os.path.join(stream_path, file))
|
||||||
|
|
||||||
def get_stream_tags(user_id: int) -> Optional[List[str]]:
|
def get_stream_tags(user_id: int) -> Optional[List[str]]:
|
||||||
"""
|
"""
|
||||||
Given a stream return tags associated with the user's stream
|
Given a stream return tags associated with the user's stream
|
||||||
|
|||||||
Reference in New Issue
Block a user