mirror of
https://github.com/mediacms-io/mediacms.git
synced 2025-11-05 23:18:53 -05:00
ref
This commit is contained in:
parent
22db570836
commit
5666c8fc27
@ -436,6 +436,8 @@ def copy_video(original_media, copy_encodings=True, title_suffix="(Trimmed)"):
|
||||
allow_download=original_media.allow_download,
|
||||
state=original_media.state,
|
||||
is_reviewed=original_media.is_reviewed,
|
||||
encoding_status=original_media.encoding_status,
|
||||
listable=original_media.listable,
|
||||
add_date=timezone.now()
|
||||
)
|
||||
models.Media.objects.bulk_create([new_media])
|
||||
@ -458,7 +460,8 @@ def copy_video(original_media, copy_encodings=True, title_suffix="(Trimmed)"):
|
||||
)
|
||||
models.Encoding.objects.bulk_create([new_encoding])
|
||||
# avoids calling signals
|
||||
# TODO: check size
|
||||
|
||||
new_encoding.update_size()
|
||||
|
||||
# Copy categories and tags
|
||||
for category in original_media.category.all():
|
||||
|
||||
@ -1221,6 +1221,18 @@ 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 set_progress(self, progress, commit=True):
|
||||
if isinstance(progress, int):
|
||||
if 0 <= progress <= 100:
|
||||
|
||||
@ -423,6 +423,7 @@ def produce_sprite_from_video(friendly_token):
|
||||
def create_hls(friendly_token):
|
||||
"""Creates HLS file for media, uses Bento4 mp4hls command"""
|
||||
|
||||
logger.info(f"Entering for {friendly_token}")
|
||||
if not hasattr(settings, "MP4HLS_COMMAND"):
|
||||
logger.info("Bento4 mp4hls command is missing from configuration")
|
||||
return False
|
||||
@ -467,6 +468,7 @@ def create_hls(friendly_token):
|
||||
if media.hls_file != pp:
|
||||
media.hls_file = pp
|
||||
media.save(update_fields=["hls_file"])
|
||||
logger.info(f"All good / exiting for {friendly_token}")
|
||||
return True
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user