fix filenames with special characters aren't urlencoded
year parsing does not remove parentheses
This commit is contained in:
parent
b2b0e3a917
commit
a51176fb93
@ -139,8 +139,9 @@ func matchYear(fileName string) (int, string) {
|
|||||||
if len(years) == 0 {
|
if len(years) == 0 {
|
||||||
return -1, fileName
|
return -1, fileName
|
||||||
}
|
}
|
||||||
|
yearStr := years[len(years)-1]
|
||||||
// get last year occurance and cut first and last char
|
// 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 {
|
if err != nil {
|
||||||
return -1, fileName
|
return -1, fileName
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"regexp"
|
"regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -43,8 +44,9 @@ type TMDBGenre struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func SearchVideo(MovieName string, year int) *VideoTMDB {
|
func SearchVideo(MovieName string, year int) *VideoTMDB {
|
||||||
url := fmt.Sprintf("%ssearch/movie?api_key=%s&query=%s", baseUrl, apiKey, MovieName)
|
fmt.Printf("Searching TMDB for: Moviename: %s, year:%d \n", MovieName, year)
|
||||||
resp, err := http.Get(url)
|
queryURL := fmt.Sprintf("%ssearch/movie?api_key=%s&query=%s", baseUrl, apiKey, url.QueryEscape(MovieName))
|
||||||
|
resp, err := http.Get(queryURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err.Error())
|
fmt.Println(err.Error())
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user