mirror of
https://codeberg.org/SafeTwitch/safetwitch-backend.git
synced 2025-01-08 13:50:05 -05:00
add login with display name
This commit is contained in:
parent
8e572b9bbd
commit
c0103c4976
5 changed files with 9 additions and 10 deletions
|
@ -20,6 +20,7 @@ type Stream struct {
|
||||||
|
|
||||||
type Streamer struct {
|
type Streamer struct {
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
|
Login string `json:"login"`
|
||||||
About string `json:"about"`
|
About string `json:"about"`
|
||||||
Pfp string `json:"pfp"`
|
Pfp string `json:"pfp"`
|
||||||
Followers int `json:"followers"`
|
Followers int `json:"followers"`
|
||||||
|
|
|
@ -3,6 +3,7 @@ package twitch
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"safetwitch-backend/extractor"
|
"safetwitch-backend/extractor"
|
||||||
"safetwitch-backend/extractor/structs"
|
"safetwitch-backend/extractor/structs"
|
||||||
|
@ -12,7 +13,7 @@ import (
|
||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ParseStreamer(streamerData gjson.Result, isLive bool, socials []structs.Social, stream *structs.Stream) (structs.Streamer, error) {
|
func ParseStreamer(streamerData gjson.Result, isLive bool, socials []structs.Social, stream *structs.Stream, login string) (structs.Streamer, error) {
|
||||||
// Store streamerColorHex in memory to use as pointer
|
// Store streamerColorHex in memory to use as pointer
|
||||||
var streamerColorHex *string
|
var streamerColorHex *string
|
||||||
rawStreamerColorHex := streamerData.Get("user.primaryColorHex").String()
|
rawStreamerColorHex := streamerData.Get("user.primaryColorHex").String()
|
||||||
|
@ -22,8 +23,11 @@ func ParseStreamer(streamerData gjson.Result, isLive bool, socials []structs.Soc
|
||||||
streamerColorHex = &rawStreamerColorHex
|
streamerColorHex = &rawStreamerColorHex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Println(streamerData.String())
|
||||||
|
|
||||||
parsedStreamer := structs.Streamer{
|
parsedStreamer := structs.Streamer{
|
||||||
Username: streamerData.Get("user.displayName").String(),
|
Username: streamerData.Get("user.displayName").String(),
|
||||||
|
Login: login,
|
||||||
About: streamerData.Get("user.description").String(),
|
About: streamerData.Get("user.description").String(),
|
||||||
Pfp: extractor.ProxyUrl(streamerData.Get("user.profileImageURL").String()),
|
Pfp: extractor.ProxyUrl(streamerData.Get("user.profileImageURL").String()),
|
||||||
Followers: int(streamerData.Get("user.followers.totalCount").Int()),
|
Followers: int(streamerData.Get("user.followers.totalCount").Int()),
|
||||||
|
|
|
@ -166,7 +166,7 @@ func GetStreamerInfo(streamerName string) (structs.Streamer, error) {
|
||||||
isLive = false
|
isLive = false
|
||||||
}
|
}
|
||||||
|
|
||||||
parsedStreamer, err := ParseStreamer(streamerData, isLive, parsedSocials, parsedStream)
|
parsedStreamer, err := ParseStreamer(streamerData, isLive, parsedSocials, parsedStream, streamerName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return structs.Streamer{}, err
|
return structs.Streamer{}, err
|
||||||
}
|
}
|
||||||
|
@ -559,7 +559,7 @@ func GetStreamerId(channelName string) (string, error) {
|
||||||
if id != "" {
|
if id != "" {
|
||||||
return id, nil
|
return id, nil
|
||||||
} else {
|
} else {
|
||||||
return "", errors.New("Could not find user")
|
return "", errors.New("could not find user")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
6
go.mod
6
go.mod
|
@ -3,6 +3,7 @@ module safetwitch-backend
|
||||||
go 1.20
|
go 1.20
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/gin-contrib/gzip v0.0.6
|
||||||
github.com/gin-gonic/gin v1.9.0
|
github.com/gin-gonic/gin v1.9.0
|
||||||
github.com/gorilla/websocket v1.5.0
|
github.com/gorilla/websocket v1.5.0
|
||||||
github.com/satori/go.uuid v1.2.0
|
github.com/satori/go.uuid v1.2.0
|
||||||
|
@ -12,8 +13,6 @@ require (
|
||||||
require (
|
require (
|
||||||
github.com/bytedance/sonic v1.8.8 // indirect
|
github.com/bytedance/sonic v1.8.8 // indirect
|
||||||
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
|
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
|
||||||
github.com/gin-contrib/cors v1.4.0 // indirect
|
|
||||||
github.com/gin-contrib/gzip v0.0.6 // indirect
|
|
||||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||||
github.com/go-playground/locales v0.14.1 // indirect
|
github.com/go-playground/locales v0.14.1 // indirect
|
||||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||||
|
@ -21,13 +20,11 @@ require (
|
||||||
github.com/goccy/go-json v0.10.2 // indirect
|
github.com/goccy/go-json v0.10.2 // indirect
|
||||||
github.com/json-iterator/go v1.1.12 // indirect
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
|
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
|
||||||
github.com/kr/pretty v0.3.0 // indirect
|
|
||||||
github.com/leodido/go-urn v1.2.4 // indirect
|
github.com/leodido/go-urn v1.2.4 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.18 // indirect
|
github.com/mattn/go-isatty v0.0.18 // indirect
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
github.com/pelletier/go-toml/v2 v2.0.7 // indirect
|
github.com/pelletier/go-toml/v2 v2.0.7 // indirect
|
||||||
github.com/rogpeppe/go-internal v1.8.0 // indirect
|
|
||||||
github.com/tidwall/match v1.1.1 // indirect
|
github.com/tidwall/match v1.1.1 // indirect
|
||||||
github.com/tidwall/pretty v1.2.1 // indirect
|
github.com/tidwall/pretty v1.2.1 // indirect
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||||
|
@ -38,6 +35,5 @@ require (
|
||||||
golang.org/x/sys v0.8.0 // indirect
|
golang.org/x/sys v0.8.0 // indirect
|
||||||
golang.org/x/text v0.9.0 // indirect
|
golang.org/x/text v0.9.0 // indirect
|
||||||
google.golang.org/protobuf v1.30.0 // indirect
|
google.golang.org/protobuf v1.30.0 // indirect
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
|
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
|
2
go.sum
2
go.sum
|
@ -8,8 +8,6 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/gin-contrib/cors v1.4.0 h1:oJ6gwtUl3lqV0WEIwM/LxPF1QZ5qe2lGWdY2+bz7y0g=
|
|
||||||
github.com/gin-contrib/cors v1.4.0/go.mod h1:bs9pNM0x/UsmHPBWT2xZz9ROh8xYjYkiURUfmBoMlcs=
|
|
||||||
github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4=
|
github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4=
|
||||||
github.com/gin-contrib/gzip v0.0.6/go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjovCXNuzzk=
|
github.com/gin-contrib/gzip v0.0.6/go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjovCXNuzzk=
|
||||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||||
|
|
Loading…
Reference in a new issue