-
Notifications
You must be signed in to change notification settings - Fork 22
/
xb.go
38 lines (33 loc) · 931 Bytes
/
xb.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package douyin
import (
"fmt"
"github.com/dop251/goja"
"github.com/foamzou/audio-get/logger"
gen_xb_js "github.com/foamzou/audio-get/processor/douyin/gen-xb-js"
)
func genXB(urlParams string, ua string) (string, error) {
vm := goja.New()
_, err := vm.RunString(gen_xb_js.CryptoMinJS) // executes a script on the global context
if err != nil {
logger.Warn("genXB failed", err)
return "", err
}
_, err = vm.RunString(gen_xb_js.AsciiBase64) // executes a script on the global context
if err != nil {
logger.Warn("genXB failed", err)
return "", err
}
_, err = vm.RunString(gen_xb_js.XB_JS) // executes a script on the global context
if err != nil {
logger.Warn("genXB failed", err)
return "", err
}
val, err := vm.RunString(fmt.Sprintf("xb_main('%s', '%s')", urlParams, ua))
if err != nil {
logger.Warn("genXB failed", err)
return "", err
}
// nolint
v := val.Export().(string)
return v, nil
}