Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
spiritLHLS committed Jul 4, 2024
1 parent de4b7fb commit e6deaa5
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 10 deletions.
22 changes: 20 additions & 2 deletions asia/Bilibili.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package asia
import (
"encoding/json"
"fmt"
"github.com/oneclickvirt/UnlockTests/model"
"github.com/oneclickvirt/UnlockTests/utils"
"io"
"net/http"
"strings"

"github.com/oneclickvirt/UnlockTests/model"
"github.com/oneclickvirt/UnlockTests/utils"
. "github.com/oneclickvirt/defaultset"
)

// Bilibili
Expand All @@ -17,14 +19,24 @@ func Bilibili(c *http.Client, name, url string) model.Result {
if c == nil {
return model.Result{Name: name}
}
if model.EnableLoger {
InitLogger()
defer Logger.Sync()
}
client := utils.Req(c)
resp, err := client.R().Get(url)
if err != nil {
if model.EnableLoger {
Logger.Info("Bilibili Get request failed: " + err.Error())
}
return model.Result{Name: name, Status: model.StatusNetworkErr, Err: err}
}
defer resp.Body.Close()
b, err := io.ReadAll(resp.Body)
if err != nil {
if model.EnableLoger {
Logger.Info("Bilibili can not parse body: " + err.Error())
}
return model.Result{Name: name, Status: model.StatusNetworkErr, Err: fmt.Errorf("can not parse body")}
}
body := string(b)
Expand All @@ -36,6 +48,9 @@ func Bilibili(c *http.Client, name, url string) model.Result {
if strings.Contains(body, "抱歉您所在地区不可观看") {
return model.Result{Name: name, Status: model.StatusNo}
}
if model.EnableLoger {
Logger.Info("Bilibili can not parse json: " + err.Error())
}
return model.Result{Name: name, Status: model.StatusErr, Err: err}
}
if strings.Contains(body, "抱歉您所在地区不可观看") || strings.Contains(body, "The area is inaccessible") ||
Expand All @@ -48,6 +63,9 @@ func Bilibili(c *http.Client, name, url string) model.Result {
unlockType := utils.GetUnlockType(result1, result2, result3)
return model.Result{Name: name, Status: model.StatusYes, UnlockType: unlockType}
}
if model.EnableLoger {
Logger.Info(fmt.Sprintf("Bilibili unexpected response code: %d", resp.StatusCode))
}
return model.Result{Name: name, Status: model.StatusUnexpected,
Err: fmt.Errorf("get api.bilibili.com failed with code: %d", resp.StatusCode)}
}
19 changes: 17 additions & 2 deletions asia/HBOGO.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package asia
import (
"encoding/json"
"fmt"
"github.com/oneclickvirt/UnlockTests/model"
"github.com/oneclickvirt/UnlockTests/utils"
"io"
"net/http"
"strings"

"github.com/oneclickvirt/UnlockTests/model"
"github.com/oneclickvirt/UnlockTests/utils"
. "github.com/oneclickvirt/defaultset"
)

