-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpresets.go
More file actions
58 lines (51 loc) · 1.15 KB
/
presets.go
File metadata and controls
58 lines (51 loc) · 1.15 KB
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
// Module for working with preset configuration yaml file.
// For more details see conf/presets.yml.dist
package main
import (
"io/ioutil"
"gopkg.in/yaml.v2"
)
// Slice of presets
type Presets []Preset
// Preset struct
type Preset struct {
// Human readable name of preset
Name string `yaml:"name"`
// Options for light control
Light Light `yaml:"light"`
// Files for playing
Files []PresetFile `yaml:"files"`
}
// Video file
type PresetFile struct {
// Full path to video file
Name string `yaml:"name"`
// Additional arguments for MPC player
Args []string `yaml:"args,flow"`
}
// Light options
type Light struct{
// Start light preset after N second
Time int `yaml:"time"`
// Light scene number
Number int `yaml:"number"`
}
// Load presets file
func LoadPresets(filename string) (Presets, error) {
var presets Presets
data, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
err = yaml.Unmarshal(data, &presets)
if err != nil {
return nil, err
}
return presets, nil
}
func (pf * PresetFile) GetFullArgs() []string {
args := make([]string, len(pf.Args) + 1)
args[0] = pf.Name
copy(args[1:], pf.Args)
return args
}