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 {