-
Notifications
You must be signed in to change notification settings - Fork 0
/
skip_file.go
41 lines (35 loc) · 674 Bytes
/
skip_file.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
package skiptro
import (
"bytes"
"fmt"
"path"
"time"
)
func EDL(scene Scene) []byte {
return []byte(fmt.Sprintf("%.2f %.2f 3\n", scene.Start.Seconds(), scene.End.Seconds()))
}
func M3U(scene Scene, filename string) []byte {
start := int(scene.Start.Seconds())
end := int(scene.End.Seconds())
name := path.Base(filename)
b := bytes.Buffer{}
preIntro := ""
if scene.Start.Truncate(time.Second) > 0 {
preIntro = fmt.Sprintf(`
#EXTVLCOPT:start-time=0
#EXTVLCOPT:stop-time=%d
#EXTINF ,PreIntro
%s
`, start, name)
}
b.WriteString(fmt.Sprintf(`#EXTM3U
#EXTM3U%s
#EXTVLCOPT:start-time=%d
#EXTINF ,PostIntro
%s
`,
preIntro,
end,
name))
return b.Bytes()
}