mirror of
https://codeberg.org/SafeTwitch/safetwitch-backend.git
synced 2024-12-22 05:02:58 -05:00
36 lines
944 B
Go
36 lines
944 B
Go
package twitch
|
|
|
|
import (
|
|
"safetwitch-backend/extractor/structs"
|
|
|
|
"github.com/tidwall/gjson"
|
|
)
|
|
|
|
func GetVODChat(vodID string, second int) ([]structs.VodComment, error) {
|
|
payload := []TwitchPayload{
|
|
{
|
|
"operationName": "VideoCommentsByOffsetOrCursor",
|
|
"variables": map[string]interface{}{
|
|
"videoID": vodID,
|
|
"contentOffsetSeconds": second,
|
|
},
|
|
"extensions": map[string]interface{}{
|
|
"persistedQuery": map[string]interface{}{
|
|
"version": 1,
|
|
"sha256Hash": "b70a3591ff0f4e0313d126c6a1502d79a1c02baebb288227c582044aa76adf6a",
|
|
},
|
|
},
|
|
},
|
|
}
|
|
_, body, err := parseResponse(payload)
|
|
if err != nil {
|
|
return []structs.VodComment{}, err
|
|
}
|
|
|
|
comments := gjson.Get(string(body), "0.data.video.comments.edges").Array()
|
|
parsedComments := []structs.VodComment{}
|
|
for _, comment := range comments {
|
|
parsedComments = append(parsedComments, ParseVODMessage(comment))
|
|
}
|
|
return parsedComments, nil
|
|
}
|