diff options
Diffstat (limited to 'pkg/media/video.go')
| -rw-r--r-- | pkg/media/video.go | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/pkg/media/video.go b/pkg/media/video.go new file mode 100644 index 0000000..bd0def8 --- /dev/null +++ b/pkg/media/video.go @@ -0,0 +1,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 +} |
