diff --git a/tubesync/sync/filtering.py b/tubesync/sync/filtering.py index e936c02..2e1eb1e 100644 --- a/tubesync/sync/filtering.py +++ b/tubesync/sync/filtering.py @@ -62,20 +62,35 @@ def filter_filter_text(instance: Media): if not filter_text: return False - # We match the filter text, so don't skip downloading this + if not instance.source.filter_text_invert: + # We match the filter text, so don't skip downloading this + if instance.source.is_regex_match(instance.title): + log.info( + f"Media: {instance.source} / {instance} has a valid " + f"title filter, not marking to be skipped" + ) + return False + + log.info( + f"Media: {instance.source} / {instance} doesn't match " + f"title filter, marking to be skipped" + ) + + return True + if instance.source.is_regex_match(instance.title): log.info( - f"Media: {instance.source} / {instance} has a valid " - f"title filter, not marking to be skipped" + f"Media: {instance.source} / {instance} matches inverted " + f"title filter, marking to be skipped" ) - return False + + return True log.info( - f"Media: {instance.source} / {instance} doesn't match " - f"title filter, marking to be skipped" + f"Media: {instance.source} / {instance} does not match the inverted " + f"title filter, not marking to be skipped" ) - - return True + return False def filter_max_cap(instance: Media): diff --git a/tubesync/sync/migrations/0023_media_duration_filter.py b/tubesync/sync/migrations/0023_media_duration_filter.py index a77e345..558cc0e 100644 --- a/tubesync/sync/migrations/0023_media_duration_filter.py +++ b/tubesync/sync/migrations/0023_media_duration_filter.py @@ -50,4 +50,13 @@ class Migration(migrations.Migration): "video greater than maximum) video duration", ), ), + migrations.AddField( + model_name="source", + name="filter_text_invert", + field=models.BooleanField( + verbose_name="invert filter text matching", + default=False, + help_text="Invert filter string regex match, skip any matching titles when selected", + ), + ), ] diff --git a/tubesync/sync/models.py b/tubesync/sync/models.py index b71d527..5e1afba 100644 --- a/tubesync/sync/models.py +++ b/tubesync/sync/models.py @@ -298,6 +298,11 @@ class Source(models.Model): blank=True, help_text=_('Regex compatible filter string for video titles') ) + filter_text_invert = models.BooleanField( + _("invert filter text matching"), + default=False, + help_text="Invert filter string regex match, skip any matching titles when selected", + ) filter_seconds = models.PositiveIntegerField( _('filter seconds'), blank=True, diff --git a/tubesync/sync/templates/sync/source.html b/tubesync/sync/templates/sync/source.html index 838eb9b..379cef8 100644 --- a/tubesync/sync/templates/sync/source.html +++ b/tubesync/sync/templates/sync/source.html @@ -44,8 +44,9 @@