-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathDiscovery+.go
52 lines (50 loc) · 1.99 KB
/
Discovery+.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
package mediaunlocktest
import (
"encoding/json"
"io"
"net/http"
)
func DiscoveryPlus(c http.Client) Result {
resp, err := GET(c, "https://us1-prod-direct.discoveryplus.com/token?deviceId=d1a4a5d25212400d1e6985984604d740&realm=go&shortlived=true")
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 {
Data struct {
Attributes struct {
Token string
}
}
}
if err := json.Unmarshal(b, &res); err != nil {
return Result{Status: StatusFailed, Err: err}
}
resp2, err := GET(c, "https://us1-prod-direct.discoveryplus.com/users/me", H{"Cookie", "_gcl_au=1.1.858579665.1632206782; _rdt_uuid=1632206782474.6a9ad4f2-8ef7-4a49-9d60-e071bce45e88; _scid=d154b864-8b7e-4f46-90e0-8b56cff67d05; _pin_unauth=dWlkPU1qWTRNR1ZoTlRBdE1tSXdNaTAwTW1Nd0xUbGxORFV0WWpZMU0yVXdPV1l6WldFeQ; _sctr=1|1632153600000; aam_fw=aam%3D9354365%3Baam%3D9040990; aam_uuid=24382050115125439381416006538140778858; st=" + res.Data.Attributes.Token + "; gi_ls=0; _uetvid=a25161a01aa711ec92d47775379d5e4d; AMCV_BC501253513148ED0A490D45%40AdobeOrg=-1124106680%7CMCIDTS%7C18894%7CMCMID%7C24223296309793747161435877577673078228%7CMCAAMLH-1633011393%7C9%7CMCAAMB-1633011393%7CRKhpRz8krg2tLO6pguXWp5olkAcUniQYPHaMWWgdJ3xzPWQmdj0y%7CMCOPTOUT-1632413793s%7CNONE%7CvVersion%7C5.2.0; ass=19ef15da-95d6-4b1d-8fa2-e9e099c9cc38.1632408400.1632406594"})
if err != nil {
return Result{Status: StatusNetworkErr, Err: err}
}
defer resp2.Body.Close()
b2, err := io.ReadAll(resp2.Body)
if err != nil {
return Result{Status: StatusNetworkErr, Err: err}
}
var res2 struct {
Data struct {
Attributes struct {
CurrentLocationTerritory string
}
}
}
if err := json.Unmarshal(b2, &res2); err != nil {
return Result{Status: StatusFailed, Err: err}
}
if res2.Data.Attributes.CurrentLocationTerritory == "us" {
return Result{Status: StatusOK}
}
return Result{Status: StatusNo}
}