From 3b20f07450f51fbb7caf6c3b3fab77b5abc3d265 Mon Sep 17 00:00:00 2001 From: tcely Date: Sat, 25 Jan 2025 19:12:36 -0500 Subject: [PATCH 1/3] Try to download thumbnail before copy --- tubesync/sync/tasks.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tubesync/sync/tasks.py b/tubesync/sync/tasks.py index ab92e2c8..f0a8856d 100644 --- a/tubesync/sync/tasks.py +++ b/tubesync/sync/tasks.py @@ -442,10 +442,14 @@ def download_media(media_id): media.downloaded_format = 'audio' media.save() # If selected, copy the thumbnail over as well - if media.source.copy_thumbnails and media.thumb: - log.info(f'Copying media thumbnail from: {media.thumb.path} ' - f'to: {media.thumbpath}') - copyfile(media.thumb.path, media.thumbpath) + if media.source.copy_thumbnails: + if not media.thumb_file_exists: + if download_media_thumbnail.now(str(media.pk), media.thumbnail): + media.refresh_from_db() + if media.thumb_file_exists: + log.info(f'Copying media thumbnail from: {media.thumb.path} ' + f'to: {media.thumbpath}') + copyfile(media.thumb.path, media.thumbpath) # If selected, write an NFO file if media.source.write_nfo: log.info(f'Writing media NFO file to: {media.nfopath}') From fe39717985a8d95f8a4dcb01ab63e91891e2f5b5 Mon Sep 17 00:00:00 2001 From: tcely Date: Sat, 25 Jan 2025 19:23:52 -0500 Subject: [PATCH 2/3] Change media download priority --- tubesync/sync/signals.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tubesync/sync/signals.py b/tubesync/sync/signals.py index cd8cf621..e2a1398c 100644 --- a/tubesync/sync/signals.py +++ b/tubesync/sync/signals.py @@ -174,7 +174,7 @@ def media_post_save(sender, instance, created, **kwargs): download_media( str(instance.pk), queue=str(instance.source.pk), - priority=15, + priority=10, verbose_name=verbose_name.format(instance.name), remove_existing_tasks=True ) From 69e895818ee5b3fe973ca21de65625234697b751 Mon Sep 17 00:00:00 2001 From: tcely Date: Sat, 25 Jan 2025 19:46:58 -0500 Subject: [PATCH 3/3] Drop the thumbnail task if media downloaded first --- tubesync/sync/tasks.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tubesync/sync/tasks.py b/tubesync/sync/tasks.py index f0a8856d..8d52b3bf 100644 --- a/tubesync/sync/tasks.py +++ b/tubesync/sync/tasks.py @@ -444,8 +444,12 @@ def download_media(media_id): # If selected, copy the thumbnail over as well if media.source.copy_thumbnails: if not media.thumb_file_exists: - if download_media_thumbnail.now(str(media.pk), media.thumbnail): - media.refresh_from_db() + thumbnail_url = media.thumbnail + if thumbnail_url: + args = ( str(media.pk), thumbnail_url, ) + delete_task_by_media('sync.tasks.download_media_thumbnail', args) + if download_media_thumbnail.now(*args): + media.refresh_from_db() if media.thumb_file_exists: log.info(f'Copying media thumbnail from: {media.thumb.path} ' f'to: {media.thumbpath}')