From 32a884365becd14dd98f70a914f5c218af4e49d8 Mon Sep 17 00:00:00 2001 From: administrator <7dn1yh5j@debauchez.fr> Date: Mon, 11 Dec 2023 19:38:36 +0100 Subject: [PATCH] Duplicate banner.jpg to background.jpg --- .../0021_source_copy_channel_images.py | 2 +- tubesync/sync/models.py | 2 +- tubesync/sync/tasks.py | 17 +++++++++-------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/tubesync/sync/migrations/0021_source_copy_channel_images.py b/tubesync/sync/migrations/0021_source_copy_channel_images.py index a8340b7..5d56892 100644 --- a/tubesync/sync/migrations/0021_source_copy_channel_images.py +++ b/tubesync/sync/migrations/0021_source_copy_channel_images.py @@ -13,6 +13,6 @@ class Migration(migrations.Migration): migrations.AddField( model_name='source', name='copy_channel_images', - field=models.BooleanField(default=False, help_text='Copy channel images : banner as banner.jpg and avatar as poster.jpg and season-poster.jpg. These may be detected and used by some media servers', verbose_name='copy channel images'), + field=models.BooleanField(default=False, help_text='Copy channel banner and avatar. These may be detected and used by some media servers', verbose_name='copy channel images'), ), ] diff --git a/tubesync/sync/models.py b/tubesync/sync/models.py index 16af753..ce6d9dc 100644 --- a/tubesync/sync/models.py +++ b/tubesync/sync/models.py @@ -346,7 +346,7 @@ class Source(models.Model): copy_channel_images = models.BooleanField( _('copy channel images'), default=False, - help_text=_('Copy channel images : banner as banner.jpg and avatar as poster.jpg and season-poster.jpg. These may be detected and used by some media servers') + help_text=_('Copy channel banner and avatar. These may be detected and used by some media servers') ) copy_thumbnails = models.BooleanField( _('copy thumbnails'), diff --git a/tubesync/sync/tasks.py b/tubesync/sync/tasks.py index 0edb0c2..cd16326 100644 --- a/tubesync/sync/tasks.py +++ b/tubesync/sync/tasks.py @@ -242,14 +242,15 @@ def download_source_images(source_id): i = get_remote_image(url) image_file = BytesIO() i.save(image_file, 'JPEG', quality=85, optimize=True, progressive=True) - file_name = "banner.jpg" - # Reset file pointer to the beginning for the next save - image_file.seek(0) - # Create a Django ContentFile from BytesIO stream - django_file = ContentFile(image_file.read()) - file_path = source.directory_path / file_name - with open(file_path, 'wb') as f: - f.write(django_file.read()) + + for file_name in ["banner.jpg", "background.jpg"]: + # Reset file pointer to the beginning for the next save + image_file.seek(0) + # Create a Django ContentFile from BytesIO stream + django_file = ContentFile(image_file.read()) + file_path = source.directory_path / file_name + with open(file_path, 'wb') as f: + f.write(django_file.read()) if avatar != None: url = avatar