From 8330101154fd49f5202bfe42d279a61a926e9436 Mon Sep 17 00:00:00 2001 From: Matt Burchett Date: Tue, 20 Nov 2018 14:14:40 -0600 Subject: [PATCH] test --- pkg/eraser/eraser.go | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/pkg/eraser/eraser.go b/pkg/eraser/eraser.go index ece7b99..9f2c335 100644 --- a/pkg/eraser/eraser.go +++ b/pkg/eraser/eraser.go @@ -8,7 +8,6 @@ import ( "net/http" "os" "path/filepath" - "sort" "git.linuxrocker.com/mattburchett/Housekeeper/pkg/config" "git.linuxrocker.com/mattburchett/Housekeeper/pkg/model" @@ -49,6 +48,7 @@ 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,13 +77,25 @@ func LookupTVFileLocation(config config.Config, ids []int) []string { plexTV := plexModel.Video for _, i := range plexTV { - count := sort.SearchStrings(fileList, i.Media.Part.File) - if count == 0 { - fileList = append(fileList, filepath.Dir(filepath.Dir(i.Media.Part.File))) + fileList = append(fileList, filepath.Dir(filepath.Dir(i.Media.Part.File))) + } + + for _, v := range fileList { + if !isValueInList(v, fileList) { + results = append(results, v) } } } - return fileList + return results +} + +func isValueInList(value string, list []string) bool { + for _, v := range list { + if v == value { + return true + } + } + return false } // DeleteMovies will actually perform the deletion.