diff --git a/internal/unicom/client.go b/internal/unicom/client.go index 580ad1a..dc3a5dc 100644 --- a/internal/unicom/client.go +++ b/internal/unicom/client.go @@ -226,9 +226,12 @@ func (c *Client) Query(ctx context.Context, phone string) (Snapshot, error) { extra.Set("language", c.plan.Language) } plan, err := c.postBill(ctx, c.plan, extra) - if err != nil { + if err != nil && !errors.Is(err, ErrNeedLogin) { return BuildSnapshot(phone, balance, nil), err } + if err != nil { + return BuildSnapshot(phone, balance, nil), nil + } return BuildSnapshot(phone, balance, plan), nil } diff --git a/internal/unicom/script.go b/internal/unicom/script.go index c0e7b87..a10027d 100644 --- a/internal/unicom/script.go +++ b/internal/unicom/script.go @@ -53,7 +53,7 @@ var ( queryKeyRE = regexp.MustCompile(`(?:VUE_APP_KEY_QUERY|key_query):"([^"]+)"`) httpsHostRE = regexp.MustCompile(`"(https://[a-zA-Z0-9.-]+\.10010\.com)"`) versionRE = regexp.MustCompile(`version:"([^"]+)"`) - languageRE = regexp.MustCompile(`language:"([^"]+)"`) + languageRE = regexp.MustCompile(`(?:language|languageType)\s*[:=]\s*"([^"]+)"`) jsPathRE = regexp.MustCompile(`["']([^"']+\.js(?:\?[^"']*)?)["']`) ) diff --git a/internal/unicom/script_test.go b/internal/unicom/script_test.go index e94b970..63379ad 100644 --- a/internal/unicom/script_test.go +++ b/internal/unicom/script_test.go @@ -78,6 +78,15 @@ func TestParseBillAPI(t *testing.T) { } } +func TestParseBillLanguageType(t *testing.T) { + js := `VUE_APP_XX_BASE_URL:"https://bill.example.10010.com",key_query:"servicequerybusiness",version:"WT",languageType="chinese" + m("".concat(g.c,"/operationservice/queryOcsPackageFlowLeftContentRevisedInJune"),e)` + api, ok := parseBillAPI(js, "https://img.example.10010.com/plan/index.html", "/operationservice/queryOcsPackageFlowLeftContentRevisedInJune") + if !ok || api.Language != "chinese" { + t.Fatalf("%v %#v", ok, api) + } +} + func TestResolveNav(t *testing.T) { texts := []string{ `function getNavJson(){ var url = CommonsVariables.QueryRequestPrefix() +'/QueryNavigations'; }`,