From a51176fb9336bb3198bc73504254d852b5d95eb6 Mon Sep 17 00:00:00 2001 From: lukas Date: Sun, 14 Mar 2021 19:01:40 +0100 Subject: [PATCH] fix filenames with special characters aren't urlencoded year parsing does not remove parentheses --- apiGo/videoparser/ReIndex.go | 3 ++- apiGo/videoparser/tmdb/TMDBApi.go | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/apiGo/videoparser/ReIndex.go b/apiGo/videoparser/ReIndex.go index a8ca707..34d315b 100644 --- a/apiGo/videoparser/ReIndex.go +++ b/apiGo/videoparser/ReIndex.go @@ -139,8 +139,9 @@ func matchYear(fileName string) (int, string) { if len(years) == 0 { return -1, fileName } + yearStr := years[len(years)-1] // get last year occurance and cut first and last char - year, err := strconv.Atoi(years[len(years)-1][1 : len(years)-1]) + year, err := strconv.Atoi(yearStr[1 : len(yearStr)-1]) if err != nil { return -1, fileName diff --git a/apiGo/videoparser/tmdb/TMDBApi.go b/apiGo/videoparser/tmdb/TMDBApi.go index 6905014..2a81d4c 100644 --- a/apiGo/videoparser/tmdb/TMDBApi.go +++ b/apiGo/videoparser/tmdb/TMDBApi.go @@ -6,6 +6,7 @@ import ( "fmt" "io/ioutil" "net/http" + "net/url" "regexp" ) @@ -43,8 +44,9 @@ type TMDBGenre struct { } func SearchVideo(MovieName string, year int) *VideoTMDB { - url := fmt.Sprintf("%ssearch/movie?api_key=%s&query=%s", baseUrl, apiKey, MovieName) - resp, err := http.Get(url) + fmt.Printf("Searching TMDB for: Moviename: %s, year:%d \n", MovieName, year) + queryURL := fmt.Sprintf("%ssearch/movie?api_key=%s&query=%s", baseUrl, apiKey, url.QueryEscape(MovieName)) + resp, err := http.Get(queryURL) if err != nil { fmt.Println(err.Error()) return nil