Commit da5769a4 authored by Ilya Simonov's avatar Ilya Simonov

delete signal for generate thumbnail

parent 43809573
......@@ -7,18 +7,18 @@ from django.db.models.signals import post_save
from . import models, utils, s3_uploader
@receiver(post_save, sender=models.Video)
def generate_default_thumbnail_for_video(sender, instance, **kwargs):
if not instance.thumbnail and instance.local_file:
if os.path.isfile(instance.local_file.path):
thumbnail_name = utils.generate_thumbnail(instance.local_file)
key = f'videos/{thumbnail_name}'
thumbnail_path = f'{settings.MEDIA_ROOT}{key}'
content = utils.get_thumbnail_content(thumbnail_path)
content_type = 'image/jpeg'
instance.thumbnail = s3_uploader.upload_file(content, key, content_type)
instance.save(update_fields=['thumbnail'])
os.remove(thumbnail_path)
# @receiver(post_save, sender=models.Video)
# def generate_default_thumbnail_for_video(sender, instance, **kwargs):
# if not instance.thumbnail and instance.local_file:
# if os.path.isfile(instance.local_file.path):
# thumbnail_name = utils.generate_thumbnail(instance.local_file)
# key = f'videos/{thumbnail_name}'
# thumbnail_path = f'{settings.MEDIA_ROOT}{key}'
#
# content = utils.get_thumbnail_content(thumbnail_path)
# content_type = 'image/jpeg'
# instance.thumbnail = s3_uploader.upload_file(content, key, content_type)
#
# instance.save(update_fields=['thumbnail'])
#
# os.remove(thumbnail_path)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment