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(
|
migrations.AddField(
|
||||||
model_name='source',
|
model_name='source',
|
||||||
name='copy_channel_images',
|
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 = models.BooleanField(
|
||||||
_('copy channel images'),
|
_('copy channel images'),
|
||||||
default=False,
|
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 = models.BooleanField(
|
||||||
_('copy thumbnails'),
|
_('copy thumbnails'),
|
||||||
|
|
|
@ -242,14 +242,15 @@ def download_source_images(source_id):
|
||||||
i = get_remote_image(url)
|
i = get_remote_image(url)
|
||||||
image_file = BytesIO()
|
image_file = BytesIO()
|
||||||
i.save(image_file, 'JPEG', quality=85, optimize=True, progressive=True)
|
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
|
for file_name in ["banner.jpg", "background.jpg"]:
|
||||||
image_file.seek(0)
|
# Reset file pointer to the beginning for the next save
|
||||||
# Create a Django ContentFile from BytesIO stream
|
image_file.seek(0)
|
||||||
django_file = ContentFile(image_file.read())
|
# Create a Django ContentFile from BytesIO stream
|
||||||
file_path = source.directory_path / file_name
|
django_file = ContentFile(image_file.read())
|
||||||
with open(file_path, 'wb') as f:
|
file_path = source.directory_path / file_name
|
||||||
f.write(django_file.read())
|
with open(file_path, 'wb') as f:
|
||||||
|
f.write(django_file.read())
|
||||||
|
|
||||||
if avatar != None:
|
if avatar != None:
|
||||||
url = avatar
|
url = avatar
|
||||||
|
|
Loading…
Reference in New Issue