From 03119e5ccfaebc6a618831bb7c312e5ce007ed2b Mon Sep 17 00:00:00 2001 From: Deluan Date: Sat, 23 Dec 2023 14:10:38 -0500 Subject: [PATCH] Add more trace log to TagLib Wrapper --- scanner/metadata/taglib/taglib_wrapper.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/scanner/metadata/taglib/taglib_wrapper.go b/scanner/metadata/taglib/taglib_wrapper.go index 2f866a530..ada16ed05 100644 --- a/scanner/metadata/taglib/taglib_wrapper.go +++ b/scanner/metadata/taglib/taglib_wrapper.go @@ -11,6 +11,7 @@ package taglib */ import "C" import ( + "encoding/json" "fmt" "os" "runtime/debug" @@ -39,6 +40,7 @@ func Read(filename string) (tags map[string][]string, err error) { id, m := newMap() defer deleteMap(id) + log.Trace("TagLib: reading tags", "filename", filename, "map_id", id) res := C.taglib_read(fp, C.ulong(id)) switch res { case C.TAGLIB_ERR_PARSE: @@ -56,7 +58,13 @@ func Read(filename string) (tags map[string][]string, err error) { case C.TAGLIB_ERR_AUDIO_PROPS: return nil, fmt.Errorf("can't get audio properties from file") } - log.Trace("TagLib: read tags", "tags", m, "filename", filename, "id", id) + if log.CurrentLevel() >= log.LevelDebug { + j, _ := json.Marshal(m) + log.Trace("TagLib: read tags", "tags", string(j), "filename", filename, "id", id) + } else { + log.Trace("TagLib: read tags", "tags", m, "filename", filename, "id", id) + } + return m, nil } @@ -107,6 +115,10 @@ func do_put_map(id C.ulong, key string, val *C.char) { m[key] = append(m[key], v) } +/* +As I'm working on the new scanner, I see that the `properties` from TagLib is ill-suited to extract multi-valued ID3 frames. I'll have to change the way we do it for ID3, probably by sending the raw frames to Go and mapping there, instead of relying on the auto-mapped `properties`. I think this would reduce our reliance on C++, while also giving us more flexibility, including parsing the USLT / SYLT frames in Go +*/ + //export go_map_put_int func go_map_put_int(id C.ulong, key *C.char, val C.int) { valStr := strconv.Itoa(int(val))