-
Notifications
You must be signed in to change notification settings - Fork 1
/
commandline.go
75 lines (61 loc) · 2.44 KB
/
commandline.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
package main
import (
"flag"
"net/url"
"./movi"
)
type Opts struct{
readfrom URL // udpxy://IP:PORT
// udp://
// path/to/file
savem3u URL // stdout
// path/to/file
savexmltv URL // stdout
// path/to/file
streamprefix URL // udpxy | udp | rtp
area int // see movistartv.go for area details
cachedays int
listpackages bool
listchannels bool
searchepg string
season string
episode string
title string
verbose bool
now bool
proxy string
}
type URL struct{
url.URL
Raw string
}
func (u *URL) String() string{
return u.Raw
}
func (u *URL) Set(s string) (err error){
parsed, err := url.Parse(s)
u.URL = *parsed
u.Raw = s
return
}
func parseCommandLine() *Opts{
opts := &Opts{}
flag.Var(&opts.readfrom, "readfrom", "Access method. udp:// reads straight from the network. udpxy://IP:PORT reads via udpxy proxy. Otherwise it's considered a file")
flag.Var(&opts.savem3u, "savem3u", "stdout Dumps the file to stdout. Otherwise it's considered a path in the filesystem. Defaults to stdout")
flag.Var(&opts.savexmltv, "savexmltv", "stdout Dumps the file to stdout. Otherwise it's considered a path in the filesystem. Defaults to stdout")
flag.Var(&opts.streamprefix, "streamprefix", "udpxy://IP:PORT, udp:// or rtp://")
flag.IntVar(&opts.area, "area", int(movi.MADRID), "Area code")
flag.IntVar(&opts.cachedays, "cachedays", 1, "Ignore cache if older than N days (default: 1)")
flag.BoolVar(&opts.listpackages, "packages", false, "")
flag.BoolVar(&opts.listchannels, "channels", false, "")
flag.BoolVar(&opts.verbose, "v", false, "")
flag.StringVar(&opts.searchepg, "searchepg", "", "Search a program")
flag.StringVar(&opts.season, "season", "", "filter season for -searchepg")
flag.StringVar(&opts.episode, "episode", "", "filter episode for -searchepg")
flag.StringVar(&opts.title, "title", "", "filter title for -searchepg")
flag.BoolVar(&opts.now, "now", false, "Currently on air")
flag.StringVar(&opts.proxy, "proxy", "", "Enable RTP proxy")
//opts.savem3u.Raw = "stdout"
flag.Parse()
return opts
}