refactor: change default output directory

This commit is contained in:
Mathis Maquenne
2025-04-26 00:49:56 +02:00
parent 7302685e34
commit 6675834842
4 changed files with 46 additions and 8 deletions
-1
View File
@@ -40,7 +40,6 @@ func (a *Album) GetOutputPath(outputDir string) string {
base := fmt.Sprintf("%s - %s", a.Results.Data.Artist, a.Results.Data.Title)
base, _ = filenamify.Filenamify(base, filenamify.Options{})
outputPath := path.Join(outputDir, base)
outputPath, _ = filenamify.Filenamify(outputPath, filenamify.Options{})
return outputPath
}
-1
View File
@@ -35,7 +35,6 @@ func (p *Playlist) GetSongs() []*Song {
func (p *Playlist) GetOutputPath(outputDir string) string {
p.Results.Data.Title, _ = filenamify.Filenamify(p.Results.Data.Title, filenamify.Options{})
outputPath := path.Join(outputDir, p.Results.Data.Title)
outputPath, _ = filenamify.Filenamify(outputPath, filenamify.Options{})
return outputPath
}
+21
View File
@@ -0,0 +1,21 @@
package utils
import (
"fmt"
"os"
)
func EnsureDir(path string) error {
info, err := os.Stat(path)
if os.IsNotExist(err) {
return os.MkdirAll(path, 0755)
}
if err != nil {
return err
}
if !info.IsDir() {
return fmt.Errorf("file already exists at %s", path)
}
return nil
}