mirror of
https://github.com/mediacms-io/mediacms.git
synced 2025-11-06 15:38:53 -05:00
ref
This commit is contained in:
parent
5123ea7f8d
commit
1fbdb86bac
@ -423,7 +423,6 @@ def copy_video(original_media, copy_encodings=True, title_suffix="(Trimmed)"):
|
||||
Returns:
|
||||
New Media object
|
||||
"""
|
||||
from .tasks import update_encoding_size
|
||||
|
||||
with open(original_media.media_file.path, "rb") as f:
|
||||
myfile = File(f)
|
||||
|
||||
@ -644,8 +644,9 @@ class Media(models.Model):
|
||||
|
||||
if encoding and encoding.status == "success" and encoding.profile.codec == "h264" and action == "add" and not encoding.chunk:
|
||||
from . import tasks
|
||||
|
||||
logger.info('ti simbainei edw')
|
||||
tasks.create_hls(self.friendly_token)
|
||||
print('ti simbainei edw2')
|
||||
|
||||
return True
|
||||
|
||||
@ -1221,17 +1222,17 @@ class Encoding(models.Model):
|
||||
|
||||
super(Encoding, self).save(*args, **kwargs)
|
||||
|
||||
def update_size(self):
|
||||
"""Update the size of the encoding file"""
|
||||
if self.media_file:
|
||||
cmd = ["stat", "-c", "%s", self.media_file.path]
|
||||
stdout = helpers.run_command(cmd).get("out")
|
||||
if stdout:
|
||||
size = int(stdout.strip())
|
||||
self.size = helpers.show_file_size(size)
|
||||
self.save(update_fields=["size"])
|
||||
return True
|
||||
return False
|
||||
def update_size_without_save(self):
|
||||
"""Update the size of an encoding without saving to avoid calling signals"""
|
||||
if self.media_file:
|
||||
cmd = ["stat", "-c", "%s", self.media_file.path]
|
||||
stdout = helpers.run_command(cmd).get("out")
|
||||
if stdout:
|
||||
size = int(stdout.strip())
|
||||
size = helpers.show_file_size(size)
|
||||
Encoding.objects.filter(pk=self.pk).update(size=size)
|
||||
return True
|
||||
return False
|
||||
|
||||
def set_progress(self, progress, commit=True):
|
||||
if isinstance(progress, int):
|
||||
|
||||
@ -810,14 +810,12 @@ def remove_media_file(media_file=None):
|
||||
|
||||
@task(name="update_encoding_size", queue="short_tasks")
|
||||
def update_encoding_size(encoding_id):
|
||||
"""Update the size of an encoding"""
|
||||
try:
|
||||
encoding = Encoding.objects.get(id=encoding_id)
|
||||
encoding.update_size()
|
||||
"""Update the size of an encoding without saving to avoid calling signals"""
|
||||
encoding = Encoding.objects.filter(id=encoding_id).first()
|
||||
if encoding:
|
||||
encoding.update_size_without_save()
|
||||
return True
|
||||
except Encoding.DoesNotExist:
|
||||
logger.info(f"Encoding with ID {encoding_id} not found")
|
||||
return False
|
||||
return False
|
||||
|
||||
|
||||
@task(name="produce_video_chapters", queue="short_tasks")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user