mirror of
https://github.com/meeb/tubesync.git
synced 2025-06-23 13:36:35 +00:00
don't add the sync.tasks.download_media_metadata task if the video is skipped or there's already a task running
This commit is contained in:
parent
435885ff61
commit
ca61df2e0b
@ -12,7 +12,7 @@ from .tasks import (delete_task_by_source, delete_task_by_media, index_source_ta
|
||||
download_media_thumbnail, download_media_metadata,
|
||||
map_task_to_instance, check_source_directory_exists,
|
||||
download_media, rescan_media_server, download_source_images,
|
||||
save_all_media_for_source)
|
||||
save_all_media_for_source, get_media_metadata_task)
|
||||
from .utils import delete_file
|
||||
from .filtering import filter_media
|
||||
|
||||
@ -133,7 +133,7 @@ def media_post_save(sender, instance, created, **kwargs):
|
||||
instance.save()
|
||||
post_save.connect(media_post_save, sender=Media)
|
||||
# If the media is missing metadata schedule it to be downloaded
|
||||
if not instance.metadata:
|
||||
if not instance.metadata and not instance.skip and not get_media_metadata_task(instance.pk):
|
||||
log.info(f'Scheduling task to download metadata for: {instance.url}')
|
||||
verbose_name = _('Downloading metadata for "{}"')
|
||||
download_media_metadata(
|
||||
|
@ -118,6 +118,12 @@ def get_media_download_task(media_id):
|
||||
except IndexError:
|
||||
return False
|
||||
|
||||
def get_media_metadata_task(media_id):
|
||||
try:
|
||||
return Task.objects.get_task('sync.tasks.download_media_metadata',
|
||||
args=(str(media_id),))[0]
|
||||
except IndexError:
|
||||
return False
|
||||
|
||||
def delete_task_by_source(task_name, source_id):
|
||||
return Task.objects.filter(task_name=task_name, queue=str(source_id)).delete()
|
||||
|
Loading…
Reference in New Issue
Block a user