-
Notifications
You must be signed in to change notification settings - Fork 549
/
Copy pathinfo.go
48 lines (45 loc) · 1.47 KB
/
info.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 live
import (
"encoding/json"
)
type Info struct {
Live Live
HostName, RoomName string
Status bool // means isLiving, maybe better to rename it
Listening, Recording bool
Initializing bool
CustomLiveId string
AudioOnly bool
}
func (i *Info) MarshalJSON() ([]byte, error) {
t := struct {
Id ID `json:"id"`
LiveUrl string `json:"live_url"`
PlatformCNName string `json:"platform_cn_name"`
HostName string `json:"host_name"`
RoomName string `json:"room_name"`
Status bool `json:"status"`
Listening bool `json:"listening"`
Recording bool `json:"recording"`
Initializing bool `json:"initializing"`
LastStartTime string `json:"last_start_time,omitempty"`
LastStartTimeUnix int64 `json:"last_start_time_unix,omitempty"`
AudioOnly bool `json:"audio_only"`
}{
Id: i.Live.GetLiveId(),
LiveUrl: i.Live.GetRawUrl(),
PlatformCNName: i.Live.GetPlatformCNName(),
HostName: i.HostName,
RoomName: i.RoomName,
Status: i.Status,
Listening: i.Listening,
Recording: i.Recording,
Initializing: i.Initializing,
AudioOnly: i.AudioOnly,
}
if !i.Live.GetLastStartTime().IsZero() {
t.LastStartTime = i.Live.GetLastStartTime().Format("2006-01-02 15:04:05")
t.LastStartTimeUnix = i.Live.GetLastStartTime().Unix()
}
return json.Marshal(t)
}