]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
直播流fix
authorqydysky <qydysky@foxmail.com>
Tue, 5 Apr 2022 12:31:51 +0000 (20:31 +0800)
committerqydysky <qydysky@foxmail.com>
Tue, 5 Apr 2022 12:31:51 +0000 (20:31 +0800)
F/cmd.go
Reply/F.go

index 1ed79c9f8e82bfef55c9e7f31e2e34daf81eb5fa..6167504f71ec76f8451fa668f0dfe90f45d4328e 100644 (file)
--- a/F/cmd.go
+++ b/F/cmd.go
@@ -1,31 +1,31 @@
 package F
 
 import (
-       "os"
        "bufio"
-       "strings"
+       "fmt"
+       "os"
        "strconv"
+       "strings"
        "time"
-       "fmt"
 
-       send "github.com/qydysky/bili_danmu/Send"
        c "github.com/qydysky/bili_danmu/CV"
+       send "github.com/qydysky/bili_danmu/Send"
 )
 
 //直播间缓存
-var liveList =make(map[string]int)
+var liveList = make(map[string]int)
 
 func Cmd() {
-       
-       cmdlog := c.Log.Base_add(`命令行操作`).L(`T: `,`回车查看帮助`)
+
+       cmdlog := c.Log.Base_add(`命令行操作`).L(`T: `, `回车查看帮助`)
        scanner := bufio.NewScanner(os.Stdin)
 
        for scanner.Scan() {
-               if inputs := scanner.Text();inputs == `` {//帮助
+               if inputs := scanner.Text(); inputs == `` { //帮助
                        fmt.Print("\n")
                        fmt.Println("切换房间->输入数字回车")
                        if c.Roomid == 0 {
-                               if _,ok := c.Cookie.LoadV(`bili_jct`).(string);ok {
+                               if _, ok := c.Cookie.LoadV(`bili_jct`).(string); ok {
                                        fmt.Println("查看直播中主播->输入' live'回车")
                                } else {
                                        fmt.Println("登陆->输入' login'回车")
@@ -35,7 +35,7 @@ func Cmd() {
                                fmt.Print("\n")
                                continue
                        }
-                       if _,ok := c.Cookie.LoadV(`bili_jct`).(string);ok {
+                       if _, ok := c.Cookie.LoadV(`bili_jct`).(string); ok {
                                fmt.Println("发送弹幕->输入' 字符串'回车")
                                fmt.Println("查看直播中主播->输入' live'回车")
                                fmt.Println("获取小心心->输入' getheart'回车")
@@ -48,9 +48,9 @@ func Cmd() {
                        fmt.Println("开始结束录制->输入' rec'回车")
                        fmt.Println("其他输出隔断不影响")
                        fmt.Print("\n")
-               } else if inputs[0] == 27 {//屏蔽功能键
+               } else if inputs[0] == 27 { //屏蔽功能键
                        cmdlog.L(`W: `, "不支持功能键")
-               } else if inputs[0] == 32 {// 开头
+               } else if inputs[0] == 32 { // 开头
                        //录制切换
                        if strings.Contains(inputs, ` rec`) && c.Roomid != 0 {
                                if !c.Liveing {
@@ -62,21 +62,21 @@ func Cmd() {
                        }
                        //直播间切换
                        if strings.Contains(inputs, ` live`) {
-                               if _,ok := c.Cookie.LoadV(`bili_jct`).(string);!ok {
+                               if _, ok := c.Cookie.LoadV(`bili_jct`).(string); !ok {
                                        cmdlog.L(`W: `, "尚未登陆,未能获取关注主播")
                                        continue
                                }
                                fmt.Print("\n")
                                if len(inputs) > 5 {
-                                       if room,ok := liveList[inputs];ok{
+                                       if room, ok := liveList[inputs]; ok {
                                                c.Roomid = room
-                                               c.Danmu_Main_mq.Push_tag(`change_room`,nil)
+                                               c.Danmu_Main_mq.Push_tag(`change_room`, nil)
                                                continue
                                        }
                                        cmdlog.L(`W: `, "输入错误", inputs)
                                        continue
                                }
-                               for k,v := range Feed_list() {
+                               for k, v := range Feed_list() {
                                        liveList[` live`+strconv.Itoa(k)] = v.Roomid
                                        fmt.Printf("%d\t%s\n\t\t\t%s\n", k, v.Uname, v.Title)
                                }
@@ -86,7 +86,7 @@ func Cmd() {
                        }
                        //登陆
                        if strings.Contains(inputs, ` login`) {
-                               if _,ok := c.Cookie.LoadV(`bili_jct`).(string);ok {
+                               if _, ok := c.Cookie.LoadV(`bili_jct`).(string); ok {
                                        cmdlog.L(`W: `, "已登陆")
                                        continue
                                }
@@ -97,7 +97,7 @@ func Cmd() {
                        }
                        //获取小心心
                        if strings.Contains(inputs, ` getheart`) && c.Roomid != 0 {
-                               if _,ok := c.Cookie.LoadV(`bili_jct`).(string);!ok {
+                               if _, ok := c.Cookie.LoadV(`bili_jct`).(string); !ok {
                                        cmdlog.L(`W: `, "尚未登陆,不能获取小心心")
                                        continue
                                }
@@ -114,7 +114,7 @@ func Cmd() {
                                }
 
                                fmt.Print("\n")
-                               for k,v := range SearchUP(inputs[7:]) {
+                               for k, v := range SearchUP(inputs[7:]) {
                                        liveList[` live`+strconv.Itoa(k)] = v.Roomid
                                        if v.Is_live {
                                                fmt.Printf("%d\t%s\t%s\n", k, `☁`, v.Uname)
@@ -129,7 +129,7 @@ func Cmd() {
                        }
                        //重载弹幕
                        if strings.Contains(inputs, ` reload`) && c.Roomid != 0 {
-                               c.Danmu_Main_mq.Push_tag(`flash_room`,nil)
+                               c.Danmu_Main_mq.Push_tag(`flash_room`, nil)
                                continue
                        }
                        //当前直播间信息
@@ -138,7 +138,9 @@ func Cmd() {
                                fmt.Println("当前直播间信息")
                                {
                                        living := `未在直播`
-                                       if c.Liveing {living = `直播中`}
+                                       if c.Liveing {
+                                               living = `直播中`
+                                       }
                                        fmt.Println(c.Uname, c.Title, living)
                                }
                                {
@@ -153,18 +155,22 @@ func Cmd() {
                                        }
                                }
                                {
-                                       fmt.Println(`营收:`, fmt.Sprintf("¥%.2f",c.Rev))
+                                       fmt.Println(`营收:`, fmt.Sprintf("¥%.2f", c.Rev))
                                }
                                fmt.Println(`舰长数:`, c.GuardNum)
                                fmt.Println(`分区排行:`, c.Note, `人气:`, c.Renqi)
-                               if c.Stream_url != ""{fmt.Println(`直播Web服务:`, c.Stream_url)}
+                               if c.Stream_url != "" {
+                                       fmt.Println(`直播Web服务:`, c.Stream_url+`/now`)
+                               }
                                fmt.Print("\n")
 
                                continue
                        }
-                       {//弹幕发送
-                               if c.Roomid == 0 {continue}
-                               if _,ok := c.Cookie.LoadV(`bili_jct`).(string);!ok {
+                       { //弹幕发送
+                               if c.Roomid == 0 {
+                                       continue
+                               }
+                               if _, ok := c.Cookie.LoadV(`bili_jct`).(string); !ok {
                                        cmdlog.L(`W: `, "尚未登陆,不能发送弹幕")
                                        continue
                                }
@@ -174,13 +180,15 @@ func Cmd() {
                                }
                                send.Danmu_s(inputs[1:], c.Roomid)
                        }
-               } else if room,err := strconv.Atoi(inputs);err == nil {//直接进入房间
+               } else if room, err := strconv.Atoi(inputs); err == nil { //直接进入房间
                        c.Roomid = room
-                       cmdlog.L(`I: `, "进入房间",room)
-                       c.Danmu_Main_mq.Push_tag(`change_room`,nil)
-               } else {//其余字符串
-                       if c.Roomid == 0 {continue}
+                       cmdlog.L(`I: `, "进入房间", room)
+                       c.Danmu_Main_mq.Push_tag(`change_room`, nil)
+               } else { //其余字符串
+                       if c.Roomid == 0 {
+                               continue
+                       }
                        send.Danmu_s(inputs, c.Roomid)
                }
        }
-}
\ No newline at end of file
+}
index 9afce207ae1ab1aa9b15e1a71618e235553c718c..063a5af735f09da7537498ec6cba53585f1a3cc5 100644 (file)
@@ -462,6 +462,8 @@ func Savestreamf() {
                                        o := bytes.Index(line, []byte(`EXT-X-MAP:URI="`)) + 15
                                        e := bytes.Index(line[o:], []byte(`"`)) + o
                                        m4s_link = string(line[o:e])
+                               } else if bytes.Contains(line, []byte("EXT-X-BILI-PREFETCH")) {
+                                       continue
                                } else if bytes.Contains(line, []byte(".m4s")) {
                                        m4s_link = string(line)
                                }
@@ -497,6 +499,9 @@ func Savestreamf() {
                                if found {
                                        offset := m4s_links[i].Offset_line - 1
                                        for i := offset; i < len(lines); i += 1 {
+                                               if bytes.Contains(lines[i], []byte("EXT-X-BILI-PREFETCH")) {
+                                                       continue
+                                               }
                                                m3u8_file_addition = append(m3u8_file_addition, lines[i]...)
                                                m3u8_file_addition = append(m3u8_file_addition, []byte("\n")...)
                                        }
@@ -510,6 +515,9 @@ func Savestreamf() {
                        if !found {
                                offset := m4s_links[1].Offset_line - 1
                                for i := offset; i < len(lines); i += 1 {
+                                       if bytes.Contains(lines[i], []byte("EXT-X-BILI-PREFETCH")) {
+                                               continue
+                                       }
                                        m3u8_file_addition = append(m3u8_file_addition, lines[i]...)
                                        m3u8_file_addition = append(m3u8_file_addition, []byte("\n")...)
                                }
@@ -1304,7 +1312,7 @@ func Savestreamf() {
                                                        for i := now - 1; i > previou; i -= 1 {
                                                                base := strconv.Itoa(i) + ".m4s"
                                                                links = append([]*m4s_link_item{
-                                                                       &m4s_link_item{
+                                                                       {
                                                                                Url:  path_front + base + path_behind,
                                                                                Base: base,
                                                                        },