-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfodder.go
82 lines (72 loc) · 1.76 KB
/
fodder.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
77
78
79
80
81
82
package main
import (
"fmt"
"flag"
"regexp"
)
const usageString = `usage: fodder [option] <url>
Scan a video stream for your username.
`
type options struct {
userNameRegexp *regexp.Regexp
url string
videoFilePath string
verbose bool
}
func main() {
var ( // arguments that need parsing
userNameExpr string
videoFilePath string
verbose bool
)
flag.Usage = func() {
fmt.Println(usageString)
flag.PrintDefaults()
}
flag.StringVar(&userNameExpr, "u", "", "regexp of username to scan for")
flag.StringVar(&videoFilePath, "f", "", "stream video file")
flag.BoolVar(&verbose, "v", false, "show verbose messages")
flag.Parse()
if (len(flag.Args()) == 0 || flag.Arg(0) == "") && videoFilePath == "" {
fmt.Println("error: no URL provided")
flag.Usage()
return
}
if (userNameExpr == "") {
fmt.Println("error: -u required")
flag.Usage()
}
userNameRegexp, err := regexp.Compile(userNameExpr)
if err != nil {
fmt.Println("error: bad regexp string for `-u`")
flag.Usage()
}
opts := &options{
url: flag.Arg(0),
userNameRegexp: userNameRegexp,
videoFilePath: videoFilePath,
verbose: verbose,
}
if err := run(opts); err != nil {
fmt.Println(err)
return
}
}
func run(opts *options) error {
vid, err := DownloadVideo(opts.url, opts.videoFilePath)
if err != nil {
return err
}
fmt.Println("download successful. processing video...")
killLog := &KillLogVid{
Vid: vid,
Match: opts.userNameRegexp,
Game: G_VALORANT,
}
killLog.Init()
if err := killLog.CropValorant(killLog); err != nil {
return fmt.Errorf("CropValorant() err: %s", err)
}
fmt.Println("all streams processed successfully.")
return nil
}