-
Notifications
You must be signed in to change notification settings - Fork 82
/
lang.go
48 lines (41 loc) · 928 Bytes
/
lang.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package olivetv
import (
"fmt"
"strings"
"time"
"github.com/go-olive/olive/foundation/olivetv/util"
)
func init() {
registerSite("lang", &lang{})
}
type lang struct {
base
}
func (this *lang) Name() string {
return "浪LIVE"
}
func (this *lang) Snap(tv *TV) error {
tv.Info = &Info{
Timestamp: time.Now().Unix(),
}
return this.set(tv)
}
func (this *lang) set(tv *TV) (err error) {
roomURL := fmt.Sprintf("https://www.lang.live/room/%s", tv.RoomID)
roomContent, err := util.GetURLContent(roomURL)
if err != nil {
return err
}
roomContent = strings.ReplaceAll(roomContent, "\\", "")
tv.streamURL, err = util.Match(`"liveurl":"([^"]+)"`, roomContent)
if err != nil {
return err
}
title, _ := util.Match(`<head><title>([^<]+)</title>`, roomContent)
tv.roomName = strings.Split(title, " - "+tv.RoomID)[0]
if tv.streamerName == "" {
tv.streamerName = tv.roomName
}
tv.roomOn = true
return nil
}