Skip to content

Commit

Permalink
Merge pull request #293 from geoah/main
Browse files Browse the repository at this point in the history
Skip metadata and thumbnails if they are past the cutoff date
  • Loading branch information
meeb committed Feb 26, 2024
2 parents c6acd53 + fa5bc3e commit 1b865bb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tubesync/sync/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,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:
log.info(f'Scheduling task to download metadata for: {instance.url}')
verbose_name = _('Downloading metadata for "{}"')
download_media_metadata(
Expand All @@ -184,7 +184,7 @@ def media_post_save(sender, instance, created, **kwargs):
# If the media is missing a thumbnail schedule it to be downloaded
if not instance.thumb_file_exists:
instance.thumb = None
if not instance.thumb:
if not instance.thumb and not instance.skip:
thumbnail_url = instance.thumbnail
if thumbnail_url:
log.info(f'Scheduling task to download thumbnail for: {instance.name} '
Expand Down
5 changes: 5 additions & 0 deletions tubesync/sync/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,11 @@ def download_media_thumbnail(media_id, url):
except Media.DoesNotExist:
# Task triggered but the media no longer exists, do nothing
return
if media.skip:
# Media was toggled to be skipped after the task was scheduled
log.warn(f'Download task triggered for media: {media} (UUID: {media.pk}) but '
f'it is now marked to be skipped, not downloading thumbnail')
return
width = getattr(settings, 'MEDIA_THUMBNAIL_WIDTH', 430)
height = getattr(settings, 'MEDIA_THUMBNAIL_HEIGHT', 240)
i = get_remote_image(url)
Expand Down

0 comments on commit 1b865bb

Please sign in to comment.