fix bug
This commit is contained in:
parent
e516932ece
commit
4568ea3913
1 changed files with 12 additions and 4 deletions
16
main.go
16
main.go
|
|
@ -8,6 +8,7 @@ import (
|
|||
"os"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/SevereCloud/vksdk/v2/api"
|
||||
"github.com/SevereCloud/vksdk/v2/events"
|
||||
|
|
@ -20,9 +21,8 @@ import (
|
|||
|
||||
var video_links chan (string)
|
||||
|
||||
// const tg_chat_id int64 = -1002135430788
|
||||
// const tg_bot_key string = "6548829570:AAFi_K-YhJwP7asF2-bwSCxrNAkkI7c7Xd0"
|
||||
// const vk_api_key string = "vk1.a.iQX883p6Es-adfHxxEBd1KSEodg79PqVNatiWAadchBPzhYJz2UGE5pgPmXNFlygj3RqTJQ7gB3juUayHFm4yYgV9fE6LPx_z3EkD3L57zXmNrLGjMdSASud4dXe7yfQNQP4OoPmmSAH4MZubPGK1JWWxzRe4wgYaooAA5ehRtcQOYjzser3kfJemt-uvT93ccikgR66QSjq0bGDsmeUyw"
|
||||
const PCUserAgent string = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36"
|
||||
const MobileUserAgent string = "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Mobile Safari/537.36"
|
||||
|
||||
func main() {
|
||||
// get config
|
||||
|
|
@ -136,7 +136,15 @@ func tg_worker(id int, bot *tgbotapi.BotAPI) {
|
|||
for link := range video_links {
|
||||
log.Println(fmt.Sprintf("[%d]", id), "Получена ссылка, загружаю:", link)
|
||||
// get video by link
|
||||
client := httpclient.New().WithHeader("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36")
|
||||
var client *httpclient.Client
|
||||
if strings.Contains(link, "VK_ANDROID") {
|
||||
// create mobile client
|
||||
client = httpclient.New().WithHeader("User-Agent", MobileUserAgent)
|
||||
} else {
|
||||
// create Desktop client
|
||||
client = httpclient.New().WithHeader("User-Agent", PCUserAgent)
|
||||
}
|
||||
|
||||
resp, err := client.Get(link).Do()
|
||||
error_logging(err)
|
||||
body, err := resp.Bytes()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue