Skip to content

Commit 8eb638d

Browse files
committed
修改为联通配置,测试
1 parent 7914588 commit 8eb638d

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

internal/app/iptv/hwctc/authenticator.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"net/http"
1111
"net/url"
1212
"regexp"
13+
"strconv"
1314
"strings"
1415
)
1516

@@ -124,9 +125,13 @@ func (c *Client) authLoginHWCTC(ctx context.Context, referer string) (string, er
124125
if err != nil {
125126
return "", err
126127
}
127-
regex := regexp.MustCompile("EncryptToken = \"(.+?)\";")
128+
regex := regexp.MustCompile("var EncryptToken = \"(.+?)\";")
128129
matches := regex.FindSubmatch(result)
129-
if len(matches) != 2 {
130+
c.logger.Info("EncryptToken cnt:" + strconv.Itoa(len(matches)))
131+
for i := range matches {
132+
c.logger.Info("EncryptToken " + strconv.Itoa(i) + ": " + string(matches[i]))
133+
}
134+
if len(matches) != 1 {
130135
return "", errors.New("failed to parse EncryptToken")
131136
}
132137
return string(matches[0]), nil
@@ -231,14 +236,15 @@ func (c *Client) validAuthenticationHWCTC(ctx context.Context, encryptToken stri
231236
if err != nil {
232237
return nil, err
233238
}
234-
regex := regexp.MustCompile("(?s)\"UserToken\" value=\"(.+?)\".+?\"tempKey\" value=\"(.*?)\".+?\"stbid\" value=\"(.*?)\"")
239+
regex := regexp.MustCompile("(?s)<input type=\"hidden\" name=\"UserToken\" value=\"(.*?)\".*<input type=\"hidden\" name=\"tempKey\" value=\"(.*?)\".*<input type=\"hidden\" name=\"stbid\" value=\"(.*?)\">")
235240
matches := regex.FindSubmatch(result)
236-
if len(matches) != 3 {
237-
return nil, errors.New("failed to parse userToken")
238-
}
241+
c.logger.Info(fmt.Sprintf("matches: %d", len(matches)))
239242
for match := range matches {
240243
c.logger.Info(string(matches[match]))
241244
}
245+
if len(matches) != 3 {
246+
return nil, errors.New("failed to parse userToken")
247+
}
242248
return &Token{
243249
UserToken: string(matches[0]),
244250
TempKey: string(matches[1]),

0 commit comments

Comments
 (0)