Skip to content

Commit 412b7d4

Browse files
Dasnapmxpv
authored andcommitted
Added option for min_age of videos (similar to max_age)
A quick implementation to set the minimum age of a video.
1 parent 9b0dd4e commit 412b7d4

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

cmd/podsync/config_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ timeout = 15
3838
quality = "low"
3939
# duration filters are in seconds
4040
# max_age is in days
41-
filters = { title = "regex for title here", min_duration = 0, max_duration = 86400, max_age = 365}
41+
# min_age is in days
42+
filters = { title = "regex for title here", min_duration = 0, max_duration = 86400, min_age = 1}
4243
playlist_sort = "desc"
4344
clean = { keep_last = 10 }
4445
[feeds.XYZ.custom]
@@ -82,6 +83,7 @@ timeout = 15
8283
assert.EqualValues(t, 0, feed.Filters.MinDuration)
8384
assert.EqualValues(t, 86400, feed.Filters.MaxDuration)
8485
assert.EqualValues(t, 365, feed.Filters.MaxAge)
86+
assert.EqualValues(t, 1, feed.Filters.MinAge)
8587
assert.EqualValues(t, 10, feed.Clean.KeepLast)
8688
assert.EqualValues(t, model.SortingDesc, feed.PlaylistSort)
8789

config.toml.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ vimeo = [ # Multiple keys will be rotated.
8383
# If set, then only download matching episodes.
8484
# Duration filters are in seconds.
8585
# max_age filter is in days.
86-
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 }
86+
# min_age filter is in days.
87+
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 }
8788

8889
# Optional extra arguments passed to youtube-dl when downloading videos from this feed.
8990
# This example would embed available English closed captions in the videos.

pkg/feed/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ type Filters struct {
5959
MinDuration int64 `toml:"min_duration"`
6060
MaxDuration int64 `toml:"max_duration"`
6161
MaxAge int `toml:"max_age"`
62+
MinAge int `toml:"min_age"`
6263
// More filters to be added here
6364
}
6465

services/update/matcher.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,13 @@ func matchFilters(episode *model.Episode, filters *feed.Filters) bool {
6060
}
6161
}
6262

63+
if filters.MinAge > 0 {
64+
dateDiff := int(time.Since(episode.PubDate).Hours()) / 24
65+
if dateDiff < filters.MinAge {
66+
logger.WithField("filter", "min_age").Infof("skipping due to min_age filter (%dd < %dd)", dateDiff, filters.MinAge)
67+
return false
68+
}
69+
}
70+
6371
return true
6472
}

0 commit comments

Comments
 (0)