diff --git a/extractor/twitch/Discover.go b/extractor/twitch/Discover.go index 1db98b5..1fae766 100644 --- a/extractor/twitch/Discover.go +++ b/extractor/twitch/Discover.go @@ -4,6 +4,8 @@ import ( "safetwitch-backend/extractor" "safetwitch-backend/extractor/structs" + "net/url" + "github.com/tidwall/gjson" ) @@ -52,13 +54,18 @@ func GetDiscoveryPage(limit int, cursor string) ([]structs.CategoryPreview, erro } func GetDiscoveryItem(name string, streamLimit int, cursor string) (structs.CategoryData, error) { + unEncoded, err := url.QueryUnescape(name) + if err != nil { + return structs.CategoryData{}, err + } + payload := []TwitchPayload{ { "operationName": "DirectoryPage_Game", "variables": map[string]interface{}{ "cursor": cursor, "imageWidth": 50, - "name": name, + "name": unEncoded, "options": map[string]interface{}{ "sort": "RELEVANCE", "recommendationsContext": map[string]interface{}{ @@ -81,7 +88,7 @@ func GetDiscoveryItem(name string, streamLimit int, cursor string) (structs.Cate { "operationName": "Directory_DirectoryBanner", "variables": map[string]interface{}{ - "name": name, + "name": unEncoded, }, "extensions": map[string]interface{}{ "persistedQuery": map[string]interface{}{ diff --git a/main.go b/main.go index 2da5c1f..855ee6c 100644 --- a/main.go +++ b/main.go @@ -63,6 +63,8 @@ func main() { router.Use(ErrorHandler) routes.SetRoutes(router) router.NoRoute(notFoundHandler) + router.UseRawPath = true + router.UnescapePathValues = false log.Println("Safetwitch API running") env = os.Getenv("PORT")