Files
arrange/cmd/am/meta.go
T
sm 0359f8c288 added meta subcommand
this command parses and prints out the metadata. Also I've used an
alternate spelling of "go wide" that I've been finding slightly more
legible these days.
2017-07-23 14:07:12 -07:00

43 lines
599 B
Go

package main
import (
"fmt"
"log"
"runtime"
"sync"
"mcquay.me/arrange"
)
func meta(files []string) {
workers := runtime.NumCPU()
if *cores != 0 {
workers = *cores
}
fc := make(chan arrange.Media)
go func() {
wg := &sync.WaitGroup{}
s := make(chan bool, workers)
for _, f := range files {
wg.Add(1)
go func(pth string) {
s <- true
pf, err := arrange.ParseFile(pth)
if err != nil {
log.Printf("%+v", err)
}
fc <- pf
<-s
wg.Done()
}(f)
}
wg.Wait()
close(fc)
}()
for f := range fc {
fmt.Printf("%+v: %v\n", f.Time, f.Path)
}
}