mirror of
https://github.com/eeeXun/GTT.git
synced 2025-05-16 07:40:44 -07:00
style: userAgent to const string
This commit is contained in:
parent
fcf2e0020a
commit
05c963f2d1
@ -90,7 +90,7 @@ Stop play sound.
|
||||
Toggle transparent.
|
||||
|
||||
`<C-\>`
|
||||
Toggle Definition/Example & Part of speech
|
||||
Toggle Definition/Example & Part of speech.
|
||||
|
||||
`<Tab>`, `<S-Tab>`
|
||||
Cycle through the pop out widget.
|
||||
|
@ -13,7 +13,8 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
textURL = "https://api.reverso.net/translate/v1/translation"
|
||||
textURL = "https://api.reverso.net/translate/v1/translation"
|
||||
userAgent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36"
|
||||
)
|
||||
|
||||
type ReversoTranslate struct {
|
||||
@ -70,7 +71,7 @@ func (t *ReversoTranslate) Translate(message string) (translation, definition, p
|
||||
textURL,
|
||||
bytes.NewBuffer([]byte(userData)))
|
||||
req.Header.Add("Content-Type", "application/json")
|
||||
req.Header.Add("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36")
|
||||
req.Header.Add("User-Agent", userAgent)
|
||||
res, err := http.DefaultClient.Do(req)
|
||||
if err != nil {
|
||||
return "", "", "", err
|
||||
|
@ -38,7 +38,7 @@ func (t *ReversoTranslate) PlayTTS(lang, message string) error {
|
||||
base64.StdEncoding.EncodeToString([]byte(message)),
|
||||
)
|
||||
req, _ := http.NewRequest("GET", urlStr, nil)
|
||||
req.Header.Add("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36")
|
||||
req.Header.Add("User-Agent", userAgent)
|
||||
res, err := http.DefaultClient.Do(req)
|
||||
if err != nil {
|
||||
t.SoundLock.Release()
|
||||
|
Loading…
x
Reference in New Issue
Block a user