Skip to content

Commit

Permalink
Remove helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Th0masL committed Nov 23, 2022
1 parent 453484a commit 4ebdc47
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ venv/

.DS_Store
/podsync
podsync.log

db
config.toml
19 changes: 4 additions & 15 deletions services/update/matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,6 @@ import (
log "github.com/sirupsen/logrus"
)

func matchDurationFilter(durationLimit int64, episodeDuration int64, operator string, logger log.FieldLogger) bool {
if durationLimit != 0 {
if operator == "min" && episodeDuration < durationLimit {
logger.Info("skipping due to duration filter")
return false
} else if operator == "max" && episodeDuration > durationLimit {
logger.Info("skipping due to duration filter")
return false
}
}
return true
}

func matchRegexpFilter(pattern, str string, negative bool, logger log.FieldLogger) bool {
if pattern != "" {
matched, err := regexp.MatchString(pattern, str)
Expand Down Expand Up @@ -54,11 +41,13 @@ func matchFilters(episode *model.Episode, filters *feed.Filters) bool {
return false
}

if !matchDurationFilter(filters.MinDuration, episode.Duration, "min", logger.WithField("filter", "min_duration")) {
if filters.MaxDuration > 0 && episode.Duration > filters.MaxDuration {
logger.WithField("filter", "max_duration").Infof("skipping due to duration filter (%ds)", episode.Duration)
return false
}

if !matchDurationFilter(filters.MaxDuration, episode.Duration, "max", logger.WithField("filter", "max_duration")) {
if filters.MinDuration > 0 && episode.Duration < filters.MinDuration {
logger.WithField("filter", "min_duration").Infof("skipping due to duration filter (%ds)", episode.Duration)
return false
}

Expand Down

0 comments on commit 4ebdc47

Please sign in to comment.