summaryrefslogtreecommitdiff
path: root/pkg/media/video.go
diff options
context:
space:
mode:
authordavy <davy.wybiral@gmail.com>2019-06-28 17:20:52 -0500
committerdavy <davy.wybiral@gmail.com>2019-06-28 17:20:52 -0500
commitb46830c8806fc1293bc8cfdf5496cd024fcde6c4 (patch)
tree409ac133758cd0e745fe930e0d30e5821e8e4190 /pkg/media/video.go
parentef01f99df7dafc61c11203e879e997c15dea98ca (diff)
added app.Watcher
Diffstat (limited to 'pkg/media/video.go')
-rw-r--r--pkg/media/video.go22
1 files changed, 21 insertions, 1 deletions
diff --git a/pkg/media/video.go b/pkg/media/video.go
index bd0def8..f79ab44 100644
--- a/pkg/media/video.go
+++ b/pkg/media/video.go
@@ -2,6 +2,7 @@ package media
import (
"os"
+ "strings"
"github.com/dhowden/tag"
)
@@ -21,14 +22,33 @@ func ParseVideo(path string) (*Video, error) {
if err != nil {
return nil, err
}
+ info, err := f.Stat()
+ if err != nil {
+ return nil, err
+ }
+ modified := info.ModTime().Format("2006-01-02")
+ name := info.Name()
+ // ID is name without extension
+ idx := strings.LastIndex(name, ".")
+ if idx == -1 {
+ idx = len(name)
+ }
+ id := name[:idx]
m, err := tag.ReadFrom(f)
if err != nil {
return nil, err
}
+ title := m.Title()
+ // Default title is filename
+ if title == "" {
+ title = name
+ }
v := &Video{
- Title: m.Title(),
+ ID: id,
+ Title: title,
Album: m.Album(),
Description: m.Comment(),
+ Modified: modified,
}
// Add thumbnail (if exists)
p := m.Picture()