-
Notifications
You must be signed in to change notification settings - Fork 51
/
Epix.go
70 lines (68 loc) · 1.83 KB
/
Epix.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
package mediaunlocktest
import (
"encoding/json"
"io"
"net/http"
"strings"
)
func Epix(c http.Client) Result {
url := "https://api.epix.com/v2/sessions"
resp, err := PostJson(c, url,
`{"device":{"guid":"e2add88e-2d92-4392-9724-326c2336013b","format":"console","os":"web","app_version":"1.0.2","model":"browser","manufacturer":"google"},"apikey":"f07debfcdf0f442bab197b517a5126ec","oauth":{"token":null}}`,
)
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}
}
s := string(b)
if strings.Contains(s, "error code") {
return Result{Status: StatusNo}
}
if strings.Contains(s, "blocked") {
return Result{Status: StatusBanned}
}
var res struct {
DeviceSession struct {
SessionToken string `json:"session_token"`
} `json:"device_session"`
}
if err := json.Unmarshal(b, &res); err != nil {
// log.Println(err)
return Result{Status: StatusFailed, Err: err}
}
url2 := "https://api.epix.com/v2/movies/16921/play"
resp2, err := PostJson(c, url2, `{}`, H{"X-Session-Token", res.DeviceSession.SessionToken})
if err != nil {
// log.Println(err)
return Result{Status: StatusNetworkErr, Err: err}
}
defer resp2.Body.Close()
b2, err := io.ReadAll(resp2.Body)
if err != nil {
// log.Println(err)
return Result{Status: StatusNetworkErr, Err: err}
}
var res2 struct {
Movie struct {
Entitlements struct {
Status string
}
}
}
if err := json.Unmarshal(b2, &res2); err != nil {
return Result{Status: StatusFailed, Err: err}
}
switch res2.Movie.Entitlements.Status {
case "PROXY_DETECTED":
return Result{Status: StatusNo}
case "GEO_BLOCKED":
return Result{Status: StatusNo}
case "NOT_SUBSCRIBED":
return Result{Status: StatusOK}
}
return Result{Status: StatusFailed}
}