From 6cd7fd8f70b46cda74b7f6426d5f813595f35256 Mon Sep 17 00:00:00 2001 From: David Howden Date: Sat, 6 Jun 2015 16:29:25 +1000 Subject: [PATCH] Added -mbz option to tag tool to output MusicBrainz information. --- tag/tag.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tag/tag.go b/tag/tag.go index 16b74e3..4755d54 100644 --- a/tag/tag.go +++ b/tag/tag.go @@ -8,14 +8,17 @@ The tag tool reads metadata from media files (as supported by the tag library). package main import ( + "encoding/json" "flag" "fmt" "os" "github.com/dhowden/tag" + "github.com/dhowden/tag/mbz" ) var raw bool +var extractMBZ bool var usage = func() { fmt.Fprintf(os.Stderr, "usage: %s [optional flags] filename\n", os.Args[0]) @@ -24,6 +27,7 @@ var usage = func() { func init() { flag.BoolVar(&raw, "raw", false, "show raw tag data") + flag.BoolVar(&extractMBZ, "mbz", false, "extract MusicBrainz tag data (if available)") flag.Usage = usage } @@ -64,6 +68,16 @@ func main() { fmt.Printf("%#v: %#v\n", k, v) } } + + if extractMBZ { + b, err := json.MarshalIndent(mbz.Extract(m), "", " ") + if err != nil { + fmt.Printf("error marshalling MusicBrainz info: %v\n", err) + return + } + + fmt.Printf("\nMusicBrainz Info:\n%v\n", string(b)) + } } func printMetadata(m tag.Metadata) {