mirror of
https://codeberg.org/SafeTwitch/safetwitch-backend.git
synced 2024-12-22 05:02:58 -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"
|
||||||
"safetwitch-backend/extractor/structs"
|
"safetwitch-backend/extractor/structs"
|
||||||
|
|
||||||
|
"net/url"
|
||||||
|
|
||||||
"github.com/tidwall/gjson"
|
"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) {
|
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{
|
payload := []TwitchPayload{
|
||||||
{
|
{
|
||||||
"operationName": "DirectoryPage_Game",
|
"operationName": "DirectoryPage_Game",
|
||||||
"variables": map[string]interface{}{
|
"variables": map[string]interface{}{
|
||||||
"cursor": cursor,
|
"cursor": cursor,
|
||||||
"imageWidth": 50,
|
"imageWidth": 50,
|
||||||
"name": name,
|
"name": unEncoded,
|
||||||
"options": map[string]interface{}{
|
"options": map[string]interface{}{
|
||||||
"sort": "RELEVANCE",
|
"sort": "RELEVANCE",
|
||||||
"recommendationsContext": map[string]interface{}{
|
"recommendationsContext": map[string]interface{}{
|
||||||
|
@ -81,7 +88,7 @@ func GetDiscoveryItem(name string, streamLimit int, cursor string) (structs.Cate
|
||||||
{
|
{
|
||||||
"operationName": "Directory_DirectoryBanner",
|
"operationName": "Directory_DirectoryBanner",
|
||||||
"variables": map[string]interface{}{
|
"variables": map[string]interface{}{
|
||||||
"name": name,
|
"name": unEncoded,
|
||||||
},
|
},
|
||||||
"extensions": map[string]interface{}{
|
"extensions": map[string]interface{}{
|
||||||
"persistedQuery": map[string]interface{}{
|
"persistedQuery": map[string]interface{}{
|
||||||
|
|
2
main.go
2
main.go
|
@ -63,6 +63,8 @@ func main() {
|
||||||
router.Use(ErrorHandler)
|
router.Use(ErrorHandler)
|
||||||
routes.SetRoutes(router)
|
routes.SetRoutes(router)
|
||||||
router.NoRoute(notFoundHandler)
|
router.NoRoute(notFoundHandler)
|
||||||
|
router.UseRawPath = true
|
||||||
|
router.UnescapePathValues = false
|
||||||
|
|
||||||
log.Println("Safetwitch API running")
|
log.Println("Safetwitch API running")
|
||||||
env = os.Getenv("PORT")
|
env = os.Getenv("PORT")
|
||||||
|
|
Loading…
Reference in a new issue