// HBOGO
Expand All @@ -18,15 +20,25 @@ func HBOGO(c *http.Client) model.Result {
if c == nil {
return model.Result{Name: name}
}
if model.EnableLoger {
InitLogger()
defer Logger.Sync()
}
url := "https://api2.hbogoasia.com/v1/geog?lang=undefined&version=0&bundleId=www.hbogoasia.com"
client := utils.Req(c)
resp, err := client.R().Get(url)
if err != nil {
if model.EnableLoger {
Logger.Info("hbogoasia Get request failed: " + err.Error())
}
return model.Result{Name: name, Status: model.StatusNetworkErr, Err: err}
}
defer resp.Body.Close()
b, err := io.ReadAll(resp.Body)
if err != nil {
if model.EnableLoger {
Logger.Info("hbogoasia can not parse body: " + err.Error())
}
return model.Result{Name: name, Status: model.StatusNetworkErr, Err: fmt.Errorf("can not parse body")}
}
//body := string(b)
Expand All @@ -36,6 +48,9 @@ func HBOGO(c *http.Client) model.Result {
Territory string `json:"territory"`
}
if err := json.Unmarshal(b, &hboRes); err != nil {
if model.EnableLoger {
Logger.Info("hbogoasia can not parse json: " + err.Error())
}
return model.Result{Name: name, Status: model.StatusErr, Err: err}
}
if hboRes.Territory == "" {
Expand Down
15 changes: 13 additions & 2 deletions asia/Hotstar.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/oneclickvirt/UnlockTests/model"
"github.com/oneclickvirt/UnlockTests/utils"
. "github.com/oneclickvirt/defaultset"
)

// HotStar
Expand All @@ -17,19 +18,29 @@ func HotStar(c *http.Client) model.Result {
if c == nil {
return model.Result{Name: name}
}
if model.EnableLoger {
InitLogger()
defer Logger.Sync()
}
url := "https://api.hotstar.com/o/v1/page/1557?offset=0&size=20&tao=0&tas=20"
client := utils.Req(c)
resp, err := client.R().Get(url)
if err != nil {
if model.EnableLoger {
Logger.Info("api.hotstar.com Get request failed: " + err.Error())
}
return model.Result{Name: name, Status: model.StatusNetworkErr, Err: err}
}
defer resp.Body.Close()
//fmt.Println(body)
if resp.StatusCode == 475 || resp.StatusCode == 403 {
return model.Result{Name: name, Status: model.StatusNo}
}
resp1, errs1 := client.R().Get("https://www.hotstar.com")
if errs1 != nil {
resp1, err1 := client.R().Get("https://www.hotstar.com")
if err1 != nil {
if model.EnableLoger {
Logger.Info("www.hotstar.com Get request failed: " + err1.Error())
}
return model.Result{Name: name, Status: model.StatusUnexpected,
Err: fmt.Errorf("get api.hotstar.com failed with code1: %d", resp.StatusCode)}
}
Expand Down
22 changes: 20 additions & 2 deletions asia/MolaTV.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package asia
import (
"encoding/json"
"fmt"
"github.com/oneclickvirt/UnlockTests/model"
"github.com/oneclickvirt/UnlockTests/utils"
"io"
"net/http"
"strings"

"github.com/oneclickvirt/UnlockTests/model"
"github.com/oneclickvirt/UnlockTests/utils"
. "github.com/oneclickvirt/defaultset"
)

// MolaTV
Expand All @@ -18,15 +20,25 @@ func MolaTV(c *http.Client) model.Result {
if c == nil {
return model.Result{Name: name}
}
if model.EnableLoger {
InitLogger()
defer Logger.Sync()
}
url := "https://mola.tv/api/v2/videos/geoguard/check/vd30491025"
client := utils.Req(c)
resp, err := client.R().Get(url)
if err != nil {
if model.EnableLoger {
Logger.Info("mola.tv Get request failed: " + err.Error())
}
return model.Result{Name: name, Status: model.StatusNetworkErr, Err: err}
}
defer resp.Body.Close()
b, err := io.ReadAll(resp.Body)
if err != nil {
if model.EnableLoger {
Logger.Info("mola.tv can not parse body: " + err.Error())
}
return model.Result{Name: name, Status: model.StatusNetworkErr, Err: fmt.Errorf("can not parse body")}
}
body := string(b)
Expand All @@ -44,6 +56,9 @@ func MolaTV(c *http.Client) model.Result {
if strings.Contains(body, "\"isAllowed\":false") {
return model.Result{Name: name, Status: model.StatusNo}
}
if model.EnableLoger {
Logger.Info("mola.tv can not parse json: " + err.Error())
}
return model.Result{Name: name, Status: model.StatusNetworkErr, Err: err}
}
if !res.Data.Attributes.IsAllowed {
Expand All @@ -53,6 +68,9 @@ func MolaTV(c *http.Client) model.Result {
unlockType := utils.GetUnlockType(result1, result2, result3)
return model.Result{Name: name, Status: model.StatusYes, UnlockType: unlockType}
}
if model.EnableLoger {
Logger.Info(fmt.Sprintf("mola.tv unexpected response code: %d", resp.StatusCode))
}
return model.Result{Name: name, Status: model.StatusUnexpected,
Err: fmt.Errorf("get mola.tv failed with code: %d", resp.StatusCode)}
}
41 changes: 39 additions & 2 deletions asia/StarPlus.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package asia
import (
"encoding/json"
"fmt"
"github.com/oneclickvirt/UnlockTests/model"
"github.com/oneclickvirt/UnlockTests/utils"
"io"
"net/http"
"strings"

"github.com/oneclickvirt/UnlockTests/model"
"github.com/oneclickvirt/UnlockTests/utils"
. "github.com/oneclickvirt/defaultset"
)

// StarPlus
Expand All @@ -18,26 +20,42 @@ func StarPlus(c *http.Client) model.Result {
if c == nil {
return model.Result{Name: name}
}
if model.EnableLoger {
InitLogger()
defer Logger.Sync()
}
url := "https://www.starplus.com/"
client := utils.Req(c)
resp, err := client.R().Get(url)
if err != nil {
if model.EnableLoger {
Logger.Info("StarPlus Get request failed: " + err.Error())
}
return model.Result{Name: name, Status: model.StatusNetworkErr, Err: err}
}
defer resp.Body.Close()
b, err := io.ReadAll(resp.Body)
if err != nil {
if model.EnableLoger {
Logger.Info("StarPlus can not parse body: " + err.Error())
}
return model.Result{Name: name, Status: model.StatusNetworkErr, Err: fmt.Errorf("can not parse body")}
}
body := string(b)
//fmt.Println(body)
if resp.StatusCode == 403 {
if model.EnableLoger {
Logger.Info("StarPlus request banned with status code: 403")
}
return model.Result{Name: name, Status: model.StatusBanned}
}
//fmt.Println(resp.StatusCode)
//fmt.Println(resp.Request.URL.String())
if resp.StatusCode == 200 {
if resp.StatusCode == 302 || resp.Header.Get("Location") == "https://www.preview.starplus.com/unavailable" {
if model.EnableLoger {
Logger.Info("StarPlus region is inaccessible")
}
return model.Result{Name: name, Status: model.StatusNo}
}
region := utils.ReParse(body, `Region:\s+([A-Za-z]{2})`)
Expand All @@ -58,6 +76,9 @@ func StarPlus(c *http.Client) model.Result {
return model.Result{Name: name, Status: model.StatusNo}
}
}
if model.EnableLoger {
Logger.Info(fmt.Sprintf("StarPlus unexpected response code: %d", resp.StatusCode))
}
return model.Result{Name: name, Status: model.StatusUnexpected,
Err: fmt.Errorf("get www.starplus.com failed with code: %d", resp.StatusCode)}
}
Expand All @@ -66,6 +87,10 @@ func StarPlus(c *http.Client) model.Result {
// StarPlus 的 另一个检测逻辑
func AnotherStarPlus(c *http.Client) model.Result {
name := "Star+"
if model.EnableLoger {
InitLogger()
defer Logger.Sync()
}
headers := map[string]string{
"authorization": "c3RhciZicm93c2VyJjEuMC4w.COknIGCR7I6N0M5PGnlcdbESHGkNv7POwhFNL-_vIdg",
}
Expand All @@ -79,13 +104,22 @@ func AnotherStarPlus(c *http.Client) model.Result {
"\"chrome\",\"browserVersion\":\"96.0.4664\"}}}}"
resp, body, err := utils.PostJson(c, "https://star.api.edge.bamgrid.com/graph/v1/device/graphql", starcontent, headers)
if err != nil {
if model.EnableLoger {
Logger.Info("star.api.edge.bamgrid.com post json err:" + err.Error())
}
return model.Result{Name: name, Status: model.StatusNetworkErr, Err: err}
}
if resp.StatusCode >= 400 {
if model.EnableLoger {
Logger.Info("star.api.edge.bamgrid.com post json err with resp status code: " + resp.Status)
}
return model.Result{Name: name, Status: model.StatusNetworkErr, Err: fmt.Errorf("resp status code >= 400")}
}
var data map[string]interface{}
if err := json.Unmarshal([]byte(body), &data); err != nil {
if model.EnableLoger {
Logger.Info("star.api.edge.bamgrid.com can not parse body:" + err.Error())
}
return model.Result{Name: name, Status: model.StatusNetworkErr, Err: fmt.Errorf("can not parse body")}
}
region := ""
Expand All @@ -112,6 +146,9 @@ func AnotherStarPlus(c *http.Client) model.Result {
} else if region == "" {
return model.Result{Name: name, Status: model.StatusNo}
}
if model.EnableLoger {
Logger.Info(fmt.Sprintf("www.starplus.com unexpected response code: %d", resp.StatusCode))
}
return model.Result{Name: name, Status: model.StatusUnexpected,
Err: fmt.Errorf("get www.starplus.com another check failed with code: %d", resp.StatusCode)}
}

0 comments on commit e6deaa5

Please sign in to comment.