-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgql.go
40 lines (34 loc) · 1.49 KB
/
gql.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package twitchpl
func NewPlaybackAccessTokenQuery(login string) GraphQLQuery {
return GraphQLQuery{
OperationName: "PlaybackAccessToken_Template",
Query: `query PlaybackAccessToken_Template($login: String!, $isLive: Boolean!, $vodID: ID!, $isVod: Boolean!, $playerType: String!) { streamPlaybackAccessToken(channelName: $login, params: {platform: "web", playerBackend: "mediaplayer", playerType: $playerType}) @include(if: $isLive) { value signature __typename } videoPlaybackAccessToken(id: $vodID, params: {platform: "web", playerBackend: "mediaplayer", playerType: $playerType}) @include(if: $isVod) { value signature __typename }}`,
Variables: GraphQLVariables{
IsLive: true,
Login: login,
PlayerType: "site",
},
}
}
type GraphQLQuery struct {
OperationName string `json:"operationName"`
Query string `json:"query"`
Variables GraphQLVariables `json:"variables"`
}
type GraphQLVariables struct {
Login string `json:"login"`
PlayerType string `json:"playerType"`
VodID string `json:"vodID"`
IsLive bool `json:"isLive"`
IsVod bool `json:"isVod"`
}
type PlaybackAccessTokenGraphQLResponse struct {
Data PlaybackAccessTokenGraphQLData `json:"data"`
}
type PlaybackAccessTokenGraphQLData struct {
StreamPlaybackAccessToken StreamPlaybackAccessToken `json:"streamPlaybackAccessToken"`
}
type StreamPlaybackAccessToken struct {
Signature string `json:"signature"`
Value string `json:"value"`
}