-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
76 lines (61 loc) · 2 KB
/
main.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
package main
import (
"log"
"os"
"time"
"gopkg.in/natefinch/lumberjack.v2"
"github.com/jawee/twitch-recorder/internal/configuration"
"github.com/jawee/twitch-recorder/internal/discordclient"
"github.com/jawee/twitch-recorder/internal/postprocessor"
"github.com/jawee/twitch-recorder/internal/processor"
"github.com/jawee/twitch-recorder/internal/recorder"
"github.com/jawee/twitch-recorder/internal/recordingtracker"
"github.com/jawee/twitch-recorder/internal/twitchclient"
)
func main() {
log.Println("twitch-recorder starting")
log.SetOutput(&lumberjack.Logger{
Filename: "/logs/twitch-recorder.log",
MaxSize: 1, // megabytes
MaxBackups: 0,
MaxAge: 0, //days
})
configProvider := new(configuration.FileConfigurationProvider)
configuration, err := configuration.New(configProvider)
if err != nil {
log.Println(err)
os.Exit(1)
}
if configuration == nil {
log.Println("Configuration is nil")
os.Exit(1)
}
clientId := configuration.ClientId
clientSecret := configuration.ClientSecret
discordToken := configuration.WebhookToken
discordId := configuration.WebhookId
twitchClient := twitch_client.New(clientId, clientSecret)
//TODO: Make configureable
baseDirectory := "/inprogress"
disc := discordclient.New(discordId, discordToken)
rec := recorder.New(baseDirectory, disc)
rt := recordingtracker.New()
c := make(chan *recorder.RecordedFile)
postproc := postprocessor.New(disc)
go startPostProcessing(postproc, c)
proc := processor.New(c, twitchClient, rec, rt)
for {
for _, streamer := range configuration.Streamers {
err := proc.ProcessStreamer(streamer)
if err != nil {
log.Println(err)
}
}
time.Sleep(time.Minute)
}
}
func startPostProcessing(postproc postprocessor.PostProcessor, c chan *recorder.RecordedFile) {
for v := range c {
go postproc.Process(v)
}
}