]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
直播服务器备链
authorqydysky <qydysky@foxmail.com>
Sat, 10 Oct 2020 01:02:46 +0000 (09:02 +0800)
committerqydysky <qydysky@foxmail.com>
Sat, 10 Oct 2020 01:02:46 +0000 (09:02 +0800)
Reply/F.go

index c04c8b5a872c7625796c5184544ca84f092f1baf..8d4a797f375471d72fd7551b4ab752713b081fa6 100644 (file)
@@ -256,8 +256,9 @@ func Saveflvf(){
 
        l := p.Logf().New().Open("danmu.log").Base(-1, "saveflv")
 
+       cuLinkIndex := 0
        api := F.New_api(c.Roomid)
-       for api.Get_live(saveflv.qn).Live_status == 1 {
+       for api.Get_live(saveflv.qn).Live_status == 1 && !saveflv.cancel.Islive() {
                c.Live = api.Live
 
                saveflv.path = strconv.Itoa(c.Roomid) + "_" + time.Now().Format("2006_01_02_15:04:05.000")
@@ -285,7 +286,7 @@ func Saveflvf(){
                        retry := 20
                        for retry > 0 && rr.ResponseCode != 200 {
                                if e := rr.Reqf(p.Rval{
-                                       Url:c.Live[0],
+                                       Url:c.Live[cuLinkIndex],
                                        Retry:10,
                                        SleepTime:5,
                                        Cookie:Cookie,
@@ -299,6 +300,8 @@ func Saveflvf(){
                                p.Sys().Timeoutf(5)
                                saveflv.wait.Done()
                                saveflv.cancel.Done()
+                               cuLinkIndex += 1
+                               if cuLinkIndex >= len(c.Live) {cuLinkIndex = 0}
                                continue
                        }
                }
@@ -307,7 +310,7 @@ func Saveflvf(){
                l.I("保存到", saveflv.path + ".flv")
 
                if e := rr.Reqf(p.Rval{
-                       Url:c.Live[0],
+                       Url:c.Live[cuLinkIndex],
                        Retry:10,
                        SleepTime:5,
                        Cookie:Cookie,