mirror of
https://codeberg.org/SafeTwitch/safetwitch-backend.git
synced 2024-12-21 20:53:00 -05:00
URL Encode categories
This commit is contained in:
parent
1e4f4df6eb
commit
f146f5390b
2 changed files with 11 additions and 2 deletions
|
@ -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{}{
|
||||
|
|
2
main.go
2
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")
|
||||
|
|
Loading…
Reference in a new issue