From 6ba9a41404fe74c979a42d06500fe01cb15563ff Mon Sep 17 00:00:00 2001 From: Chneemann Date: Mon, 19 Aug 2024 22:09:05 +0200 Subject: [PATCH] update documentation --- backend/videoflix/content/signals.py | 3 +-- backend/videoflix/content/tasks.py | 6 ++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/videoflix/content/signals.py b/backend/videoflix/content/signals.py index e954a43..b4a77a0 100644 --- a/backend/videoflix/content/signals.py +++ b/backend/videoflix/content/signals.py @@ -9,9 +9,8 @@ import shutil @receiver(post_save, sender=Video) def video_post_save(sender, instance, created, **kwargs): """ - Generates a thumbnail for a newly created `Video` instance. + Generates a thumbnail, enqueues tasks to convert the video to different resolutions, and schedules the deletion of the original video file. """ - # With Django RQ Worker (My server is too slow for it) if created: queue = django_rq.get_queue("default", autocommit=True) diff --git a/backend/videoflix/content/tasks.py b/backend/videoflix/content/tasks.py index df7eeba..d686d99 100644 --- a/backend/videoflix/content/tasks.py +++ b/backend/videoflix/content/tasks.py @@ -5,6 +5,9 @@ import os from django.conf import settings def convert_video_to_hls(source, resolution, model_id): + """ + Converts a video to the HLS format + """ target_dir = os.path.join(os.path.dirname(source), str(model_id)) os.makedirs(target_dir, exist_ok=True) @@ -38,6 +41,9 @@ def delete_original_video(source): print(f"Error deleting original file: {e}") def create_thumbnails(instance, model_id): + """ + Creates high-resolution and low-resolution thumbnails from a video file + """ video_file_path = instance.video_file.path thumbnail_dir = os.path.join(settings.THUMBNAIL_DIR, str(model_id))