forked from nkeonkeo/MediaUnlockTest
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathChannel5.go
executable file
·47 lines (39 loc) · 1.1 KB
/
Channel5.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
package mediaunlocktest
import (
"encoding/json"
"io"
"net/http"
"strconv"
"time"
)
func Channel5(c http.Client) Result {
timestamp := time.Now().Unix()
resp, err := GET(c, "https://cassie.channel5.com/api/v2/live_media/my5desktopng/C5.json?timestamp="+strconv.FormatInt(timestamp, 10)+"&auth=0_rZDiY0hp_TNcDyk2uD-Kl40HqDbXs7hOawxyqPnbI")
if err != nil {
return Result{Status: StatusNetworkErr, Err: err}
}
defer resp.Body.Close()
b, err := io.ReadAll(resp.Body)
if err != nil {
return Result{Status: StatusNetworkErr, Err: err}
}
var res struct {
Code string `json:"code"`
}
if err := json.Unmarshal(b, &res); err != nil {
if err.Error() == `invalid character '<' looking for beginning of value` {
return Result{Status: StatusBanned}
}
return Result{Status: StatusFailed, Err: err}
}
if res.Code == "3000" {
return Result{Status: StatusNo}
}
if res.Code == "3001" {
return Result{Status: StatusNo, Info: "Proxy Detected"}
}
if res.Code == "4003" {
return Result{Status: StatusOK}
}
return Result{Status: StatusUnexpected}
}