From 0478cb399e7a2fa73e6278e8e6fd58d02c7cc610 Mon Sep 17 00:00:00 2001 From: administrator <7dn1yh5j@debauchez.fr> Date: Mon, 11 Dec 2023 19:24:44 +0100 Subject: [PATCH] Clean code and rename thumbnail by images It now exports banner as banner.jpg and avatar as poster.jpg and season-poster.jpg --- Pipfile | 2 +- ...el_thumbnails2.py => 0021_source_copy_channel_images.py} | 4 ++-- tubesync/sync/models.py | 6 +++--- tubesync/sync/signals.py | 6 +++--- tubesync/sync/tasks.py | 4 ++-- tubesync/sync/views.py | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) rename tubesync/sync/migrations/{0021_source_copy_channel_thumbnails2.py => 0021_source_copy_channel_images.py} (63%) diff --git a/Pipfile b/Pipfile index bfe7a90..bb2f955 100644 --- a/Pipfile +++ b/Pipfile @@ -22,4 +22,4 @@ mysqlclient = "*" yt-dlp = "*" redis = "*" hiredis = "*" -requests = {extras = ["socks"], version = "*"} \ No newline at end of file +requests = {extras = ["socks"], version = "*"} diff --git a/tubesync/sync/migrations/0021_source_copy_channel_thumbnails2.py b/tubesync/sync/migrations/0021_source_copy_channel_images.py similarity index 63% rename from tubesync/sync/migrations/0021_source_copy_channel_thumbnails2.py rename to tubesync/sync/migrations/0021_source_copy_channel_images.py index 178ac97..a8340b7 100644 --- a/tubesync/sync/migrations/0021_source_copy_channel_thumbnails2.py +++ b/tubesync/sync/migrations/0021_source_copy_channel_images.py @@ -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'), ), ] diff --git a/tubesync/sync/models.py b/tubesync/sync/models.py index f0b88a1..16af753 100644 --- a/tubesync/sync/models.py +++ b/tubesync/sync/models.py @@ -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'), diff --git a/tubesync/sync/signals.py b/tubesync/sync/signals.py index abb212c..6d2f182 100644 --- a/tubesync/sync/signals.py +++ b/tubesync/sync/signals.py @@ -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) diff --git a/tubesync/sync/tasks.py b/tubesync/sync/tasks.py index b51ca55..0edb0c2 100644 --- a/tubesync/sync/tasks.py +++ b/tubesync/sync/tasks.py @@ -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 diff --git a/tubesync/sync/views.py b/tubesync/sync/views.py index af0ded5..a97b1ea 100644 --- a/tubesync/sync/views.py +++ b/tubesync/sync/views.py @@ -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')