-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathiptv.go
76 lines (66 loc) · 1.49 KB
/
iptv.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 (
"fmt"
"github.com/urfave/cli"
"os"
"./factory"
"./iptv-server"
"./version"
)
type (
// Config : IPTV Configuration file information
Config struct {
iptvcfg string
}
)
var config Config
var iptvFlags = []cli.Flag{
&cli.StringFlag{
Name: "iptvcfg",
Usage: "config file",
},
}
func action(c *cli.Context) error {
if err := initialize(c); err != nil {
fmt.Print(err)
}
if err := start(); err != nil {
fmt.Print(err)
}
return nil
}
func main() {
app := cli.NewApp()
app.Name = "IPTV"
app.Usage = "-free5gccfg common configuration file -iptvcfg iptv configuration file"
app.Action = action
fmt.Println(app.Name)
app.Flags = iptvFlags
if err := app.Run(os.Args); err != nil {
fmt.Printf("Error args: %v", err)
}
}
func initialize(c *cli.Context) error {
config = Config{
iptvcfg: c.String("iptvcfg"),
}
if config.iptvcfg != "" {
factory.InitConfigFactory(config.iptvcfg)
} else {
DefaultIptvConfigPath := "./iptvcfg.conf"
factory.InitConfigFactory(DefaultIptvConfigPath)
}
return nil
}
func start() error {
// Run gin Server
server := iptvserver.Server{}
server.IptvServerIpv4Port = factory.IptvConfig.Configuration.IPTVServer.ServerAddr
server.Channels = factory.IptvConfig.Configuration.IPTVServer.Channel
server.CacheFolder = factory.IptvConfig.Configuration.IPTVServer.CacheFolder
server.WebClient = factory.IptvConfig.Configuration.IPTVServer.WebClientFolder
server.Version = version.GetVersion()
server.Start()
// Run AF
return nil
}