From 943cb9a807a64d2c3a65de509dde0968644d1fb7 Mon Sep 17 00:00:00 2001 From: Markos Gogoulos Date: Wed, 21 May 2025 19:16:48 +0300 Subject: [PATCH] feat --- files/methods.py | 4 ++-- files/tasks.py | 26 ++++++++++---------------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/files/methods.py b/files/methods.py index 502982d1..37872074 100644 --- a/files/methods.py +++ b/files/methods.py @@ -464,7 +464,7 @@ def copy_video(original_media, copy_encodings=True, title_suffix="(Trimmed)"): if copy_encodings: - for encoding in original_media.encodings.filter(chunk=False): + for encoding in original_media.encodings.filter(chunk=False, status="success"): if encoding.media_file: with open(encoding.media_file.path, "rb") as f: myfile = File(f) @@ -472,7 +472,7 @@ def copy_video(original_media, copy_encodings=True, title_suffix="(Trimmed)"): media_file=myfile, media=new_media, profile=encoding.profile, - status=encoding.status, + status="success", progress=100, chunk=False, logs=f"Copied from encoding {encoding.id}" diff --git a/files/tasks.py b/files/tasks.py index 8fb0db92..a973a653 100644 --- a/files/tasks.py +++ b/files/tasks.py @@ -974,14 +974,11 @@ def video_trim_task(self, trim_request_id): encoding.delete() deleted_encodings = handle_pending_running_encodings(target_media) - if deleted_encodings: - # give the chance to run encodings for encodings that didnt make it - target_media.encode(force=False) - trim_request_status = "running" - # TODO: find way to call post_trim_action only after this has finished... - else: - post_trim_action.delay(target_media.friendly_token) - trim_request_status = "success" + # give the chance to run encodings for encodings that didnt make it + target_media.encode(force=False) + trim_request_status = "running" + # TODO: find way to call post_trim_action only after this has finished... + post_trim_action.delay(target_media.friendly_token) trim_request.status = trim_request_status trim_request.save(update_fields=["status"]) @@ -1001,14 +998,11 @@ def video_trim_task(self, trim_request_id): encoding.delete() deleted_encodings = handle_pending_running_encodings(target_media) - if deleted_encodings: - # give the chance to run encodings for encodings that didnt make it - target_media.encode(force=False) - trim_request_status = "running" - # TODO: find way to call post_trim_action only after this has finished... - else: - post_trim_action.delay(target_media.friendly_token) - trim_request_status = "success" + # give the chance to run encodings for encodings that didnt make it + target_media.encode(force=False) + trim_request_status = "running" + # TODO: find way to call post_trim_action only after this has finished... + post_trim_action.delay(target_media.friendly_token) trim_request.status = trim_request_status trim_request.save(update_fields=["status"])