From 3857ba91a6ab9d503912cf7ee5e88bdec3bf94d2 Mon Sep 17 00:00:00 2001 From: Unlock Music Dev Date: Tue, 6 Dec 2022 01:32:02 +0800 Subject: [PATCH] feat(meta): allow read tags from streams --- internal/ffmpeg/ffprobe.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/internal/ffmpeg/ffprobe.go b/internal/ffmpeg/ffprobe.go index f98ef9d..b328fb0 100644 --- a/internal/ffmpeg/ffprobe.go +++ b/internal/ffmpeg/ffprobe.go @@ -27,6 +27,17 @@ func (r *Result) getTagByKey(key string) string { return v } } + + for _, stream := range r.Streams { // try to find in streams + if stream.CodecType != "audio" { + continue + } + for k, v := range stream.Tags { + if key == strings.ToLower(k) { + return v + } + } + } return "" } func (r *Result) GetTitle() string { @@ -81,6 +92,7 @@ type Stream struct { StartTime string `json:"start_time"` BitRate string `json:"bit_rate"` Disposition *ProbeDisposition `json:"disposition"` + Tags map[string]string `json:"tags"` } type ProbeDisposition struct {