forked from ninjasphere/go-castv2
/
InitializeQueue.go
73 lines (63 loc) · 1.83 KB
/
InitializeQueue.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package youtube
import (
"net/url"
"strconv"
"github.com/AndreasAbdi/go-castv2/generic"
"github.com/imroc/req"
)
const actionSetPlaylist = "setPlaylist"
//components for the initializeQueueRequest parameters and body
const listIDKey = "_listId"
const actionKey = "__sc"
const currentTimeKey = "_currentTime"
const currentIndexKey = "_currentIndex"
const audioOnlyKey = "_audioOnly"
const countKey = "count"
const videoIDKey = "_videoId"
const defaultTime = "0"
const defaultIndex = -1
const defaultAudioOnlySetting = "false"
const defaultCount = 1
type initializeQueueRequestParams struct {
VideoID string
ListID string
LoungeID string
RequestCount int
SessionRequestCount int
SessionID string
GSessionID string
}
func createInitializeQueueRequest(params initializeQueueRequestParams) 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,
}
index := strconv.Itoa(defaultIndex)
count := strconv.Itoa(defaultCount)
body := map[string][]string{
listIDKey: []string{params.ListID},
actionKey: []string{actionSetPlaylist},
currentTimeKey: []string{defaultTime},
currentIndexKey: []string{index},
audioOnlyKey: []string{defaultAudioOnlySetting},
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(),
}
}