Duplicate banner.jpg to background.jpg
This commit is contained in:
parent
0478cb399e
commit
32a884365b
|
@ -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'),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -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'),
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue