From f9686bbfc46614c4fd86922ba263f2a692d13488 Mon Sep 17 00:00:00 2001 From: Emmm Monster <58943012+emmmx@users.noreply.github.com> Date: Sun, 16 May 2021 12:15:22 +0800 Subject: [PATCH] Decoder.GetAudioExt() return extension with . --- algo/common/raw.go | 2 +- algo/kwm/kwm.go | 2 +- algo/ncm/ncm.go | 4 +++- algo/qmc/qmc.go | 5 ++++- algo/tm/tm.go | 5 ++++- algo/xm/xm.go | 6 +++++- cmd/um/main.go | 2 +- 7 files changed, 19 insertions(+), 7 deletions(-) diff --git a/algo/common/raw.go b/algo/common/raw.go index fda4331..5182757 100644 --- a/algo/common/raw.go +++ b/algo/common/raw.go @@ -27,7 +27,7 @@ func (d RawDecoder) GetAudioData() []byte { } func (d RawDecoder) GetAudioExt() string { - return d.audioExt + return "." + d.audioExt } func (d RawDecoder) GetMeta() Meta { diff --git a/algo/kwm/kwm.go b/algo/kwm/kwm.go index ed30107..e0097e8 100644 --- a/algo/kwm/kwm.go +++ b/algo/kwm/kwm.go @@ -40,7 +40,7 @@ func (d *Decoder) GetAudioData() []byte { } func (d *Decoder) GetAudioExt() string { - return d.outputExt + return "." + d.outputExt } func (d *Decoder) GetMeta() common.Meta { diff --git a/algo/ncm/ncm.go b/algo/ncm/ncm.go index dbd94d0..9b4334a 100644 --- a/algo/ncm/ncm.go +++ b/algo/ncm/ncm.go @@ -201,7 +201,9 @@ func (d *Decoder) Decode() error { func (d Decoder) GetAudioExt() string { if d.meta != nil { - return d.meta.GetFormat() + if format := d.meta.GetFormat(); format != "" { + return "." + d.meta.GetFormat() + } } return "" } diff --git a/algo/qmc/qmc.go b/algo/qmc/qmc.go index 1e9db44..6f6586e 100644 --- a/algo/qmc/qmc.go +++ b/algo/qmc/qmc.go @@ -84,7 +84,10 @@ func (d Decoder) GetAudioData() []byte { } func (d Decoder) GetAudioExt() string { - return d.audioExt + if d.audioExt != "" { + return "." + d.audioExt + } + return "" } func (d Decoder) GetMeta() common.Meta { diff --git a/algo/tm/tm.go b/algo/tm/tm.go index 3e96365..a505ba4 100644 --- a/algo/tm/tm.go +++ b/algo/tm/tm.go @@ -25,7 +25,10 @@ func (d *Decoder) GetAudioData() []byte { } func (d *Decoder) GetAudioExt() string { - return d.audioExt + if d.audioExt != "" { + return "." + d.audioExt + } + return "" } func (d *Decoder) GetMeta() common.Meta { diff --git a/algo/xm/xm.go b/algo/xm/xm.go index 5f8c64d..de5bbcb 100644 --- a/algo/xm/xm.go +++ b/algo/xm/xm.go @@ -38,7 +38,11 @@ func (d *Decoder) GetAudioData() []byte { } func (d *Decoder) GetAudioExt() string { - return d.outputExt + if d.outputExt != "" { + return "." + d.outputExt + + } + return "" } func (d *Decoder) GetMeta() common.Meta { diff --git a/cmd/um/main.go b/cmd/um/main.go index 19513e1..8722bb9 100644 --- a/cmd/um/main.go +++ b/cmd/um/main.go @@ -119,7 +119,7 @@ func tryDecFile(inputFile string, outputDir string, allDec []common.NewDecoderFu outExt := dec.GetAudioExt() if outExt == "" { - outExt = "mp3" + outExt = ".mp3" } filenameOnly := strings.TrimSuffix(filepath.Base(inputFile), filepath.Ext(inputFile))