Adding Exclude List, #3

This commit is contained in:
Matt Burchett 2020-12-11 15:39:17 -06:00
parent f3424d83bc
commit 33d7c5eaa7
2 changed files with 16 additions and 0 deletions

View File

@ -20,6 +20,7 @@ type Config struct {
ServerName string `json:"serverName"` ServerName string `json:"serverName"`
SonarrContext string `json:"sonarrContext"` SonarrContext string `json:"sonarrContext"`
SonarrAPIKey string `json:"sonarrAPIKey"` 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. //GetConfig gets the configuration values for the api using the file in the supplied configPath.

View File

@ -9,6 +9,7 @@ import (
"net/http" "net/http"
"sort" "sort"
"strconv" "strconv"
"strings"
"git.linuxrocker.com/mattburchett/Housekeeper/pkg/config" "git.linuxrocker.com/mattburchett/Housekeeper/pkg/config"
"git.linuxrocker.com/mattburchett/Housekeeper/pkg/model" "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) epoch := util.SubtractedEpoch(days)
exclude := strings.Split(config.ExcludeList, ",")
fmt.Println(exclude)
var breakOut bool
for _, i := range data { 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 { if int64(i.LastPlayed) <= epoch && int64(i.LastPlayed) != 0 {
titles = append(titles, i.Title) titles = append(titles, i.Title)
strirk, err := strconv.Atoi(i.RatingKey) strirk, err := strconv.Atoi(i.RatingKey)