forked from ninjasphere/go-castv2
/
Action.go
53 lines (46 loc) · 1.21 KB
/
Action.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
41
42
43
44
45
46
47
48
49
50
51
52
53
package youtube
import (
"net/url"
"strconv"
"github.com/AndreasAbdi/go-castv2/generic"
"github.com/imroc/req"
)
type actionRequestParameters struct {
VideoID string
ActionID string
LoungeID string
RequestCount int
SessionRequestCount int
SessionID string
GSessionID string
}
//CreateActionRequest to be sent to active session.
func createActionRequest(params actionRequestParameters) generic.RequestComponents {
requestCount := params.RequestCount
header := req.Header{
loungeIDHeader: params.LoungeID,
}
for k, v := range defaultHeaders {
header[k] = v
}
reqParams := req.Param{
sessionIDKey: params.SessionID,
gSessionIDKey: params.GSessionID,
requestIDKey: requestCount,
versionKey: bindVersion,
cVersionKey: bindCVersion,
}
count := strconv.Itoa(defaultCount)
body := map[string][]string{
actionKey: []string{params.ActionID},
videoIDKey: []string{params.VideoID},
countKey: []string{count},
}
formattedBody := FormatSessionParameters(body, params.SessionRequestCount)
return generic.RequestComponents{
URL: bindURL,
Header: header,
Params: reqParams,
Body: url.Values(formattedBody).Encode(),
}
}