forked from nkeonkeo/MediaUnlockTest
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathGemini.go
executable file
·54 lines (44 loc) · 1.61 KB
/
Gemini.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
package mediaunlocktest
import (
"io"
"regexp"
"net/http"
"strings"
)
func extractGeminiRegion(body string) string {
regex := regexp.MustCompile(`,2,1,200,"([A-Z]{3})"`)
matches := regex.FindStringSubmatch(body)
if len(matches) > 1 {
return matches[1]
}
return ""
}
func Gemini(c http.Client) Result {
resp, err := GET(c, "https://gemini.google.com/?hl=en",
H{"Cookie", "SOCS=CAISOAgeEitib3FfaWRlbnRpdHlmcm9udGVuZHVpc2VydmVyXzIwMjQwODExLjA4X3AwGgV6aC1DTiACGgYIgOfvtQY; NID=516=I_1jljreYQcLJzkCvUL8k6eIiBqaC8_mkGLq8XaPbFdY2MMgL9re9rZw7NC9scKoZJyI3pzxTfTqhklea0KVsKRKeRMyl-TOLZgzpb_rqoL2vH7J2_5Wlef7KTXVuLfArRqcGeFWF4OZ6HBfQqu7BQc_YiFfiXshUK1bAp19DZQOQ_nmzgacv-HSMnOG6wPOJsBD7qNXmf4IuQ;__Secure-ENID=delete"},
)
if err != nil {
return Result{Status: StatusNetworkErr, Err: err}
}
defer resp.Body.Close()
if resp.StatusCode == 403 {
return Result{Status: StatusBanned}
}
if resp.StatusCode == 302 {
return Result{Status: StatusFailed}
}
bodyBytes, err := io.ReadAll(resp.Body)
bodyString := string(bodyBytes)
if err != nil {
return Result{Status: StatusNetworkErr, Err: err}
}
regionThreeCode := extractGeminiRegion(bodyString)
regionTwoCode := threeToTwoCode(regionThreeCode)
if regionThreeCode != "" && regionTwoCode != "" {
if !strings.Contains(bodyString, "45617354,null,true") {
return Result{Status: StatusNo, Region: strings.ToLower(regionTwoCode)}
}
return Result{Status: StatusOK, Region: strings.ToLower(regionTwoCode)}
}
return Result{Status: StatusUnexpected}
}