From 31dc49eae4940546f5ff1fc44f1b237121ae8a57 Mon Sep 17 00:00:00 2001 From: Matt Burchett Date: Tue, 20 Nov 2018 14:20:34 -0600 Subject: [PATCH] test --- pkg/eraser/eraser.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/pkg/eraser/eraser.go b/pkg/eraser/eraser.go index 01b4d38..317b2a1 100644 --- a/pkg/eraser/eraser.go +++ b/pkg/eraser/eraser.go @@ -11,6 +11,7 @@ import ( "git.linuxrocker.com/mattburchett/Housekeeper/pkg/config" "git.linuxrocker.com/mattburchett/Housekeeper/pkg/model" + "github.com/forestgiant/sliceutil" ) // LookupMovieFileLocation will gather a list of Information based on IDs returned by locator.GetTitles @@ -48,7 +49,6 @@ func LookupMovieFileLocation(config config.Config, ids []int) []string { // LookupTVFileLocation will gather a list of Information based on IDs returned by locator.GetTitles func LookupTVFileLocation(config config.Config, ids []int) []string { fileList := make([]string, 0) - results := make([]string, 0) for _, i := range ids { plexURL := fmt.Sprintf("%s:%d%s%d%s%s", config.PlexHost, config.PlexPort, "/library/metadata/", i, "/allLeaves/?X-Plex-Token=", config.PlexToken) @@ -77,17 +77,13 @@ func LookupTVFileLocation(config config.Config, ids []int) []string { plexTV := plexModel.Video for _, i := range plexTV { - fileList = append(fileList, filepath.Dir(filepath.Dir(i.Media.Part.File))) - } - - for _, v := range fileList { - boolean := isValueInList(v, fileList) - if !boolean { - results = append(results, v) + if sliceutil.Contains(fileList, i) { + fileList = append(fileList, filepath.Dir(filepath.Dir(i.Media.Part.File))) } } + } - return results + return fileList } func isValueInList(value string, list []string) bool {