mirror of
https://github.com/meeb/tubesync.git
synced 2025-06-26 15:06:36 +00:00
Merge branch 'main' of github.com:meeb/tubesync
This commit is contained in:
commit
fcb9803da6
@ -23,8 +23,8 @@ def filter_media(instance: Media):
|
||||
skip = True
|
||||
|
||||
# Check if older than source_cutoff
|
||||
#if filter_source_cutoff(instance):
|
||||
# skip = True
|
||||
if filter_source_cutoff(instance):
|
||||
skip = True
|
||||
|
||||
# Check if we have filter_text and filter text matches
|
||||
if filter_filter_text(instance):
|
||||
@ -127,20 +127,15 @@ def filter_max_cap(instance: Media):
|
||||
return False
|
||||
|
||||
|
||||
# If the source has a cut-off, check the upload date is within the allowed delta
|
||||
# TODO: days to keep should be compared to downloaded date, not published
|
||||
# If the source has a cut-off, check the download date is within the allowed delta
|
||||
def filter_source_cutoff(instance: Media):
|
||||
if instance.source.delete_old_media and instance.source.days_to_keep > 0:
|
||||
if not isinstance(instance.published, datetime):
|
||||
# Media has no known published date or incomplete metadata
|
||||
log.info(
|
||||
f"Media: {instance.source} / {instance} has no published date, skipping"
|
||||
)
|
||||
return True
|
||||
if instance.source.delete_old_media and instance.source.days_to_keep_date:
|
||||
if not instance.downloaded or not isinstance(instance.download_date, datetime):
|
||||
return False
|
||||
|
||||
delta = timezone.now() - timedelta(days=instance.source.days_to_keep)
|
||||
if instance.published < delta:
|
||||
# Media was published after the cutoff date, skip it
|
||||
days_to_keep_age = instance.source.days_to_keep_date
|
||||
if instance.download_date < days_to_keep_age:
|
||||
# Media has expired, skip it
|
||||
log.info(
|
||||
f"Media: {instance.source} / {instance} is older than "
|
||||
f"{instance.source.days_to_keep} days, skipping"
|
||||
|
@ -460,6 +460,14 @@ class Source(models.Model):
|
||||
else:
|
||||
return False
|
||||
|
||||
@property
|
||||
def days_to_keep_date(self):
|
||||
delta = self.days_to_keep
|
||||
if delta > 0:
|
||||
return timezone.now() - timedelta(days=delta)
|
||||
else:
|
||||
return False
|
||||
|
||||
@property
|
||||
def extension(self):
|
||||
'''
|
||||
|
Loading…
Reference in New Issue
Block a user