diff --git a/apiGo/videoparser/ReIndexTVShows.go b/apiGo/videoparser/ReIndexTVShows.go index 7b7392e..f496add 100644 --- a/apiGo/videoparser/ReIndexTVShows.go +++ b/apiGo/videoparser/ReIndexTVShows.go @@ -2,7 +2,6 @@ package videoparser import ( "fmt" - "openmediacenter/apiGo/api/types" "openmediacenter/apiGo/database" "openmediacenter/apiGo/videoparser/tmdb" "regexp" @@ -10,17 +9,19 @@ import ( "strings" ) -func startTVShowReindex(files []Show, sett types.SettingsType) { - // have fun with db insertions here! - +func startTVShowReindex(files []Show) { allTVshows := getAllTVShows() for _, file := range files { // insert new TVShow entry if not existing. insertShowIfNotExisting(file, allTVshows) + AppendMessage("Processing show: " + file.Name) insertEpisodesIfNotExisting(file) } + + AppendMessage("reindex finished successfully!") + SendEvent("stop") } func insertEpisodesIfNotExisting(show Show) { @@ -44,11 +45,9 @@ func insertEpisodesIfNotExisting(show Show) { diff := difference(show.files, dbepisodes) for _, s := range diff { + AppendMessage("Adding Episode: " + s) insertEpisode(s, show.Name) } - - fmt.Println("diff is...") - fmt.Println(len(diff)) } func insertEpisode(path string, ShowName string) { diff --git a/apiGo/videoparser/ReIndexTVShows_test.go b/apiGo/videoparser/ReIndexTVShows_test.go new file mode 100644 index 0000000..fc05648 --- /dev/null +++ b/apiGo/videoparser/ReIndexTVShows_test.go @@ -0,0 +1,13 @@ +package videoparser + +import "testing" + +func TestDifference(t *testing.T) { + arr1 := []string{"test1", "test2", "test3"} + arr2 := []string{"test1", "test3"} + + res := difference(arr1, arr2) + if len(res) != 1 || res[0] != "test2" { + t.Errorf("wrong difference result.") + } +} diff --git a/apiGo/videoparser/VideoParser.go b/apiGo/videoparser/VideoParser.go index 9e15195..f056b7b 100644 --- a/apiGo/videoparser/VideoParser.go +++ b/apiGo/videoparser/VideoParser.go @@ -112,15 +112,13 @@ func StartTVShowReindex() { } } - fmt.Println(files) - if err != nil { fmt.Println(err.Error()) } // start reindex process AppendMessage("Starting Reindexing!") - go startTVShowReindex(files, mSettings) + go startTVShowReindex(files) } func StartCleanup() {