From 756f6c6be3c18aa144252dee9899bc986f027e20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=82=A5=E7=BE=8A?= Date: Wed, 28 Feb 2024 18:13:58 +0800 Subject: [PATCH] fix time error --- Golang/liveurls/huya.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Golang/liveurls/huya.go b/Golang/liveurls/huya.go index 3a6d8fe..6b96336 100644 --- a/Golang/liveurls/huya.go +++ b/Golang/liveurls/huya.go @@ -98,14 +98,17 @@ func getUUID() int64 { } func processAntiCode(antiCode string, uid int, streamName string) string { - location, _ := time.LoadLocation("Asia/Shanghai") - now := time.Now().In(location) + TimeLocation, err := time.LoadLocation("Asia/Shanghai") + if err != nil { + TimeLocation = time.FixedZone("CST", 8*60*60) + } + now := time.Now().In(TimeLocation) q, _ := url.ParseQuery(antiCode) q.Set("t", "102") q.Set("ctype", "tars_mp") q.Set("wsTime", strconv.FormatInt(time.Now().Unix()+21600, 16)) q.Set("ver", "1") - q.Set("sv", now.Format("2006010203")) + q.Set("sv", now.Format("2006010215")) seqId := strconv.Itoa(uid + int(time.Now().UnixNano()/int64(time.Millisecond))) q.Set("seqid", seqId) q.Set("uid", strconv.Itoa(uid))