From 33d7c5eaa73603e9c88b9cba512244f50033bf38 Mon Sep 17 00:00:00 2001 From: Matt Burchett Date: Fri, 11 Dec 2020 15:39:17 -0600 Subject: [PATCH] Adding Exclude List, #3 --- pkg/config/config.go | 1 + pkg/locator/locator.go | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/pkg/config/config.go b/pkg/config/config.go index 0bf9643..500af5e 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -20,6 +20,7 @@ type Config struct { ServerName string `json:"serverName"` SonarrContext string `json:"sonarrContext"` SonarrAPIKey string `json:"sonarrAPIKey"` + ExcludeList string `json:"excludeList"` // ExcludeList will be checked against any section. } //GetConfig gets the configuration values for the api using the file in the supplied configPath. diff --git a/pkg/locator/locator.go b/pkg/locator/locator.go index 8506f41..05faf78 100644 --- a/pkg/locator/locator.go +++ b/pkg/locator/locator.go @@ -9,6 +9,7 @@ import ( "net/http" "sort" "strconv" + "strings" "git.linuxrocker.com/mattburchett/Housekeeper/pkg/config" "git.linuxrocker.com/mattburchett/Housekeeper/pkg/model" @@ -121,7 +122,21 @@ func GetTitles(config config.Config, sectionID int, days int) ([]int, []string) epoch := util.SubtractedEpoch(days) + exclude := strings.Split(config.ExcludeList, ",") + + fmt.Println(exclude) + var breakOut bool + for _, i := range data { + for _, ex := range exclude { + if strings.Contains(i.Title, ex) { + breakOut = true + } + } + if breakOut { + breakOut = false + continue + } if int64(i.LastPlayed) <= epoch && int64(i.LastPlayed) != 0 { titles = append(titles, i.Title) strirk, err := strconv.Atoi(i.RatingKey)