mirror of
https://github.com/mediacms-io/mediacms.git
synced 2025-11-06 23:48:54 -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:
|
Returns:
|
||||||
New Media object
|
New Media object
|
||||||
"""
|
"""
|
||||||
from .tasks import update_encoding_size
|
|
||||||
|
|
||||||
with open(original_media.media_file.path, "rb") as f:
|
with open(original_media.media_file.path, "rb") as f:
|
||||||
myfile = File(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:
|
if encoding and encoding.status == "success" and encoding.profile.codec == "h264" and action == "add" and not encoding.chunk:
|
||||||
from . import tasks
|
from . import tasks
|
||||||
|
logger.info('ti simbainei edw')
|
||||||
tasks.create_hls(self.friendly_token)
|
tasks.create_hls(self.friendly_token)
|
||||||
|
print('ti simbainei edw2')
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -1221,15 +1222,15 @@ class Encoding(models.Model):
|
|||||||
|
|
||||||
super(Encoding, self).save(*args, **kwargs)
|
super(Encoding, self).save(*args, **kwargs)
|
||||||
|
|
||||||
def update_size(self):
|
def update_size_without_save(self):
|
||||||
"""Update the size of the encoding file"""
|
"""Update the size of an encoding without saving to avoid calling signals"""
|
||||||
if self.media_file:
|
if self.media_file:
|
||||||
cmd = ["stat", "-c", "%s", self.media_file.path]
|
cmd = ["stat", "-c", "%s", self.media_file.path]
|
||||||
stdout = helpers.run_command(cmd).get("out")
|
stdout = helpers.run_command(cmd).get("out")
|
||||||
if stdout:
|
if stdout:
|
||||||
size = int(stdout.strip())
|
size = int(stdout.strip())
|
||||||
self.size = helpers.show_file_size(size)
|
size = helpers.show_file_size(size)
|
||||||
self.save(update_fields=["size"])
|
Encoding.objects.filter(pk=self.pk).update(size=size)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
@ -810,13 +810,11 @@ def remove_media_file(media_file=None):
|
|||||||
|
|
||||||
@task(name="update_encoding_size", queue="short_tasks")
|
@task(name="update_encoding_size", queue="short_tasks")
|
||||||
def update_encoding_size(encoding_id):
|
def update_encoding_size(encoding_id):
|
||||||
"""Update the size of an encoding"""
|
"""Update the size of an encoding without saving to avoid calling signals"""
|
||||||
try:
|
encoding = Encoding.objects.filter(id=encoding_id).first()
|
||||||
encoding = Encoding.objects.get(id=encoding_id)
|
if encoding:
|
||||||
encoding.update_size()
|
encoding.update_size_without_save()
|
||||||
return True
|
return True
|
||||||
except Encoding.DoesNotExist:
|
|
||||||
logger.info(f"Encoding with ID {encoding_id} not found")
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user