-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchecklive.go
47 lines (42 loc) · 973 Bytes
/
checklive.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
package main
import (
"fmt"
yt "github.com/steampoweredtaco/youtubelive"
"time"
)
var (
channel = "@christinafixates"
clientID = ""
clientSecret = ""
refreshToken = ""
additionalScopes = []string{}
)
const (
// Can set this to false if you want to hardcode the values above (not recommended). See LoadOauthCredentialsFromDotFile.
loadFromDotEnv = true
)
func main() {
if loadFromDotEnv {
var err error
clientID, clientSecret, refreshToken, additionalScopes, err = yt.LoadOauthCredentialsFromDotFile()
if err != nil {
panic(err)
}
}
ytLive, err := yt.NewYouTubeLive(clientID, clientSecret, yt.RefreshToken(refreshToken))
if err != nil {
panic(err)
}
channelID, err := ytLive.ChannelIDFromChannelHandle(channel)
if err != nil {
panic(err)
}
for {
isLive, err := ytLive.IsLive(channelID)
if err != nil {
panic(err)
}
fmt.Printf("%s is live? %v\n", channel, isLive)
time.Sleep(5 * time.Second)
}
}