Skip to content

Commit

Permalink
增强 Watcha 检测
Browse files Browse the repository at this point in the history
  • Loading branch information
spiritLHLS committed Feb 4, 2025
1 parent 751db1c commit 0c251d2
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 20 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

[![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Foneclickvirt%2FUnlockTests&count_bg=%2323E01C&title_bg=%23555555&icon=sonarcloud.svg&icon_color=%23E7E7E7&title=hits&edge_flat=false)](https://hits.seeyoufarm.com) [![Build and Release](https://github.com/oneclickvirt/UnlockTests/actions/workflows/main.yaml/badge.svg)](https://github.com/oneclickvirt/UnlockTests/actions/workflows/main.yaml)

[<img src="https://api.gitsponsors.com/api/badge/img?id=807989375" height="20">](https://api.gitsponsors.com/api/badge/link?p=HYcyVL/QcRsW5E3VC2mPZnaAdjsqIdoVKZdrcZu6PaIHP2B2oikl8HhupvR5fLIoClrL/5KIJokR896YV4hwM3Rm3QRoZueHedGa+T5//Qgvsxx3E5C3g8HCxwH1G/EWPyhSv2S+mUnYfk4Ill7HyA==)

解锁测试模块 (Unlock Tests Module)

## 使用
Expand Down
4 changes: 2 additions & 2 deletions fr/Salto.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ func Salto(c *http.Client) model.Result {
return model.Result{Name: name, Status: model.StatusNetworkErr, Err: err}
}
defer resp.Body.Close()
b, err := io.ReadAll(resp.Body)
_, err = io.ReadAll(resp.Body)
if err == nil {
fmt.Println(string(b), resp.StatusCode)
return model.Result{Name: name, Status: model.StatusErr, Err: err}
}
return model.Result{Name: name, Status: model.StatusUnexpected,
Err: fmt.Errorf("get geo.salto.fr failed with code: %d", resp.StatusCode)}
Expand Down
47 changes: 30 additions & 17 deletions kr/Watcha.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,20 @@ func Watcha(c *http.Client) model.Result {
if c == nil {
return model.Result{Name: name}
}
url := "https://watcha.com/"
// 首先检查 API 接口
apiURL := "https://watcha.com/api/aio_browses/tvod/all?size=3"
client := utils.Req(c)
// 检查 API 接口
resp1, err := client.R().Get(apiURL)
if err != nil {
return model.Result{Name: name, Status: model.StatusNetworkErr, Err: err}
}
defer resp1.Body.Close()
if resp1.StatusCode == 451 {
return model.Result{Name: name, Status: model.StatusNo}
}
// 检查主页面
url := "https://watcha.com/browse/theater"
headers := map[string]string{
"User-Agent": model.UA_Browser,
"host": "watcha.com",
Expand All @@ -25,34 +38,34 @@ func Watcha(c *http.Client) model.Result {
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "\"Windows\"",
"upgrade-insecure-requests": "1",
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7' -H 'sec-fetch-site: none' -H 'sec-fetch-mode: navigate' -H 'sec-fetch-user: ?1' -H 'sec-fetch-dest: document' -H 'accept-language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
}
client := utils.Req(c)
client = utils.SetReqHeaders(client, headers)
resp, err := client.R().Get(url)
resp2, err := client.R().Get(url)
if err != nil {
return model.Result{Name: name, Status: model.StatusNetworkErr, Err: err}
}
defer resp.Body.Close()
//b, err := io.ReadAll(resp.Body)
//if err != nil {
// return model.Result{Name: name, Status: model.StatusNetworkErr, Err: fmt.Errorf("can not parse body")}
//}
//body := string(b)
//fmt.Println(body)
if resp.StatusCode == 451 {
defer resp2.Body.Close()
// 检查各种状态码
if resp2.StatusCode == 451 {
return model.Result{Name: name, Status: model.StatusNo}
} else if resp.StatusCode == 403 {
} else if resp2.StatusCode == 403 {
return model.Result{Name: name, Status: model.StatusBanned}
} else if resp.StatusCode == 200 {
} else if resp2.StatusCode == 200 {
result1, result2, result3 := utils.CheckDNS(hostname)
unlockType := utils.GetUnlockType(result1, result2, result3)
return model.Result{Name: name, Status: model.StatusYes, UnlockType: unlockType, Region: "kr"}
} else if resp.StatusCode == 302 && resp.Header.Get("Location") == "/ja-JP/browse/theater" {
} else if resp2.StatusCode == 302 {
location := resp2.Header.Get("Location")
result1, result2, result3 := utils.CheckDNS(hostname)
unlockType := utils.GetUnlockType(result1, result2, result3)
return model.Result{Name: name, Status: model.StatusYes, UnlockType: unlockType, Region: "jp"}
switch location {
case "/ja-JP/browse/theater":
return model.Result{Name: name, Status: model.StatusYes, UnlockType: unlockType, Region: "jp"}
case "/ko-KR/browse/theater":
return model.Result{Name: name, Status: model.StatusYes, UnlockType: unlockType, Region: "kr"}
}
}
return model.Result{Name: name, Status: model.StatusUnexpected,
Err: fmt.Errorf("get watcha.com failed with code: %d", resp.StatusCode)}
Err: fmt.Errorf("get watcha.com failed with code: %d", resp2.StatusCode)}
}
2 changes: 1 addition & 1 deletion th/AISPlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func AISPlay(c *http.Client) model.Result {
}

result := extractHeaderValue(resp, "X-Geo-Protection-System-Status")
fmt.Println(result)
// fmt.Println(result)
switch result {
case "BLOCK":
return model.Result{Name: name, Status: model.StatusNo}
Expand Down

0 comments on commit 0c251d2

Please sign in to comment.