diff --git a/africa/BeinConnect.go b/africa/BeinConnect.go index 9184e49..3251db2 100644 --- a/africa/BeinConnect.go +++ b/africa/BeinConnect.go @@ -8,7 +8,6 @@ import ( "github.com/oneclickvirt/UnlockTests/model" "github.com/oneclickvirt/UnlockTests/utils" - . "github.com/oneclickvirt/defaultset" ) // BeinConnect @@ -19,43 +18,27 @@ func BeinConnect(c *http.Client) model.Result { if c == nil { return model.Result{Name: name} } - if model.EnableLoger { - InitLogger() - defer Logger.Sync() - } url := "https://proxies.bein-mena-production.eu-west-2.tuc.red/proxy/availableOffers" client := utils.Req(c) resp, err := client.R().Get(url) if err != nil { - if model.EnableLoger { - Logger.Info("BeinConnect 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("BeinConnect read resp.Body failed: " + err.Error()) - } return model.Result{Name: name, Status: model.StatusNetworkErr, Err: fmt.Errorf("can not parse body")} } body := string(b) //fmt.Println(body) if strings.Contains(body, "Unavailable For Legal Reasons") || resp.StatusCode == 403 || resp.StatusCode == 451 { - if model.EnableLoger { - Logger.Info("BeinConnect access denied due to legal reasons: " + body) - } return model.Result{Name: name, Status: model.StatusNo} } else if resp.StatusCode == 200 || resp.StatusCode == 500 { result1, result2, result3 := utils.CheckDNS(hostname) unlockType := utils.GetUnlockType(result1, result2, result3) return model.Result{Name: name, Status: model.StatusYes, UnlockType: unlockType} } - if model.EnableLoger { - Logger.Info(fmt.Sprintf("BeinConnect unexpected response code: %d", resp.StatusCode)) - } return model.Result{Name: name, Status: model.StatusUnexpected, Err: fmt.Errorf("get proxies.bein-mena-production.eu-west-2.tuc.red failed with code: %d", resp.StatusCode)} } diff --git a/africa/DSTV.go b/africa/DSTV.go index 19032b1..0352246 100644 --- a/africa/DSTV.go +++ b/africa/DSTV.go @@ -6,7 +6,6 @@ import ( "github.com/oneclickvirt/UnlockTests/model" "github.com/oneclickvirt/UnlockTests/utils" - . "github.com/oneclickvirt/defaultset" ) // DSTV @@ -17,17 +16,10 @@ func DSTV(c *http.Client) model.Result { if c == nil { return model.Result{Name: name} } - if model.EnableLoger { - InitLogger() - defer Logger.Sync() - } url := "https://authentication.dstv.com/favicon.ico" client := utils.Req(c) resp, err := client.R().Get(url) if err != nil { - if model.EnableLoger { - Logger.Info("DSTV Get request failed: " + err.Error()) - } return model.Result{Name: name, Status: model.StatusNetworkErr, Err: err} } defer resp.Body.Close() @@ -44,9 +36,6 @@ func DSTV(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("DSTV unexpected response code: %d", resp.StatusCode)) - } return model.Result{Name: name, Status: model.StatusUnexpected, Err: fmt.Errorf("get authentication.dstv.com failed with code: %d", resp.StatusCode)} } diff --git a/africa/Showmax.go b/africa/Showmax.go index ba254ce..ba68560 100644 --- a/africa/Showmax.go +++ b/africa/Showmax.go @@ -8,7 +8,6 @@ import ( "github.com/oneclickvirt/UnlockTests/model" "github.com/oneclickvirt/UnlockTests/utils" - . "github.com/oneclickvirt/defaultset" ) // Showmax @@ -19,10 +18,6 @@ func Showmax(c *http.Client) model.Result { if c == nil { return model.Result{Name: name} } - if model.EnableLoger { - InitLogger() - defer Logger.Sync() - } url := "https://www.showmax.com/" headers := map[string]string{ "Host": "www.showmax.com", @@ -43,17 +38,11 @@ func Showmax(c *http.Client) model.Result { client = utils.SetReqHeaders(client, headers) resp, err := client.R().Get(url) if err != nil { - if model.EnableLoger { - Logger.Info("Showmax 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("Showmax can not parse body: " + err.Error()) - } return model.Result{Name: name, Status: model.StatusNetworkErr, Err: fmt.Errorf("can not parse body")} } body := string(b) @@ -69,9 +58,6 @@ func Showmax(c *http.Client) model.Result { unlockType := utils.GetUnlockType(result1, result2, result3) return model.Result{Name: name, Status: model.StatusYes, Region: strings.ToLower(region), UnlockType: unlockType} } - if model.EnableLoger { - Logger.Info(fmt.Sprintf("Showmax unexpected response code: %d", resp.StatusCode)) - } return model.Result{Name: name, Status: model.StatusUnexpected, Err: fmt.Errorf("get www.showmax.com failed with code: %d", resp.StatusCode)} } diff --git a/asia/Bilibili.go b/asia/Bilibili.go index 172e6fe..d565a5f 100644 --- a/asia/Bilibili.go +++ b/asia/Bilibili.go @@ -9,7 +9,6 @@ import ( "github.com/oneclickvirt/UnlockTests/model" "github.com/oneclickvirt/UnlockTests/utils" - . "github.com/oneclickvirt/defaultset" ) // Bilibili @@ -19,24 +18,14 @@ 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) @@ -48,9 +37,6 @@ 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") || @@ -63,9 +49,6 @@ 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)} } diff --git a/asia/HBOGO.go b/asia/HBOGO.go index dcd555c..c4999a4 100644 --- a/asia/HBOGO.go +++ b/asia/HBOGO.go @@ -9,7 +9,6 @@ import ( "github.com/oneclickvirt/UnlockTests/model" "github.com/oneclickvirt/UnlockTests/utils" - . "github.com/oneclickvirt/defaultset" ) // HBOGO @@ -20,25 +19,15 @@ 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) @@ -48,9 +37,6 @@ 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 == "" { diff --git a/asia/Hotstar.go b/asia/Hotstar.go index 50d3007..d4fe45f 100644 --- a/asia/Hotstar.go +++ b/asia/Hotstar.go @@ -7,7 +7,6 @@ import ( "github.com/oneclickvirt/UnlockTests/model" "github.com/oneclickvirt/UnlockTests/utils" - . "github.com/oneclickvirt/defaultset" ) // HotStar @@ -18,17 +17,10 @@ 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() @@ -38,9 +30,6 @@ func HotStar(c *http.Client) model.Result { } 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)} } diff --git a/asia/MolaTV.go b/asia/MolaTV.go index 860fe7a..e817764 100644 --- a/asia/MolaTV.go +++ b/asia/MolaTV.go @@ -9,7 +9,6 @@ import ( "github.com/oneclickvirt/UnlockTests/model" "github.com/oneclickvirt/UnlockTests/utils" - . "github.com/oneclickvirt/defaultset" ) // MolaTV @@ -20,25 +19,15 @@ 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) @@ -56,9 +45,6 @@ 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 { @@ -68,9 +54,6 @@ 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)} } diff --git a/asia/StarPlus.go b/asia/StarPlus.go index f300a8b..8c890c3 100644 --- a/asia/StarPlus.go +++ b/asia/StarPlus.go @@ -9,7 +9,6 @@ import ( "github.com/oneclickvirt/UnlockTests/model" "github.com/oneclickvirt/UnlockTests/utils" - . "github.com/oneclickvirt/defaultset" ) // StarPlus @@ -20,42 +19,26 @@ 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})`) @@ -76,9 +59,6 @@ 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)} } @@ -87,10 +67,6 @@ 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", } @@ -104,22 +80,13 @@ 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 := "" @@ -146,9 +113,6 @@ 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)} } diff --git a/au/7Plus.go b/au/7Plus.go index e037db7..3771a08 100644 --- a/au/7Plus.go +++ b/au/7Plus.go @@ -2,9 +2,10 @@ package au import ( "fmt" + "net/http" + "github.com/oneclickvirt/UnlockTests/model" "github.com/oneclickvirt/UnlockTests/utils" - "net/http" ) // Au7plus diff --git a/au/ABCiView.go b/au/ABCiView.go index a6f3262..34a9711 100644 --- a/au/ABCiView.go +++ b/au/ABCiView.go @@ -2,11 +2,12 @@ package au import ( "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" ) // ABCiView diff --git a/au/Binge.go b/au/Binge.go index 1beaece..349cbbb 100644 --- a/au/Binge.go +++ b/au/Binge.go @@ -2,9 +2,10 @@ package au import ( "fmt" + "net/http" + "github.com/oneclickvirt/UnlockTests/model" "github.com/oneclickvirt/UnlockTests/utils" - "net/http" ) // Binge diff --git a/uts/uts.go b/uts/uts.go index d08a16f..4a5a472 100644 --- a/uts/uts.go +++ b/uts/uts.go @@ -91,9 +91,11 @@ func ShowResult(r *model.Result) (s string) { return formatResult(Yellow, "Restricted", *r) case model.StatusErr: s = Yellow("Error") - // if r.Err != nil { - // s += ": " + r.Err.Error() - // } + if model.EnableLoger { + InitLogger() + defer Logger.Sync() + Logger.Info(r.Name + " " + r.Err.Error()) + } return s case model.StatusNo: return formatResult(Red, "NO", *r)