fix: replace forbidden chars in output file name
This commit is contained in:
@@ -4,6 +4,8 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"path"
|
||||
|
||||
"github.com/flytam/filenamify"
|
||||
)
|
||||
|
||||
type Album struct {
|
||||
@@ -33,7 +35,12 @@ func (a *Album) GetSongs() []*Song {
|
||||
}
|
||||
|
||||
func (a *Album) GetOutputPath(outputDir string) string {
|
||||
return path.Join(outputDir, fmt.Sprintf("%s - %s", a.Data.Artist, a.Data.Title))
|
||||
base := fmt.Sprintf("%s - %s", a.Data.Artist, a.Data.Title)
|
||||
base, _ = filenamify.Filenamify(base, filenamify.Options{})
|
||||
outputPath := path.Join(outputDir, base)
|
||||
outputPath, _ = filenamify.Filenamify(outputPath, filenamify.Options{})
|
||||
|
||||
return outputPath
|
||||
}
|
||||
|
||||
func (a *Album) GetTitle() string {
|
||||
|
||||
@@ -3,6 +3,8 @@ package deezer
|
||||
import (
|
||||
"encoding/json"
|
||||
"path"
|
||||
|
||||
"github.com/flytam/filenamify"
|
||||
)
|
||||
|
||||
type Playlist struct {
|
||||
@@ -27,7 +29,11 @@ func (p *Playlist) GetSongs() []*Song {
|
||||
}
|
||||
|
||||
func (p *Playlist) GetOutputPath(outputDir string) string {
|
||||
return path.Join(outputDir, p.Data.Title)
|
||||
p.Data.Title, _ = filenamify.Filenamify(p.Data.Title, filenamify.Options{})
|
||||
outputPath := path.Join(outputDir, p.Data.Title)
|
||||
outputPath, _ = filenamify.Filenamify(outputPath, filenamify.Options{})
|
||||
|
||||
return outputPath
|
||||
}
|
||||
|
||||
func (p *Playlist) GetTitle() string {
|
||||
|
||||
Reference in New Issue
Block a user