Duplicate banner.jpg to background.jpg

This commit is contained in:
administrator 2023-12-11 19:38:36 +01:00
parent 0478cb399e
commit 32a884365b
3 changed files with 11 additions and 10 deletions

View File

@ -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'),
),
]

View File

@ -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'),

View File

@ -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