@@ -2,9 +2,11 @@ package getters
2
2
3
3
import (
4
4
"errors"
5
- "fmt"
6
5
"regexp"
7
6
"strings"
7
+ "fmt"
8
+ "strconv"
9
+ "encoding/hex"
8
10
)
9
11
10
12
//huya 虎牙直播
@@ -66,22 +68,39 @@ func (i *huya) GetLiveInfo(id string) (live LiveInfo, err error) {
66
68
}
67
69
}()
68
70
live = LiveInfo {RoomID : id }
69
- url := "http://m.huya.com/" + id
70
- html , err := httpGetWithUA (url , ipadUA )
71
- title := getValue (html , "liveRoomName" )
72
- nick := getValue (html , "ANTHOR_NICK" )
73
- img := getValue (html , "picURL" )
74
- reg , _ := regexp .Compile ("cid: '(\\ d+/\\ d+)'" )
75
- cid := strings .Replace (reg .FindStringSubmatch (html )[1 ], "/" , "_" , 1 )
76
- video := fmt .Sprintf ("http://hls.yy.com/%s_100571200.flv" , cid )
77
- live .LiveNick = nick
78
- live .LivingIMG = img
71
+ url := "http://www.huya.com/" + id
72
+ html , err := httpGet (url )
73
+ reg , _ := regexp .Compile ("\" channel\" :\" *(\\ d+)\" *," )
74
+ channel , _ := strconv .Atoi (reg .FindStringSubmatch (html )[1 ])
75
+ reg , _ = regexp .Compile ("\" sid\" :\" *(\\ d+)\" *," )
76
+ sid , _ := strconv .Atoi (reg .FindStringSubmatch (html )[1 ])
77
+ _hex := fmt .Sprintf ("0000009E10032C3C4C56066C6976657569660D6765744C6976696E67496E666F7D0000750800010604745265711D0000680A0A0300000000000000001620FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF2600361777656226323031377633322E313131302E33266875796146005C0B1300000000%08x2300000000%08x3300000000000000000B8C980CA80C" ,
78
+ channel , sid )
79
+ _hex = strings .ToUpper (_hex )
80
+ req_data , _ := hex .DecodeString (_hex )
81
+ video_content , err := httpPost ("http://cdn.wup.huya.com/" , string (req_data ))
82
+ print (video_content )
83
+
84
+ reg , _ = regexp .Compile (fmt .Sprintf ("(%d-%d[^f]+)" , channel , sid ))
85
+ video_id := reg .FindStringSubmatch (video_content )[1 ]
86
+
87
+ reg , _ = regexp .Compile ("wsSecret=([0-9a-z]{32})" )
88
+ wsSecret := reg .FindStringSubmatch (video_content )[1 ]
89
+
90
+ reg , _ = regexp .Compile ("wsTime=([0-9a-z]{8})" )
91
+ wsTime := reg .FindStringSubmatch (video_content )[1 ]
92
+
93
+ reg , _ = regexp .Compile ("://(.+\\ .(flv|stream)\\ .huya\\ .com/(hqlive|huyalive))" )
94
+ video_url := reg .FindStringSubmatch (video_content )[1 ]
95
+
96
+ live .VideoURL = fmt .Sprintf ("http://%s/%s.flv?wsSecret=%s&wsTime=%s" , video_url , video_id , wsSecret , wsTime )
97
+
98
+ url = "http://m.huya.com/" + id
99
+ html , err = httpGetWithUA (url , ipadUA )
100
+ live .LiveNick = getValue (html , "ANTHOR_NICK" )
101
+ live .LivingIMG = getValue (html , "picURL" )
79
102
live .RoomDetails = ""
80
- live .RoomTitle = title
81
- live .VideoURL = video
82
- if live .VideoURL == "" {
83
- err = errors .New ("fail get data" )
84
- }
103
+ live .RoomTitle = getValue (html , "liveRoomName" )
85
104
return
86
105
}
87
106
0 commit comments