Only return True when instance.skip was changed

This commit is contained in:
tcely 2025-02-15 16:02:33 -05:00 committed by GitHub
parent 5b28acbd33
commit 785ba9eb05
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -11,7 +11,7 @@ from .overrides.custom_filter import filter_custom
# Check the filter conditions for instance, return is if the Skip property has changed so we can do other things # Check the filter conditions for instance, return is if the Skip property has changed so we can do other things
def filter_media(instance: Media): def filter_media(instance: Media):
unskip = False unskip = True
# Assume we aren't skipping it, if any of these conditions are true, we skip it # Assume we aren't skipping it, if any of these conditions are true, we skip it
skip = False skip = False
@ -30,41 +30,42 @@ def filter_media(instance: Media):
if not skip and not download_kept: if not skip and not download_kept:
skip = True skip = True
keep_newly_published_video = (
is_published and download_kept and
not (instance.downloaded or video_too_old)
)
# Check if we have filter_text and filter text matches # Check if we have filter_text and filter text matches
if not skip and filter_filter_text(instance): if not skip and filter_filter_text(instance):
skip = True skip = True
unskip = False
# Check if the video is longer than the max, or shorter than the min # Check if the video is longer than the max, or shorter than the min
if not skip and filter_duration(instance): if not skip and filter_duration(instance):
skip = True skip = True
unskip = False
# If we aren't already skipping the file, call our custom function that can be overridden # If we aren't already skipping the file, call our custom function that can be overridden
if not skip and filter_custom(instance): if not skip and filter_custom(instance):
log.info(f"Media: {instance.source} / {instance} has been skipped by Custom Filter") log.info(f"Media: {instance.source} / {instance} has been skipped by Custom Filter")
skip = True skip = True
unskip = False
keep_newly_published_video = (
is_published and download_kept and
not (instance.downloaded or video_too_old)
)
# Check if skipping # Check if skipping
if keep_newly_published_video: if not keep_newly_published_video:
unskip = True unskip = False
if instance.skip != skip: if instance.skip != skip:
was_skipped = instance.skip was_skipped = instance.skip
instance.skip = skip instance.skip = skip
if was_skipped and unskip: if was_skipped and not (unskip or skip):
instance.skip = False
elif was_skipped and not unskip and not skip:
instance.skip = True instance.skip = True
if instance.skip != was_skipped: if instance.skip != was_skipped:
log.info( log.info(
f"Media: {instance.source} / {instance} has changed skip setting to {instance.skip}" f"Media: {instance.source} / {instance} has changed skip setting to {instance.skip}"
) )
return True return True
return False return False