Clean code and rename thumbnail by images
It now exports banner as banner.jpg and avatar as poster.jpg and season-poster.jpg
This commit is contained in:
parent
a359c989d2
commit
0478cb399e
2
Pipfile
2
Pipfile
|
@ -22,4 +22,4 @@ mysqlclient = "*"
|
|||
yt-dlp = "*"
|
||||
redis = "*"
|
||||
hiredis = "*"
|
||||
requests = {extras = ["socks"], version = "*"}
|
||||
requests = {extras = ["socks"], version = "*"}
|
||||
|
|
|
@ -12,7 +12,7 @@ class Migration(migrations.Migration):
|
|||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='source',
|
||||
name='copy_channel_thumbnails',
|
||||
field=models.BooleanField(default=False, help_text='Copy channel thumbnails in poster.jpg and season-poster.jpg, these may be detected and used by some media servers', verbose_name='copy channel thumbnails'),
|
||||
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'),
|
||||
),
|
||||
]
|
|
@ -343,10 +343,10 @@ class Source(models.Model):
|
|||
default=FALLBACK_NEXT_BEST_HD,
|
||||
help_text=_('What do do when media in your source resolution and codecs is not available')
|
||||
)
|
||||
copy_channel_thumbnails = models.BooleanField(
|
||||
_('copy channel thumbnails'),
|
||||
copy_channel_images = models.BooleanField(
|
||||
_('copy channel images'),
|
||||
default=False,
|
||||
help_text=_('Copy channel thumbnails in poster.jpg and season-poster.jpg, these may be detected and used by some media servers')
|
||||
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')
|
||||
)
|
||||
copy_thumbnails = models.BooleanField(
|
||||
_('copy thumbnails'),
|
||||
|
|
|
@ -10,7 +10,7 @@ from .models import Source, Media, MediaServer
|
|||
from .tasks import (delete_task_by_source, delete_task_by_media, index_source_task,
|
||||
download_media_thumbnail, download_media_metadata,
|
||||
map_task_to_instance, check_source_directory_exists,
|
||||
download_media, rescan_media_server, download_source_thumbnail)
|
||||
download_media, rescan_media_server, download_source_images)
|
||||
from .utils import delete_file
|
||||
|
||||
|
||||
|
@ -47,8 +47,8 @@ def source_post_save(sender, instance, created, **kwargs):
|
|||
priority=0,
|
||||
verbose_name=verbose_name.format(instance.name)
|
||||
)
|
||||
if instance.source_type != Source.SOURCE_TYPE_YOUTUBE_PLAYLIST and instance.copy_channel_thumbnails:
|
||||
download_source_thumbnail(
|
||||
if instance.source_type != Source.SOURCE_TYPE_YOUTUBE_PLAYLIST and instance.copy_channel_images:
|
||||
download_source_images(
|
||||
str(instance.pk),
|
||||
priority=0,
|
||||
verbose_name=verbose_name.format(instance.name)
|
||||
|
|
|
@ -221,7 +221,7 @@ def check_source_directory_exists(source_id):
|
|||
|
||||
|
||||
@background(schedule=0)
|
||||
def download_source_thumbnail(source_id):
|
||||
def download_source_images(source_id):
|
||||
'''
|
||||
Downloads an image and save it as a local thumbnail attached to a
|
||||
Source instance.
|
||||
|
@ -230,7 +230,7 @@ def download_source_thumbnail(source_id):
|
|||
source = Source.objects.get(pk=source_id)
|
||||
except Source.DoesNotExist:
|
||||
# Task triggered but the source no longer exists, do nothing
|
||||
log.error(f'Task download_source_thumbnail(pk={source_id}) called but no '
|
||||
log.error(f'Task download_source_images(pk={source_id}) called but no '
|
||||
f'source exists with ID: {source_id}')
|
||||
return
|
||||
avatar, banner = source.get_image_url
|
||||
|
|
|
@ -297,7 +297,7 @@ class EditSourceMixin:
|
|||
fields = ('source_type', 'key', 'name', 'directory', 'filter_text', 'media_format',
|
||||
'index_schedule', 'download_media', 'download_cap', 'delete_old_media',
|
||||
'delete_removed_media', 'days_to_keep', 'source_resolution', 'source_vcodec',
|
||||
'source_acodec', 'prefer_60fps', 'prefer_hdr', 'fallback', 'copy_channel_thumbnails',
|
||||
'source_acodec', 'prefer_60fps', 'prefer_hdr', 'fallback', 'copy_channel_images',
|
||||
'copy_thumbnails', 'write_nfo', 'write_json', 'embed_metadata', 'embed_thumbnail',
|
||||
'enable_sponsorblock', 'sponsorblock_categories', 'write_subtitles',
|
||||
'auto_subtitles', 'sub_langs')
|
||||
|
|
Loading…
Reference in New Issue