From 600e26edb36261ea82e3edf63ee2a5ec9a67247b Mon Sep 17 00:00:00 2001 From: Dasnap Date: Thu, 22 May 2025 13:06:35 +0100 Subject: [PATCH 1/2] Added option for min_age of videos (similar to max_age) A quick implementation to set the minimum age of a video. --- cmd/podsync/config_test.go | 4 +++- config.toml.example | 3 ++- pkg/feed/config.go | 1 + services/update/matcher.go | 8 ++++++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/cmd/podsync/config_test.go b/cmd/podsync/config_test.go index b5de84ac..d588258a 100644 --- a/cmd/podsync/config_test.go +++ b/cmd/podsync/config_test.go @@ -38,7 +38,8 @@ timeout = 15 quality = "low" # duration filters are in seconds # max_age is in days - filters = { title = "regex for title here", min_duration = 0, max_duration = 86400, max_age = 365} + # min_age is in days + filters = { title = "regex for title here", min_duration = 0, max_duration = 86400, min_age = 1} playlist_sort = "desc" clean = { keep_last = 10 } [feeds.XYZ.custom] @@ -82,6 +83,7 @@ timeout = 15 assert.EqualValues(t, 0, feed.Filters.MinDuration) assert.EqualValues(t, 86400, feed.Filters.MaxDuration) assert.EqualValues(t, 365, feed.Filters.MaxAge) + assert.EqualValues(t, 1, feed.Filters.MinAge) assert.EqualValues(t, 10, feed.Clean.KeepLast) assert.EqualValues(t, model.SortingDesc, feed.PlaylistSort) diff --git a/config.toml.example b/config.toml.example index 80df9728..24874a13 100644 --- a/config.toml.example +++ b/config.toml.example @@ -83,7 +83,8 @@ vimeo = [ # Multiple keys will be rotated. # If set, then only download matching episodes. # Duration filters are in seconds. # max_age filter is in days. - filters = { title = "regex for title here", not_title = "regex for negative title match", description = "...", not_description = "...", min_duration = 0, max_duration = 86400, max_age = 365 } + # min_age filter is in days. + filters = { title = "regex for title here", not_title = "regex for negative title match", description = "...", not_description = "...", min_duration = 0, max_duration = 86400, max_age = 365, min_age = 1 } # Optional extra arguments passed to youtube-dl when downloading videos from this feed. # This example would embed available English closed captions in the videos. diff --git a/pkg/feed/config.go b/pkg/feed/config.go index d45f0f7c..30c943d2 100644 --- a/pkg/feed/config.go +++ b/pkg/feed/config.go @@ -59,6 +59,7 @@ type Filters struct { MinDuration int64 `toml:"min_duration"` MaxDuration int64 `toml:"max_duration"` MaxAge int `toml:"max_age"` + MinAge int `toml:"min_age"` // More filters to be added here } diff --git a/services/update/matcher.go b/services/update/matcher.go index 8470dca4..fda338c6 100644 --- a/services/update/matcher.go +++ b/services/update/matcher.go @@ -60,5 +60,13 @@ func matchFilters(episode *model.Episode, filters *feed.Filters) bool { } } + if filters.MinAge > 0 { + dateDiff := int(time.Since(episode.PubDate).Hours()) / 24 + if dateDiff < filters.MinAge { + logger.WithField("filter", "min_age").Infof("skipping due to min_age filter (%dd < %dd)", dateDiff, filters.MinAge) + return false + } + } + return true } From 75376826c7c698903fdb4ac7162362776f7b45f3 Mon Sep 17 00:00:00 2001 From: Dasnap Date: Sun, 25 May 2025 15:49:09 +0100 Subject: [PATCH 2/2] Update cmd/podsync/config_test.go Co-authored-by: Ken E. <35490395+KenErikson@users.noreply.github.com> --- cmd/podsync/config_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/podsync/config_test.go b/cmd/podsync/config_test.go index d588258a..15230ebe 100644 --- a/cmd/podsync/config_test.go +++ b/cmd/podsync/config_test.go @@ -39,7 +39,7 @@ timeout = 15 # duration filters are in seconds # max_age is in days # min_age is in days - filters = { title = "regex for title here", min_duration = 0, max_duration = 86400, min_age = 1} + filters = { title = "regex for title here", min_duration = 0, max_duration = 86400, max_age = 365, min_age = 1} playlist_sort = "desc" clean = { keep_last = 10 } [feeds.XYZ.custom]