mirror of
https://git.um-react.app/um/cli.git
synced 2025-11-28 11:43:02 +00:00
feat(qmc): support audio meta getter
This commit is contained in:
@@ -209,6 +209,22 @@ func tryDecFile(inputFile string, outputDir string, allDec []common.NewDecoderFu
|
||||
return err
|
||||
}
|
||||
|
||||
if audioMetaGetter, ok := dec.(common.AudioMetaGetter); ok {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
meta, err := audioMetaGetter.GetAudioMeta(ctx)
|
||||
if err != nil {
|
||||
logger.Warn("get audio meta failed", zap.Error(err))
|
||||
} else {
|
||||
logger.Info("audio metadata",
|
||||
zap.String("title", meta.GetTitle()),
|
||||
zap.Strings("artists", meta.GetArtists()),
|
||||
zap.String("album", meta.GetAlbum()),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if coverGetter, ok := dec.(common.CoverImageGetter); ok {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
@@ -227,22 +243,6 @@ func tryDecFile(inputFile string, outputDir string, allDec []common.NewDecoderFu
|
||||
}
|
||||
}
|
||||
|
||||
if audioMetaGetter, ok := dec.(common.AudioMetaGetter); ok {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
meta, err := audioMetaGetter.GetAudioMeta(ctx)
|
||||
if err != nil {
|
||||
logger.Warn("get audio meta failed", zap.Error(err))
|
||||
} else {
|
||||
logger.Info("audio metadata",
|
||||
zap.String("title", meta.GetTitle()),
|
||||
zap.Strings("artists", meta.GetArtists()),
|
||||
zap.String("album", meta.GetAlbum()),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// if source file need to be removed
|
||||
if removeSource {
|
||||
err := os.RemoveAll(inputFile)
|
||||
|
||||
Reference in New Issue
Block a user