TV Show Fix #6

Merged
mattburchett merged 17 commits from matt/#2 into master 2018-11-20 23:08:30 +00:00
Showing only changes of commit 8330101154 - Show all commits

View File

@ -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.