-
Notifications
You must be signed in to change notification settings - Fork 1
/
SaaS.go
56 lines (47 loc) · 1.26 KB
/
SaaS.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
/*
SaaS means "Sosach Is A Service". Project focused on stream fresh WEBM from 2ch.hk/b
*/
package main
import (
"SaaS/HTTPPlayer"
"encoding/json"
"flag"
"io/ioutil"
"log"
)
// Type represents structure of configuration file(JSON)
type configFile struct {
Port string
JSONUrl string
BoardAddress string
DownloadURL string
BrowserUserAgent string
Cookie string
SaveDirectory string
}
// Function read configuration and set return configFile type
func readConfig(confFilePath *string) (*configFile, error) {
var config *configFile
confFile, err := ioutil.ReadFile(*confFilePath)
if err != nil {
return config, err
}
err = json.Unmarshal(confFile, &config)
if err != nil {
return config, err
}
return config, nil
}
func main() {
configFilePath := flag.String("conf", "config.json", "indicate path to config.json")
flag.Parse()
config, err := readConfig(configFilePath)
if err != nil {
log.Fatalln("Error on reading config file: ", err)
}
player, err := HTTPPlayer.NewHTTPPlayer(config.SaveDirectory, config.Cookie, config.BrowserUserAgent, config.BoardAddress, config.DownloadURL, config.JSONUrl, config.Port)
if err != nil {
log.Fatalln("Error on creating HTTP Player: ", err)
}
player.ListenAndServe()
}