Decoder.GetAudioExt() return extension with .

This commit is contained in:
Emmm Monster 2021-05-16 12:15:22 +08:00
parent 9caf11217b
commit f9686bbfc4
No known key found for this signature in database
GPG Key ID: C98279C83FB50DB9
7 changed files with 19 additions and 7 deletions

View File

@ -27,7 +27,7 @@ func (d RawDecoder) GetAudioData() []byte {
} }
func (d RawDecoder) GetAudioExt() string { func (d RawDecoder) GetAudioExt() string {
return d.audioExt return "." + d.audioExt
} }
func (d RawDecoder) GetMeta() Meta { func (d RawDecoder) GetMeta() Meta {

View File

@ -40,7 +40,7 @@ func (d *Decoder) GetAudioData() []byte {
} }
func (d *Decoder) GetAudioExt() string { func (d *Decoder) GetAudioExt() string {
return d.outputExt return "." + d.outputExt
} }
func (d *Decoder) GetMeta() common.Meta { func (d *Decoder) GetMeta() common.Meta {

View File

@ -201,7 +201,9 @@ func (d *Decoder) Decode() error {
func (d Decoder) GetAudioExt() string { func (d Decoder) GetAudioExt() string {
if d.meta != nil { if d.meta != nil {
return d.meta.GetFormat() if format := d.meta.GetFormat(); format != "" {
return "." + d.meta.GetFormat()
}
} }
return "" return ""
} }

View File

@ -84,7 +84,10 @@ func (d Decoder) GetAudioData() []byte {
} }
func (d Decoder) GetAudioExt() string { func (d Decoder) GetAudioExt() string {
return d.audioExt if d.audioExt != "" {
return "." + d.audioExt
}
return ""
} }
func (d Decoder) GetMeta() common.Meta { func (d Decoder) GetMeta() common.Meta {

View File

@ -25,7 +25,10 @@ func (d *Decoder) GetAudioData() []byte {
} }
func (d *Decoder) GetAudioExt() string { func (d *Decoder) GetAudioExt() string {
return d.audioExt if d.audioExt != "" {
return "." + d.audioExt
}
return ""
} }
func (d *Decoder) GetMeta() common.Meta { func (d *Decoder) GetMeta() common.Meta {

View File

@ -38,7 +38,11 @@ func (d *Decoder) GetAudioData() []byte {
} }
func (d *Decoder) GetAudioExt() string { func (d *Decoder) GetAudioExt() string {
return d.outputExt if d.outputExt != "" {
return "." + d.outputExt
}
return ""
} }
func (d *Decoder) GetMeta() common.Meta { func (d *Decoder) GetMeta() common.Meta {

View File

@ -119,7 +119,7 @@ func tryDecFile(inputFile string, outputDir string, allDec []common.NewDecoderFu
outExt := dec.GetAudioExt() outExt := dec.GetAudioExt()
if outExt == "" { if outExt == "" {
outExt = "mp3" outExt = ".mp3"
} }
filenameOnly := strings.TrimSuffix(filepath.Base(inputFile), filepath.Ext(inputFile)) filenameOnly := strings.TrimSuffix(filepath.Base(inputFile), filepath.Ext(inputFile))