forked from muesli/obs-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecording.go
147 lines (122 loc) · 3.11 KB
/
recording.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
package main
import (
"fmt"
"strconv"
"github.com/muesli/coral"
)
var (
recordingCmd = &coral.Command{
Use: "recording",
Short: "manage recordings",
Long: `The recording command manages recordings`,
RunE: nil,
}
startStopRecordingCmd = &coral.Command{
Use: "toggle",
Short: "Toggle recording",
RunE: func(cmd *coral.Command, args []string) error {
return startStopRecording()
},
}
startRecordingCmd = &coral.Command{
Use: "start",
Short: "Starts recording",
RunE: func(cmd *coral.Command, args []string) error {
return startRecording()
},
}
stopRecordingCmd = &coral.Command{
Use: "stop",
Short: "Stops recording",
RunE: func(cmd *coral.Command, args []string) error {
return stopRecording()
},
}
pauseRecordingCmd = &coral.Command{
Use: "pause",
Short: "manage paused state",
}
enablePauseRecordingCmd = &coral.Command{
Use: "enable",
Short: "Pause recording",
RunE: func(cmd *coral.Command, args []string) error {
return pauseRecording()
},
}
resumePauseRecordingCmd = &coral.Command{
Use: "resume",
Short: "Resume recording",
RunE: func(cmd *coral.Command, args []string) error {
return resumeRecording()
},
}
togglePauseRecordingCmd = &coral.Command{
Use: "toggle",
Short: "Pause/resume recording",
RunE: func(cmd *coral.Command, args []string) error {
return pauseResumeRecording()
},
}
recordingStatusCmd = &coral.Command{
Use: "status",
Short: "Reports recording status",
RunE: func(cmd *coral.Command, args []string) error {
return recordingStatus()
},
}
)
func startStopRecording() error {
_, err := client.Record.ToggleRecord()
return err
}
func startRecording() error {
_, err := client.Record.StartRecord()
return err
}
func stopRecording() error {
_, err := client.Record.StopRecord()
return err
}
func pauseRecording() error {
_, err := client.Record.PauseRecord()
return err
}
func resumeRecording() error {
_, err := client.Record.ResumeRecord()
return err
}
func pauseResumeRecording() error {
_, err := client.Record.ToggleRecordPause()
return err
}
func recordingStatus() error {
r, err := client.Record.GetRecordStatus()
if err != nil {
return err
}
fmt.Printf("Recording: %s\n", strconv.FormatBool(r.OutputActive))
if !r.OutputActive {
return nil
}
fmt.Printf("Paused: %s\n", strconv.FormatBool(r.OuputPaused))
// TODO: see if recording filename is available from another API method
// fmt.Printf("File: %s\n", r.RecordingFilename)
fmt.Printf("Timecode: %s\n", r.OutputTimecode)
// st, err := os.Stat(r.RecordingFilename)
// if err != nil {
// return err
// }
// fmt.Printf("Filesize: %s\n", humanize.Bytes(uint64(st.Size())))
return nil
}
func init() {
pauseRecordingCmd.AddCommand(enablePauseRecordingCmd)
pauseRecordingCmd.AddCommand(resumePauseRecordingCmd)
pauseRecordingCmd.AddCommand(togglePauseRecordingCmd)
recordingCmd.AddCommand(startStopRecordingCmd)
recordingCmd.AddCommand(startRecordingCmd)
recordingCmd.AddCommand(stopRecordingCmd)
recordingCmd.AddCommand(pauseRecordingCmd)
recordingCmd.AddCommand(recordingStatusCmd)
rootCmd.AddCommand(recordingCmd)
}