Enable filter_source_cutoff with new logic
This commit is contained in:
1 parent
bb73cc6c97
commit
a4794ec3b1
1 file changed
+9
-14
@@ -23,8 +23,8 @@ def filter_media(instance: Media):
|
|||||||
skip = True
|
skip = True
|
||||||
|
|
||||||
# Check if older than source_cutoff
|
# Check if older than source_cutoff
|
||||||
#if filter_source_cutoff(instance):
|
if filter_source_cutoff(instance):
|
||||||
# skip = True
|
skip = True
|
||||||
|
|
||||||
# Check if we have filter_text and filter text matches
|
# Check if we have filter_text and filter text matches
|
||||||
if filter_filter_text(instance):
|
if filter_filter_text(instance):
|
||||||
@@ -127,20 +127,15 @@ def filter_max_cap(instance: Media):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
# If the source has a cut-off, check the upload date is within the allowed delta
|
# If the source has a cut-off, check the download date is within the allowed delta
|
||||||
# TODO: days to keep should be compared to downloaded date, not published
|
|
||||||
def filter_source_cutoff(instance: Media):
|
def filter_source_cutoff(instance: Media):
|
||||||
if instance.source.delete_old_media and instance.source.days_to_keep > 0:
|
if instance.source.delete_old_media and instance.source.days_to_keep_date:
|
||||||
if not isinstance(instance.published, datetime):
|
if not instance.downloaded or not isinstance(instance.download_date, datetime):
|
||||||
# Media has no known published date or incomplete metadata
|
return False
|
||||||
log.info(
|
|
||||||
f"Media: {instance.source} / {instance} has no published date, skipping"
|
|
||||||
)
|
|
||||||
return True
|
|
||||||
|
|
||||||
delta = timezone.now() - timedelta(days=instance.source.days_to_keep)
|
days_to_keep_age = instance.source.days_to_keep_date
|
||||||
if instance.published < delta:
|
if instance.download_date < days_to_keep_age:
|
||||||
# Media was published after the cutoff date, skip it
|
# Media has expired, skip it
|
||||||
log.info(
|
log.info(
|
||||||
f"Media: {instance.source} / {instance} is older than "
|
f"Media: {instance.source} / {instance} is older than "
|
||||||
f"{instance.source.days_to_keep} days, skipping"
|
f"{instance.source.days_to_keep} days, skipping"
|
||||||
|
|||||||
Reference in new issue
Block a user