blob: bd0def8e696969a14971cf27eb764a6260741d38 (
plain)
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
|
package media
import (
"os"
"github.com/dhowden/tag"
)
type Video struct {
ID string
Title string
Album string
Description string
Thumb []byte
ThumbType string
Modified string
}
func ParseVideo(path string) (*Video, error) {
f, err := os.Open(path)
if err != nil {
return nil, err
}
m, err := tag.ReadFrom(f)
if err != nil {
return nil, err
}
v := &Video{
Title: m.Title(),
Album: m.Album(),
Description: m.Comment(),
}
// Add thumbnail (if exists)
p := m.Picture()
if p != nil {
v.Thumb = p.Data
v.ThumbType = p.MIMEType
}
return v, nil
}
|